@10stars/config 12.0.0 → 13.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/eslint.config.browser.ts +12 -0
- package/eslint.config.node.ts +12 -0
- package/eslint.config.ts +271 -0
- package/package.json +16 -18
- package/readme.md +1 -3
- package/src/index.ts +0 -0
- package/{tsconfig.json → tsconfig.base.json} +1 -1
- package/.eslintrc.js +0 -278
package/eslint.config.ts
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import typescriptEslint from "@typescript-eslint/eslint-plugin"
|
|
2
|
+
import _import from "eslint-plugin-import"
|
|
3
|
+
import react from "eslint-plugin-react"
|
|
4
|
+
import builtinModules from "builtin-modules"
|
|
5
|
+
// import 10StarsReactHooks from "@10stars/eslint-plugin-react-hooks";
|
|
6
|
+
import regexp from "eslint-plugin-regexp"
|
|
7
|
+
import noRelativeImportPaths from "eslint-plugin-no-relative-import-paths"
|
|
8
|
+
import simpleImportSort from "eslint-plugin-simple-import-sort"
|
|
9
|
+
import sortKeysFix from "eslint-plugin-sort-keys-fix"
|
|
10
|
+
import { fixupPluginRules } from "@eslint/compat"
|
|
11
|
+
import globals from "globals"
|
|
12
|
+
import tsParser from "@typescript-eslint/parser"
|
|
13
|
+
import path from "node:path"
|
|
14
|
+
import { fileURLToPath } from "node:url"
|
|
15
|
+
import js from "@eslint/js"
|
|
16
|
+
import { FlatCompat } from "@eslint/eslintrc"
|
|
17
|
+
import type { Linter } from "eslint"
|
|
18
|
+
|
|
19
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
20
|
+
const __dirname = path.dirname(__filename)
|
|
21
|
+
const compat = new FlatCompat({
|
|
22
|
+
baseDirectory: __dirname,
|
|
23
|
+
recommendedConfig: js.configs.recommended,
|
|
24
|
+
allConfig: js.configs.all,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export default [
|
|
28
|
+
{
|
|
29
|
+
ignores: ["**/node_modules", "**/.git", "**/dist", "**/tmp"],
|
|
30
|
+
},
|
|
31
|
+
...(compat.extends(
|
|
32
|
+
"eslint:recommended",
|
|
33
|
+
"plugin:@typescript-eslint/strict-type-checked",
|
|
34
|
+
"plugin:@typescript-eslint/stylistic-type-checked",
|
|
35
|
+
"plugin:react/recommended",
|
|
36
|
+
"plugin:@10stars/react-hooks/recommended",
|
|
37
|
+
"plugin:regexp/recommended",
|
|
38
|
+
"prettier",
|
|
39
|
+
) as any),
|
|
40
|
+
{
|
|
41
|
+
plugins: {
|
|
42
|
+
"@typescript-eslint": typescriptEslint,
|
|
43
|
+
import: fixupPluginRules(_import),
|
|
44
|
+
react,
|
|
45
|
+
// "@10stars/react-hooks": 10StarsReactHooks,
|
|
46
|
+
regexp,
|
|
47
|
+
"no-relative-import-paths": noRelativeImportPaths,
|
|
48
|
+
"simple-import-sort": simpleImportSort,
|
|
49
|
+
"sort-keys-fix": sortKeysFix,
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
languageOptions: {
|
|
53
|
+
parser: tsParser,
|
|
54
|
+
ecmaVersion: "latest",
|
|
55
|
+
sourceType: "module",
|
|
56
|
+
|
|
57
|
+
parserOptions: {
|
|
58
|
+
ecmaFeatures: {
|
|
59
|
+
jsx: true,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
settings: {
|
|
65
|
+
"import/parsers": {
|
|
66
|
+
"@typescript-eslint/parser": [".ts", ".tsx"],
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"import/extensions": [".ts", ".tsx", ".js", ".jsx"],
|
|
70
|
+
|
|
71
|
+
react: {
|
|
72
|
+
version: "18.0.0",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
rules: {
|
|
77
|
+
"no-case-declarations": 0,
|
|
78
|
+
|
|
79
|
+
"no-relative-import-paths/no-relative-import-paths": [
|
|
80
|
+
1,
|
|
81
|
+
{
|
|
82
|
+
allowSameFolder: true,
|
|
83
|
+
allowedDepth: 2,
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
|
|
87
|
+
"import/order": 0,
|
|
88
|
+
"import/no-unresolved": 0,
|
|
89
|
+
"import/no-duplicates": 1,
|
|
90
|
+
"import/no-nodejs-modules": [
|
|
91
|
+
2,
|
|
92
|
+
{
|
|
93
|
+
allow: builtinModules.flatMap((v) => [
|
|
94
|
+
`node:${v}`,
|
|
95
|
+
`node:${v}/promises`,
|
|
96
|
+
]),
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
|
|
100
|
+
"sort-imports": 0,
|
|
101
|
+
"simple-import-sort/imports": 1,
|
|
102
|
+
"simple-import-sort/exports": 1,
|
|
103
|
+
"react/display-name": 0,
|
|
104
|
+
"react/no-children-prop": 0,
|
|
105
|
+
|
|
106
|
+
"react/no-unknown-property": [
|
|
107
|
+
2,
|
|
108
|
+
{
|
|
109
|
+
ignore: ["sx"],
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
|
|
113
|
+
"react/prop-types": 0,
|
|
114
|
+
"react/react-in-jsx-scope": 0,
|
|
115
|
+
|
|
116
|
+
"react/jsx-filename-extension": [
|
|
117
|
+
1,
|
|
118
|
+
{
|
|
119
|
+
extensions: [".jsx", ".tsx"],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
|
|
123
|
+
"react/no-invalid-html-attribute": 2,
|
|
124
|
+
"react/prefer-stateless-function": 2,
|
|
125
|
+
"react/jsx-boolean-value": [1, "never"],
|
|
126
|
+
"react/jsx-curly-brace-presence": [1, "always"],
|
|
127
|
+
"react/jsx-fragments": 1,
|
|
128
|
+
"react/jsx-no-bind": 1,
|
|
129
|
+
"react/jsx-no-constructed-context-values": 1,
|
|
130
|
+
|
|
131
|
+
"react/jsx-no-script-url": [
|
|
132
|
+
2,
|
|
133
|
+
[
|
|
134
|
+
{
|
|
135
|
+
name: "Link",
|
|
136
|
+
props: ["to"],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "NavLink",
|
|
140
|
+
props: ["to"],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "a",
|
|
144
|
+
props: ["href", "to"],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
],
|
|
148
|
+
|
|
149
|
+
"react/jsx-no-useless-fragment": 1,
|
|
150
|
+
"react/jsx-no-target-blank": 2,
|
|
151
|
+
"react/jsx-sort-props": 1,
|
|
152
|
+
|
|
153
|
+
"@10stars/react-hooks/exhaustive-deps": [
|
|
154
|
+
1,
|
|
155
|
+
{
|
|
156
|
+
additionalHooks:
|
|
157
|
+
"(useUpdateEffect|useIsomorphicLayoutEffect|useDeepCompareEffect|useShallowCompareEffect|useCustomCompareEffect)",
|
|
158
|
+
ignoreThisDependency: "always",
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
|
|
162
|
+
"@typescript-eslint/restrict-template-expressions": [
|
|
163
|
+
"error",
|
|
164
|
+
{
|
|
165
|
+
allowNumber: true,
|
|
166
|
+
},
|
|
167
|
+
],
|
|
168
|
+
|
|
169
|
+
"@typescript-eslint/prefer-nullish-coalescing": 0,
|
|
170
|
+
"@typescript-eslint/consistent-indexed-object-style": 0,
|
|
171
|
+
"@typescript-eslint/no-throw-literal": 0,
|
|
172
|
+
"@typescript-eslint/no-unnecessary-condition": 0,
|
|
173
|
+
"@typescript-eslint/no-confusing-void-expression": 0,
|
|
174
|
+
"@typescript-eslint/no-invalid-void-type": 0,
|
|
175
|
+
"@typescript-eslint/no-dynamic-delete": 0,
|
|
176
|
+
"@typescript-eslint/no-empty-interface": 0,
|
|
177
|
+
"@typescript-eslint/no-unused-vars": 0,
|
|
178
|
+
"@typescript-eslint/no-empty-function": 0,
|
|
179
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
180
|
+
"@typescript-eslint/ban-types": 0,
|
|
181
|
+
"@typescript-eslint/only-throw-error": 0,
|
|
182
|
+
"@typescript-eslint/use-unknown-in-catch-callback-variable": 0,
|
|
183
|
+
"@typescript-eslint/no-unsafe-assignment": 0,
|
|
184
|
+
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
185
|
+
"@typescript-eslint/no-unsafe-return": 0,
|
|
186
|
+
"@typescript-eslint/no-unsafe-enum-comparison": 0,
|
|
187
|
+
"@typescript-eslint/no-non-null-assertion": 0,
|
|
188
|
+
"@typescript-eslint/unbound-method": 0,
|
|
189
|
+
quotes: 0,
|
|
190
|
+
|
|
191
|
+
"@typescript-eslint/array-type": [
|
|
192
|
+
1,
|
|
193
|
+
{
|
|
194
|
+
default: "array",
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
|
|
198
|
+
"@typescript-eslint/quotes": [1, "backtick"],
|
|
199
|
+
"@typescript-eslint/consistent-type-definitions": [1, "interface"],
|
|
200
|
+
"no-magic-numbers": 0,
|
|
201
|
+
|
|
202
|
+
"@typescript-eslint/no-magic-numbers": [
|
|
203
|
+
1,
|
|
204
|
+
{
|
|
205
|
+
ignore: [
|
|
206
|
+
0, 0.25, -0.25, 0.5, -0.5, 0.75, -0.75, 1, -1, 1.25, -1.25, 1.5,
|
|
207
|
+
-1.5, 1.75, -1.75, 2, -2, 2.25, -2.25, 2.5, -2.5, 2.75, -2.75, 3,
|
|
208
|
+
-3, 3.25, -3.25, 3.5, -3.5, 3.75, -3.75, 4, -4, 4.25, -4.25, 4.5,
|
|
209
|
+
-4.5, 4.75, -4.75, 5, -5, 5.25, -5.25, 5.5, -5.5, 5.75, -5.75, 6,
|
|
210
|
+
-6, 6.25, -6.25, 6.5, -6.5, 6.75, -6.75, 7, -7, 7.25, -7.25, 7.5,
|
|
211
|
+
-7.5, 7.75, -7.75, 8, -8, 8.25, -8.25, 8.5, -8.5, 8.75, -8.75, 9,
|
|
212
|
+
-9, 9.25, -9.25, 9.5, -9.5, 9.75, -9.75, 10, -10,
|
|
213
|
+
],
|
|
214
|
+
|
|
215
|
+
ignoreTypeIndexes: true,
|
|
216
|
+
ignoreReadonlyClassProperties: true,
|
|
217
|
+
ignoreNumericLiteralTypes: true,
|
|
218
|
+
ignoreEnums: true,
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
|
|
222
|
+
"@typescript-eslint/no-unnecessary-type-arguments": 1,
|
|
223
|
+
"@typescript-eslint/unified-signatures": 1,
|
|
224
|
+
"@typescript-eslint/prefer-string-starts-ends-with": 1,
|
|
225
|
+
"@typescript-eslint/prefer-regexp-exec": 1,
|
|
226
|
+
"@typescript-eslint/prefer-includes": 1,
|
|
227
|
+
"@typescript-eslint/require-array-sort-compare": 1,
|
|
228
|
+
"@typescript-eslint/prefer-for-of": 1,
|
|
229
|
+
|
|
230
|
+
"@typescript-eslint/no-misused-promises": [
|
|
231
|
+
1,
|
|
232
|
+
{
|
|
233
|
+
checksVoidReturn: false,
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
|
|
237
|
+
"@typescript-eslint/no-floating-promises": [
|
|
238
|
+
1,
|
|
239
|
+
{
|
|
240
|
+
ignoreVoid: true,
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
|
|
244
|
+
"@typescript-eslint/no-unnecessary-qualifier": 1,
|
|
245
|
+
"@typescript-eslint/no-extraneous-class": 1,
|
|
246
|
+
"@typescript-eslint/explicit-member-accessibility": 1,
|
|
247
|
+
|
|
248
|
+
"@typescript-eslint/member-ordering": [
|
|
249
|
+
1,
|
|
250
|
+
{
|
|
251
|
+
default: [
|
|
252
|
+
"public-static-field",
|
|
253
|
+
"public-instance-field",
|
|
254
|
+
"public-constructor",
|
|
255
|
+
"private-static-field",
|
|
256
|
+
"private-instance-field",
|
|
257
|
+
"private-constructor",
|
|
258
|
+
"public-instance-method",
|
|
259
|
+
"protected-instance-method",
|
|
260
|
+
"private-instance-method",
|
|
261
|
+
],
|
|
262
|
+
},
|
|
263
|
+
],
|
|
264
|
+
|
|
265
|
+
"no-useless-constructor": 0,
|
|
266
|
+
"@typescript-eslint/no-useless-constructor": 1,
|
|
267
|
+
"regexp/no-useless-escape": 1,
|
|
268
|
+
"regexp/use-ignore-case": 0,
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
] satisfies Linter.Config[]
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"name": "@10stars/config",
|
|
7
|
-
"version": "
|
|
7
|
+
"version": "13.0.0",
|
|
8
8
|
"author": "10stars.dev <web@alexandrov.co> (https://alexandrov.co)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"bin": {
|
|
@@ -12,43 +12,41 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"src",
|
|
15
|
-
".
|
|
15
|
+
"eslint.config.ts",
|
|
16
|
+
"eslint.config.browser.ts",
|
|
17
|
+
"eslint.config.node.ts",
|
|
16
18
|
".prettierrc.js",
|
|
17
19
|
"commitlint.config.js",
|
|
18
|
-
"tsconfig.json"
|
|
20
|
+
"tsconfig.base.json"
|
|
19
21
|
],
|
|
20
|
-
"tsconfig": "./tsconfig.json",
|
|
21
22
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"lint": "eslint .",
|
|
24
|
-
"lint-rule-timings": "cross-env TIMING=1 npm run lint"
|
|
23
|
+
"config": "tsx ./src/index.ts"
|
|
25
24
|
},
|
|
26
25
|
"comments-dependencies": {
|
|
27
|
-
"tsx": "newer tsx breaks ladle"
|
|
28
|
-
"eslint": "eslint-plugin-react doesn't support ESLint 9 yet; see https://github.com/jsx-eslint/eslint-plugin-react/pull/3759 ",
|
|
29
|
-
"builtin-modules": "newer version breaks ESLint; we must upgrade to ESLint 9 first"
|
|
26
|
+
"tsx": "newer tsx breaks ladle"
|
|
30
27
|
},
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"@10stars/eslint-plugin-react-hooks": "^4.3.4",
|
|
33
29
|
"@commitlint/cli": "^19.0.0",
|
|
34
30
|
"@commitlint/config-conventional": "^19.0.0",
|
|
35
31
|
"@types/lodash": "^4.0.0",
|
|
36
32
|
"@types/node": "^22.0.0",
|
|
37
33
|
"@types/react": "^18.0.0",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
39
|
-
"@typescript-eslint/parser": "^
|
|
40
|
-
"builtin-modules": "^
|
|
41
|
-
"esbuild": "~0.
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
35
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
36
|
+
"builtin-modules": "^5.0.0",
|
|
37
|
+
"esbuild": "~0.25.0",
|
|
42
38
|
"tsx": "4.11.2",
|
|
43
|
-
"eslint": "^
|
|
44
|
-
"eslint
|
|
39
|
+
"@eslint/compat": "^1.0.0",
|
|
40
|
+
"@eslint/eslintrc": "^3.0.0",
|
|
41
|
+
"@eslint/js": "^9.0.0",
|
|
42
|
+
"eslint-config-prettier": "^10.0.0",
|
|
45
43
|
"eslint-plugin-import": "^2.0.0",
|
|
46
44
|
"eslint-plugin-no-relative-import-paths": "^1.5.4",
|
|
47
45
|
"eslint-plugin-react": "^7.0.0",
|
|
48
46
|
"eslint-plugin-regexp": "^2.0.0",
|
|
49
47
|
"eslint-plugin-simple-import-sort": "^12.0.0",
|
|
50
48
|
"eslint-plugin-sort-keys-fix": "^1.0.0",
|
|
51
|
-
"
|
|
49
|
+
"globals": "^16.0.0",
|
|
52
50
|
"husky": "^9.0.0",
|
|
53
51
|
"prettier": "^3.0.0",
|
|
54
52
|
"type-fest": "^4.0.0",
|
package/readme.md
CHANGED
|
@@ -11,6 +11,4 @@
|
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
- You can learn more about, for example, [ESLint Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) on the official ESLint website.
|
|
14
|
+
You can learn more about [ESLint Shareable Configs](http://eslint.org/docs/developer-guide/shareable-configs) on the official ESLint website.
|
package/src/index.ts
CHANGED
|
File without changes
|
package/.eslintrc.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
const builtinModules = require("builtin-modules")
|
|
2
|
-
/**
|
|
3
|
-
* @todo
|
|
4
|
-
* - prohibit "whiteSpace" style rule
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @return [0, 0.25, -0.25, 0.5, -0.5, 0.75, -0.75, 1, -1, ..., 10, -10]
|
|
8
|
-
*/
|
|
9
|
-
const allowedMagicNumbers = (() => {
|
|
10
|
-
const magicNumbers = []
|
|
11
|
-
const max = 10
|
|
12
|
-
|
|
13
|
-
for (let i = 0; i < max + 1; i++) {
|
|
14
|
-
if (i === max) {
|
|
15
|
-
magicNumbers.push(i, -i)
|
|
16
|
-
continue
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (i === -i) magicNumbers.push(i)
|
|
20
|
-
else magicNumbers.push(i, -i)
|
|
21
|
-
|
|
22
|
-
const numOfDecimals = 4
|
|
23
|
-
const decimalPoint = 1 / numOfDecimals
|
|
24
|
-
for (let b = 1; b < numOfDecimals; b++) {
|
|
25
|
-
const decimal = i + b * decimalPoint
|
|
26
|
-
magicNumbers.push(decimal, -decimal)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return magicNumbers
|
|
31
|
-
})()
|
|
32
|
-
|
|
33
|
-
const reactUseHooks = [
|
|
34
|
-
`useUpdateEffect`,
|
|
35
|
-
`useIsomorphicLayoutEffect`,
|
|
36
|
-
`useDeepCompareEffect`,
|
|
37
|
-
`useShallowCompareEffect`,
|
|
38
|
-
`useCustomCompareEffect`,
|
|
39
|
-
]
|
|
40
|
-
|
|
41
|
-
const type = {
|
|
42
|
-
ignore: 0,
|
|
43
|
-
warning: 1,
|
|
44
|
-
error: 2,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
module.exports = {
|
|
48
|
-
root: true, // https://eslint.org/docs/latest/use/configure/configuration-files#using-configuration-files
|
|
49
|
-
parser: `@typescript-eslint/parser`, // Specifies the ESLint parser
|
|
50
|
-
parserOptions: {
|
|
51
|
-
ecmaVersion: `latest`, // Allows for the parsing of modern ECMAScript features
|
|
52
|
-
sourceType: `module`, // Allows for the use of imports
|
|
53
|
-
ecmaFeatures: {
|
|
54
|
-
jsx: true, // Allows for the parsing of JSX
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
ignorePatterns: [`**/node_modules`, `**/.git`, `**/dist`, `**/tmp`],
|
|
58
|
-
plugins: [
|
|
59
|
-
`@typescript-eslint`,
|
|
60
|
-
`import`,
|
|
61
|
-
`react`,
|
|
62
|
-
`@10stars/react-hooks`, // https://reactjs.org/docs/hooks-rules.html#eslint-plugin
|
|
63
|
-
`regexp`,
|
|
64
|
-
`no-relative-import-paths`,
|
|
65
|
-
`simple-import-sort`,
|
|
66
|
-
`sort-keys-fix`,
|
|
67
|
-
],
|
|
68
|
-
env: {
|
|
69
|
-
browser: true,
|
|
70
|
-
jest: true,
|
|
71
|
-
},
|
|
72
|
-
extends: [
|
|
73
|
-
`eslint:recommended`,
|
|
74
|
-
`plugin:@typescript-eslint/strict-type-checked`,
|
|
75
|
-
`plugin:@typescript-eslint/stylistic-type-checked`,
|
|
76
|
-
`plugin:react/recommended`,
|
|
77
|
-
`plugin:@10stars/react-hooks/recommended`,
|
|
78
|
-
`plugin:regexp/recommended`,
|
|
79
|
-
|
|
80
|
-
`prettier`, // disables all formatting rules see: https://github.com/prettier/eslint-config-prettier
|
|
81
|
-
|
|
82
|
-
// We use only few custom rules from the import plugin and we override some aspects with simple-import-sort
|
|
83
|
-
// "plugin:import/typescript",
|
|
84
|
-
// "plugin:import/warnings",
|
|
85
|
-
// "plugin:import/errors",
|
|
86
|
-
],
|
|
87
|
-
settings: {
|
|
88
|
-
"import/parsers": { "@typescript-eslint/parser": [`.ts`, `.tsx`] },
|
|
89
|
-
"import/extensions": [`.ts`, `.tsx`, `.js`, `.jsx`],
|
|
90
|
-
react: {
|
|
91
|
-
version: `18.0.0`,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
rules: {
|
|
95
|
-
/**
|
|
96
|
-
* ESLint core rules
|
|
97
|
-
*/
|
|
98
|
-
"no-case-declarations": type.ignore, // TypeScript shows us error, if the variable is reused in the same scope, so this rule is not applicable
|
|
99
|
-
/**
|
|
100
|
-
* eslint-plugin-no-relative-import-paths
|
|
101
|
-
*/
|
|
102
|
-
"no-relative-import-paths/no-relative-import-paths": [
|
|
103
|
-
type.warning,
|
|
104
|
-
{ allowSameFolder: true, allowedDepth: 2 },
|
|
105
|
-
],
|
|
106
|
-
/**
|
|
107
|
-
* eslint-plugin-import @see https://github.com/benmosher/eslint-plugin-import
|
|
108
|
-
*/
|
|
109
|
-
"import/order": type.ignore, // turn off in favor of eslint-plugin-simple-import-sort
|
|
110
|
-
"import/no-unresolved": type.ignore,
|
|
111
|
-
"import/no-duplicates": type.warning,
|
|
112
|
-
"import/no-nodejs-modules": [
|
|
113
|
-
type.error,
|
|
114
|
-
{
|
|
115
|
-
allow: builtinModules.flatMap((v) => [
|
|
116
|
-
`node:${v}`,
|
|
117
|
-
`node:${v}/promises`,
|
|
118
|
-
]),
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
/**
|
|
122
|
-
* eslint-plugin-simple-import-sort
|
|
123
|
-
*/
|
|
124
|
-
"sort-imports": type.ignore, // we use eslint-plugin-import instead
|
|
125
|
-
"simple-import-sort/imports": type.warning,
|
|
126
|
-
"simple-import-sort/exports": type.warning,
|
|
127
|
-
/**
|
|
128
|
-
* React
|
|
129
|
-
*/
|
|
130
|
-
"react/display-name": type.ignore,
|
|
131
|
-
"react/no-children-prop": type.ignore,
|
|
132
|
-
"react/no-unknown-property": [
|
|
133
|
-
type.error /** @see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md#rule-options */,
|
|
134
|
-
{
|
|
135
|
-
ignore: [
|
|
136
|
-
`sx`, // we ignore sx, because we use PigmentCSS @see https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md#rule-options
|
|
137
|
-
],
|
|
138
|
-
},
|
|
139
|
-
],
|
|
140
|
-
"react/prop-types": type.ignore,
|
|
141
|
-
"react/react-in-jsx-scope": type.ignore,
|
|
142
|
-
"react/jsx-filename-extension": [
|
|
143
|
-
type.warning,
|
|
144
|
-
{ extensions: [`.jsx`, `.tsx`] },
|
|
145
|
-
], // also want to use with ".tsx"
|
|
146
|
-
"react/no-invalid-html-attribute": type.error,
|
|
147
|
-
"react/prefer-stateless-function": type.error,
|
|
148
|
-
"react/jsx-boolean-value": [type.warning, "never"],
|
|
149
|
-
"react/jsx-curly-brace-presence": [type.warning, "always"],
|
|
150
|
-
"react/jsx-fragments": type.warning,
|
|
151
|
-
"react/jsx-no-bind": type.warning,
|
|
152
|
-
"react/jsx-no-constructed-context-values": type.warning,
|
|
153
|
-
"react/jsx-no-script-url": [
|
|
154
|
-
type.error,
|
|
155
|
-
[
|
|
156
|
-
{ name: "Link", props: ["to"] },
|
|
157
|
-
{ name: "NavLink", props: ["to"] },
|
|
158
|
-
{ name: "a", props: ["href", "to"] },
|
|
159
|
-
],
|
|
160
|
-
],
|
|
161
|
-
"react/jsx-no-useless-fragment": type.warning,
|
|
162
|
-
"react/jsx-no-target-blank": type.error,
|
|
163
|
-
"react/jsx-sort-props": type.warning,
|
|
164
|
-
/**
|
|
165
|
-
* Hooks
|
|
166
|
-
*/
|
|
167
|
-
"@10stars/react-hooks/exhaustive-deps": [
|
|
168
|
-
type.warning,
|
|
169
|
-
{
|
|
170
|
-
additionalHooks: `(${reactUseHooks.join(`|`)})`,
|
|
171
|
-
ignoreThisDependency: `always`,
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
/**
|
|
175
|
-
* TypeScript
|
|
176
|
-
* List of ignored (not recommended) rules we also explored:
|
|
177
|
-
* - @typescript-eslint/consistent-type-assertions
|
|
178
|
-
* - @typescript-eslint/explicit-module-boundary-types
|
|
179
|
-
* - @typescript-eslint/no-require-imports
|
|
180
|
-
* - @typescript-eslint/no-type-alias
|
|
181
|
-
* - @typescript-eslint/strict-boolean-expressions // doesn't work well
|
|
182
|
-
*/
|
|
183
|
-
// changed recommended rules
|
|
184
|
-
"@typescript-eslint/restrict-template-expressions": [
|
|
185
|
-
"error", // https://typescript-eslint.io/rules/restrict-template-expressions/
|
|
186
|
-
{ allowNumber: true }, // we allow numbers in template strings
|
|
187
|
-
],
|
|
188
|
-
// disabled recommended rules
|
|
189
|
-
"@typescript-eslint/prefer-nullish-coalescing": type.ignore, // doesn't make sense sometimes and actually could introduce a bug
|
|
190
|
-
"@typescript-eslint/consistent-indexed-object-style": type.ignore,
|
|
191
|
-
"@typescript-eslint/no-throw-literal": type.ignore,
|
|
192
|
-
"@typescript-eslint/no-unnecessary-condition": type.ignore,
|
|
193
|
-
"@typescript-eslint/no-confusing-void-expression": type.ignore,
|
|
194
|
-
"@typescript-eslint/no-invalid-void-type": type.ignore,
|
|
195
|
-
"@typescript-eslint/no-dynamic-delete": type.ignore, // we use it for "unset" function
|
|
196
|
-
"@typescript-eslint/no-empty-interface": type.ignore, // most of the time it's a work-in-progress interface
|
|
197
|
-
"@typescript-eslint/no-unused-vars": type.ignore, // removed by bundler, so it shouldn't be a rule
|
|
198
|
-
"@typescript-eslint/no-empty-function": type.ignore, // used for prototyping
|
|
199
|
-
"@typescript-eslint/no-explicit-any": type.ignore,
|
|
200
|
-
"@typescript-eslint/ban-types": type.ignore,
|
|
201
|
-
"@typescript-eslint/only-throw-error": type.ignore, // it's useful to have a flexibility in throwing a plain object
|
|
202
|
-
"@typescript-eslint/use-unknown-in-catch-callback-variable": type.ignore, // we explicitly set the type in the catch block
|
|
203
|
-
// ---- we ignore these "no-unsafe-*" as it noticeably slows down the code writing
|
|
204
|
-
"@typescript-eslint/no-unsafe-assignment": type.ignore,
|
|
205
|
-
"@typescript-eslint/no-unsafe-member-access": type.ignore,
|
|
206
|
-
"@typescript-eslint/no-unsafe-return": type.ignore,
|
|
207
|
-
"@typescript-eslint/no-unsafe-enum-comparison": type.ignore, // generated enums would be considered unsafe, so the rule must be turned off
|
|
208
|
-
"@typescript-eslint/no-non-null-assertion": type.ignore, // sometimes TS incorrectly asserts, so there's a need to override
|
|
209
|
-
"@typescript-eslint/unbound-method": type.ignore,
|
|
210
|
-
// other
|
|
211
|
-
quotes: type.ignore,
|
|
212
|
-
"@typescript-eslint/array-type": [type.warning, { default: `array` }],
|
|
213
|
-
"@typescript-eslint/quotes": [type.warning, `backtick`],
|
|
214
|
-
"@typescript-eslint/consistent-type-definitions": [
|
|
215
|
-
type.warning, // @see https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces
|
|
216
|
-
`interface`, // VSCode's Code lens can only highlight use of properties in "interface" definitions
|
|
217
|
-
],
|
|
218
|
-
"no-magic-numbers": type.ignore,
|
|
219
|
-
"@typescript-eslint/no-magic-numbers": [
|
|
220
|
-
type.warning,
|
|
221
|
-
{
|
|
222
|
-
ignore: allowedMagicNumbers,
|
|
223
|
-
ignoreTypeIndexes: true,
|
|
224
|
-
ignoreReadonlyClassProperties: true,
|
|
225
|
-
ignoreNumericLiteralTypes: true,
|
|
226
|
-
ignoreEnums: true,
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
"@typescript-eslint/no-unnecessary-type-arguments": type.warning,
|
|
230
|
-
"@typescript-eslint/unified-signatures": type.warning,
|
|
231
|
-
// string
|
|
232
|
-
"@typescript-eslint/prefer-string-starts-ends-with": type.warning,
|
|
233
|
-
// RegExp
|
|
234
|
-
"@typescript-eslint/prefer-regexp-exec": type.warning,
|
|
235
|
-
// array
|
|
236
|
-
"@typescript-eslint/prefer-includes": type.warning,
|
|
237
|
-
"@typescript-eslint/require-array-sort-compare": type.warning,
|
|
238
|
-
// loops
|
|
239
|
-
"@typescript-eslint/prefer-for-of": type.warning,
|
|
240
|
-
// promises
|
|
241
|
-
"@typescript-eslint/no-misused-promises": [
|
|
242
|
-
type.warning,
|
|
243
|
-
{ checksVoidReturn: false },
|
|
244
|
-
],
|
|
245
|
-
"@typescript-eslint/no-floating-promises": [
|
|
246
|
-
type.warning,
|
|
247
|
-
{ ignoreVoid: true },
|
|
248
|
-
],
|
|
249
|
-
// namespace
|
|
250
|
-
"@typescript-eslint/no-unnecessary-qualifier": type.warning,
|
|
251
|
-
// for classes
|
|
252
|
-
"@typescript-eslint/no-extraneous-class": type.warning,
|
|
253
|
-
"@typescript-eslint/explicit-member-accessibility": type.warning,
|
|
254
|
-
"@typescript-eslint/member-ordering": [
|
|
255
|
-
type.warning,
|
|
256
|
-
{
|
|
257
|
-
default: [
|
|
258
|
-
`public-static-field`,
|
|
259
|
-
`public-instance-field`,
|
|
260
|
-
`public-constructor`,
|
|
261
|
-
`private-static-field`,
|
|
262
|
-
`private-instance-field`,
|
|
263
|
-
`private-constructor`,
|
|
264
|
-
`public-instance-method`,
|
|
265
|
-
`protected-instance-method`,
|
|
266
|
-
`private-instance-method`,
|
|
267
|
-
],
|
|
268
|
-
},
|
|
269
|
-
],
|
|
270
|
-
"no-useless-constructor": type.ignore,
|
|
271
|
-
"@typescript-eslint/no-useless-constructor": type.warning,
|
|
272
|
-
/**
|
|
273
|
-
* Regex
|
|
274
|
-
*/
|
|
275
|
-
"regexp/no-useless-escape": type.warning,
|
|
276
|
-
"regexp/use-ignore-case": type.ignore, // results in a bug; https://github.com/ota-meshi/eslint-plugin-regexp/issues/672
|
|
277
|
-
},
|
|
278
|
-
}
|