-
Notifications
You must be signed in to change notification settings - Fork 7
/
eslint.config.mjs
65 lines (59 loc) · 1.74 KB
/
eslint.config.mjs
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
// @ts-check
import tsPlugin from '@typescript-eslint/eslint-plugin';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import hooksPlugin from 'eslint-plugin-react-hooks';
import reactPlugin from 'eslint-plugin-react';
export default tseslint.config(
eslint.configs.recommended,
// See https://stackoverflow.com/a/64488474/388951
...tseslint.configs.recommendedTypeChecked.map((config) => ({
...config,
files: ['src/**/*.{ts,tsx}'], // We use TS config only for TS files
})),
...tseslint.configs.stylisticTypeChecked.map((config) => ({
...config,
files: ['src/**/*.{ts,tsx}'], // We use TS config only for TS files
})),
{
plugins: {
// @ts-ignore
'react-hooks': hooksPlugin,
},
// @ts-ignore
rules: hooksPlugin.configs.recommended.rules,
},
{
...reactPlugin.configs.flat.recommended,
settings: {
react: {
version: 'detect',
},
},
rules: {
// I don't really care to replace all apostrophes with '
'react/no-unescaped-entities': 'off',
},
},
{
files: ['src/**/*.{ts,tsx}'],
// This is required, see the docs
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
// This is needed in order to specify the desired behavior for its rules
plugins: {
'@typescript-eslint': tsPlugin,
'react-hooks': hooksPlugin,
},
// After defining the plugin, you can use the rules like this
rules: {
// Sometimes it's convenient to give the index a name.
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/array-type': 'off', // ['error', {default: "array-simple"}],
},
},
);