@allthings/eslint-config 1.0.0 → 2.0.0

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.
Files changed (4) hide show
  1. package/README.md +1 -1
  2. package/index.js +258 -1
  3. package/node.js +70 -0
  4. package/package.json +8 -6
package/README.md CHANGED
@@ -40,7 +40,7 @@ yarn deploy
40
40
 
41
41
  Run `yarn link` in the project folder
42
42
 
43
- Run `yarn link @allthings/eslint-config` in the project that you want to test it against
43
+ Run `yarn link @allthings/eslint-config` in the project that you want to test it against
44
44
 
45
45
  After you finish run in your project `yarn unlink @allthings/eslint-config` and then `yarn install --force`
46
46
  to restore the initial state of dependencies
package/index.js CHANGED
@@ -30,6 +30,8 @@ sortedPaths.push(...keptPaths)
30
30
 
31
31
  const hookPropertyMap = new Map(
32
32
  [
33
+ ['eslint-plugin-unicorn', 'eslint-plugin-unicorn'],
34
+ ['eslint-plugin-jest', 'eslint-plugin-jest'],
33
35
  ['eslint-plugin-import', 'eslint-plugin-import'],
34
36
  ['eslint-plugin-react', 'eslint-plugin-react'],
35
37
  ['eslint-plugin-react-hooks', 'eslint-plugin-react-hooks'],
@@ -38,6 +40,7 @@ const hookPropertyMap = new Map(
38
40
  'eslint-plugin-typescript-sort-keys',
39
41
  'eslint-plugin-typescript-sort-keys',
40
42
  ],
43
+ ['eslint-plugin-prefer-arrow', 'eslint-plugin-prefer-arrow'],
41
44
  ['eslint-plugin-simple-import-sort', 'eslint-plugin-simple-import-sort'],
42
45
  ].map(([request, replacement]) => [
43
46
  request,
@@ -59,6 +62,7 @@ require('@rushstack/eslint-patch/modern-module-resolution')
59
62
 
60
63
  module.exports = {
61
64
  extends: [
65
+ 'plugin:unicorn/recommended',
62
66
  'plugin:import/recommended',
63
67
  'plugin:import/typescript',
64
68
  'eslint:recommended',
@@ -71,14 +75,83 @@ module.exports = {
71
75
  'plugin:prettier/recommended',
72
76
  ],
73
77
  plugins: [
78
+ 'unicorn',
79
+ 'jest',
74
80
  'import',
75
81
  'react',
76
82
  'react-hooks',
77
83
  'jsx-a11y',
78
84
  'typescript-sort-keys',
85
+ 'prefer-arrow',
79
86
  'simple-import-sort',
80
87
  ],
81
88
  rules: {
89
+ '@typescript-eslint/adjacent-overload-signatures': 'error',
90
+ '@typescript-eslint/array-type': [
91
+ 'error',
92
+ {
93
+ default: 'array',
94
+ },
95
+ ],
96
+ '@typescript-eslint/ban-types': [
97
+ 'error',
98
+ {
99
+ types: {
100
+ Object: {
101
+ message: 'Avoid using the `Object` type. Did you mean `object`?',
102
+ },
103
+ Function: {
104
+ message:
105
+ 'Avoid using the `Function` type. Prefer a specific function type, like `() => void`.',
106
+ },
107
+ Boolean: {
108
+ message: 'Avoid using the `Boolean` type. Did you mean `boolean`?',
109
+ },
110
+ Number: {
111
+ message: 'Avoid using the `Number` type. Did you mean `number`?',
112
+ },
113
+ String: {
114
+ message: 'Avoid using the `String` type. Did you mean `string`?',
115
+ },
116
+ Symbol: {
117
+ message: 'Avoid using the `Symbol` type. Did you mean `symbol`?',
118
+ },
119
+ },
120
+ },
121
+ ],
122
+ '@typescript-eslint/consistent-type-assertions': 'error',
123
+ '@typescript-eslint/explicit-function-return-type': [
124
+ 'warn', // TODO: strict later
125
+ {
126
+ allowExpressions: false,
127
+ allowTypedFunctionExpressions: false,
128
+ allowHigherOrderFunctions: false,
129
+ allowDirectConstAssertionInArrowFunctions: true,
130
+ allowConciseArrowFunctionExpressionsStartingWithVoid: true,
131
+ },
132
+ ],
133
+ '@typescript-eslint/explicit-module-boundary-types': [
134
+ 'warn', // TODO: strict later
135
+ {
136
+ allowArgumentsExplicitlyTypedAsAny: true,
137
+ allowDirectConstAssertionInArrowFunctions: true,
138
+ allowHigherOrderFunctions: false,
139
+ allowTypedFunctionExpressions: false,
140
+ },
141
+ ],
142
+ '@typescript-eslint/member-delimiter-style': [
143
+ 'error',
144
+ {
145
+ multiline: {
146
+ delimiter: 'none',
147
+ requireLast: true,
148
+ },
149
+ singleline: {
150
+ delimiter: 'semi',
151
+ requireLast: false,
152
+ },
153
+ },
154
+ ],
82
155
  '@typescript-eslint/naming-convention': [
83
156
  'error',
84
157
  {
@@ -90,7 +163,72 @@ module.exports = {
90
163
  selector: 'interface',
91
164
  },
92
165
  ],
93
- '@typescript-eslint/no-unused-vars': 'error',
166
+ '@typescript-eslint/no-empty-function': 'error',
167
+ '@typescript-eslint/no-empty-interface': 'error',
168
+ '@typescript-eslint/no-explicit-any': 'error',
169
+ '@typescript-eslint/no-for-in-array': 'error',
170
+ '@typescript-eslint/no-inferrable-types': 'error',
171
+ '@typescript-eslint/no-misused-new': 'error',
172
+ '@typescript-eslint/no-namespace': 'error',
173
+ '@typescript-eslint/no-shadow': [
174
+ 'error',
175
+ {
176
+ hoist: 'all',
177
+ },
178
+ ],
179
+ '@typescript-eslint/no-this-alias': 'error',
180
+ '@typescript-eslint/no-unused-expressions': 'error',
181
+ '@typescript-eslint/no-unused-vars': [
182
+ 'error',
183
+ { varsIgnorePattern: '^jsx$' },
184
+ ],
185
+ '@typescript-eslint/no-use-before-define': 'error',
186
+ '@typescript-eslint/no-var-requires': 'error',
187
+ '@typescript-eslint/prefer-for-of': 'error',
188
+ '@typescript-eslint/prefer-function-type': 'error',
189
+ '@typescript-eslint/prefer-namespace-keyword': 'error',
190
+ '@typescript-eslint/quotes': [
191
+ 'error',
192
+ 'single',
193
+ {
194
+ avoidEscape: true,
195
+ },
196
+ ],
197
+ '@typescript-eslint/semi': ['error', 'never'],
198
+ '@typescript-eslint/triple-slash-reference': [
199
+ 'error',
200
+ {
201
+ path: 'always',
202
+ types: 'prefer-import',
203
+ lib: 'always',
204
+ },
205
+ ],
206
+ '@typescript-eslint/type-annotation-spacing': 'error',
207
+ '@typescript-eslint/typedef': 'error',
208
+ '@typescript-eslint/unified-signatures': 'error',
209
+ 'arrow-body-style': ['error', 'as-needed'],
210
+ complexity: [
211
+ 'error',
212
+ {
213
+ max: 15,
214
+ },
215
+ ],
216
+ 'constructor-super': 'error',
217
+ eqeqeq: ['error', 'smart'],
218
+ 'guard-for-in': 'error',
219
+ 'id-denylist': [
220
+ 'error',
221
+ 'any',
222
+ 'Number',
223
+ 'number',
224
+ 'String',
225
+ 'string',
226
+ 'Boolean',
227
+ 'boolean',
228
+ 'Undefined',
229
+ 'undefined',
230
+ ],
231
+ 'id-match': 'error',
94
232
  'import/no-anonymous-default-export': [
95
233
  'error',
96
234
  {
@@ -104,8 +242,58 @@ module.exports = {
104
242
  allowObject: true,
105
243
  },
106
244
  ],
245
+ 'import/no-extraneous-dependencies': [
246
+ 'error',
247
+ {
248
+ devDependencies: true,
249
+ },
250
+ ],
251
+ 'jest/no-disabled-tests': 'warn',
252
+ 'jest/no-focused-tests': 'error',
253
+ 'jest/no-identical-title': 'error',
254
+ 'jest/valid-expect': 'error',
255
+ 'max-classes-per-file': ['error', 1],
256
+ 'no-bitwise': 'error',
257
+ 'no-caller': 'error',
258
+ 'no-cond-assign': 'error',
107
259
  'no-console': 'error',
260
+ 'no-debugger': 'error',
261
+ 'no-duplicate-case': 'error',
262
+ 'no-duplicate-imports': 'error',
263
+ 'no-empty': 'error',
264
+ 'no-eval': 'error',
265
+ 'no-extra-bind': 'error',
266
+ 'no-multiple-empty-lines': 'error',
267
+ 'no-new-func': 'error',
268
+ 'no-new-wrappers': 'error',
269
+ 'no-param-reassign': 'error',
270
+ 'no-redeclare': 'error',
271
+ 'no-return-await': 'error',
272
+ 'no-sequences': 'error',
273
+ 'no-sparse-arrays': 'error',
274
+ 'no-template-curly-in-string': 'error',
275
+ 'no-throw-literal': 'error',
276
+ 'no-trailing-spaces': 'error',
277
+ 'no-undef-init': 'error',
278
+ 'no-unsafe-finally': 'error',
279
+ 'no-unused-labels': 'error',
280
+ 'no-var': 'error',
281
+ 'object-shorthand': 'error',
282
+ 'one-var': ['error', 'never'],
283
+ 'padding-line-between-statements': [
284
+ 'error',
285
+ {
286
+ blankLine: 'always',
287
+ prev: '*',
288
+ next: 'return',
289
+ },
290
+ ],
291
+ 'prefer-arrow/prefer-arrow-functions': 'error',
292
+ 'prefer-const': 'error',
293
+ 'prefer-object-spread': 'error',
294
+ 'prefer-template': 'error',
108
295
  quotes: ['error', 'single', { avoidEscape: true }],
296
+ radix: 'error',
109
297
  'react-hooks/exhaustive-deps': 'error',
110
298
  'react/jsx-curly-brace-presence': [
111
299
  'error',
@@ -124,6 +312,51 @@ module.exports = {
124
312
  'simple-import-sort/imports': 'error',
125
313
  'simple-import-sort/exports': 'error',
126
314
  'sort-keys': 'error',
315
+ 'spaced-comment': [
316
+ 'error',
317
+ 'always',
318
+ {
319
+ markers: ['/'],
320
+ },
321
+ ],
322
+ 'unicorn/better-regex': 'off',
323
+ 'unicorn/expiring-todo-comments': 'off',
324
+ 'unicorn/filename-case': [
325
+ 'warn',
326
+ {
327
+ cases: {
328
+ camelCase: true,
329
+ pascalCase: true,
330
+ },
331
+ },
332
+ ],
333
+ 'unicorn/import-style': 'warn',
334
+ 'unicorn/no-array-reduce': 'off',
335
+ 'unicorn/no-console-spaces': 'off',
336
+ 'unicorn/no-document-cookie': 'warn',
337
+ 'unicorn/no-empty-file': 'off',
338
+ 'unicorn/no-hex-escape': 'warn',
339
+ 'unicorn/no-invalid-remove-event-listener': 'warn',
340
+ 'unicorn/no-nested-ternary': 'off',
341
+ 'unicorn/no-object-as-default-parameter': 'warn',
342
+ 'unicorn/no-unreadable-array-destructuring': 'off',
343
+ 'unicorn/no-unsafe-regex': 'off',
344
+ 'unicorn/no-unused-properties': 'warn',
345
+ 'unicorn/no-zero-fractions': 'off',
346
+ 'unicorn/prefer-export-from': 'off',
347
+ 'unicorn/prefer-includes': 'off',
348
+ 'unicorn/prefer-module': 'warn',
349
+ 'unicorn/prefer-optional-catch-binding': 'off',
350
+ 'unicorn/prefer-prototype-methods': 'off',
351
+ 'unicorn/prefer-query-selector': 'off',
352
+ 'unicorn/prefer-regexp-test': 'off',
353
+ 'unicorn/prefer-set-has': 'off',
354
+ 'unicorn/prefer-set-size': 'off',
355
+ 'unicorn/prefer-string-replace-all': 'off',
356
+ 'unicorn/relative-url-style': 'off',
357
+ 'unicorn/switch-case-braces': 'off',
358
+ 'unicorn/template-indent': 'off',
359
+ 'use-isnan': 'error',
127
360
  },
128
361
  parser: '@typescript-eslint/parser',
129
362
  parserOptions: {
@@ -159,6 +392,30 @@ module.exports = {
159
392
  env: {
160
393
  browser: true,
161
394
  node: true,
395
+ 'jest/globals': true,
396
+ },
397
+ globals: {
398
+ describe: true,
399
+ expect: true,
400
+ fetch: false,
401
+ it: true,
402
+ jest: true,
403
+ MutationObserver: true,
162
404
  },
405
+ overrides: [
406
+ {
407
+ // because of jest
408
+ files: ['*.test.ts'],
409
+ rules: {
410
+ '@typescript-eslint/explicit-function-return-type': [
411
+ 'warn',
412
+ {
413
+ allowTypedFunctionExpressions: true,
414
+ },
415
+ ],
416
+ '@typescript-eslint/no-explicit-any': 'off',
417
+ },
418
+ },
419
+ ],
163
420
  root: true,
164
421
  }
package/node.js CHANGED
@@ -28,6 +28,8 @@ sortedPaths.push(...keptPaths.reverse())
28
28
 
29
29
  const hookPropertyMap = new Map(
30
30
  [
31
+ ['eslint-plugin-unicorn', 'eslint-plugin-unicorn'],
32
+ ['eslint-plugin-jest', 'eslint-plugin-jest'],
31
33
  ['eslint-plugin-import', 'eslint-plugin-import'],
32
34
  [
33
35
  'eslint-plugin-typescript-sort-keys',
@@ -55,6 +57,7 @@ require('@rushstack/eslint-patch/modern-module-resolution')
55
57
 
56
58
  module.exports = {
57
59
  extends: [
60
+ 'plugin:unicorn/recommended',
58
61
  'plugin:import/recommended',
59
62
  'plugin:import/typescript',
60
63
  'eslint:recommended',
@@ -64,6 +67,8 @@ module.exports = {
64
67
  'plugin:prettier/recommended',
65
68
  ],
66
69
  plugins: [
70
+ 'unicorn',
71
+ 'jest',
67
72
  'import',
68
73
  'typescript-sort-keys',
69
74
  'prefer-arrow',
@@ -230,6 +235,10 @@ module.exports = {
230
235
  devDependencies: true,
231
236
  },
232
237
  ],
238
+ 'jest/no-disabled-tests': 'warn',
239
+ 'jest/no-focused-tests': 'error',
240
+ 'jest/no-identical-title': 'error',
241
+ 'jest/valid-expect': 'error',
233
242
  'max-classes-per-file': ['error', 1],
234
243
  'no-bitwise': 'error',
235
244
  'no-caller': 'error',
@@ -282,6 +291,43 @@ module.exports = {
282
291
  markers: ['/'],
283
292
  },
284
293
  ],
294
+ 'unicorn/better-regex': 'off',
295
+ 'unicorn/expiring-todo-comments': 'off',
296
+ 'unicorn/filename-case': [
297
+ 'warn',
298
+ {
299
+ cases: {
300
+ camelCase: true,
301
+ pascalCase: true,
302
+ },
303
+ },
304
+ ],
305
+ 'unicorn/import-style': 'warn',
306
+ 'unicorn/no-array-reduce': 'off',
307
+ 'unicorn/no-console-spaces': 'off',
308
+ 'unicorn/no-document-cookie': 'warn',
309
+ 'unicorn/no-empty-file': 'off',
310
+ 'unicorn/no-hex-escape': 'warn',
311
+ 'unicorn/no-invalid-remove-event-listener': 'warn',
312
+ 'unicorn/no-nested-ternary': 'off',
313
+ 'unicorn/no-object-as-default-parameter': 'warn',
314
+ 'unicorn/no-unreadable-array-destructuring': 'off',
315
+ 'unicorn/no-unsafe-regex': 'off',
316
+ 'unicorn/no-unused-properties': 'warn',
317
+ 'unicorn/no-zero-fractions': 'off',
318
+ 'unicorn/prefer-export-from': 'off',
319
+ 'unicorn/prefer-includes': 'off',
320
+ 'unicorn/prefer-module': 'warn',
321
+ 'unicorn/prefer-optional-catch-binding': 'off',
322
+ 'unicorn/prefer-prototype-methods': 'off',
323
+ 'unicorn/prefer-query-selector': 'off',
324
+ 'unicorn/prefer-regexp-test': 'off',
325
+ 'unicorn/prefer-set-has': 'off',
326
+ 'unicorn/prefer-set-size': 'off',
327
+ 'unicorn/prefer-string-replace-all': 'off',
328
+ 'unicorn/relative-url-style': 'off',
329
+ 'unicorn/switch-case-braces': 'off',
330
+ 'unicorn/template-indent': 'off',
285
331
  'use-isnan': 'error',
286
332
  },
287
333
  parser: '@typescript-eslint/parser',
@@ -316,6 +362,30 @@ module.exports = {
316
362
  env: {
317
363
  node: true,
318
364
  es6: true,
365
+ 'jest/globals': true,
366
+ },
367
+ globals: {
368
+ describe: true,
369
+ expect: true,
370
+ fetch: false,
371
+ it: true,
372
+ jest: true,
373
+ MutationObserver: true,
319
374
  },
375
+ overrides: [
376
+ {
377
+ // because of jest
378
+ files: ['*.test.ts'],
379
+ rules: {
380
+ '@typescript-eslint/explicit-function-return-type': [
381
+ 'warn',
382
+ {
383
+ allowTypedFunctionExpressions: true,
384
+ },
385
+ ],
386
+ '@typescript-eslint/no-explicit-any': 'off',
387
+ },
388
+ },
389
+ ],
320
390
  root: true,
321
391
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allthings/eslint-config",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "ESlint shareable config for Allthings style",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -15,21 +15,23 @@
15
15
  "postdeploy": "git push --tags origin HEAD"
16
16
  },
17
17
  "dependencies": {
18
- "@rushstack/eslint-patch": "^1.3.3",
19
- "@typescript-eslint/eslint-plugin": "^6.6.0",
20
- "@typescript-eslint/parser": "^6.6.0",
18
+ "@rushstack/eslint-patch": "^1.4.0",
19
+ "@typescript-eslint/eslint-plugin": "^6.7.2",
20
+ "@typescript-eslint/parser": "^6.7.2",
21
21
  "eslint-config-prettier": "^9.0.0",
22
22
  "eslint-import-resolver-node": "^0.3.9",
23
23
  "eslint-import-resolver-typescript": "^3.6.0",
24
24
  "eslint-plugin-import": "^2.28.1",
25
+ "eslint-plugin-jest": "^27.4.0",
25
26
  "eslint-plugin-jsx-a11y": "^6.7.1",
26
- "eslint-plugin-n": "^16.0.2",
27
+ "eslint-plugin-n": "^16.1.0",
27
28
  "eslint-plugin-prefer-arrow": "^1.2.3",
28
29
  "eslint-plugin-prettier": "^5.0.0",
29
30
  "eslint-plugin-react": "^7.33.2",
30
31
  "eslint-plugin-react-hooks": "^4.6.0",
31
32
  "eslint-plugin-simple-import-sort": "^10.0.0",
32
- "eslint-plugin-typescript-sort-keys": "^2.3.0"
33
+ "eslint-plugin-typescript-sort-keys": "^3.0.0",
34
+ "eslint-plugin-unicorn": "^48.0.1"
33
35
  },
34
36
  "peerDependencies": {
35
37
  "eslint": ">=8.22.0",