eslint-config-mgz 1.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/README.md +444 -0
- package/base.js +45 -0
- package/flat-config.js +80 -0
- package/index.js +27 -0
- package/package.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# eslint-config-mgz
|
|
2
|
+
|
|
3
|
+
Shared ESLint configuration for React + TypeScript projects
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🇷🇺 Русский
|
|
8
|
+
|
|
9
|
+
### 📦 Описание
|
|
10
|
+
|
|
11
|
+
`eslint-config-mgz` — это переиспользуемая конфигурация ESLint
|
|
12
|
+
для frontend проектов с React и TypeScript:
|
|
13
|
+
|
|
14
|
+
- ✅ **TypeScript** поддержка с `@typescript-eslint`
|
|
15
|
+
- ✅ **React** правила и хуки
|
|
16
|
+
- ✅ **Import** правила для модулей
|
|
17
|
+
- ✅ **JSX accessibility** проверки
|
|
18
|
+
- ✅ **Prettier** интеграция (отключает конфликтующие правила)
|
|
19
|
+
|
|
20
|
+
Цель пакета — стандартизировать линтинг во всех проектах и обеспечить качество кода.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
### 📂 Содержимое пакета
|
|
25
|
+
|
|
26
|
+
| Файл | Назначение |
|
|
27
|
+
| ---------------- | ----------------------------------- |
|
|
28
|
+
| `base.js` | Основная конфигурация ESLint (v7-8) |
|
|
29
|
+
| `flat-config.js` | Flat config для ESLint v9+ |
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
### 🚀 Установка
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# ESLint v7-8 (обязательные)
|
|
37
|
+
npm install -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier
|
|
38
|
+
|
|
39
|
+
# ESLint v9+ (обязательные + опциональные)
|
|
40
|
+
npm install -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier @eslint/js typescript-eslint
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# ESLint v7-8 (обязательные)
|
|
45
|
+
pnpm add -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier
|
|
46
|
+
|
|
47
|
+
# ESLint v9+ (обязательные + опциональные)
|
|
48
|
+
pnpm add -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier @eslint/js typescript-eslint
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# ESLint v7-8 (обязательные)
|
|
53
|
+
yarn add -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier
|
|
54
|
+
|
|
55
|
+
# ESLint v9+ (обязательные + опциональные)
|
|
56
|
+
yarn add -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier @eslint/js typescript-eslint
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## 🚨 **Совместимость с ESLint**
|
|
62
|
+
|
|
63
|
+
### 📊 **Таблица совместимости:**
|
|
64
|
+
|
|
65
|
+
| ESLint версия | Совместимость | Конфиг файл | Примечания |
|
|
66
|
+
| ------------- | ------------- | ----------------- | ----------------------- |
|
|
67
|
+
| **v7.x** | ✅ Полная | `.eslintrc.*` | Рекомендуется |
|
|
68
|
+
| **v8.x** | ✅ Полная | `.eslintrc.*` | Рекомендуется |
|
|
69
|
+
| **v9.x** | ✅ Полная | `eslint.config.*` | Используйте flat-config |
|
|
70
|
+
|
|
71
|
+
### 🧩 Использование
|
|
72
|
+
|
|
73
|
+
#### В .eslintrc.js
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
module.exports = {
|
|
77
|
+
extends: ["eslint-config-mgz"],
|
|
78
|
+
parserOptions: {
|
|
79
|
+
project: "./tsconfig.json",
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### В .eslintrc.json
|
|
85
|
+
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"extends": ["eslint-config-mgz"],
|
|
89
|
+
"parserOptions": {
|
|
90
|
+
"project": "./tsconfig.json"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### С дополнительными правилами
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
module.exports = {
|
|
99
|
+
extends: ["eslint-config-mgz"],
|
|
100
|
+
rules: {
|
|
101
|
+
// Ваши дополнительные правила
|
|
102
|
+
"no-console": "warn",
|
|
103
|
+
"@typescript-eslint/no-unused-vars": "error",
|
|
104
|
+
},
|
|
105
|
+
parserOptions: {
|
|
106
|
+
project: "./tsconfig.json",
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### Для ESLint v9+ (Flat Config)
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
// eslint.config.js
|
|
115
|
+
import config from "eslint-config-mgz/flat-config";
|
|
116
|
+
|
|
117
|
+
export default config;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Или с дополнительными правилами:
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
// eslint.config.js
|
|
124
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
125
|
+
import baseConfig from "eslint-config-mgz";
|
|
126
|
+
|
|
127
|
+
const compat = new FlatCompat();
|
|
128
|
+
export default [
|
|
129
|
+
...compat.config(baseConfig),
|
|
130
|
+
{
|
|
131
|
+
rules: {
|
|
132
|
+
// Ваши дополнительные правила
|
|
133
|
+
"no-console": "warn",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
#### Для старых версий ESLint (v7-8)
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Принудительное использование старого формата в v9
|
|
143
|
+
npx eslint --config .eslintrc.js src/
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
### 🧠 Включенные правила
|
|
149
|
+
|
|
150
|
+
#### **ESLint Recommended**
|
|
151
|
+
|
|
152
|
+
- Базовые правила JavaScript
|
|
153
|
+
|
|
154
|
+
#### **TypeScript ESLint**
|
|
155
|
+
|
|
156
|
+
- Правила для TypeScript кода
|
|
157
|
+
- Строгая типизация
|
|
158
|
+
- Лучшие практики TS
|
|
159
|
+
|
|
160
|
+
#### **React ESLint**
|
|
161
|
+
|
|
162
|
+
- Правила для React компонентов
|
|
163
|
+
- React Hooks правила
|
|
164
|
+
- JSX правила
|
|
165
|
+
|
|
166
|
+
#### **Import ESLint**
|
|
167
|
+
|
|
168
|
+
- Правила импортов модулей
|
|
169
|
+
- Проверка путей импорта
|
|
170
|
+
|
|
171
|
+
#### **JSX Accessibility**
|
|
172
|
+
|
|
173
|
+
- Доступность JSX элементов
|
|
174
|
+
- WCAG рекомендации
|
|
175
|
+
|
|
176
|
+
#### **Prettier Integration**
|
|
177
|
+
|
|
178
|
+
- Отключение конфликтующих правил
|
|
179
|
+
- Совместимость с prettier
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
### ⚠️ Важные нюансы
|
|
184
|
+
|
|
185
|
+
- **Peer dependencies**: Все плагины нужно устанавливать отдельно
|
|
186
|
+
- **TypeScript**: Требуется `tsconfig.json` для parserOptions.project
|
|
187
|
+
- **React**: Автоматически определяет версию React
|
|
188
|
+
- **Prettier**: Рекомендуется использовать вместе с prettier-config-mgz
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
### ❓ Возможные вопросы
|
|
193
|
+
|
|
194
|
+
**Нужен ли tsconfig.json?**
|
|
195
|
+
Да, для правильной работы TypeScript правил нужен файл tsconfig.json.
|
|
196
|
+
|
|
197
|
+
**Можно ли переопределять правила?**
|
|
198
|
+
Да, добавляйте свои правила в локальном .eslintrc файле.
|
|
199
|
+
|
|
200
|
+
**Почему некоторые правила отключены?**
|
|
201
|
+
Некоторые правила отключены намеренно для гибкости или из-за конфликтов с другими инструментами.
|
|
202
|
+
|
|
203
|
+
## 🇬🇧 English
|
|
204
|
+
|
|
205
|
+
### 📦 Description
|
|
206
|
+
|
|
207
|
+
`eslint-config-mgz` is a shared ESLint configuration
|
|
208
|
+
for frontend projects with React and TypeScript:
|
|
209
|
+
|
|
210
|
+
- ✅ **TypeScript** support with `@typescript-eslint`
|
|
211
|
+
- ✅ **React** rules and hooks
|
|
212
|
+
- ✅ **Import** rules for modules
|
|
213
|
+
- ✅ **JSX accessibility** checks
|
|
214
|
+
- ✅ **Prettier** integration (disables conflicting rules)
|
|
215
|
+
|
|
216
|
+
The goal is to standardize linting across all projects and ensure code quality.
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
### 📂 Package contents
|
|
221
|
+
|
|
222
|
+
| File | Purpose |
|
|
223
|
+
| ---------------- | -------------------------------- |
|
|
224
|
+
| `base.js` | Main ESLint configuration (v7-8) |
|
|
225
|
+
| `flat-config.js` | Flat config for ESLint v9+ |
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### 🚀 Installation
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
npm install -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 🚨 **ESLint Compatibility**
|
|
238
|
+
|
|
239
|
+
### 📊 **Compatibility Table:**
|
|
240
|
+
|
|
241
|
+
| ESLint Version | Compatibility | Config File | Notes |
|
|
242
|
+
| -------------- | ------------- | ----------------- | --------------- |
|
|
243
|
+
| **v7.x** | ✅ Full | `.eslintrc.*` | Recommended |
|
|
244
|
+
| **v8.x** | ✅ Full | `.eslintrc.*` | Recommended |
|
|
245
|
+
| **v9.x** | ✅ Full | `eslint.config.*` | Use flat-config |
|
|
246
|
+
|
|
247
|
+
### 🧩 Usage
|
|
248
|
+
|
|
249
|
+
#### In .eslintrc.js
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
module.exports = {
|
|
253
|
+
extends: ["eslint-config-mgz"],
|
|
254
|
+
parserOptions: {
|
|
255
|
+
project: "./tsconfig.json",
|
|
256
|
+
},
|
|
257
|
+
};
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
#### With additional rules
|
|
261
|
+
|
|
262
|
+
```javascript
|
|
263
|
+
module.exports = {
|
|
264
|
+
extends: ["eslint-config-mgz"],
|
|
265
|
+
rules: {
|
|
266
|
+
// Your additional rules
|
|
267
|
+
"no-console": "warn",
|
|
268
|
+
},
|
|
269
|
+
parserOptions: {
|
|
270
|
+
project: "./tsconfig.json",
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### For ESLint v9+ (Flat Config)
|
|
276
|
+
|
|
277
|
+
```javascript
|
|
278
|
+
// eslint.config.js
|
|
279
|
+
import config from "eslint-config-mgz/flat-config";
|
|
280
|
+
|
|
281
|
+
export default config;
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Or with additional rules:
|
|
285
|
+
|
|
286
|
+
```javascript
|
|
287
|
+
// eslint.config.js
|
|
288
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
289
|
+
import baseConfig from "eslint-config-mgz";
|
|
290
|
+
|
|
291
|
+
const compat = new FlatCompat();
|
|
292
|
+
export default [
|
|
293
|
+
...compat.config(baseConfig),
|
|
294
|
+
{
|
|
295
|
+
rules: {
|
|
296
|
+
// Your additional rules
|
|
297
|
+
"no-console": "warn",
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
];
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
#### For older ESLint versions (v7-8)
|
|
304
|
+
|
|
305
|
+
```bash
|
|
306
|
+
# Force old config format in v9
|
|
307
|
+
npx eslint --config .eslintrc.js src/
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
### ⚠️ Important notes
|
|
313
|
+
|
|
314
|
+
- **Peer dependencies**: All plugins must be installed separately
|
|
315
|
+
- **TypeScript**: Requires `tsconfig.json` for parserOptions.project
|
|
316
|
+
- **React**: Automatically detects React version
|
|
317
|
+
- **Prettier**: Recommended to use with prettier-config-mgz
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
### ❓ Possible questions
|
|
322
|
+
|
|
323
|
+
**Is tsconfig.json required?**
|
|
324
|
+
Yes, needed for proper TypeScript rules functioning.
|
|
325
|
+
|
|
326
|
+
**Can rules be overridden?**
|
|
327
|
+
Yes, add your rules in local .eslintrc file.
|
|
328
|
+
|
|
329
|
+
**Why are some rules disabled?**
|
|
330
|
+
Some rules are intentionally disabled for flexibility or due to conflicts with other tools.
|
|
331
|
+
|
|
332
|
+
## 🇰🇿 Қазақша
|
|
333
|
+
|
|
334
|
+
### 📦 Сипаттама
|
|
335
|
+
|
|
336
|
+
`eslint-config-mgz` — React және TypeScript жобалары үшін
|
|
337
|
+
қайта қолданылатын ESLint конфигурациясы:
|
|
338
|
+
|
|
339
|
+
- ✅ **TypeScript** `@typescript-eslint` арқылы қолдау
|
|
340
|
+
- ✅ **React** ережелері және хуктары
|
|
341
|
+
- ✅ **Import** модульдердің ережелері
|
|
342
|
+
- ✅ **JSX accessibility** тексерулері
|
|
343
|
+
- ✅ **Prettier** интеграциясы (қайшы келетін ережелерді өшіру)
|
|
344
|
+
|
|
345
|
+
Мақсаты — барлық жобаларда линтингті стандарттау және код сапасын қамтамасыз ету.
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
### 📂 Пакет құрамында
|
|
350
|
+
|
|
351
|
+
| Файл | Мақсаты |
|
|
352
|
+
| ---------------- | ----------------------------- |
|
|
353
|
+
| `base.js` | Негізгі ESLint конфигі (v7-8) |
|
|
354
|
+
| `flat-config.js` | Flat config ESLint v9+ үшін |
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### 🚀 Орнату
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
npm install -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-import eslint-plugin-jsx-a11y eslint-config-prettier
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
## 🚨 **ESLint үйлесімділігі**
|
|
367
|
+
|
|
368
|
+
### 📊 **Үйлесімділік кестесі:**
|
|
369
|
+
|
|
370
|
+
| ESLint нұсқасы | Үйлесімділік | Конфиг файл | Ескертулер |
|
|
371
|
+
| -------------- | ------------ | ----------------- | ------------------------ |
|
|
372
|
+
| **v7.x** | ✅ Толық | `.eslintrc.*` | Ұсынылады |
|
|
373
|
+
| **v8.x** | ✅ Толық | `.eslintrc.*` | Ұсынылады |
|
|
374
|
+
| **v9.x** | ✅ Толық | `eslint.config.*` | flat-config пайдаланыңыз |
|
|
375
|
+
|
|
376
|
+
### 🧩 Қолдану
|
|
377
|
+
|
|
378
|
+
#### .eslintrc.js ішінде
|
|
379
|
+
|
|
380
|
+
```javascript
|
|
381
|
+
module.exports = {
|
|
382
|
+
extends: ["eslint-config-mgz"],
|
|
383
|
+
parserOptions: {
|
|
384
|
+
project: "./tsconfig.json",
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
#### ESLint v9+ үшін (Flat Config)
|
|
390
|
+
|
|
391
|
+
```javascript
|
|
392
|
+
// eslint.config.js
|
|
393
|
+
import config from "eslint-config-mgz/flat-config";
|
|
394
|
+
|
|
395
|
+
export default config;
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
Қосымша ережелермен:
|
|
399
|
+
|
|
400
|
+
```javascript
|
|
401
|
+
// eslint.config.js
|
|
402
|
+
import { FlatCompat } from "@eslint/eslintrc";
|
|
403
|
+
import baseConfig from "eslint-config-mgz";
|
|
404
|
+
|
|
405
|
+
const compat = new FlatCompat();
|
|
406
|
+
export default [
|
|
407
|
+
...compat.config(baseConfig),
|
|
408
|
+
{
|
|
409
|
+
rules: {
|
|
410
|
+
// Сіздің қосымша ережелеріңіз
|
|
411
|
+
"no-console": "warn",
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
];
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
#### Ескі ESLint нұсқалары үшін (v7-8)
|
|
418
|
+
|
|
419
|
+
```bash
|
|
420
|
+
# v9-да ескі конфиг форматын мәжбүрлеу
|
|
421
|
+
npx eslint --config .eslintrc.js src/
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
### ⚠️ Маңызды ескертулер
|
|
427
|
+
|
|
428
|
+
- **Peer dependencies**: Барлық плагиндерді бөлек орнату қажет
|
|
429
|
+
- **TypeScript**: parserOptions.project үшін tsconfig.json қажет
|
|
430
|
+
- **React**: React нұсқасын автоматты түрде анықтайды
|
|
431
|
+
- **Prettier**: prettier-config-mgz бірге қолдану ұсынылады
|
|
432
|
+
|
|
433
|
+
---
|
|
434
|
+
|
|
435
|
+
### ❓ Мүмкін сұрақтар
|
|
436
|
+
|
|
437
|
+
**tsconfig.json қажет пе?**
|
|
438
|
+
Иә, TypeScript ережелерінің дұрыс жұмысы үшін қажет.
|
|
439
|
+
|
|
440
|
+
**Ережелерді өзгертуге бола ма?**
|
|
441
|
+
Иә, жергілікті .eslintrc файлында өз ережелеріңізді қосыңыз.
|
|
442
|
+
|
|
443
|
+
**Неге кейбір ережелер өшірілген?**
|
|
444
|
+
Кейбір ережелер икемділік үшін немесе басқа құралдармен қайшылықтар салдарынан арнайы өшірілген.
|
package/base.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
parser: "@typescript-eslint/parser",
|
|
3
|
+
extends: [
|
|
4
|
+
"eslint:recommended",
|
|
5
|
+
"plugin:react/recommended",
|
|
6
|
+
"plugin:react-hooks/recommended",
|
|
7
|
+
"plugin:import/recommended",
|
|
8
|
+
"plugin:jsx-a11y/recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended",
|
|
10
|
+
"eslint-config-prettier",
|
|
11
|
+
],
|
|
12
|
+
settings: {
|
|
13
|
+
react: { version: "detect" },
|
|
14
|
+
"import/resolver": {
|
|
15
|
+
node: {
|
|
16
|
+
paths: ["src"],
|
|
17
|
+
extensions: [".js", ".jsx", ".ts", ".tsx"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
plugins: ["@typescript-eslint"],
|
|
22
|
+
rules: {
|
|
23
|
+
"no-alert": "error",
|
|
24
|
+
"no-console": "error",
|
|
25
|
+
"no-undef-init": "error",
|
|
26
|
+
"no-undefined": "error",
|
|
27
|
+
"no-var": "error",
|
|
28
|
+
"no-inline-comments": "off",
|
|
29
|
+
"no-use-before-define": "off",
|
|
30
|
+
"import/no-unresolved": "off",
|
|
31
|
+
"react/react-in-jsx-scope": "off",
|
|
32
|
+
"react/display-name": "off",
|
|
33
|
+
"react/no-array-index-key": "warn",
|
|
34
|
+
"no-duplicate-imports": "warn",
|
|
35
|
+
"jsx-a11y/no-autofocus": "off",
|
|
36
|
+
"jsx-a11y/anchor-has-content": "off",
|
|
37
|
+
"jsx-a11y/heading-has-content": "off",
|
|
38
|
+
"react/prop-types": "off",
|
|
39
|
+
"react/no-unknown-property": [
|
|
40
|
+
"error",
|
|
41
|
+
{ ignore: ["cmdk-input-wrapper", "cmdk-empty"] },
|
|
42
|
+
],
|
|
43
|
+
"import/named": "off",
|
|
44
|
+
},
|
|
45
|
+
};
|
package/flat-config.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// eslint-config-mgz/flat-config.js
|
|
2
|
+
import { configs as jsConfigs } from "@eslint/js";
|
|
3
|
+
import tsPlugin from "@typescript-eslint/eslint-plugin";
|
|
4
|
+
import tsParser from "@typescript-eslint/parser";
|
|
5
|
+
import reactPlugin from "eslint-plugin-react";
|
|
6
|
+
import reactHooksPlugin from "eslint-plugin-react-hooks";
|
|
7
|
+
import importPlugin from "eslint-plugin-import";
|
|
8
|
+
import jsxA11yPlugin from "eslint-plugin-jsx-a11y";
|
|
9
|
+
|
|
10
|
+
export default [
|
|
11
|
+
// Игнорируем лишние файлы
|
|
12
|
+
{
|
|
13
|
+
ignores: [
|
|
14
|
+
"dist/**",
|
|
15
|
+
"build/**",
|
|
16
|
+
"node_modules/**",
|
|
17
|
+
".eslintrc.*",
|
|
18
|
+
".prettierrc.*",
|
|
19
|
+
"eslint.config.*",
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// Базовые правила ESLint
|
|
24
|
+
jsConfigs.recommended,
|
|
25
|
+
|
|
26
|
+
// TypeScript rules
|
|
27
|
+
{
|
|
28
|
+
files: ["**/*.{ts,tsx}"],
|
|
29
|
+
languageOptions: {
|
|
30
|
+
parser: tsParser,
|
|
31
|
+
parserOptions: {
|
|
32
|
+
project: "./tsconfig.json",
|
|
33
|
+
ecmaVersion: "latest",
|
|
34
|
+
sourceType: "module",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
rules: {
|
|
38
|
+
...tsPlugin.configs.recommended.rules,
|
|
39
|
+
"@typescript-eslint/no-unused-vars": "warn",
|
|
40
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
41
|
+
"@typescript-eslint/prefer-const": "error",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// React rules
|
|
46
|
+
{
|
|
47
|
+
files: ["**/*.{jsx,tsx}"],
|
|
48
|
+
plugins: {
|
|
49
|
+
react: reactPlugin,
|
|
50
|
+
"react-hooks": reactHooksPlugin,
|
|
51
|
+
import: importPlugin,
|
|
52
|
+
"jsx-a11y": jsxA11yPlugin,
|
|
53
|
+
},
|
|
54
|
+
rules: {
|
|
55
|
+
"react/react-in-jsx-scope": "off",
|
|
56
|
+
"react/prop-types": "off",
|
|
57
|
+
"react/display-name": "off",
|
|
58
|
+
"react/no-array-index-key": "warn",
|
|
59
|
+
"react-hooks/rules-of-hooks": "error",
|
|
60
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
61
|
+
"import/no-unresolved": "off",
|
|
62
|
+
"import/named": "off",
|
|
63
|
+
"jsx-a11y/no-autofocus": "off",
|
|
64
|
+
"jsx-a11y/anchor-has-content": "off",
|
|
65
|
+
"jsx-a11y/heading-has-content": "off",
|
|
66
|
+
"no-alert": "error",
|
|
67
|
+
"no-console": "error",
|
|
68
|
+
"no-undef-init": "error",
|
|
69
|
+
"no-undefined": "error",
|
|
70
|
+
"no-var": "error",
|
|
71
|
+
"no-inline-comments": "off",
|
|
72
|
+
"no-use-before-define": "off",
|
|
73
|
+
"no-duplicate-imports": "warn",
|
|
74
|
+
"react/no-unknown-property": [
|
|
75
|
+
"error",
|
|
76
|
+
{ ignore: ["cmdk-input-wrapper", "cmdk-empty"] },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
];
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// eslint-config-mgz/index.js
|
|
2
|
+
function isEslintV9Plus() {
|
|
3
|
+
try {
|
|
4
|
+
require.resolve("@eslint/js");
|
|
5
|
+
return true;
|
|
6
|
+
} catch {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let config;
|
|
12
|
+
|
|
13
|
+
if (isEslintV9Plus()) {
|
|
14
|
+
config = require("./flat-config").default;
|
|
15
|
+
} else {
|
|
16
|
+
const { FlatCompat } = require("@eslint/eslintrc");
|
|
17
|
+
const baseConfig = require("./base");
|
|
18
|
+
|
|
19
|
+
const compat = new FlatCompat({
|
|
20
|
+
baseDirectory: __dirname,
|
|
21
|
+
resolvePluginsRelativeTo: __dirname,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
config = compat.config(baseConfig);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = config;
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eslint-config-mgz",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
8
|
+
"@typescript-eslint/parser": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
9
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
10
|
+
"eslint-plugin-react": "^7.0.0 || ^8.0.0",
|
|
11
|
+
"eslint-plugin-react-hooks": "^4.0.0 || ^5.0.0 || ^7.0.0",
|
|
12
|
+
"eslint-plugin-import": "^2.0.0",
|
|
13
|
+
"eslint-plugin-jsx-a11y": "^6.0.0",
|
|
14
|
+
"eslint-config-prettier": "^9.0.0"
|
|
15
|
+
}
|
|
16
|
+
}
|