-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy patheslint.config.mjs
More file actions
236 lines (219 loc) · 7.23 KB
/
eslint.config.mjs
File metadata and controls
236 lines (219 loc) · 7.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import formatjs from 'eslint-plugin-formatjs';
import prettier from 'eslint-plugin-prettier';
// import patternflyReact from "eslint-plugin-patternfly-react";
import react from 'eslint-plugin-react';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import sortKeysFix from 'eslint-plugin-sort-keys-fix';
import testingLibrary from 'eslint-plugin-testing-library';
import globals from 'globals';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
{
ignores: [
'**/node_modules',
'**/public',
'**/dist',
'**/.DS_Store',
'**/coverage',
'**/npm-debug.log',
'**/yarn-debug.log',
'**/yarn-error.log',
'**/.idea',
'**/.project',
'**/.classpath',
'**/.c9',
'**/*.launch',
'**/.settings',
'**/*.sublime-workspace',
'**/.history',
'**/.vscode',
'**/*.swp',
'**/*.test.ts',
'**/*.test.tsx',
],
},
...fixupConfigRules(
compat.extends(
// '@redhat-cloud-services/eslint-config-redhat-cloud-services',
'eslint:recommended', // Extended by eslint-config-redhat-cloud-services
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended', // Extended by eslint-config-redhat-cloud-services
'plugin:react-hooks/recommended'
)
),
{
plugins: {
'@typescript-eslint': fixupPluginRules(typescriptEslint),
formatjs,
// 'patternfly-react': patternflyReact,
prettier, // Plugin defined by eslint-config-redhat-cloud-services
react: fixupPluginRules(react),
'simple-import-sort': simpleImportSort,
'sort-keys-fix': sortKeysFix,
'testing-library': testingLibrary,
},
languageOptions: {
globals: {
...globals.browser,
...globals.node,
afterEach: 'readonly',
beforeEach: 'readonly',
describe: 'readonly',
expect: 'readonly',
global: 'writable',
insights: 'readonly',
it: 'readonly',
jest: 'readonly',
mount: 'readonly',
render: 'readonly',
require: 'readonly',
test: 'readonly',
shallow: 'readonly',
},
ecmaVersion: 'latest',
sourceType: 'module',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/camelcase': 'off',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/indent': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-namespace': 'error',
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-function-type': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/triple-slash-reference': 'error',
'@typescript-eslint/unified-signatures': 'error',
'arrow-parens': [
2,
'as-needed',
{
requireForBlockBody: false,
},
],
'constructor-super': 'error',
curly: 'error',
'dot-notation': 'error',
eqeqeq: ['error', 'smart'],
// 'formatjs/enforce-default-message': 'error', // Not working -- see https://github.com/formatjs/formatjs/issues/4388
// 'formatjs/enforce-description': 'error',
// 'formatjs/enforce-id': 'error',
'guard-for-in': 'error',
'max-classes-per-file': ['error', 1],
'max-len': 'off',
'no-bitwise': 'error',
'no-caller': 'error',
'no-cond-assign': 'error',
'no-console': 'error',
'no-debugger': 'error',
'no-empty': 'error',
'no-eval': 'error',
'no-new-wrappers': 'error',
'no-prototype-builtins': 'off',
'no-restricted-imports': [
'error',
{
patterns: ['../*/**'],
},
],
'no-shadow': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'off',
'no-undef': 'off',
'no-undef-init': 'error',
'no-unsafe-finally': 'error',
'no-unused-expressions': [
'warn',
{
allowTernary: true,
allowShortCircuit: true,
},
],
'no-unused-labels': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'one-var': ['error', 'never'],
'patternfly-react/no-anonymous-functions': 0,
'prefer-const': 'error',
'prettier/prettier': 'error',
radix: ['error', 'as-needed'],
'react-hooks/exhaustive-deps': 0,
'react-hooks/immutability': 0, // Temp workaround for 7.1.1
'react-hooks/set-state-in-render': 0, // Temp workaround for 7.1.1
'react-hooks/preserve-manual-memoization': 0, // Temp workaround for 7.0.0
'react-hooks/set-state-in-effect': 0, // Temp workaround for 7.0.0
'react/display-name': 0,
'react/no-is-mounted': 0,
'react/no-unescaped-entities': [
'error',
{
forbid: ['>', '}'],
},
],
'react/no-unknown-property': [
'error',
{
ignore: ['key'],
},
],
'react/prop-types': 0,
'simple-import-sort/imports': 'error',
'spaced-comment': 'error',
'rulesdir/disallow-pf-migrated-components': 'off',
'rulesdir/forbid-pf-relative-imports': 'off',
'testing-library/await-async-queries': 'error',
'testing-library/no-await-sync-queries': 'error',
// 'testing-library/no-debugging-utils': 'warn', // Not working -- see https://eslint.org/docs/latest/use/troubleshooting/v9-rule-api-changes
'testing-library/no-dom-import': 'off',
'use-isnan': 'error',
},
},
{
files: ['src/locales/messages.ts'],
rules: {
'sort-keys-fix/sort-keys-fix': 'error',
},
},
...compat.extends('plugin:testing-library/react').map(config => ({
...config,
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
})),
];