-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.js
167 lines (145 loc) · 3.78 KB
/
eslint.config.js
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
import js from '@eslint/js'
import eslintTypescript from '@typescript-eslint/eslint-plugin'
import typescriptParser from '@typescript-eslint/parser'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import n from 'eslint-plugin-n'
import nodeImport from 'eslint-plugin-node-import'
import preferArrow from 'eslint-plugin-prefer-arrow'
import prettier from 'eslint-plugin-prettier'
// import react from 'eslint-plugin-react'
import reactHooks from 'eslint-plugin-react-hooks'
import simpleImportSort from 'eslint-plugin-simple-import-sort'
import tailwindcss from 'eslint-plugin-tailwindcss'
import testingLibrary from 'eslint-plugin-testing-library'
import unicorn from 'eslint-plugin-unicorn'
import globals from 'globals'
const configs = [
{
ignores: ['**/node_modules/**', '**/dist/**', '.git/**'],
},
js.configs.recommended,
{
languageOptions: {
ecmaVersion: 2023,
sourceType: 'module',
globals: {
...globals.browser,
...globals.es2021,
...globals.node,
},
},
plugins: {
'prefer-arrow': preferArrow,
'node-import': nodeImport,
// import: eslintImport,
// promise,
// sonarjs,
unicorn,
n,
'simple-import-sort': simpleImportSort,
},
rules: {
// ...eslintImport.configs.recommended.rules,
...n.configs.recommended.rules,
'node-import/prefer-node-protocol': 2,
'prefer-arrow/prefer-arrow-functions': [
2,
{
disallowPrototype: true,
singleReturnOnly: false,
classPropertiesAllowed: false,
},
],
// ...promise.configs.recommended.rules,
'simple-import-sort/imports': 2,
'simple-import-sort/exports': 2,
// ...sonarjs.configs.recommended.rules,
...unicorn.configs.recommended.rules,
},
},
{
rules: {
'n/no-missing-import': 0, // false positives
'n/hashbang': [2, { additionalExecutables: ['migrate.ts'] }],
'prefer-const': 2,
'unicorn/no-abusive-eslint-disable': 0,
'unicorn/no-null': 0,
'unicorn/number-literal-case': 0, // conflicts with prettier
'unicorn/prevent-abbreviations': [0, { checkProperties: true }],
},
},
{
plugins: { prettier },
// @ts-expect-error - no types
rules: prettier.configs.recommended.rules,
},
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
tsconfigRootDir: process.cwd(),
project: ['./tsconfig.json'],
},
},
plugins: {
'@typescript-eslint': eslintTypescript,
},
settings: {
'import/resolver': {
typescript: { alwaysTryTypes: true },
node: { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
},
},
rules: eslintTypescript.configs.recommended.rules,
},
{
files: ['**/*.jsx', '**/*.tsx', '**/*.js', '**/*.ts'],
languageOptions: {
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
plugins: {
'react-hooks': reactHooks,
'jsx-a11y': jsxA11y,
// react,
tailwindcss,
},
rules: {
// ...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
...jsxA11y.configs.recommended.rules,
...tailwindcss.configs.recommended.rules,
},
settings: {
react: {
version: 'detect',
},
},
},
{
files: [
'**/test/*.js',
'**/test/*.ts',
'**/test/*.jsx',
'**/test/*.tsx',
'**/*.test.js',
'**/*.test.ts',
'**/*.test.jsx',
'**/*.test.tsx',
],
plugins: {
'testing-library': testingLibrary,
},
languageOptions: {
globals: {
...globals.jest,
},
},
rules: testingLibrary.configs.react.rules,
},
]
export default configs