@dubium/eslint-config 1.0.11 → 1.0.13
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/README.md +39 -0
- package/config/typescript.js +28 -32
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -74,6 +74,45 @@ export default defineConfig([
|
|
|
74
74
|
]);
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
+
Or
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
import { defineConfig } from "eslint/config"
|
|
81
|
+
import { base } from "@dubium/eslint-config/base"
|
|
82
|
+
import { typescript } from "@dubium/eslint-config/typescript"
|
|
83
|
+
import { react } from "@dubium/eslint-config/react"
|
|
84
|
+
import globals from "globals"
|
|
85
|
+
|
|
86
|
+
const enhancedTypescript = {
|
|
87
|
+
...typescript,
|
|
88
|
+
languageOptions: {
|
|
89
|
+
...typescript.languageOptions,
|
|
90
|
+
parserOptions: {
|
|
91
|
+
...( typescript.languageOptions?.parserOptions || {} ),
|
|
92
|
+
project: "./tsconfig.json",
|
|
93
|
+
tsconfigRootDir: process.cwd(),
|
|
94
|
+
// Support path aliases (@/*)
|
|
95
|
+
EXPERIMENTAL_useProjectService: true,
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default defineConfig([
|
|
101
|
+
base,
|
|
102
|
+
enhancedTypescript,
|
|
103
|
+
react,
|
|
104
|
+
{
|
|
105
|
+
languageOptions: {
|
|
106
|
+
globals: {
|
|
107
|
+
...globals.node,
|
|
108
|
+
...globals.browser,
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
])
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
|
|
77
116
|
You can also use only the configs you need:
|
|
78
117
|
|
|
79
118
|
```js
|
package/config/typescript.js
CHANGED
|
@@ -15,45 +15,41 @@ export const typescript = {
|
|
|
15
15
|
},
|
|
16
16
|
|
|
17
17
|
rules: {
|
|
18
|
-
|
|
19
|
-
* Запрещает объявление неиспользуемых переменных
|
|
20
|
-
* Disallows unused variables
|
|
21
|
-
* Ссылка: https://eslint.org/docs/latest/rules/no-unused-vars
|
|
22
|
-
*/
|
|
18
|
+
// Отключаем базовые ESLint правила в пользу TypeScript
|
|
23
19
|
"no-unused-vars": "off",
|
|
20
|
+
"no-duplicate-imports": "off",
|
|
21
|
+
|
|
22
|
+
// TypeScript правила
|
|
24
23
|
"@typescript-eslint/no-explicit-any": "warn",
|
|
25
24
|
"@typescript-eslint/consistent-type-imports": "error",
|
|
26
25
|
"@typescript-eslint/no-unused-vars": [ "warn" ],
|
|
27
26
|
"@typescript-eslint/no-unsafe-argument": "error",
|
|
28
|
-
"@typescript-eslint/no-unsafe-assignment": "
|
|
29
|
-
"@typescript-eslint/no-unsafe-call": "
|
|
27
|
+
"@typescript-eslint/no-unsafe-assignment": "warn",
|
|
28
|
+
"@typescript-eslint/no-unsafe-call": "warn",
|
|
30
29
|
"@typescript-eslint/no-unsafe-member-access": "error",
|
|
31
30
|
"@typescript-eslint/require-await": "warn",
|
|
32
31
|
"@typescript-eslint/await-thenable": "warn",
|
|
33
|
-
"@typescript-eslint/no-indexed-access-type": "error",
|
|
34
|
-
|
|
35
|
-
// Дополнительные правила для чистоты типов:
|
|
36
|
-
"@typescript-eslint/no-type-alias": [
|
|
37
|
-
"error",
|
|
38
|
-
{
|
|
39
|
-
"allowAliases": "in-unions-and-intersections",
|
|
40
|
-
"allowCallbacks": "always",
|
|
41
|
-
"allowConditionalTypes": "always",
|
|
42
|
-
"allowConstructors": "never",
|
|
43
|
-
"allowLiterals": "in-unions-and-intersections",
|
|
44
|
-
"allowMappedTypes": "always",
|
|
45
|
-
"allowTupleTypes": "always",
|
|
46
|
-
"allowGenerics": "always"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
|
|
50
|
-
// Запрещает сложные utility types
|
|
51
|
-
"@typescript-eslint/no-unnecessary-type-parameters": "error",
|
|
52
|
-
|
|
53
|
-
// Требует явных типов вместо infer
|
|
54
|
-
"@typescript-eslint/no-inferrable-types": "error",
|
|
55
32
|
|
|
56
|
-
//
|
|
33
|
+
// Вместо удалённого no-indexed-access-type используйте:
|
|
34
|
+
"@typescript-eslint/consistent-indexed-object-style": [ "error", "record" ],
|
|
35
|
+
|
|
36
|
+
"@typescript-eslint/no-inferrable-types": "error",
|
|
57
37
|
"@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
58
|
-
|
|
59
|
-
|
|
38
|
+
|
|
39
|
+
// Дополнительные полезные правила:
|
|
40
|
+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
|
|
41
|
+
"@typescript-eslint/no-unnecessary-condition": "warn",
|
|
42
|
+
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
43
|
+
"@typescript-eslint/prefer-nullish-coalescing": "warn",
|
|
44
|
+
"@typescript-eslint/prefer-optional-chain": "warn",
|
|
45
|
+
|
|
46
|
+
// Безопасность типов
|
|
47
|
+
"@typescript-eslint/no-unsafe-return": "error",
|
|
48
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "error",
|
|
49
|
+
|
|
50
|
+
// Чистота кода
|
|
51
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
52
|
+
"@typescript-eslint/no-base-to-string": "error",
|
|
53
|
+
"@typescript-eslint/no-confusing-void-expression": "error",
|
|
54
|
+
}
|
|
55
|
+
}
|