Skip to content

Commit af4ed8e

Browse files
vishalshrm539Sharma
andauthored
Move to ESLint 9 (#574)
* Move to ESLint 9 * update package-lock * Remove unused @ts-ignore * Move back to Cosmos 8 * Updated package-lock * Updated @pega/configs * Updated package-lock --------- Co-authored-by: Sharma <[email protected]>
1 parent 0c3da75 commit af4ed8e

File tree

9 files changed

+4010
-1852
lines changed

9 files changed

+4010
-1852
lines changed

.eslintignore

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

.eslintrc.json

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

eslint.config.mjs

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

0 commit comments

Comments
 (0)