-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy patheslint.config.mjs
More file actions
238 lines (236 loc) · 7.61 KB
/
eslint.config.mjs
File metadata and controls
238 lines (236 loc) · 7.61 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
237
238
// SPDX-FileCopyrightText: Meta Platforms, Inc. and its affiliates
// SPDX-FileCopyrightText: TNG Technology Consulting GmbH <https://www.tngtech.com>
//
// SPDX-License-Identifier: Apache-2.0
import eslintReact from '@eslint-react/eslint-plugin';
import { fixupPluginRules, includeIgnoreFile } from '@eslint/compat';
import eslint from '@eslint/js';
import eslintPluginQuery from '@tanstack/eslint-plugin-query';
import vitest from '@vitest/eslint-plugin';
import eslintPluginCheckFile from 'eslint-plugin-check-file';
import eslintConfigJestDom from 'eslint-plugin-jest-dom';
import eslintConfigPlaywright from 'eslint-plugin-playwright';
import eslintPluginReactHooks from 'eslint-plugin-react-hooks';
import eslintConfigTestingLibrary from 'eslint-plugin-testing-library';
import globals from 'globals';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import tseslint from 'typescript-eslint';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const gitignorePath = path.resolve(__dirname, '.gitignore');
export default tseslint.config(
includeIgnoreFile(gitignorePath),
{
name: 'Global ignore patterns',
ignores: [
'.lintstagedrc.js',
'commitlint.config.ts',
'eslint.config.mjs',
'index.html',
'notices.template.html',
'vite.config.mts',
'.yarn',
'src/ElectronBackend/db/generated',
],
},
{
plugins: {
'check-file': eslintPluginCheckFile,
vitest: vitest,
'jest-dom': fixupPluginRules(eslintConfigJestDom),
'@tanstack/query': eslintPluginQuery,
// @ts-ignore
'react-hooks': fixupPluginRules(eslintPluginReactHooks),
},
linterOptions: {
reportUnusedDisableDirectives: true,
},
languageOptions: {
globals: {
...globals.node,
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
fetch: true,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2018,
sourceType: 'module',
projectService: {
allowDefaultProject: ['tools/*.mjs'],
},
tsconfigRootDir: import.meta.dirname,
},
},
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
eslintConfigTestingLibrary.configs['flat/react'],
eslintReact.configs['recommended-typescript'],
],
settings: {
react: {
version: 'detect',
},
},
rules: {
...eslintPluginQuery.configs.recommended.rules,
...eslintPluginReactHooks.configs.recommended.rules,
...vitest.configs.recommended.rules,
'react/display-name': 'off',
'react/prop-types': 'off',
'react/react-in-jsx-scope': 'off',
'@eslint-react/no-array-index-key': 'off',
'@eslint-react/hooks-extra/no-direct-set-state-in-use-effect': 'off',
'@typescript-eslint/array-type': ['error', { default: 'generic' }],
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/ban-ts-comment': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-magic-numbers': [
'error',
{
ignore: [-1, 0, 1, 2, 100],
ignoreArrayIndexes: true,
ignoreTypeIndexes: true,
},
],
'@typescript-eslint/no-misused-promises': [
'error',
{ checksVoidReturn: false },
],
'@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
'@typescript-eslint/no-non-null-assertion': 'error',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-unused-expressions': [
'error',
{ allowShortCircuit: true, allowTernary: true },
],
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/prefer-as-const': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-readonly': 'error',
'@typescript-eslint/require-await': 'error',
'@typescript-eslint/restrict-template-expressions': [
'error',
{ allowBoolean: true, allowNumber: true, allowNever: true },
],
'@typescript-eslint/switch-exhaustiveness-check': [
'error',
{ considerDefaultExhaustiveForUnions: true },
],
'vitest/consistent-test-it': 'error',
'vitest/prefer-spy-on': 'error',
'check-file/filename-naming-convention': [
'error',
{
'**/*.{js,mjs,ts,tsx}':
'+([a-zA-Z0-9-])*(.(d|test|style|util|util.test))',
},
{ ignoreMiddleExtensions: true },
],
'no-alert': 'error',
'no-console': 'off',
'no-duplicate-imports': 'error',
'no-else-return': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-lone-blocks': 'error',
'no-lonely-if': 'error',
'no-magic-numbers': 'off',
'no-multi-assign': 'error',
'no-nested-ternary': 'off',
'no-new-func': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@faker-js/faker',
message: 'Please use shared faker instead.',
},
{
name: 'react-hot-toast',
message: 'Please use toast from Toaster instead.',
},
{
name: 'react',
importNames: ['default'],
message:
'React is automatically in scope with the new JSX transform. Remove the default React import.',
},
{
name: 'react',
importNames: ['*'],
message:
'Avoid namespace React imports. Import the needed hooks/components directly.',
},
],
},
],
'no-return-assign': 'error',
'no-return-await': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-shadow': 'off',
'no-template-curly-in-string': 'error',
'no-throw-literal': 'error',
'no-unused-expressions': 'off',
'no-unused-vars': 'off',
'no-use-before-define': 'off',
'no-useless-call': 'error',
'no-useless-computed-key': 'error',
'no-useless-concat': 'error',
'no-useless-constructor': 'off',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': 'error',
'prefer-template': 'error',
curly: 'error',
eqeqeq: 'error',
quotes: [
'warn',
'single',
{ avoidEscape: true, allowTemplateLiterals: false },
],
yoda: 'error',
},
},
{
files: ['src/e2e-tests/**/*'],
extends: [eslintConfigPlaywright.configs['flat/recommended']],
rules: {
'playwright/expect-expect': 'off',
'testing-library/prefer-screen-queries': 'off',
'testing-library/no-node-access': 'off',
'react-hooks/rules-of-hooks': 'off',
},
},
{
files: [
'**/*.test.ts',
'**/*.test.tsx',
'src/testing/**/*',
'src/e2e-tests/**/*',
],
rules: {
'@typescript-eslint/no-magic-numbers': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@eslint-react/no-unnecessary-use-prefix': 'off',
'@eslint-react/no-missing-key': 'off',
'vitest/expect-expect': [
'error',
{
assertFunctionNames: ['expect*'],
},
],
},
},
);