@shopgate/eslint-config 7.30.3 → 7.31.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@shopgate/eslint-config",
3
- "version": "7.30.3",
3
+ "version": "7.31.0-alpha.1",
4
4
  "description": "Eslint configuration for the Shopgate Connect projects.",
5
5
  "author": "Shopgate <support@shopgate.com>",
6
6
  "license": "Apache-2.0",
7
7
  "main": "./ruleset/index.js",
8
8
  "dependencies": {
9
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
10
+ "@typescript-eslint/parser": "^5.62.0",
9
11
  "eslint-config-airbnb": "^19.0.4",
10
12
  "eslint-import-resolver-babel-module": "^5.3.2",
11
13
  "eslint-import-resolver-exports": "^1.0.0-beta.5",
14
+ "eslint-import-resolver-typescript": "3.6.1",
12
15
  "eslint-plugin-cypress": "^2.6.1",
13
16
  "eslint-plugin-eslint-comments": "^3.2.0",
14
17
  "eslint-plugin-extra-rules": "~0.0.0-development",
15
18
  "eslint-plugin-import": "^2.32.0",
19
+ "eslint-plugin-jsdoc": "^62.7.1",
16
20
  "eslint-plugin-json": "^3.1.0",
17
21
  "eslint-plugin-jsx-a11y": "^6.10.2",
18
22
  "eslint-plugin-react": "^7.37.5",
package/ruleset/index.js CHANGED
@@ -3,6 +3,7 @@ module.exports = {
3
3
  './main',
4
4
  './react',
5
5
  './extras',
6
+ './typescript',
6
7
  ].map(require.resolve),
7
8
  rules: {},
8
9
  };
package/ruleset/main.js CHANGED
@@ -163,33 +163,55 @@ module.exports = {
163
163
  {
164
164
  files: [
165
165
  '**/*.spec.js',
166
+ '**/*.spec.ts',
166
167
  '**/*.spec.jsx',
168
+ '**/*.spec.tsx',
167
169
  '**/*.test.js',
170
+ '**/*.test.ts',
168
171
  '**/*.test.jsx',
172
+ '**/*.test.tsx',
169
173
  '**/*.mock.js',
174
+ '**/*.mock.ts',
170
175
  '**/*.mock.jsx',
176
+ '**/*.mock.tsx',
171
177
  '**/spec.js',
178
+ '**/spec.ts',
172
179
  '**/spec.jsx',
180
+ '**/spec.tsx',
173
181
  '**/mock.js',
182
+ '**/mock.ts',
174
183
  '**/mock.jsx',
184
+ '**/mock.tsx',
175
185
  ],
176
186
  rules: {
177
187
  // Allow more than one class per file in test files
178
188
  'max-classes-per-file': 'off',
179
189
  // Allow non-camelcase names in test files (e.g., snake_case from API)
180
190
  camelcase: 'off',
191
+ // Don't require JSDoc in test/mock files
192
+ 'require-jsdoc': 'off',
193
+ 'valid-jsdoc': 'off',
194
+ 'no-console': 'off',
181
195
  },
182
196
  },
183
197
  ],
184
198
  settings: {
199
+ 'import/parsers': {
200
+ '@typescript-eslint/parser': ['.ts', '.tsx'],
201
+ },
185
202
  'import/extensions': [
186
203
  '.js',
187
204
  '.json',
188
205
  '.jsx',
206
+ '.ts',
207
+ '.tsx',
189
208
  ],
190
209
  'import/resolver': {
191
210
  exports: {},
192
- node: {},
211
+ node: { extensions: ['.js', '.jsx', '.ts', '.tsx', '.d.ts'] },
212
+ typescript: {
213
+ alwaysTryTypes: true,
214
+ },
193
215
  },
194
216
  },
195
217
  };
@@ -0,0 +1,114 @@
1
+ module.exports = {
2
+ overrides: [
3
+ {
4
+ files: ['**/*.ts', '**/*.tsx'],
5
+ parser: '@typescript-eslint/parser',
6
+ plugins: ['@typescript-eslint', 'jsdoc'],
7
+ extends: [
8
+ 'plugin:@typescript-eslint/recommended',
9
+ ],
10
+ rules: {
11
+ // Prefer TS variants
12
+ 'no-unused-vars': 'off',
13
+ 'no-shadow': 'off',
14
+ 'no-use-before-define': 'off',
15
+
16
+ '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
17
+ '@typescript-eslint/no-shadow': 'warn',
18
+ '@typescript-eslint/no-use-before-define': [
19
+ 'error',
20
+ {
21
+ functions: false,
22
+ classes: true,
23
+ variables: false,
24
+ },
25
+ ],
26
+
27
+ // Common TS ergonomics (tune as you like)
28
+ '@typescript-eslint/consistent-type-imports': ['warn', { prefer: 'type-imports' }],
29
+
30
+ 'valid-jsdoc': 'off',
31
+ 'require-jsdoc': 'off',
32
+ // Require JSDoc only for "public" (exported) APIs.
33
+ 'jsdoc/require-jsdoc': ['warn', {
34
+ publicOnly: true,
35
+ require: {
36
+ ArrowFunctionExpression: true,
37
+ FunctionDeclaration: true,
38
+ ClassDeclaration: true,
39
+ MethodDefinition: true,
40
+ },
41
+ }],
42
+ // Require JSDoc Description only for "public" (exported) APIs.
43
+ 'jsdoc/require-description': ['warn', {
44
+ contexts: [
45
+ // export function foo() {}
46
+ 'ExportNamedDeclaration > FunctionDeclaration',
47
+ // export const foo = () => {}
48
+ 'ExportNamedDeclaration VariableDeclarator > ArrowFunctionExpression',
49
+ // export class Foo {}
50
+ 'ExportNamedDeclaration > ClassDeclaration',
51
+ // export default function foo() {}
52
+ // export default function () {}
53
+ 'ExportDefaultDeclaration > FunctionDeclaration',
54
+ // export default class Foo {}
55
+ 'ExportDefaultDeclaration > ClassDeclaration',
56
+ // const Foo = () => {}; export default Foo;
57
+ 'Program > VariableDeclaration > VariableDeclarator > ArrowFunctionExpression',
58
+ ],
59
+ }],
60
+
61
+ 'jsdoc/require-param': 'warn',
62
+ // When @param is provided, it also needs to be described
63
+ 'jsdoc/require-param-description': 'warn',
64
+
65
+ 'jsdoc/require-returns': 'warn',
66
+ // When @returns is provided, it also needs to be described
67
+ 'jsdoc/require-returns-description': 'warn',
68
+
69
+ // Disallow usage of JSDoc types for params. That's already done by TS
70
+ 'jsdoc/no-types': 'error',
71
+ // Check if JSDoc only contains valid tags e.g. @example or @deprecated
72
+ 'jsdoc/check-tag-names': 'warn',
73
+ // Check if param names match function names
74
+ 'jsdoc/check-param-names': 'warn',
75
+ // Reports invalid alignment of JSDoc block asterisks.
76
+ 'jsdoc/check-alignment': 'warn',
77
+ 'jsdoc/check-line-alignment': 'warn',
78
+ 'jsdoc/sort-tags': 'warn',
79
+
80
+ 'react/jsx-filename-extension': [
81
+ 'error',
82
+ { extensions: ['.jsx', '.tsx'] }, // Allow JSX in .tsx files
83
+ ],
84
+ // Special max-len rules for TS files that allow longer lines in comments
85
+ 'max-len': ['error', 100, 2, {
86
+ ignoreUrls: true,
87
+ ignoreComments: true,
88
+ ignoreRegExpLiterals: true,
89
+ ignoreStrings: true,
90
+ ignoreTemplateLiterals: true,
91
+ }],
92
+
93
+ // '@stylistic/object-curly-spacing': ['warn', 'always'],
94
+ // '@stylistic/type-annotation-spacing': 'warn',
95
+ // '@stylistic/type-generic-spacing': 'warn',
96
+ // '@stylistic/type-named-tuple-spacing': 'warn',
97
+ // '@stylistic/member-delimiter-style': 'warn',
98
+ },
99
+ },
100
+ // Rules for React components in .tsx files
101
+ {
102
+ files: ['**/*.tsx'],
103
+ rules: {
104
+ 'react/prop-types': 'off',
105
+ 'react/require-default-props': 'off',
106
+ 'jsdoc/require-param-description': 'warn',
107
+ // JSDoc for params is not needed for React components, as already covered by TS.
108
+ 'jsdoc/require-param': 'off',
109
+ // JSDoc for return values is not needed for React components, as already covered by TS.
110
+ 'jsdoc/require-returns': 'off',
111
+ },
112
+ },
113
+ ],
114
+ };