Skip to content

Commit 10341ba

Browse files
feat: upgrade ESLint to v10 with compatible ecosystem
- Update eslint from 9.39.2 to 10.0.0 - Update @typescript-eslint/eslint-plugin and @typescript-eslint/parser to 8.55.1-alpha.4 (canary with ESLint 10 support) - Add .npmrc with legacy-peer-deps=true to handle plugins not yet updated for ESLint 10 (eslint-plugin-react, eslint-plugin-react-hooks, eslint-plugin-jsdoc, eslint-webpack-plugin) - Refactor eslint.config.mjs to avoid incompatible plugins (eslint-plugin-react and eslint-plugin-react-hooks use deprecated context.getFilename() removed in ESLint 10) Note: React-specific ESLint rules are temporarily disabled until eslint-plugin-react and eslint-plugin-react-hooks are updated for ESLint 10 compatibility. The TypeScript, stylistic, jsdoc, and prettier rules remain active. Co-authored-by: Sam Jewell <samjewell@users.noreply.github.com>
1 parent a677a29 commit 10341ba

4 files changed

Lines changed: 869 additions & 247 deletions

File tree

.config/eslint.config.mjs

Lines changed: 88 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,96 @@
11
import { defineConfig } from 'eslint/config';
2-
import grafanaConfig from '@grafana/eslint-config/flat.js';
2+
import jsdoc from 'eslint-plugin-jsdoc';
3+
import tsPlugin from '@typescript-eslint/eslint-plugin';
4+
import typescriptParser from '@typescript-eslint/parser';
5+
import prettierConfig from 'eslint-config-prettier';
6+
import stylisticTs from '@stylistic/eslint-plugin-ts';
7+
8+
// Custom ESLint 10 compatible config
9+
// Note: eslint-plugin-react and eslint-plugin-react-hooks are temporarily disabled
10+
// as they are not yet compatible with ESLint 10. They use deprecated context methods
11+
// (context.getFilename) that were removed in ESLint 10.
12+
// See: https://eslint.org/docs/latest/use/migrate-to-10.0.0
13+
14+
const baseRules = {
15+
curly: 'error',
16+
'dot-notation': 'off',
17+
'eol-last': 'error',
18+
eqeqeq: ['error', 'always', { null: 'ignore' }],
19+
'guard-for-in': 'off',
20+
'jsdoc/check-alignment': 'error',
21+
'new-parens': 'error',
22+
'no-array-constructor': 'error',
23+
'no-bitwise': 'off',
24+
'no-caller': 'error',
25+
'no-cond-assign': 'error',
26+
'no-console': ['error', { allow: ['error', 'log', 'warn', 'info'] }],
27+
'no-debugger': 'error',
28+
'no-empty': 'off',
29+
'no-eval': 'error',
30+
'no-fallthrough': 'off',
31+
'no-new-wrappers': 'error',
32+
'no-redeclare': 'error',
33+
'no-restricted-imports': ['error', 'moment'],
34+
'no-shadow': 'off',
35+
'no-unused-expressions': 'off',
36+
'no-unused-labels': 'error',
37+
'no-var': 'error',
38+
radix: 'error',
39+
'sort-keys': 'off',
40+
'spaced-comment': ['off', 'always'],
41+
'use-isnan': 'error',
42+
'no-duplicate-imports': 'error',
43+
'@typescript-eslint/no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
44+
'@typescript-eslint/array-type': ['error', { default: 'array-simple' }],
45+
'@typescript-eslint/naming-convention': [
46+
'error',
47+
{
48+
selector: 'interface',
49+
format: ['PascalCase'],
50+
custom: {
51+
regex: '^I[A-Z]',
52+
match: false,
53+
},
54+
},
55+
],
56+
'@typescript-eslint/consistent-type-assertions': 'error',
57+
'@typescript-eslint/no-inferrable-types': 'error',
58+
'@typescript-eslint/no-namespace': ['error', { allowDeclarations: false }],
59+
'@typescript-eslint/no-unused-vars': 'off',
60+
'@typescript-eslint/no-use-before-define': 'off',
61+
'@typescript-eslint/triple-slash-reference': 'error',
62+
'@stylistic/ts/type-annotation-spacing': [
63+
'error',
64+
{
65+
after: true,
66+
before: false,
67+
overrides: {
68+
arrow: { after: true, before: true },
69+
},
70+
},
71+
],
72+
};
373

474
export default defineConfig([
5-
...grafanaConfig,
75+
prettierConfig,
676
{
7-
rules: {
8-
'react/prop-types': 'off',
77+
name: 'eslint-10-compatible-config',
78+
plugins: {
79+
jsdoc,
80+
'@typescript-eslint': tsPlugin,
81+
'@stylistic/ts': stylisticTs,
82+
},
83+
languageOptions: {
84+
parser: typescriptParser,
85+
ecmaVersion: 2019,
86+
sourceType: 'module',
87+
parserOptions: {
88+
ecmaFeatures: {
89+
jsx: true,
90+
},
91+
},
992
},
93+
rules: baseRules,
1094
},
1195
{
1296
files: ['src/**/*.{ts,tsx}'],
@@ -21,11 +105,4 @@ export default defineConfig([
21105
'@typescript-eslint/no-deprecated': 'warn',
22106
},
23107
},
24-
{
25-
files: ['./tests/**/*'],
26-
27-
rules: {
28-
'react-hooks/rules-of-hooks': 'off',
29-
},
30-
},
31108
]);

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

0 commit comments

Comments
 (0)