@codfish/eslint-config 12.3.0 → 13.1.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @codfish/eslint-config
2
2
 
3
3
  > Modern ESLint configuration with TypeScript, React/Next.js, YAML, Testing Library, and testing framework support using
4
- > ESLint v9+ flat config format.
4
+ > ESLint v10+ flat config format.
5
5
 
6
6
  [![version](https://img.shields.io/npm/v/@codfish/eslint-config.svg)](http://npm.im/@codfish/eslint-config)
7
7
  [![downloads](https://img.shields.io/npm/dm/@codfish/eslint-config.svg)](http://npm-stat.com/charts.html?package=@codfish/eslint-config&from=2015-08-01)
@@ -24,6 +24,10 @@
24
24
  - [Use in combination with prettier-plugin-tailwindcss](#use-in-combination-with-prettier-plugin-tailwindcss)
25
25
  - [Example scripts](#example-scripts)
26
26
  - [Commitlint Configuration](#commitlint-configuration)
27
+ - [Upgrading to ESLint 10](#upgrading-to-eslint-10)
28
+ - [Breaking Changes in ESLint 10](#breaking-changes-in-eslint-10)
29
+ - [Migration Steps](#migration-steps)
30
+ - [What Changed](#what-changed)
27
31
  - [Migration from Legacy Config](#migration-from-legacy-config)
28
32
 
29
33
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -31,7 +35,7 @@
31
35
 
32
36
  ## Features
33
37
 
34
- - **Modern ESLint v9+ flat config**: Uses the new flat configuration format
38
+ - **Modern ESLint v10+ flat config**: Uses the new flat configuration format
35
39
  - **Dynamic feature detection**: Automatically configures based on your project's dependencies
36
40
  - **TypeScript support**: Full TypeScript linting with modern typescript-eslint parser and rules
37
41
  - **React ecosystem**: React, React Hooks, and JSX accessibility rules when React is detected
@@ -49,7 +53,7 @@
49
53
  Install the package and required peer dependencies:
50
54
 
51
55
  ```sh
52
- npm i -D eslint@9 @codfish/eslint-config
56
+ npm i -D eslint@10 @codfish/eslint-config
53
57
 
54
58
  # Optionally, you can uninstall plugins or presets you don't need to manage anymore,
55
59
  # @codfish/eslint-config includes them all.
@@ -379,7 +383,7 @@ export default {
379
383
  ### Use in combination with prettier-plugin-tailwindcss
380
384
 
381
385
  ```sh
382
- npm i -D eslint@9 @codfish/eslint-config prettier-plugin-tailwindcss
386
+ npm i -D eslint@10 @codfish/eslint-config prettier-plugin-tailwindcss
383
387
  ```
384
388
 
385
389
  ```js
@@ -501,11 +505,72 @@ jobs:
501
505
  --verbose
502
506
  ```
503
507
 
508
+ ## Upgrading to ESLint 10
509
+
510
+ This package now requires **ESLint 10.0.0 or higher** and **Node.js v20.19.0 or higher**.
511
+
512
+ ### Breaking Changes in ESLint 10
513
+
514
+ - **ESLint 10 Required**: Minimum ESLint version is now 10.0.0
515
+ - **Node.js v20.19.0+**: Minimum Node.js version increased from v20.0.0 to v20.19.0
516
+ - **Legacy eslintrc removed**: ESLint 10 completely removes the deprecated eslintrc config system (this package already
517
+ uses flat config)
518
+ - **Improved JSX tracking**: ESLint 10 properly tracks JSX references in scope analysis, which may surface previously
519
+ hidden unused import warnings in React files
520
+ - **New recommended rules**: Three new rules enabled in `eslint:recommended`:
521
+ - `no-unassigned-vars` - Disallow variables that are assigned but never used
522
+ - `no-useless-assignment` - Disallow assignments that don't change the value
523
+ - `preserve-caught-error` - Enforce that caught errors are not reassigned
524
+
525
+ ### Migration Steps
526
+
527
+ 1. **Update Node.js** (if needed):
528
+
529
+ ```sh
530
+ node --version # Ensure you're on v20.19.0+ or v22.13.0+
531
+ ```
532
+
533
+ 2. **Update ESLint and this config**:
534
+
535
+ ```sh
536
+ npm install --save-dev eslint@10 @codfish/eslint-config@latest
537
+ ```
538
+
539
+ 3. **Install dependencies with legacy peer deps** (required until all plugins update):
540
+
541
+ ```sh
542
+ npm install --legacy-peer-deps
543
+ ```
544
+
545
+ This is necessary because some ESLint plugins haven't updated their `peerDependencies` to include ESLint 10 yet. The
546
+ plugins still work correctly with ESLint 10.
547
+
548
+ 4. **Run linting** and check for new violations:
549
+
550
+ ```sh
551
+ npm run lint
552
+ ```
553
+
554
+ 5. **Review React files** for newly reported unused imports. ESLint 10's improved JSX tracking may flag imports that
555
+ were previously ignored but are actually used in JSX.
556
+
557
+ ### What Changed
558
+
559
+ Since this package already uses ESLint's flat config format (the biggest change in ESLint 9), the upgrade to ESLint 10
560
+ is relatively smooth. The main changes are:
561
+
562
+ - ✅ Flat config format (already implemented)
563
+ - ✅ Plugin configurations updated to ESLint 10-compatible versions
564
+ - ✅ All tests passing with ESLint 10
565
+ - ⚠️ Some plugins show peer dependency warnings but work correctly (ecosystem is catching up)
566
+
567
+ For more details, see the [ESLint 10 Migration Guide](https://eslint.org/docs/latest/use/migrate-to-10.0.0).
568
+
504
569
  ## Migration from Legacy Config
505
570
 
506
571
  If you're upgrading from an older version that used Airbnb presets:
507
572
 
508
- 1. **Update to ESLint v9+**: `npm install --save-dev eslint@9`
573
+ 1. **Update to ESLint v10+**: `npm install --save-dev eslint@10`
509
574
  2. **Switch to flat config**: Replace `.eslintrc.js` with `eslint.config.js`
510
575
  3. **Use import syntax**: Change from `require()` to `import` statements
511
576
  4. **Remove explicit React config**: React support is now automatically detected
@@ -0,0 +1,38 @@
1
+ export default tseslintConfig;
2
+ export const rules: {
3
+ '@typescript-eslint/no-unused-vars': (string | {
4
+ ignoreRestSiblings: boolean;
5
+ })[];
6
+ '@typescript-eslint/no-empty-function': string;
7
+ '@typescript-eslint/naming-convention': (string | {
8
+ selector: string[];
9
+ format: string[];
10
+ custom: {
11
+ regex: string;
12
+ match: boolean;
13
+ };
14
+ })[];
15
+ '@typescript-eslint/ban-ts-comment': (string | {
16
+ 'ts-ignore': string;
17
+ 'ts-expect-error': string;
18
+ 'ts-nocheck': string;
19
+ })[];
20
+ '@typescript-eslint/no-restricted-types': (string | {
21
+ types: {
22
+ 'React.FC': {
23
+ message: string;
24
+ };
25
+ 'React.FunctionComponent': {
26
+ message: string;
27
+ };
28
+ };
29
+ })[];
30
+ } | {
31
+ '@typescript-eslint/no-unused-vars'?: never;
32
+ '@typescript-eslint/no-empty-function'?: never;
33
+ '@typescript-eslint/naming-convention'?: never;
34
+ '@typescript-eslint/ban-ts-comment'?: never;
35
+ '@typescript-eslint/no-restricted-types'?: never;
36
+ };
37
+ declare const tseslintConfig: import("eslint").Linter.Config[];
38
+ //# sourceMappingURL=typescript.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../rules/typescript.js"],"names":[],"mappings":";AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCO;AA9CP,8BACa,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CACsC"}
package/index.js CHANGED
@@ -8,14 +8,13 @@ import prettierConfig from 'eslint-plugin-prettier/recommended';
8
8
  import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
9
9
  import ymlPlugin from 'eslint-plugin-yml';
10
10
  import globals from 'globals';
11
- import tseslint from 'typescript-eslint';
12
11
 
13
12
  import prettierBuiltInConfig from './prettier.js';
14
13
  import configFilesConfig from './rules/config-files.js';
15
14
  import reactConfig from './rules/react.js';
16
15
  import testConfig from './rules/tests.js';
16
+ import tseslintConfig, { rules as tsRules } from './rules/typescript.js';
17
17
  import { hasLocalConfig, ifAnyDep } from './utils.js';
18
-
19
18
  const useBuiltinPrettierConfig = !hasLocalConfig('prettier');
20
19
 
21
20
  /**
@@ -34,7 +33,7 @@ export default defineConfig([
34
33
 
35
34
  files: ['**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'],
36
35
 
37
- extends: [js.configs.recommended, tseslint.configs.recommended],
36
+ extends: [js.configs.recommended, ...tseslintConfig],
38
37
 
39
38
  plugins: {
40
39
  'simple-import-sort': simpleImportSortPlugin,
@@ -43,6 +42,9 @@ export default defineConfig([
43
42
  languageOptions: {
44
43
  ecmaVersion: 'latest',
45
44
  sourceType: 'module',
45
+ parserOptions: {
46
+ ecmaFeatures: { jsx: true },
47
+ },
46
48
  globals: {
47
49
  ...globals.browser,
48
50
  ...globals.node,
@@ -54,8 +56,10 @@ export default defineConfig([
54
56
  // Error handling rules to enforce using the Error object
55
57
  'no-throw-literal': 'error',
56
58
  'prefer-promise-reject-errors': 'error',
59
+ 'no-unused-vars': ['error', { ignoreRestSiblings: true }],
60
+ 'no-empty-function': 'off',
57
61
 
58
- // Asynchronous functions that dont use await might not need to be asynchronous functions
62
+ // Asynchronous functions that don't use await might not need to be asynchronous functions
59
63
  // Usually result of refactoring, leads to misunderstanding/misusage
60
64
  'require-await': 'error',
61
65
 
@@ -85,44 +89,6 @@ export default defineConfig([
85
89
  'simple-import-sort/exports': 'error',
86
90
  'sort-imports': 'off',
87
91
 
88
- // Allows destructuring of rest properties even if they are unused
89
- '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
90
- '@typescript-eslint/no-empty-function': 'off',
91
- '@typescript-eslint/naming-convention': [
92
- 'error',
93
- {
94
- selector: ['interface', 'typeAlias'],
95
- format: ['PascalCase'],
96
- custom: {
97
- regex: '^I[A-Z]', // prevent prefixing interfaces and type alias declarations with "I"
98
- match: false,
99
- },
100
- },
101
- ],
102
- '@typescript-eslint/ban-ts-comment': [
103
- 'error',
104
- {
105
- // If you need to use a ts comment, make sure you have a description.
106
- 'ts-ignore': 'allow-with-description',
107
- 'ts-expect-error': 'allow-with-description',
108
- 'ts-nocheck': 'allow-with-description',
109
- },
110
- ],
111
-
112
- '@typescript-eslint/no-restricted-types': [
113
- 'error',
114
- {
115
- types: {
116
- 'React.FC': {
117
- message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
118
- },
119
- 'React.FunctionComponent': {
120
- message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
121
- },
122
- },
123
- },
124
- ],
125
-
126
92
  // 1. Encouraging `lodash-es` imports per file
127
93
  // lodash imports should use `lodash-es` package and should be imported per file.
128
94
  // E.G: `import get from "lodash-es/get"`
@@ -170,6 +136,9 @@ export default defineConfig([
170
136
  ],
171
137
  },
172
138
  ],
139
+
140
+ // TypeScript rules (empty object when typescript is not installed)
141
+ ...tsRules,
173
142
  },
174
143
  },
175
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codfish/eslint-config",
3
- "version": "12.3.0",
3
+ "version": "13.1.0",
4
4
  "description": "Modern ESLint configuration with TypeScript, React, and testing framework support.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -54,44 +54,45 @@
54
54
  "prepare": "husky"
55
55
  },
56
56
  "dependencies": {
57
- "@commitlint/cli": "^20.4.0",
58
- "@commitlint/config-conventional": "^20.4.0",
59
- "@eslint/js": "^9.35.0",
60
- "@eslint/json": "^1.0.0",
57
+ "@commitlint/cli": "^20.4.2",
58
+ "@commitlint/config-conventional": "^20.4.2",
59
+ "@eslint/js": "^10.0.0",
60
+ "@eslint/json": "^1.0.1",
61
61
  "@eslint/markdown": "^7.5.1",
62
- "@html-eslint/eslint-plugin": "^0.54.2",
63
- "@html-eslint/parser": "^0.54.0",
62
+ "@html-eslint/eslint-plugin": "^0.57.1",
63
+ "@html-eslint/parser": "^0.57.1",
64
64
  "@next/eslint-plugin-next": "^16.1.6",
65
65
  "@tanstack/eslint-plugin-query": "^5.91.4",
66
- "@vitest/eslint-plugin": "^1.3.10",
66
+ "@vitest/eslint-plugin": "^1.6.9",
67
67
  "cosmiconfig": "^9.0.0",
68
68
  "eslint-config-prettier": "^10.1.8",
69
- "eslint-plugin-jest": "^29.0.1",
69
+ "eslint-plugin-jest": "^29.15.0",
70
70
  "eslint-plugin-jsx-a11y": "^6.10.2",
71
- "eslint-plugin-prettier": "^5.5.4",
71
+ "eslint-plugin-prettier": "^5.5.5",
72
72
  "eslint-plugin-react": "^7.37.5",
73
73
  "eslint-plugin-react-hooks": "^7.0.1",
74
- "eslint-plugin-react-refresh": "^0.5.0",
74
+ "eslint-plugin-react-refresh": "^0.5.2",
75
75
  "eslint-plugin-simple-import-sort": "^12.1.1",
76
- "eslint-plugin-testing-library": "^7.1.0",
77
- "eslint-plugin-yml": "^3.0.0",
76
+ "eslint-plugin-testing-library": "^7.16.0",
77
+ "eslint-plugin-yml": "^3.3.0",
78
78
  "globals": "^17.3.0",
79
79
  "lodash.has": "^4.5.2",
80
80
  "prettier": ">= 3",
81
81
  "read-package-up": "^12.0.0",
82
- "typescript-eslint": "^8.44.0"
82
+ "typescript-eslint": "^8.56.1"
83
83
  },
84
84
  "devDependencies": {
85
+ "@types/node": "^25.3.3",
85
86
  "@vitest/coverage-v8": "^4.0.18",
86
- "doctoc": "^2.2.1",
87
- "eslint": "^9.35.0",
87
+ "doctoc": "^2.3.0",
88
+ "eslint": "^10.0.2",
88
89
  "husky": "^9.1.7",
89
- "lint-staged": "^16.1.6",
90
+ "lint-staged": "^16.3.0",
90
91
  "typescript": "^5.9.2",
91
92
  "vitest": "^4.0.18"
92
93
  },
93
94
  "engines": {
94
- "node": ">=20.0.0"
95
+ "node": ">=20.19.0"
95
96
  },
96
97
  "files": [
97
98
  "dist",
@@ -104,7 +105,7 @@
104
105
  "commitlint.js"
105
106
  ],
106
107
  "peerDependencies": {
107
- "eslint": ">= 9",
108
+ "eslint": ">= 10",
108
109
  "prettier": ">= 3"
109
110
  },
110
111
  "peerDependenciesMeta": {
@@ -127,6 +128,6 @@
127
128
  ]
128
129
  },
129
130
  "volta": {
130
- "node": "24.8.0"
131
+ "node": "24.14.0"
131
132
  }
132
133
  }
@@ -0,0 +1,56 @@
1
+ import { hasAnyDep } from '../utils.js';
2
+
3
+ /**
4
+ * TypeScript ESLint configuration. Dynamically loads typescript-eslint
5
+ * only when typescript is installed in the consuming project.
6
+ *
7
+ * - https://typescript-eslint.io/
8
+ */
9
+ const hasTypeScript = hasAnyDep('typescript');
10
+ const tseslintConfig =
11
+ /** @type {import('eslint').Linter.Config[]} */
12
+ (hasTypeScript ? [(await import('typescript-eslint')).configs.recommended] : []);
13
+
14
+ export default tseslintConfig;
15
+
16
+ export const rules = hasTypeScript
17
+ ? {
18
+ // Allows destructuring of rest properties even if they are unused
19
+ '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }],
20
+ '@typescript-eslint/no-empty-function': 'off',
21
+ '@typescript-eslint/naming-convention': [
22
+ 'error',
23
+ {
24
+ selector: ['interface', 'typeAlias'],
25
+ format: ['PascalCase'],
26
+ custom: {
27
+ regex: '^I[A-Z]', // prevent prefixing interfaces and type alias declarations with "I"
28
+ match: false,
29
+ },
30
+ },
31
+ ],
32
+ '@typescript-eslint/ban-ts-comment': [
33
+ 'error',
34
+ {
35
+ // If you need to use a ts comment, make sure you have a description.
36
+ 'ts-ignore': 'allow-with-description',
37
+ 'ts-expect-error': 'allow-with-description',
38
+ 'ts-nocheck': 'allow-with-description',
39
+ },
40
+ ],
41
+
42
+ '@typescript-eslint/no-restricted-types': [
43
+ 'error',
44
+ {
45
+ types: {
46
+ 'React.FC': {
47
+ message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
48
+ },
49
+ 'React.FunctionComponent': {
50
+ message: 'Useless and has some drawbacks, see https://github.com/facebook/create-react-app/pull/8177',
51
+ },
52
+ },
53
+ },
54
+ ],
55
+ }
56
+ : {};