Skip to content

Commit 5a88e95

Browse files
author
Sharma
committed
Move to ESLint 9
1 parent 7a71403 commit 5a88e95

File tree

177 files changed

+18667
-10963
lines changed

Some content is hidden

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

177 files changed

+18667
-10963
lines changed

.eslintignore

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

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Use default npmjs registry for the SDKs
22
registry = https://registry.npmjs.org/
33
// For now, turn off npm auto-install of peer dependencies to get rid of warnings
4-
legacy-peer-deps=true
4+
legacy-peer-deps=false

.prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Prettier config options: https://prettier.io/docs/en/options.html
22
// Shared front-end config: https://git.pega.io/projects/FE/repos/configs/browse/packages/prettier-config/index.json
33

4-
module.exports = import('@pega/prettier-config').then(pegaPrettierConfig => ({
4+
module.exports = import('@pega/prettier-config').then((pegaPrettierConfig) => ({
55
...pegaPrettierConfig.default,
6-
printWidth: 150
6+
printWidth: 150,
77
}));

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@
4949
"eslint.enable": true,
5050
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
5151
"eslint.workingDirectories": [{ "pattern": "." }],
52+
"eslint.useFlatConfig": true,
5253
"prettier.configPath": ".prettierrc.js"
5354
}

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+
'packages/react-sdk-components/src/index.tsx',
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+
]);

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ module.exports = {
44
roots: ['<rootDir>/packages/react-sdk-components/tests/unit/'],
55
preset: 'ts-jest',
66
transform: {
7-
'^.+\\.(t|j)sx?$': 'ts-jest'
7+
'^.+\\.(t|j)sx?$': 'ts-jest',
88
},
99
setupFilesAfterEnv: ['<rootDir>/packages/react-sdk-components/tests/setupTests.js'],
10-
coverageDirectory: 'tests/coverage'
10+
coverageDirectory: 'tests/coverage',
1111
};

0 commit comments

Comments
 (0)