-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.mjs
195 lines (190 loc) · 6.94 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
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
import eslint from "@eslint/js";
import importPlugin from "eslint-plugin-import";
import jsxA11y from "eslint-plugin-jsx-a11y";
import react from "eslint-plugin-react";
import hooks from "eslint-plugin-react-hooks";
//import prettier from "eslint-plugin-prettier/recommended";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
import pluginCypress from 'eslint-plugin-cypress/flat'
import pluginMocha from 'eslint-plugin-mocha'
import pluginChaiFriendly from 'eslint-plugin-chai-friendly'
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
importPlugin.flatConfigs.recommended,
pluginMocha.configs.flat.recommended,
pluginCypress.configs.recommended,
pluginChaiFriendly.configs.recommendedFlat,
jsxA11y.flatConfigs.strict,
{
linterOptions: {
reportUnusedDisableDirectives: "warn"
}
},
{
files: ["**/*.{ts,tsx,mtsx}"],
...importPlugin.flatConfigs.typescript,
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: ["./tsconfig.json", "./cypress/tsconfig.json"]
},
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
'import/resolver': {
"typescript": {
"alwaysTryTypes": true,
project: ['tsconfig.json']
}
}
}
},
{
rules: {
"no-restricted-imports": "off",
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/no-restricted-imports": [
'error',
{
"paths": [
{
"name": "react-redux",
"importNames": ["useSelector", "useStore", "useDispatch"],
"message": "Please use pre-typed versions from `src/app/hooks.ts` instead."
},
{
"name": "@reduxjs/toolkit",
"importNames": ["createSlice"],
"message": "Please use thunk-able versions from `src/app/createAppSlice.ts` instead."
},
{
"name": "@reduxjs/toolkit",
"importNames": ["createAsyncThunk"],
"message": "Please use thunk-able versions from `src/app/createAppAsyncThunk.ts` instead."
}
]
}
],
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/restrict-template-expressions': ['error', {
allowNullish: true
}],
'@typescript-eslint/restrict-plus-operands': ['error', {
allowNullish: true
}],
'@typescript-eslint/no-invalid-void-type': ['off'],
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
"@typescript-eslint/no-explicit-any": [
'error'
],
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
argsIgnorePattern: '^_',
ignoreRestSiblings: true,
},
],
'@typescript-eslint/await-thenable': 'warn',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-misused-new': 'error',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksConditionals: false,
checksVoidReturn: false,
},
],
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/prefer-as-const': 'warn',
'@typescript-eslint/promise-function-async': 'warn',
'import/default': 'error',
'import/export': 'error',
'import/named': 'error',
'import/no-cycle': 'error',
'import/no-duplicates': 'error',
'import/no-unresolved': 'error',
'import/no-useless-path-segments': 'warn',
'import/order': [
'warn',
{
alphabetize: {
caseInsensitive: true,
order: 'asc',
},
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
],
'newlines-between': 'always',
},
],
'no-constant-binary-expression': 'error',
'no-constant-condition': 'error',
'no-dupe-args': 'error',
'no-dupe-keys': 'error',
'no-empty-pattern': 'error',
'no-extra-boolean-cast': 'error',
'no-redeclare': 'error',
'no-return-await': 'error',
'no-unsafe-negation': 'warn',
'no-unused-private-class-members': 'error',
'prefer-const': 'warn',
'prefer-promise-reject-errors': ['error', { allowEmptyReject: true }],
// Prevent unexpected parseInt() output that does not return the number calculated in decimal when given a value such as parseInt(071).
radix: 'error',
'require-atomic-updates': ['error', { allowProperties: true }],
'valid-typeof': 'warn'
}
},
{
files: ["**/*.{jsx,mjsx,tsx,mtsx,ts}"],
...react.configs.flat.recommended,
plugins: {
react,
"react-hooks": hooks,
"react-refresh": reactRefresh,
},
rules: {
...hooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'error',
{ allowConstantExport: true },
],
"react-hooks/exhaustive-deps": [
"error"
],
'react-hooks/rules-of-hooks': 'error',
},
},
{
files: ["**/*.{js,mjs,cjs}"],
...tseslint.configs.disableTypeChecked,
},
//prettier,
{
ignores: [
".vscode/**",
"node_modules/**",
"public/**",
"build/**",
"dist/**",
".github/**",
".swc/**",
"dev-dist/**",
"eslint.config.mjs"
],
},
);