@foray1010/eslint-config 12.3.1 → 13.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/CHANGELOG.md CHANGED
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [13.0.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@12.4.0...@foray1010/eslint-config@13.0.0) (2024-08-27)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ - **eslint-config:** require node `^18.18.0 || >=20.9.0`
11
+
12
+ ### Features
13
+
14
+ - **eslint-config:** require eslint v9 ([198866f](https://github.com/foray1010/common-presets/commit/198866f67ec6f9d534d71878c4a72e8af517d1f0))
15
+
16
+ ### Bug Fixes
17
+
18
+ - **deps:** update dependency eslint-plugin-functional to v7 ([3762aa6](https://github.com/foray1010/common-presets/commit/3762aa6819c8efe24b6426b75d385c1991b0e8c4))
19
+ - **deps:** update dependency eslint-plugin-import-x to v4 ([8e5d140](https://github.com/foray1010/common-presets/commit/8e5d140f6e7b8541f17d25a6f47ea75070ffbdd5))
20
+ - **eslint-config:** replace eslint-plugin-deprecation by typescript-eslint ([7b1e637](https://github.com/foray1010/common-presets/commit/7b1e637d55f54f5996451025112257327a6905cf))
21
+
22
+ ## [12.4.0](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@12.3.1...@foray1010/eslint-config@12.4.0) (2024-08-20)
23
+
24
+ ### Features
25
+
26
+ - **eslint-config:** support all hooks in use-deep-compare ([e689bce](https://github.com/foray1010/common-presets/commit/e689bceed67924c5b4fa31066d818fa7f73c27a0))
27
+
28
+ ### Bug Fixes
29
+
30
+ - **deps:** update dependency typescript-eslint to v8 ([e755b3e](https://github.com/foray1010/common-presets/commit/e755b3ef4fe40fa86a1e24b78660dd7911eac5d7))
31
+
6
32
  ## [12.3.1](https://github.com/foray1010/common-presets/compare/@foray1010/eslint-config@12.3.0...@foray1010/eslint-config@12.3.1) (2024-07-25)
7
33
 
8
34
  ### Bug Fixes
package/bases/base.mjs CHANGED
@@ -23,8 +23,7 @@ async function generateTypeScriptConfig() {
23
23
 
24
24
  // eslint-disable-next-line import-x/no-unresolved
25
25
  const tseslint = (await import('typescript-eslint')).default
26
- const eslintPluginDeprecation = (await import('eslint-plugin-deprecation'))
27
- .default
26
+ // eslint-disable-next-line import-x/no-unresolved
28
27
  const eslintPluginFunctional = (await import('eslint-plugin-functional'))
29
28
  .default
30
29
 
@@ -52,22 +51,10 @@ async function generateTypeScriptConfig() {
52
51
  },
53
52
  },
54
53
  plugins: {
55
- deprecation: eslintPluginDeprecation,
56
54
  functional: eslintPluginFunctional,
57
55
  },
58
56
  rules: {
59
57
  ...eslintPluginImportX.configs['typescript']?.rules,
60
- // extend existing rule
61
- '@typescript-eslint/ban-types': [
62
- 'error',
63
- {
64
- types: {
65
- // TypeScript team suggests to use `<T extends {}>` https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#unconstrained-generics-no-longer-assignable-to
66
- '{}': false,
67
- },
68
- extendDefaults: true,
69
- },
70
- ],
71
58
  // separate type exports which allow certain optimizations within compilers
72
59
  '@typescript-eslint/consistent-type-exports': [
73
60
  'error',
@@ -102,10 +89,14 @@ async function generateTypeScriptConfig() {
102
89
  ],
103
90
  // sometimes auto detect can provide a better and narrower type
104
91
  '@typescript-eslint/explicit-module-boundary-types': 'off',
92
+ // do not allow usage of deprecated code
93
+ '@typescript-eslint/no-deprecated': 'error',
105
94
  // disallow duplicated value in enum as it is error-prone
106
95
  '@typescript-eslint/no-duplicate-enum-values': 'error',
107
96
  // need empty function for react context default value
108
97
  '@typescript-eslint/no-empty-function': 'off',
98
+ // TypeScript team suggests to use `<T extends {}>` https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#unconstrained-generics-no-longer-assignable-to
99
+ '@typescript-eslint/no-empty-object-type': 'off',
109
100
  // when using typescript 5.0 with verbatimModuleSyntax flag on, compiler will not remove import statements with only inline type imports which lead to side effects
110
101
  '@typescript-eslint/no-import-type-side-effects': 'error',
111
102
  // enforce correct usage of `void` type
@@ -159,8 +150,6 @@ async function generateTypeScriptConfig() {
159
150
  '@typescript-eslint/switch-exhaustiveness-check': 'error',
160
151
  // ignore static function as those are not supposed to use `this`
161
152
  '@typescript-eslint/unbound-method': ['error', { ignoreStatic: true }],
162
- // do not allow usage of deprecated code
163
- 'deprecation/deprecation': 'error',
164
153
  // use with functional/type-declaration-immutability
165
154
  'functional/prefer-immutable-types': [
166
155
  'error',
@@ -265,48 +254,13 @@ const baseConfig = [
265
254
  js.configs.recommended,
266
255
  eslintPluginRegexp.configs['flat/recommended'],
267
256
  {
268
- languageOptions: {
269
- ecmaVersion: 2023,
270
- globals: {
271
- ...globals.es2023,
272
- /* Not using `node` to explicitly import node.js only built-in modules, e.g.
273
- * import { Buffer } from 'node:buffer'
274
- * import process from 'node:process'
275
- */
276
- ...globals['shared-node-browser'],
277
- },
278
- },
279
- plugins: {
280
- '@eslint-community/eslint-comments': eslintPluginEslintComments,
281
- // @ts-expect-error Type is not compact with flat config
282
- 'import-x': eslintPluginImportX,
283
- unicorn: eslintPluginUnicorn,
284
- },
257
+ ...eslintPluginImportX.flatConfigs.recommended,
285
258
  rules: {
286
- ...eslintPluginEslintComments.configs['recommended']?.rules,
287
- ...eslintPluginImportX.configs['recommended']?.rules,
288
- ...Object.fromEntries(
289
- Object.entries(
290
- eslintPluginUnicorn.configs['flat/recommended']?.rules ?? {},
291
- ).filter(([ruleName]) => {
292
- // only use a subset of recommended rules as other rules are too strict
293
- return (
294
- ruleName.startsWith('unicorn/no-useless-') ||
295
- ruleName.startsWith('unicorn/prefer-')
296
- )
297
- }),
298
- ),
299
- // allow disable eslint rules for whole file without re-enable it in the end of the file
300
- '@eslint-community/eslint-comments/disable-enable-pair': [
301
- 'error',
302
- { allowWholeFile: true },
303
- ],
304
- // make sure every eslint-disable comments are in use
305
- '@eslint-community/eslint-comments/no-unused-disable': 'error',
306
- // always use named function for easier to debug via stack trace
307
- 'func-names': ['error', 'as-needed'],
259
+ ...eslintPluginImportX.flatConfigs.recommended.rules,
308
260
  // this rule doesn't support commonjs, some dependencies are using commonjs
309
261
  'import-x/default': 'off',
262
+ // Does not work after upgrading to eslint-plugin-import-x v4, got this error message: `sourceType 'module' is not supported when ecmaVersion < 2015. Consider adding `{ ecmaVersion: 2015 }` to the parser options. (undefined:undefined)`
263
+ 'import-x/export': 'off',
310
264
  // enforce extensions for both cjs and esm
311
265
  'import-x/extensions': [
312
266
  'error',
@@ -374,6 +328,46 @@ const baseConfig = [
374
328
  'import-x/namespace': 'off',
375
329
  'import-x/no-named-as-default': 'off',
376
330
  'import-x/no-named-as-default-member': 'off',
331
+ },
332
+ },
333
+ {
334
+ languageOptions: {
335
+ ecmaVersion: 2023,
336
+ globals: {
337
+ ...globals.es2023,
338
+ /* Not using `node` to explicitly import node.js only built-in modules, e.g.
339
+ * import { Buffer } from 'node:buffer'
340
+ * import process from 'node:process'
341
+ */
342
+ ...globals['shared-node-browser'],
343
+ },
344
+ },
345
+ plugins: {
346
+ '@eslint-community/eslint-comments': eslintPluginEslintComments,
347
+ unicorn: eslintPluginUnicorn,
348
+ },
349
+ rules: {
350
+ ...eslintPluginEslintComments.configs['recommended']?.rules,
351
+ ...Object.fromEntries(
352
+ Object.entries(
353
+ eslintPluginUnicorn.configs['flat/recommended']?.rules ?? {},
354
+ ).filter(([ruleName]) => {
355
+ // only use a subset of recommended rules as other rules are too strict
356
+ return (
357
+ ruleName.startsWith('unicorn/no-useless-') ||
358
+ ruleName.startsWith('unicorn/prefer-')
359
+ )
360
+ }),
361
+ ),
362
+ // allow disable eslint rules for whole file without re-enable it in the end of the file
363
+ '@eslint-community/eslint-comments/disable-enable-pair': [
364
+ 'error',
365
+ { allowWholeFile: true },
366
+ ],
367
+ // make sure every eslint-disable comments are in use
368
+ '@eslint-community/eslint-comments/no-unused-disable': 'error',
369
+ // always use named function for easier to debug via stack trace
370
+ 'func-names': ['error', 'as-needed'],
377
371
  // prefer explicitly convert type for readability
378
372
  'no-implicit-coercion': 'error',
379
373
  // make sure private class members are in-use
package/bases/browser.mjs CHANGED
@@ -50,11 +50,11 @@ const browserConfig = [
50
50
  ...(await generateJestDomConfig()),
51
51
  {
52
52
  files: testFileGlobs,
53
- plugins: {
54
- 'testing-library': eslintPluginTestingLibrary,
55
- },
53
+ ...eslintPluginTestingLibrary.configs['flat/dom'],
54
+ },
55
+ {
56
+ files: testFileGlobs,
56
57
  rules: {
57
- ...eslintPluginTestingLibrary.configs['dom']?.rules,
58
58
  // allow to use nodejs modules in tests
59
59
  'import-x/no-nodejs-modules': 'off',
60
60
  },
package/bases/react.mjs CHANGED
@@ -53,18 +53,19 @@ const reactConfig = [
53
53
  {
54
54
  // support package `use-deep-compare`
55
55
  additionalHooks:
56
- '(useDeepCompareCallback|useDeepCompareEffect|useDeepCompareMemo)',
56
+ /^(useDeepCompareCallback|useDeepCompareEffect|useDeepCompareImperativeHandle|useDeepCompareLayoutEffect|useDeepCompareMemo)$/u
57
+ .source,
57
58
  },
58
59
  ],
59
60
  },
60
61
  },
61
62
  {
62
63
  files: testFileGlobs,
63
- plugins: {
64
- 'testing-library': eslintPluginTestingLibrary,
65
- },
64
+ ...eslintPluginTestingLibrary.configs['flat/react'],
65
+ },
66
+ {
67
+ files: testFileGlobs,
66
68
  rules: {
67
- ...eslintPluginTestingLibrary.configs['react']?.rules,
68
69
  // avoid using unnecessary `await` as workaround for `not wrapped in act(...)` warnings
69
70
  'testing-library/no-await-sync-events': [
70
71
  'error',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@foray1010/eslint-config",
4
- "version": "12.3.1",
4
+ "version": "13.0.0",
5
5
  "homepage": "https://github.com/foray1010/common-presets/tree/master/packages/eslint-config#readme",
6
6
  "bugs": "https://github.com/foray1010/common-presets/issues",
7
7
  "repository": {
@@ -20,37 +20,36 @@
20
20
  "type:check": "tsc"
21
21
  },
22
22
  "dependencies": {
23
- "@eslint-community/eslint-plugin-eslint-comments": "^4.1.0",
24
- "@eslint/js": "^8.53.0",
23
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
24
+ "@eslint/js": "^9.9.1",
25
25
  "@foray1010/common-presets-utils": "^8.0.0",
26
26
  "confusing-browser-globals": "^1.0.11",
27
27
  "eslint-config-prettier": "^9.1.0",
28
- "eslint-import-resolver-typescript": "^3.6.1",
28
+ "eslint-import-resolver-typescript": "^3.6.3",
29
29
  "eslint-plugin-compat": "^6.0.0",
30
- "eslint-plugin-deprecation": "^3.0.0",
31
- "eslint-plugin-functional": "^6.0.0",
32
- "eslint-plugin-import-x": "^3.0.1",
33
- "eslint-plugin-jest": "^28.6.0",
30
+ "eslint-plugin-functional": "^7.0.2",
31
+ "eslint-plugin-import-x": "^4.1.0",
32
+ "eslint-plugin-jest": "^28.8.0",
34
33
  "eslint-plugin-jest-dom": "^5.4.0",
35
- "eslint-plugin-n": "^17.0.0",
34
+ "eslint-plugin-n": "^17.10.2",
36
35
  "eslint-plugin-prettier": "^5.2.1",
37
36
  "eslint-plugin-react": "^7.35.0",
38
- "eslint-plugin-react-hooks": "^4.6.0",
37
+ "eslint-plugin-react-hooks": "^4.6.2",
39
38
  "eslint-plugin-regexp": "^2.6.0",
40
- "eslint-plugin-simple-import-sort": "^12.0.0",
41
- "eslint-plugin-testing-library": "^6.1.2",
39
+ "eslint-plugin-simple-import-sort": "^12.1.1",
40
+ "eslint-plugin-testing-library": "^6.3.0",
42
41
  "eslint-plugin-unicorn": "^55.0.0",
43
- "globals": "^15.4.0",
44
- "typescript-eslint": "^7.16.1"
42
+ "globals": "^15.9.0",
43
+ "typescript-eslint": "^8.3.0"
45
44
  },
46
45
  "devDependencies": {
47
46
  "@types/confusing-browser-globals": "1.0.3",
48
- "@types/eslint": "8.56.10",
47
+ "@types/eslint": "9.6.1",
49
48
  "@types/eslint__js": "8.42.3"
50
49
  },
51
50
  "peerDependencies": {
52
51
  "@testing-library/dom": "^10.0.0",
53
- "eslint": "^8.52.0",
52
+ "eslint": "^9.0.0",
54
53
  "prettier": "^3.0.0",
55
54
  "typescript": "^5.0.2"
56
55
  },
@@ -63,10 +62,10 @@
63
62
  }
64
63
  },
65
64
  "engines": {
66
- "node": "^18.12.0 || >=20.9.0"
65
+ "node": "^18.18.0 || >=20.9.0"
67
66
  },
68
67
  "publishConfig": {
69
68
  "access": "public"
70
69
  },
71
- "gitHead": "7901467ba1addb02e74bd1da0a3bece07cffd22b"
70
+ "gitHead": "aa4ee431e3dd279c5e4b1e14977c39a0466c1e5a"
72
71
  }