Skip to content

Commit 9bf870b

Browse files
author
Sharma
committed
Upgraded EsLint to 9
1 parent bbfd3f2 commit 9bf870b

File tree

50 files changed

+2506
-1278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2506
-1278
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 148 deletions
This file was deleted.

eslint.config.mjs

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

0 commit comments

Comments
 (0)