@dubium/eslint-config 1.0.12 → 1.0.14
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 +34 -25
- package/config/typescript.js +26 -30
- package/package.json +1 -1
- package/README-RU.md +0 -181
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@ Install the config and the required peer dependencies according to your needs.
|
|
|
14
14
|
### 🔹 Base configuration (`base`)
|
|
15
15
|
|
|
16
16
|
```bash
|
|
17
|
-
npm install -D eslint @dubium/eslint-config
|
|
17
|
+
npm install -D eslint @eslint/js globals @dubium/eslint-config
|
|
18
18
|
# or
|
|
19
|
-
yarn add -D eslint @dubium/eslint-config
|
|
19
|
+
yarn add -D eslint @eslint/js globals @dubium/eslint-config
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
<sub>It is also recommended to install `globals` if you use global variables in your ESLint config.</sub>
|
|
@@ -26,9 +26,9 @@ yarn add -D eslint @dubium/eslint-config
|
|
|
26
26
|
### 🔹 TypeScript (`typescript`)
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
|
-
npm install -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
29
|
+
npm install -D typescript-eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
30
30
|
# or
|
|
31
|
-
yarn add -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
31
|
+
yarn add -D typescript-eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
---
|
|
@@ -53,28 +53,19 @@ yarn add -D eslint-plugin-jsx-a11y
|
|
|
53
53
|
|
|
54
54
|
---
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
### 🔹 Prettier
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
```bash
|
|
59
|
+
npm install -D prettier eslint-config-prettier eslint-plugin-prettier
|
|
60
|
+
# or
|
|
61
|
+
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier
|
|
62
|
+
```
|
|
59
63
|
|
|
60
|
-
|
|
61
|
-
import { defineConfig } from "eslint/config";
|
|
62
|
-
import {
|
|
63
|
-
base,
|
|
64
|
-
typescript,
|
|
65
|
-
react,
|
|
66
|
-
jsxA11y,
|
|
67
|
-
} from "@dubium/eslint-config";
|
|
64
|
+
###
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
base,
|
|
71
|
-
typescript,
|
|
72
|
-
react,
|
|
73
|
-
jsxA11y,
|
|
74
|
-
]);
|
|
75
|
-
```
|
|
66
|
+
## ⚙️ Usage
|
|
76
67
|
|
|
77
|
-
|
|
68
|
+
Create an `eslint.config.js` file:
|
|
78
69
|
|
|
79
70
|
```js
|
|
80
71
|
import { defineConfig } from "eslint/config"
|
|
@@ -82,7 +73,10 @@ import { base } from "@dubium/eslint-config/base"
|
|
|
82
73
|
import { typescript } from "@dubium/eslint-config/typescript"
|
|
83
74
|
import { react } from "@dubium/eslint-config/react"
|
|
84
75
|
import globals from "globals"
|
|
76
|
+
import prettier from "eslint-config-prettier"
|
|
77
|
+
import eslintPluginPrettier from "eslint-plugin-prettier"
|
|
85
78
|
|
|
79
|
+
// Модифицируем typescript конфиг для поддержки type-aware правил
|
|
86
80
|
const enhancedTypescript = {
|
|
87
81
|
...typescript,
|
|
88
82
|
languageOptions: {
|
|
@@ -91,17 +85,23 @@ const enhancedTypescript = {
|
|
|
91
85
|
...( typescript.languageOptions?.parserOptions || {} ),
|
|
92
86
|
project: "./tsconfig.json",
|
|
93
87
|
tsconfigRootDir: process.cwd(),
|
|
94
|
-
//
|
|
88
|
+
// Для поддержки path aliases (@/*)
|
|
95
89
|
EXPERIMENTAL_useProjectService: true,
|
|
96
90
|
},
|
|
97
91
|
},
|
|
98
92
|
}
|
|
99
93
|
|
|
100
|
-
export default defineConfig([
|
|
94
|
+
export default defineConfig( [
|
|
101
95
|
base,
|
|
102
96
|
enhancedTypescript,
|
|
103
97
|
react,
|
|
104
98
|
{
|
|
99
|
+
plugins: {
|
|
100
|
+
prettier: eslintPluginPrettier,
|
|
101
|
+
},
|
|
102
|
+
rules: {
|
|
103
|
+
"prettier/prettier": "error",
|
|
104
|
+
},
|
|
105
105
|
languageOptions: {
|
|
106
106
|
globals: {
|
|
107
107
|
...globals.node,
|
|
@@ -109,7 +109,16 @@ export default defineConfig([
|
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
},
|
|
112
|
-
|
|
112
|
+
prettier,
|
|
113
|
+
{
|
|
114
|
+
files: [ "**/*.schema.ts" ],
|
|
115
|
+
rules: {
|
|
116
|
+
"@typescript-eslint/no-unsafe-call": "off",
|
|
117
|
+
"@typescript-eslint/no-unsafe-assignment": "off"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
] )
|
|
121
|
+
|
|
113
122
|
|
|
114
123
|
```
|
|
115
124
|
|
package/config/typescript.js
CHANGED
|
@@ -15,12 +15,11 @@ 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" ],
|
|
@@ -30,30 +29,27 @@ export const typescript = {
|
|
|
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
|
+
}
|
package/package.json
CHANGED
package/README-RU.md
DELETED
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
# @dubium/eslint-config
|
|
2
|
-
|
|
3
|
-
**Flat ESLint config** для проектов Dubium — модульный, расширяемый и строго структурированный.
|
|
4
|
-
Поддерживает **TypeScript**, **React** и **доступность (a11y)**.
|
|
5
|
-
|
|
6
|
-
[English version](https://github.com/DubiumEkb/dubium-design/blob/main/packages/eslint-config/README.md)
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 📦 Установка
|
|
11
|
-
|
|
12
|
-
Установи сам конфиг и нужные peer-зависимости под конкретные нужды.
|
|
13
|
-
|
|
14
|
-
### 🔹 Базовая конфигурация (`base`)
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install -D eslint @dubium/eslint-config
|
|
18
|
-
# или
|
|
19
|
-
yarn add -D eslint @dubium/eslint-config
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
<sub>Также рекомендуется установить `globals`, если используется в `.eslintrc`.</sub>
|
|
23
|
-
|
|
24
|
-
---
|
|
25
|
-
|
|
26
|
-
### 🔹 TypeScript (`typescript`)
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
30
|
-
# или
|
|
31
|
-
yarn add -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
### 🔹 React (`react`)
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
40
|
-
# или
|
|
41
|
-
yarn add -D eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
### 🔹 Доступность (`jsxA11y`)
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npm install -D eslint-plugin-jsx-a11y
|
|
50
|
-
# или
|
|
51
|
-
yarn add -D eslint-plugin-jsx-a11y
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## ⚙️ Использование
|
|
57
|
-
|
|
58
|
-
Создай файл `eslint.config.js`:
|
|
59
|
-
|
|
60
|
-
```js
|
|
61
|
-
import { defineConfig } from "eslint/config";
|
|
62
|
-
import {
|
|
63
|
-
base,
|
|
64
|
-
typescript,
|
|
65
|
-
react,
|
|
66
|
-
jsxA11y,
|
|
67
|
-
} from "@dubium/eslint-config";
|
|
68
|
-
|
|
69
|
-
export default defineConfig([
|
|
70
|
-
base,
|
|
71
|
-
typescript,
|
|
72
|
-
react,
|
|
73
|
-
jsxA11y,
|
|
74
|
-
]);
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Или
|
|
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
|
-
|
|
116
|
-
Можно использовать только нужные конфиги:
|
|
117
|
-
|
|
118
|
-
```js
|
|
119
|
-
export default defineConfig([
|
|
120
|
-
base,
|
|
121
|
-
typescript,
|
|
122
|
-
]);
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
> Если в проекте используются глобальные переменные (например, `window`, `process`, `jest` и т.п.), рекомендуем дополнительно установить пакет `globals` и добавить их в конфигурацию ESLint:
|
|
128
|
-
>
|
|
129
|
-
> ```js
|
|
130
|
-
> import globals from "globals";
|
|
131
|
-
>
|
|
132
|
-
> export default defineConfig({
|
|
133
|
-
> languageOptions: {
|
|
134
|
-
> globals: {
|
|
135
|
-
> ...globals.browser,
|
|
136
|
-
> ...globals.node,
|
|
137
|
-
> ...globals.jest,
|
|
138
|
-
> },
|
|
139
|
-
> },
|
|
140
|
-
> // другие настройки
|
|
141
|
-
> });
|
|
142
|
-
> ```
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## 🧩 Доступные конфиги
|
|
147
|
-
|
|
148
|
-
| Конфиг | Импорт из | Описание |
|
|
149
|
-
| ------------ | ---------------------------------- | ---------------------------------- |
|
|
150
|
-
| `base` | `@dubium/eslint-config/base` | Базовая настройка JS/TS + globals |
|
|
151
|
-
| `typescript` | `@dubium/eslint-config/typescript` | Поддержка TypeScript |
|
|
152
|
-
| `react` | `@dubium/eslint-config/react` | React, хуки и React Refresh |
|
|
153
|
-
| `jsxA11y` | `@dubium/eslint-config/jsx-a11y` | Рекомендации по доступности (a11y) |
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## 🔍 Проверка финального конфига
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
npx eslint --print-config src/index.ts
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
Или:
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
npm run lint:inspect
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
---
|
|
170
|
-
|
|
171
|
-
## 🔧 Требования
|
|
172
|
-
|
|
173
|
-
* **Node.js** `>=18`
|
|
174
|
-
* **ESLint** `^9.0.0` (Flat Config)
|
|
175
|
-
* Проект должен использовать `type: "module"`
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## 📝 Лицензия
|
|
180
|
-
|
|
181
|
-
[MIT](./LICENSE) © [Dubium](https://github.com/DubiumEkb)
|