@mrpalmer/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.
package/index.js CHANGED
@@ -1,427 +1,21 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
-
4
- const tsConfig = fs.existsSync('tsconfig.json')
5
- ? path.resolve('tsconfig.json')
6
- : fs.existsSync('types/tsconfig.json')
7
- ? path.resolve('types/tsconfig.json')
8
- : undefined
9
-
10
- module.exports = {
11
- env: {
12
- browser: true,
13
- es6: true,
14
- node: true,
15
- },
16
- extends: ['prettier', './import.js'],
17
- rules: {
18
- 'accessor-pairs': 'error',
19
- 'array-callback-return': 'error',
20
- 'arrow-body-style': 'off',
21
- 'block-scoped-var': 'error',
22
- camelcase: 'off',
23
- 'capitalized-comments': 'off',
24
- 'class-methods-use-this': 'off',
25
- complexity: ['error', 20],
26
- 'consistent-return': 'error',
27
- 'consistent-this': 'off',
28
- 'constructor-super': 'error',
29
- curly: ['error', 'multi-line'],
30
- 'default-case': 'error',
31
- 'default-case-last': 'error',
32
- 'default-param-last': 'off',
33
- 'dot-notation': 'error',
34
- eqeqeq: ['error', 'smart'],
35
- 'for-direction': 'error',
36
- 'func-name-matching': 'error',
37
- 'func-names': 'error',
38
- 'func-style': 'off',
39
- 'getter-return': ['error', { allowImplicit: true }],
40
- 'grouped-accessor-pairs': 'off',
41
- 'guard-for-in': 'error',
42
- 'id-denylist': 'error',
43
- 'id-length': 'off',
44
- 'id-match': [
45
- 'error',
46
- // camelCase, PascalCase, __filename, CONST_VALUE, stream$, $el
47
- '^\\$?(__)?(([A-Z]|[a-z]|[0-9]+)|([A-Z_]))*\\$?$',
48
- ],
49
- 'init-declarations': 'off',
50
- 'line-comment-position': 'off',
51
- 'lines-between-class-members': 'off',
52
- 'max-classes-per-file': 'off',
53
- 'max-depth': ['error', 4],
54
- 'max-lines': [
55
- 'error',
56
- { max: 2500, skipBlankLines: false, skipComments: false },
57
- ],
58
- 'max-lines-per-function': 'off',
59
- 'max-nested-callbacks': ['error', 7],
60
- 'max-params': ['error', 7],
61
- 'max-statements': 'off',
62
- 'max-statements-per-line': ['error', { max: 1 }],
63
- 'multiline-comment-style': 'off',
64
- 'new-cap': 'error',
65
- 'no-alert': 'error',
66
- 'no-array-constructor': 'error',
67
- 'no-async-promise-executor': 'off',
68
- 'no-await-in-loop': 'error',
69
- 'no-bitwise': 'error',
70
- 'no-caller': 'error',
71
- 'no-case-declarations': 'error',
72
- 'no-class-assign': 'error',
73
- 'no-compare-neg-zero': 'error',
74
- 'no-cond-assign': 'error',
75
- 'no-console': 'off',
76
- 'no-const-assign': 'error',
77
- 'no-constant-condition': 'error',
78
- 'no-constructor-return': 'error',
79
- 'no-continue': 'off',
80
- 'no-control-regex': 'error',
81
- 'no-debugger': 'error',
82
- 'no-delete-var': 'error',
83
- 'no-div-regex': 'error',
84
- 'no-dupe-args': 'error',
85
- 'no-dupe-class-members': 'error',
86
- 'no-dupe-else-if': 'error',
87
- 'no-dupe-keys': 'error',
88
- 'no-duplicate-case': 'error',
89
- 'no-duplicate-imports': 'error',
90
- 'no-else-return': 'off',
91
- 'no-empty': 'error',
92
- 'no-empty-character-class': 'error',
93
- 'no-empty-function': 'off',
94
- 'no-empty-pattern': 'error',
95
- 'no-eq-null': 'off',
96
- 'no-eval': 'error',
97
- 'no-ex-assign': 'error',
98
- 'no-extend-native': 'error',
99
- 'no-extra-bind': 'error',
100
- 'no-extra-boolean-cast': 'off',
101
- 'no-extra-label': 'error',
102
- 'no-fallthrough': 'error',
103
- 'no-func-assign': 'error',
104
- 'no-global-assign': 'error',
105
- 'no-implicit-coercion': 'off',
106
- 'no-implicit-globals': 'error',
107
- 'no-implied-eval': 'error',
108
- 'no-import-assign': 'error',
109
- 'no-inline-comments': 'off',
110
- 'no-inner-declarations': 'error',
111
- 'no-invalid-regexp': 'error',
112
- 'no-invalid-this': 'error',
113
- 'no-irregular-whitespace': 'error',
114
- 'no-iterator': 'error',
115
- 'no-label-var': 'error',
116
- 'no-labels': 'error',
117
- 'no-lone-blocks': 'error',
118
- 'no-lonely-if': 'error',
119
- 'no-loop-func': 'error',
120
- 'no-loss-of-precision': 'error',
121
- 'no-magic-numbers': 'off',
122
- 'no-misleading-character-class': 'off',
123
- 'no-multi-assign': 'error',
124
- 'no-multi-str': 'error',
125
- 'no-negated-condition': 'error',
126
- 'no-nested-ternary': 'off',
127
- 'no-new': 'error',
128
- 'no-new-func': 'error',
129
- 'no-new-object': 'error',
130
- 'no-new-symbol': 'error',
131
- 'no-new-wrappers': 'error',
132
- 'no-nonoctal-decimal-escape': 'error',
133
- 'no-obj-calls': 'error',
134
- 'no-octal': 'error',
135
- 'no-octal-escape': 'error',
136
- 'no-param-reassign': 'off',
137
- 'no-plusplus': 'off',
138
- 'no-promise-executor-return': 'off',
139
- 'no-proto': 'error',
140
- 'no-prototype-builtins': 'off',
141
- 'no-redeclare': 'error',
142
- 'no-regex-spaces': 'error',
143
- 'no-restricted-exports': 'off',
144
- 'no-restricted-globals': ['error', 'event', 'fdescribe'],
145
- 'no-restricted-imports': 'off',
146
- 'no-restricted-properties': 'off',
147
- 'no-restricted-syntax': ['error', 'WithStatement'],
148
- 'no-return-assign': 'error',
149
- 'no-return-await': 'error',
150
- 'no-script-url': 'error',
151
- 'no-self-assign': 'error',
152
- 'no-self-compare': 'error',
153
- 'no-sequences': 'error',
154
- 'no-setter-return': 'error',
155
- 'no-shadow': 'off',
156
- 'no-shadow-restricted-names': 'error',
157
- 'no-sparse-arrays': 'error',
158
- 'no-template-curly-in-string': 'error',
159
- 'no-ternary': 'off',
160
- 'no-this-before-super': 'error',
161
- 'no-throw-literal': 'error',
162
- 'no-undef': 'error',
163
- 'no-undef-init': 'error',
164
- 'no-undefined': 'off',
165
- 'no-underscore-dangle': 'off',
166
- 'no-unmodified-loop-condition': 'error',
167
- 'no-unneeded-ternary': 'error',
168
- 'no-unreachable': 'error',
169
- 'no-unreachable-loop': 'error',
170
- 'no-unsafe-finally': 'error',
171
- 'no-unsafe-negation': 'error',
172
- 'no-unsafe-optional-chaining': 'error',
173
- 'no-unused-expressions': 'off',
174
- 'no-unused-labels': 'error',
175
- 'no-unused-private-class-members': 'error',
176
- 'no-unused-vars': [
177
- 'error',
178
- {
179
- args: 'after-used',
180
- argsIgnorePattern: '^_',
181
- ignoreRestSiblings: true,
182
- varsIgnorePattern: '^ignored',
183
- },
184
- ],
185
- 'no-use-before-define': ['error', 'nofunc'],
186
- 'no-useless-backreference': 'error',
187
- 'no-useless-call': 'error',
188
- 'no-useless-catch': 'error',
189
- 'no-useless-computed-key': 'error',
190
- 'no-useless-concat': 'error',
191
- 'no-useless-constructor': 'error',
192
- 'no-useless-escape': 'error',
193
- 'no-useless-rename': 'error',
194
- 'no-useless-return': 'error',
195
- 'no-var': 'error',
196
- 'no-void': 'off',
197
- 'no-warning-comments': [
198
- 'error',
199
- { location: 'anywhere', terms: ['fixme'] },
200
- ],
201
- 'no-with': 'off',
202
- 'object-shorthand': ['error', 'properties'],
203
- 'one-var': ['error', { initialized: 'never', uninitialized: 'always' }],
204
- 'operator-assignment': 'off',
205
- 'padding-line-between-statements': 'off',
206
- 'prefer-arrow-callback': [
207
- 'error',
208
- { allowNamedFunctions: true, allowUnboundThis: true },
209
- ],
210
- 'prefer-const': 'error',
211
- 'prefer-destructuring': 'off',
212
- 'prefer-exponentiation-operator': 'warn',
213
- 'prefer-named-capture-group': 'off',
214
- 'prefer-numeric-literals': 'error',
215
- 'prefer-object-has-own': 'error',
216
- 'prefer-object-spread': 'warn',
217
- 'prefer-promise-reject-errors': 'off',
218
- 'prefer-regex-literals': 'off',
219
- 'prefer-rest-params': 'error',
220
- 'prefer-spread': 'error',
221
- 'prefer-template': 'error',
222
- radix: 'error',
223
- 'require-atomic-updates': 'off',
224
- 'require-await': 'off',
225
- 'require-unicode-regexp': 'off',
226
- 'require-yield': 'error',
227
- 'sort-imports': 'off',
228
- 'sort-keys': 'off',
229
- 'sort-vars': 'off',
230
- 'spaced-comment': 'off',
231
- strict: 'error',
232
- 'symbol-description': 'error',
233
- 'use-isnan': 'error',
234
- 'valid-typeof': 'error',
235
- 'vars-on-top': 'error',
236
- yoda: 'error',
237
- },
238
- overrides: [
239
- {
240
- files: ['**/*.ts?(x)'],
241
- parser: '@typescript-eslint/parser',
242
- parserOptions: {
243
- ecmaVersion: 2018,
244
- project: tsConfig,
245
- sourceType: 'module',
246
- },
247
- plugins: ['@typescript-eslint'],
248
- rules: {
249
- 'constructor-super': 'off', // ts(2335) & ts(2377)
250
- 'getter-return': 'off', // ts(2378)
251
- 'no-const-assign': 'off', // ts(2588)
252
- 'no-dupe-args': 'off', // ts(2300)
253
- 'no-dupe-keys': 'off', // ts(1117)
254
- 'no-func-assign': 'off', // ts(2539)
255
- 'no-import-assign': 'off', // ts(2539) & ts(2540)
256
- 'no-new-symbol': 'off', // ts(2588)
257
- 'no-obj-calls': 'off', // ts(2349)
258
- 'no-setter-return': 'off', // ts(2408)
259
- 'no-this-before-super': 'off', // ts(2376)
260
- 'no-undef': 'off', // ts(2304)
261
- 'no-unreachable': 'off', // ts(7027)
262
- 'no-unsafe-negation': 'off', // ts(2365) & ts(2360) & ts(2358)
263
- 'valid-typeof': 'off', // ts(2367)
264
-
265
- 'consistent-return': 'off', // in TS this is much less an issue
266
- 'no-var': 'error', // TS transpiles let/const to var, so no need for vars anymore
267
- 'prefer-const': 'error', // TS provides better types with const
268
- 'prefer-rest-params': 'error', // TS provides better types with rest args over arguments
269
- 'prefer-spread': 'error', // TS transpiles spread to apply, so no need for manual apply
270
-
271
- 'default-param-last': 'off',
272
- '@typescript-eslint/default-param-last': 'off',
273
-
274
- 'dot-notation': 'off',
275
- '@typescript-eslint/dot-notation': 'error',
276
-
277
- 'init-declarations': 'off',
278
- '@typescript-eslint/init-declarations': 'off',
279
-
280
- 'lines-between-class-members': 'off',
281
- '@typescript-eslint/lines-between-class-members': 'off',
282
-
283
- 'no-array-constructor': 'off',
284
- '@typescript-eslint/no-array-constructor': 'error',
285
-
286
- 'no-dupe-class-members': 'off',
287
- '@typescript-eslint/no-dupe-class-members': 'off', // ts(2393) & ts(2300)
288
-
289
- 'no-duplicate-imports': 'off',
290
- '@typescript-eslint/no-duplicate-imports': 'error',
291
-
292
- 'no-empty-function': 'off',
293
- '@typescript-eslint/no-empty-function': 'off',
294
-
295
- 'no-implied-eval': 'error',
296
- '@typescript-eslint/no-implied-eval': 'error',
297
-
298
- 'no-invalid-this': 'off',
299
- '@typescript-eslint/no-invalid-this': 'error',
300
-
301
- 'no-loop-func': 'off',
302
- '@typescript-eslint/no-loop-func': 'error',
303
-
304
- 'no-loss-of-precision': 'off',
305
- '@typescript-eslint/no-loss-of-precision': 'error',
306
-
307
- 'no-magic-numbers': 'off',
308
- '@typescript-eslint/no-magic-numbers': 'off',
309
-
310
- 'no-redeclare': 'off',
311
- '@typescript-eslint/no-redeclare': 'off', // ts(2451)
312
-
313
- 'no-return-await': 'off',
314
- '@typescript-eslint/return-await': 'error',
315
-
316
- 'no-shadow': 'off',
317
- '@typescript-eslint/no-shadow': 'off',
318
-
319
- 'no-throw-literal': 'off',
320
- '@typescript-eslint/no-throw-literal': 'error',
321
-
322
- 'no-use-before-define': 'off',
323
- '@typescript-eslint/no-use-before-define': ['error', 'nofunc'],
324
-
325
- 'no-unused-expressions': 'off',
326
- '@typescript-eslint/no-unused-expressions': 'off',
327
-
328
- 'no-unused-vars': 'off',
329
- '@typescript-eslint/no-unused-vars': [
330
- 'error',
331
- {
332
- args: 'after-used',
333
- argsIgnorePattern: '^_',
334
- ignoreRestSiblings: true,
335
- varsIgnorePattern: '^ignored',
336
- },
337
- ],
338
-
339
- 'no-useless-constructor': 'off',
340
- '@typescript-eslint/no-useless-constructor': 'error',
1
+ import globals from 'globals'
2
+ import { config } from 'typescript-eslint'
3
+ import base from './configs/base.js'
4
+ import jest from './configs/jest.js'
5
+ import react from './configs/react.js'
6
+ import typescript from './configs/typescript.js'
7
+
8
+ const configs = {
9
+ all: [...base, ...react, ...jest, ...typescript],
10
+ base,
11
+ jest,
12
+ react,
13
+ typescript,
14
+ }
341
15
 
342
- '@typescript-eslint/adjacent-overload-signatures': 'error',
343
- '@typescript-eslint/array-type': 'off',
344
- '@typescript-eslint/await-thenable': 'error',
345
- '@typescript-eslint/ban-ts-comment': 'error',
346
- '@typescript-eslint/ban-tslint-comment': 'error',
347
- '@typescript-eslint/ban-types': 'off',
348
- '@typescript-eslint/class-literal-property-style': 'off',
349
- '@typescript-eslint/consistent-indexed-object-style': 'off',
350
- '@typescript-eslint/consistent-type-assertions': 'off',
351
- '@typescript-eslint/consistent-type-definitions': 'off',
352
- '@typescript-eslint/consistent-type-imports': 'off',
353
- '@typescript-eslint/explicit-function-return-type': 'off',
354
- '@typescript-eslint/explicit-module-boundary-types': 'off',
355
- '@typescript-eslint/member-delimiter-style': 'off',
356
- '@typescript-eslint/member-ordering': 'off',
357
- '@typescript-eslint/method-signature-style': 'off',
358
- '@typescript-eslint/naming-convention': 'off',
359
- '@typescript-eslint/no-base-to-string': 'warn',
360
- '@typescript-eslint/no-confusing-non-null-assertion': 'off',
361
- '@typescript-eslint/no-confusing-void-expression': 'off',
362
- '@typescript-eslint/no-dynamic-delete': 'error',
363
- '@typescript-eslint/no-empty-interface': 'error',
364
- '@typescript-eslint/no-explicit-any': 'error',
365
- '@typescript-eslint/no-extra-non-null-assertion': 'error',
366
- '@typescript-eslint/no-extraneous-class': 'error',
367
- '@typescript-eslint/no-floating-promises': 'warn',
368
- '@typescript-eslint/no-for-in-array': 'error',
369
- '@typescript-eslint/no-implicit-any-catch': 'warn',
370
- '@typescript-eslint/no-inferrable-types': 'off',
371
- '@typescript-eslint/no-invalid-void-type': 'warn',
372
- '@typescript-eslint/no-misused-new': 'error',
373
- '@typescript-eslint/no-misused-promises': [
374
- 'warn',
375
- { checksVoidReturn: false },
376
- ],
377
- '@typescript-eslint/no-namespace': 'error',
378
- '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
379
- '@typescript-eslint/no-non-null-assertion': 'error',
380
- '@typescript-eslint/no-parameter-properties': 'off',
381
- '@typescript-eslint/no-require-imports': 'off',
382
- '@typescript-eslint/no-this-alias': 'error',
383
- '@typescript-eslint/no-type-alias': 'off',
384
- '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
385
- '@typescript-eslint/no-unnecessary-condition': 'error',
386
- '@typescript-eslint/no-unnecessary-qualifier': 'warn',
387
- '@typescript-eslint/no-unnecessary-type-arguments': 'off',
388
- '@typescript-eslint/no-unnecessary-type-assertion': 'error',
389
- '@typescript-eslint/no-unnecessary-type-constraint': 'error',
390
- '@typescript-eslint/no-unsafe-argument': 'error',
391
- '@typescript-eslint/no-unsafe-assignment': 'warn',
392
- '@typescript-eslint/no-unsafe-call': 'warn',
393
- '@typescript-eslint/no-unsafe-member-access': 'warn',
394
- '@typescript-eslint/no-unsafe-return': 'off',
395
- '@typescript-eslint/no-var-requires': 'error',
396
- '@typescript-eslint/non-nullable-type-assertion-style': 'off',
397
- '@typescript-eslint/prefer-as-const': 'error',
398
- '@typescript-eslint/prefer-enum-initializers': 'error',
399
- '@typescript-eslint/prefer-for-of': 'off',
400
- '@typescript-eslint/prefer-function-type': 'off',
401
- '@typescript-eslint/prefer-includes': 'error',
402
- '@typescript-eslint/prefer-literal-enum-member': 'error',
403
- '@typescript-eslint/prefer-namespace-keyword': 'error',
404
- '@typescript-eslint/prefer-nullish-coalescing': 'error',
405
- '@typescript-eslint/prefer-optional-chain': 'error',
406
- '@typescript-eslint/prefer-readonly': 'off',
407
- '@typescript-eslint/prefer-readonly-parameter-types': 'off',
408
- '@typescript-eslint/prefer-reduce-type-parameter': 'warn',
409
- '@typescript-eslint/prefer-regexp-exec': 'off',
410
- '@typescript-eslint/prefer-string-starts-ends-with': 'error',
411
- '@typescript-eslint/prefer-ts-expect-error': 'error',
412
- '@typescript-eslint/promise-function-async': 'off',
413
- '@typescript-eslint/require-array-sort-compare': 'off',
414
- '@typescript-eslint/require-await': 'off',
415
- '@typescript-eslint/restrict-plus-operands': 'error',
416
- '@typescript-eslint/restrict-template-expressions': 'off',
417
- '@typescript-eslint/sort-type-union-intersection-members': 'off',
418
- '@typescript-eslint/strict-boolean-expressions': 'off',
419
- '@typescript-eslint/switch-exhaustiveness-check': 'error',
420
- '@typescript-eslint/triple-slash-reference': 'error',
421
- '@typescript-eslint/typedef': 'off',
422
- '@typescript-eslint/unbound-method': 'error',
423
- '@typescript-eslint/unified-signatures': 'warn',
424
- },
425
- },
426
- ],
16
+ export default {
17
+ config,
18
+ configs,
19
+ globals,
427
20
  }
21
+ export { config, configs, globals }
package/package.json CHANGED
@@ -1,44 +1,58 @@
1
1
  {
2
2
  "name": "@mrpalmer/eslint-config",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Mike Palmer's personal ESLint rules",
5
5
  "license": "MIT",
6
+ "type": "module",
6
7
  "main": "index.js",
7
8
  "scripts": {
8
- "find-new-rules": "run-p find-new-rules:*",
9
- "find-new-rules:jest": "eslint-find-rules --unused ./test/jest.js",
10
- "find-new-rules:jsx-a11y": "eslint-find-rules --unused ./test/jsx-a11y.js",
11
- "find-new-rules:main": "eslint-find-rules --unused ./index.js",
12
- "find-new-rules:react": "eslint-find-rules --unused ./test/react.js",
13
- "lint": "eslint --config index.js .",
14
- "validate": "run-p lint find-new-rules"
9
+ "check-config": "run-p check-config:*",
10
+ "check-config:jest": "cd test && validate-config -f component.test.js",
11
+ "check-config:jest-ts": "cd test && validate-config -f component.test.ts",
12
+ "check-config:js": "cd test && validate-config -f index.js",
13
+ "check-config:ts": "cd test && validate-config -f index.ts",
14
+ "dev": "cd test && eslint-config-inspector",
15
+ "validate": "npm run check-config"
15
16
  },
16
17
  "dependencies": {
17
- "@typescript-eslint/eslint-plugin": "^5.9.0",
18
- "@typescript-eslint/parser": "^5.9.0",
19
- "eslint-config-prettier": "^8.3.0",
20
- "eslint-plugin-import": "^2.25.4",
21
- "eslint-plugin-jest": "^25.3.4",
22
- "eslint-plugin-jest-dom": "^4.0.1",
23
- "eslint-plugin-jsx-a11y": "^6.5.1",
24
- "eslint-plugin-react": "^7.28.0",
25
- "eslint-plugin-react-hooks": "^4.3.0",
26
- "eslint-plugin-testing-library": "^5.0.1",
27
- "read-pkg-up": "^7.0.1",
28
- "semver": "^7.3.2"
18
+ "@eslint/js": "^9.20.0",
19
+ "@types/eslint__js": "^8.42.3",
20
+ "eslint-plugin-import": "^2.31.0",
21
+ "eslint-plugin-jest": "^28.11.0",
22
+ "eslint-plugin-jest-dom": "^5.5.0",
23
+ "eslint-plugin-jsx-a11y": "^6.10.2",
24
+ "eslint-plugin-react": "^7.37.4",
25
+ "eslint-plugin-react-hooks": "^5.1.0",
26
+ "eslint-plugin-testing-library": "^7.1.1",
27
+ "globals": "^15.14.0",
28
+ "read-package-up": "^11.0.0",
29
+ "semver": "^7.3.2",
30
+ "typescript-eslint": "^8.23.0"
29
31
  },
30
32
  "peerDependencies": {
31
- "eslint": "^8.0.0",
32
- "typescript": "^4.0.0"
33
+ "@testing-library/dom": "*",
34
+ "@testing-library/jest-dom": "*",
35
+ "@testing-library/react": "*",
36
+ "eslint": "^9.0.0",
37
+ "typescript": "^5.0.0"
33
38
  },
34
39
  "peerDependenciesMeta": {
40
+ "@testing-library/dom": {
41
+ "optional": true
42
+ },
43
+ "@testing-library/jest-dom": {
44
+ "optional": true
45
+ },
46
+ "@testing-library/react": {
47
+ "optional": true
48
+ },
35
49
  "typescript": {
36
50
  "optional": true
37
51
  }
38
52
  },
39
53
  "engines": {
40
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0",
41
- "npm": ">=6",
54
+ "node": ">=20",
55
+ "npm": ">=8",
42
56
  "yarn": ">=1"
43
57
  }
44
58
  }
@@ -0,0 +1,41 @@
1
+ import { readPackageUpSync } from 'read-package-up'
2
+ import * as semver from 'semver'
3
+
4
+ /** @typedef {Record<string, string>} Dependencies */
5
+
6
+ /**
7
+ * Get all dependencies from the current project
8
+ * @returns {Dependencies}
9
+ */
10
+ export function getAllDependencies() {
11
+ try {
12
+ const result = readPackageUpSync() ?? {}
13
+ return {
14
+ ...result.packageJson?.peerDependencies,
15
+ ...result.packageJson?.devDependencies,
16
+ ...result.packageJson?.dependencies,
17
+ }
18
+ } catch {
19
+ return {}
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Get the installed version of a dependency
25
+ * @param {Dependencies} allDeps
26
+ * @param {string} depName
27
+ * @returns {string | undefined}
28
+ */
29
+ export function getMinimumSupportedVersion(allDeps, depName) {
30
+ if (!allDeps[depName]) {
31
+ return undefined
32
+ }
33
+
34
+ const versions = semver
35
+ .validRange(allDeps[depName])
36
+ .replace(/[>=<|]/g, ' ')
37
+ .split(' ')
38
+ .filter(Boolean)
39
+ .sort(semver.compare)
40
+ return versions[0]
41
+ }
package/import.js DELETED
@@ -1,72 +0,0 @@
1
- module.exports = {
2
- env: {
3
- es6: true,
4
- },
5
- parserOptions: {
6
- ecmaVersion: 2018,
7
- sourceType: 'module',
8
- },
9
- plugins: ['import'],
10
- settings: {
11
- 'import/ignore': ['node_modules', '.json$', '.(scss|less|css|styl)$'],
12
- },
13
- rules: {
14
- 'import/default': 'error',
15
- 'import/dynamic-import-chunkname': 'off',
16
- 'import/export': 'error',
17
- 'import/exports-last': 'off',
18
- 'import/extensions': 'off',
19
- 'import/first': 'error',
20
- 'import/group-exports': 'off',
21
- 'import/max-dependencies': 'off',
22
- 'import/named': 'error',
23
- 'import/namespace': 'error',
24
- 'import/newline-after-import': 'off',
25
- 'import/no-absolute-path': 'error',
26
- 'import/no-amd': 'error',
27
- 'import/no-anonymous-default-export': 'error',
28
- 'import/no-commonjs': 'off',
29
- 'import/no-cycle': 'off',
30
- 'import/no-default-export': 'off',
31
- 'import/no-deprecated': 'warn',
32
- 'import/no-duplicates': 'error',
33
- 'import/no-dynamic-require': 'off',
34
- 'import/no-extraneous-dependencies': 'error',
35
- 'import/no-import-module-exports': 'error',
36
- 'import/no-internal-modules': 'off',
37
- 'import/no-mutable-exports': 'error',
38
- 'import/no-named-as-default': 'error',
39
- 'import/no-named-as-default-member': 'error',
40
- 'import/no-named-default': 'error',
41
- 'import/no-named-export': 'off',
42
- 'import/no-namespace': 'off',
43
- 'import/no-nodejs-modules': 'off',
44
- 'import/no-relative-packages': 'warn',
45
- 'import/no-relative-parent-imports': 'off',
46
- 'import/no-restricted-paths': 'off',
47
- 'import/no-self-import': 'error',
48
- 'import/no-unassigned-import': 'off',
49
- 'import/no-unresolved': 'error',
50
- 'import/no-unused-modules': 'off',
51
- 'import/no-useless-path-segments': 'error',
52
- 'import/no-webpack-loader-syntax': 'error',
53
- 'import/order': 'off',
54
- 'import/prefer-default-export': 'off',
55
- 'import/unambiguous': 'off',
56
- },
57
- overrides: [
58
- {
59
- files: ['**/*.ts?(x)'],
60
- extends: 'plugin:import/typescript',
61
- parser: '@typescript-eslint/parser',
62
- parserOptions: {
63
- ecmaVersion: 2018,
64
- sourceType: 'module',
65
- },
66
- plugins: ['@typescript-eslint'],
67
- rules: {
68
- 'import/no-unresolved': 'off', // ts(2307)
69
- },
70
- },
71
- ],
72
- }