Skip to content

Commit 0a2845c

Browse files
committed
Upgrade Eslint to v9.x
1 parent 3add40c commit 0a2845c

File tree

4 files changed

+255
-142
lines changed

4 files changed

+255
-142
lines changed

.eslintignore .eslintignore-old

File renamed without changes.

eslint.config.mjs

+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import eslint from '@eslint/js';
2+
import eslintPluginFormatjs from 'eslint-plugin-formatjs';
3+
import eslintPluginPatternflyReact from 'eslint-plugin-patternfly-react';
4+
import eslintPluginPrettier from 'eslint-plugin-prettier';
5+
// import jestPlugin from 'eslint-plugin-jest';
6+
import eslintPluginReact from 'eslint-plugin-react';
7+
import eslintPluginSimpleImportSort from 'eslint-plugin-simple-import-sort';
8+
import eslintPluginTestingLibrary from 'eslint-plugin-testing-library';
9+
import eslintPluginSortKeysFix from 'eslint-plugin-sort-keys-fix';
10+
import eslintConfigRedhatCloudServices from '@redhat-cloud-services/eslint-config-redhat-cloud-services';
11+
// import testingLibraryReact from '@testing-library/react';
12+
import tseslint from 'typescript-eslint';
13+
14+
// export default tseslint.config(
15+
export default [
16+
// {
17+
// ignores: ['src/testUtils.ts'],
18+
// },
19+
eslint.configs.recommended,
20+
...tseslint.configs.recommended,
21+
{
22+
// files: ['src/**/*.ts)', 'src/**/*.tsx'],
23+
plugins: {
24+
// 'rulesdir' : eslintConfigRedhatCloudServices, // not working
25+
// 'patternfly': eslintPluginPatternflyReact, // not working
26+
'prettier': eslintPluginPrettier,
27+
'formatjs': eslintPluginFormatjs, // not working -- see https://github.com/formatjs/formatjs/issues/4388
28+
'react': eslintPluginReact,
29+
'simple-import-sort': eslintPluginSimpleImportSort,
30+
'testing-library': eslintPluginTestingLibrary, // not working -- see https://github.com/testing-library/eslint-plugin-testing-library/issues/899
31+
},
32+
languageOptions: {
33+
globals: {
34+
// 'browser': true,
35+
// 'es6': true,
36+
// 'node': true,
37+
},
38+
parser: tseslint.parser,
39+
'parserOptions': {
40+
'sourceType': 'module',
41+
},
42+
},
43+
settings: {
44+
react: {
45+
version: 'detect'
46+
}
47+
},
48+
rules: {
49+
'@typescript-eslint/adjacent-overload-signatures': 'error',
50+
'@typescript-eslint/array-type': 'error',
51+
'@typescript-eslint/ban-types': 'error',
52+
'@typescript-eslint/camelcase': 'off',
53+
// '@typescript-eslint/class-name-casing': 'error',
54+
'@typescript-eslint/consistent-type-assertions': 'error',
55+
'@typescript-eslint/consistent-type-definitions': 'error',
56+
// '@typescript-eslint/consistent-type-exports': 'error',
57+
'@typescript-eslint/consistent-type-imports': 'error',
58+
'@typescript-eslint/explicit-function-return-type': 'off',
59+
'@typescript-eslint/explicit-module-boundary-types': 'off',
60+
'@typescript-eslint/explicit-member-accessibility': 'off',
61+
'@typescript-eslint/indent': 'off',
62+
// '@typescript-eslint/interface-name-prefix': 'error',
63+
'@typescript-eslint/no-empty-function': 'off',
64+
'@typescript-eslint/no-empty-interface': 'off',
65+
'@typescript-eslint/no-misused-new': 'error',
66+
'@typescript-eslint/no-namespace': 'error',
67+
'@typescript-eslint/no-var-requires': 'off',
68+
'@typescript-eslint/prefer-for-of': 'error',
69+
'@typescript-eslint/prefer-function-type': 'error',
70+
'@typescript-eslint/prefer-namespace-keyword': 'error',
71+
'@typescript-eslint/no-explicit-any': 'off',
72+
'@typescript-eslint/no-use-before-define': 'off',
73+
'@typescript-eslint/no-inferrable-types': 'off',
74+
'@typescript-eslint/triple-slash-reference': 'error',
75+
'@typescript-eslint/unified-signatures': 'error',
76+
'arrow-parens': [2, 'as-needed', { 'requireForBlockBody': false }],
77+
'constructor-super': 'error',
78+
'curly': 'error',
79+
'dot-notation': 'error',
80+
'eqeqeq': [
81+
'error',
82+
'smart'
83+
],
84+
// 'formatjs/enforce-default-message': 'error',
85+
// 'formatjs/enforce-description': 'error',
86+
// 'formatjs/enforce-id': 'error',
87+
'guard-for-in': 'error',
88+
'max-classes-per-file': [
89+
'error',
90+
1
91+
],
92+
'max-len': 'off',
93+
'no-bitwise': 'error',
94+
'no-caller': 'error',
95+
'no-cond-assign': 'error',
96+
'no-console': 'error',
97+
'no-debugger': 'error',
98+
'no-empty': 'error',
99+
'no-eval': 'error',
100+
'no-new-wrappers': 'error',
101+
'no-prototype-builtins': 'off',
102+
'no-restricted-imports': ['error', {
103+
'patterns': ['../*/**']
104+
}],
105+
'no-shadow': 'error',
106+
'no-throw-literal': 'error',
107+
'no-trailing-spaces': 'off',
108+
'no-undef': 'off',
109+
'no-undef-init': 'error',
110+
'no-unsafe-finally': 'error',
111+
'no-unused-expressions': ['error', {
112+
'allowTernary': true,
113+
'allowShortCircuit': true
114+
}],
115+
'no-unused-labels': 'error',
116+
'no-var': 'error',
117+
'object-shorthand': 'error',
118+
'one-var': [
119+
'error',
120+
'never'
121+
],
122+
'patternfly-react/no-anonymous-functions': 0,
123+
'prefer-const': 'error',
124+
'prettier/prettier': 'error',
125+
'radix': [
126+
'error',
127+
'as-needed'
128+
],
129+
'react-hooks/exhaustive-deps': 0, // 'warn',
130+
'react/display-name': 0,
131+
'react/no-unescaped-entities': ['error', { 'forbid': ['>', '}']}],
132+
'react/no-unknown-property': ['error', { 'ignore': ['key']}],
133+
'react/prop-types': 0,
134+
'simple-import-sort/imports': 'error',
135+
'spaced-comment': 'error',
136+
'rulesdir/disallow-pf-migrated-components': 'off',
137+
'rulesdir/forbid-pf-relative-imports': 'off',
138+
// 'testing-library/await-async-queries': 'error',
139+
// 'testing-library/no-await-sync-queries': 'error',
140+
// 'testing-library/no-debugging-utils': 'warn',
141+
// 'testing-library/no-dom-import': 'off',
142+
'use-isnan': 'error'
143+
}
144+
},
145+
{
146+
files: [ 'src/locales/messages.ts' ],
147+
plugins: {
148+
'sort-keys-fix': eslintPluginSortKeysFix,
149+
},
150+
rules: {
151+
'sort-keys-fix/sort-keys-fix': 'error'
152+
}
153+
}, {
154+
// Enable eslint-plugin-testing-library rules or preset only for matching files!
155+
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
156+
// 'extends': ['plugin:testing-library/react']
157+
plugins: {
158+
// 'testing-library/react': testingLibraryReact,
159+
'testing-library/react': eslintPluginTestingLibrary,
160+
},
161+
}
162+
];

0 commit comments

Comments
 (0)