Skip to content

Commit ee37904

Browse files
vishalshrm539Sharma
andauthored
Upgraded Eslint to 9 (#582)
* Upgraded Eslint to 9 * Fixed package-lock --------- Co-authored-by: Sharma <[email protected]>
1 parent 4d622b8 commit ee37904

File tree

3 files changed

+1787
-7525
lines changed

3 files changed

+1787
-7525
lines changed

eslint.config.mjs

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
import { globalIgnores } from 'eslint/config';
2+
import { fileURLToPath } from 'node:url';
3+
import eslint from '@eslint/js';
4+
import tseslint from 'typescript-eslint';
5+
import sonarjs from 'eslint-plugin-sonarjs';
6+
import importPlugin from 'eslint-plugin-import';
7+
import react from 'eslint-plugin-react';
8+
import reactHooks from 'eslint-plugin-react-hooks';
9+
import { defineConfig } from 'eslint/config';
10+
11+
export default defineConfig([
12+
eslint.configs.recommended,
13+
...tseslint.configs.recommended,
14+
globalIgnores([
15+
'**/node_modules',
16+
'packages/*/lib',
17+
'!**/.storybook',
18+
'.storybook/public',
19+
'**/demo.stories.jsx',
20+
'**/mock.stories.js',
21+
'**/demo.stories.tsx',
22+
'**/demo.test.tsx',
23+
'**/*.test.tsx',
24+
'**/mock.stories.ts',
25+
'**/*.mdx',
26+
'**/webpack.config.js',
27+
'src/helpers/config_access.js',
28+
'**/*.html',
29+
'**/*.css',
30+
'**/*.json',
31+
'**/*.md',
32+
'**/*.svg',
33+
'**/*.zip',
34+
'**/*.d.ts',
35+
'*.storybook/*',
36+
'**/*.cjs',
37+
'**/*.mjs',
38+
'**/paths.js',
39+
'dist/*',
40+
'lib/*',
41+
'**/ext-libs.js'
42+
]),
43+
{
44+
languageOptions: {
45+
globals: {
46+
PCore: 'readonly',
47+
window: true,
48+
console: true,
49+
document: true,
50+
fetch: true
51+
},
52+
53+
ecmaVersion: 13,
54+
sourceType: 'script',
55+
56+
parserOptions: {
57+
project: 'tsconfig.json',
58+
ecmaFeatures: {
59+
jsx: true
60+
}
61+
}
62+
},
63+
64+
settings: {
65+
'import/resolver': {
66+
typescript: {},
67+
react: {
68+
version: 'detect'
69+
},
70+
node: {
71+
extensions: ['.js', '.jsx', '.ts', '.tsx']
72+
}
73+
},
74+
75+
react: {
76+
version: 'detect'
77+
}
78+
},
79+
80+
plugins: { sonarjs, import: importPlugin, react, 'react-hooks': reactHooks },
81+
rules: {
82+
'react/jsx-filename-extension': [0, { extensions: ['.jsx', '*.tsx'] }],
83+
84+
// Prettier recommends running separately from a linter.
85+
// https://prettier.io/docs/en/integrating-with-linters.html#notes
86+
'prettier/prettier': 'off',
87+
88+
// Disable rules from shared configs we're not ready for yet.
89+
'sonarjs/cognitive-complexity': ['warn', 20],
90+
'sonarjs/no-duplicate-string': 'off',
91+
92+
//
93+
// Initial release: turning these off; phase in to "warn" or "error" over time
94+
// For "quotes" and "@typescript-eslint/quotes", see override below for .ts/.tsx files
95+
'import/extensions': ['off', 'never'],
96+
'import/named': 'off',
97+
'import/no-cycle': 'off',
98+
'import/no-duplicates': 'off',
99+
'import/no-extraneous-dependencies': 'off',
100+
'import/no-named-as-default': 'off',
101+
'import/no-named-as-default-member': 'off',
102+
'import/no-self-import': 'off',
103+
'import/no-unresolved': 'off',
104+
'import/no-useless-path-segments': 'off',
105+
'import/order': 'off',
106+
107+
'no-underscore-dangle': 'off', // TODO : adhere to standard naming
108+
'no-restricted-syntax': 'warn', // TODO : fix for-in loops
109+
110+
'jsx-a11y/alt-text': 'off',
111+
'jsx-a11y/anchor-is-valid': 'off',
112+
'jsx-a11y/click-events-have-key-events': 'off',
113+
'jsx-a11y/label-has-associated-control': 'off',
114+
'jsx-a11y/no-static-element-interactions': 'off',
115+
116+
'@typescript-eslint/naming-convention': 'off', // prefer warn but needs different parserOptions
117+
'@typescript-eslint/ban-types': 'off', // also, see override below
118+
'@typescript-eslint/no-explicit-any': 'off', // prefer warn but needs different parserOptions
119+
'@typescript-eslint/no-empty-object-type': 'off', // prefer warn but needs different parserOptions
120+
'@typescript-eslint/ban-ts-comment': 'off', // prefer warn but needs different parserOptions
121+
'@typescript-eslint/no-unsafe-function-type': 'off',
122+
123+
'import/no-relative-packages': 'off' // arnab
124+
}
125+
},
126+
{
127+
files: ['**/*.@(ts|tsx)'],
128+
129+
rules: {
130+
'@typescript-eslint/method-signature-style': ['error', 'property'],
131+
quotes: 'off',
132+
'@typescript-eslint/quotes': 'off'
133+
}
134+
},
135+
{
136+
files: ['**/*.@(jsx|tsx|mdx)'],
137+
138+
rules: {
139+
'react/react-in-jsx-scope': 'off',
140+
'react-hooks/rules-of-hooks': 'off',
141+
'react-hooks/exhaustive-deps': 'off'
142+
}
143+
},
144+
{
145+
files: ['**/*.@(ts|tsx)'],
146+
rules: {
147+
'no-console': 'off',
148+
'import/prefer-default-export': 'off',
149+
'import/no-relative-packages': 'off',
150+
'react/jsx-fragments': 'off',
151+
'react/react-in-jsx-scope': 'off',
152+
'react-hooks/exhaustive-deps': 'off',
153+
'sonarjs/cognitive-complexity': ['warn', 45]
154+
}
155+
},
156+
{
157+
files: ['**/*.@(js|jsx|ts|tsx|mdx)'],
158+
rules: {}
159+
},
160+
161+
{
162+
files: ['*/**/mocks/**.@(mocks|styles).@(tsx|ts)'],
163+
164+
rules: {
165+
'import/prefer-default-export': ['off']
166+
}
167+
}
168+
]);

0 commit comments

Comments
 (0)