eslint-config-mgz 1.0.4 → 1.0.7

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.
Files changed (3) hide show
  1. package/README.md +159 -9
  2. package/flat-config.js +110 -0
  3. package/package.json +17 -4
package/README.md CHANGED
@@ -23,28 +23,51 @@ Shared ESLint configuration for React + TypeScript projects
23
23
 
24
24
  ### 📂 Содержимое пакета
25
25
 
26
- | Файл | Назначение |
27
- | --------- | ---------------------------- |
28
- | `base.js` | Основная конфигурация ESLint |
26
+ | Файл | Назначение |
27
+ | ---------------- | ----------------------------------- |
28
+ | `base.js` | Основная конфигурация ESLint (v7-8) |
29
+ | `flat-config.js` | Flat config для ESLint v9+ |
29
30
 
30
31
  ---
31
32
 
32
33
  ### 🚀 Установка
33
34
 
34
35
  ```bash
36
+ # ESLint v7-8 (обязательные)
35
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
36
41
  ```
37
42
 
38
43
  ```bash
44
+ # ESLint v7-8 (обязательные)
39
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
40
49
  ```
41
50
 
42
51
  ```bash
52
+ # ESLint v7-8 (обязательные)
43
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
44
57
  ```
45
58
 
46
59
  ---
47
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
+
48
71
  ### 🧩 Использование
49
72
 
50
73
  #### В .eslintrc.js
@@ -85,6 +108,41 @@ module.exports = {
85
108
  };
86
109
  ```
87
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
+
88
146
  ---
89
147
 
90
148
  ### 🧠 Включенные правила
@@ -161,9 +219,10 @@ The goal is to standardize linting across all projects and ensure code quality.
161
219
 
162
220
  ### 📂 Package contents
163
221
 
164
- | File | Purpose |
165
- | --------- | ------------------------- |
166
- | `base.js` | Main ESLint configuration |
222
+ | File | Purpose |
223
+ | ---------------- | -------------------------------- |
224
+ | `base.js` | Main ESLint configuration (v7-8) |
225
+ | `flat-config.js` | Flat config for ESLint v9+ |
167
226
 
168
227
  ---
169
228
 
@@ -175,6 +234,16 @@ npm install -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-es
175
234
 
176
235
  ---
177
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
+
178
247
  ### 🧩 Usage
179
248
 
180
249
  #### In .eslintrc.js
@@ -203,6 +272,41 @@ module.exports = {
203
272
  };
204
273
  ```
205
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
+
206
310
  ---
207
311
 
208
312
  ### ⚠️ Important notes
@@ -244,9 +348,10 @@ Some rules are intentionally disabled for flexibility or due to conflicts with o
244
348
 
245
349
  ### 📂 Пакет құрамында
246
350
 
247
- | Файл | Мақсаты |
248
- | --------- | ---------------------- |
249
- | `base.js` | Негізгі ESLint конфигі |
351
+ | Файл | Мақсаты |
352
+ | ---------------- | ----------------------------- |
353
+ | `base.js` | Негізгі ESLint конфигі (v7-8) |
354
+ | `flat-config.js` | Flat config ESLint v9+ үшін |
250
355
 
251
356
  ---
252
357
 
@@ -258,6 +363,16 @@ npm install -D eslint-config-mgz eslint @typescript-eslint/parser @typescript-es
258
363
 
259
364
  ---
260
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
+
261
376
  ### 🧩 Қолдану
262
377
 
263
378
  #### .eslintrc.js ішінде
@@ -271,6 +386,41 @@ module.exports = {
271
386
  };
272
387
  ```
273
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
+
274
424
  ---
275
425
 
276
426
  ### ⚠️ Маңызды ескертулер
package/flat-config.js ADDED
@@ -0,0 +1,110 @@
1
+ // Universal config for ESLint v7+
2
+ // Automatically detects ESLint version and returns appropriate format
3
+ // Usage: import config from 'eslint-config-mgz/flat-config';
4
+
5
+ function isEslintV9Plus() {
6
+ try {
7
+ // Check if @eslint/js is available (ESLint v9+)
8
+ require.resolve("@eslint/js");
9
+ // Check if typescript-eslint is available
10
+ require.resolve("typescript-eslint");
11
+ return true;
12
+ } catch {
13
+ return false;
14
+ }
15
+ }
16
+
17
+ let config;
18
+
19
+ if (isEslintV9Plus()) {
20
+ // ESLint v9+ - Use native flat config
21
+ const js = require("@eslint/js");
22
+ const tseslint = require("typescript-eslint");
23
+
24
+ config = [
25
+ {
26
+ ignores: [
27
+ "dist/**",
28
+ "build/**",
29
+ "node_modules/**",
30
+ ".eslintrc.*",
31
+ ".prettierrc.*",
32
+ "eslint.config.*",
33
+ ],
34
+ },
35
+ js.configs.recommended,
36
+ ...tseslint.configs.recommended,
37
+ {
38
+ files: ["**/*.{js,jsx,ts,tsx}"],
39
+ languageOptions: {
40
+ parser: tseslint.parser,
41
+ parserOptions: {
42
+ project: "./tsconfig.json",
43
+ ecmaVersion: "latest",
44
+ sourceType: "module",
45
+ },
46
+ },
47
+ plugins: {
48
+ "@typescript-eslint": tseslint.plugin,
49
+ react: require("eslint-plugin-react"),
50
+ "react-hooks": require("eslint-plugin-react-hooks"),
51
+ import: require("eslint-plugin-import"),
52
+ "jsx-a11y": require("eslint-plugin-jsx-a11y"),
53
+ },
54
+ rules: {
55
+ // React rules
56
+ "react/react-in-jsx-scope": "off",
57
+ "react/prop-types": "off",
58
+ "react/display-name": "off",
59
+ "react/no-array-index-key": "warn",
60
+ "react-hooks/rules-of-hooks": "error",
61
+ "react-hooks/exhaustive-deps": "warn",
62
+
63
+ // Import rules
64
+ "import/no-unresolved": "off",
65
+ "import/named": "off",
66
+
67
+ // JSX accessibility
68
+ "jsx-a11y/no-autofocus": "off",
69
+ "jsx-a11y/anchor-has-content": "off",
70
+ "jsx-a11y/heading-has-content": "off",
71
+
72
+ // General rules
73
+ "no-alert": "error",
74
+ "no-console": "error",
75
+ "no-undef-init": "error",
76
+ "no-undefined": "error",
77
+ "no-var": "error",
78
+ "no-inline-comments": "off",
79
+ "no-use-before-define": "off",
80
+ "no-duplicate-imports": "warn",
81
+
82
+ // TypeScript specific
83
+ "@typescript-eslint/no-unused-vars": "warn",
84
+ "@typescript-eslint/no-explicit-any": "warn",
85
+ "@typescript-eslint/prefer-const": "error",
86
+
87
+ // Custom rules for unknown properties
88
+ "react/no-unknown-property": [
89
+ "error",
90
+ {
91
+ ignore: ["cmdk-input-wrapper", "cmdk-empty"],
92
+ },
93
+ ],
94
+ },
95
+ },
96
+ ];
97
+ } else {
98
+ // ESLint v7-8 - Use legacy config with FlatCompat
99
+ const { FlatCompat } = require("@eslint/eslintrc");
100
+ const baseConfig = require("./base");
101
+
102
+ const compat = new FlatCompat({
103
+ baseDirectory: __dirname,
104
+ resolvePluginsRelativeTo: __dirname,
105
+ });
106
+
107
+ config = compat.config(baseConfig);
108
+ }
109
+
110
+ module.exports = config;
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "eslint-config-mgz",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "Shared ESLint config for React + TypeScript projects",
5
5
  "main": "base.js",
6
6
  "files": [
7
7
  "README.md",
8
- "base.js"
8
+ "base.js",
9
+ "flat-config.js"
9
10
  ],
10
11
  "readme": "README.md",
12
+ "exports": {
13
+ ".": "./base.js",
14
+ "./flat-config": "./flat-config.js"
15
+ },
11
16
  "keywords": [
12
17
  "eslint",
13
18
  "typescript",
@@ -17,14 +22,22 @@
17
22
  "author": "DSRC TEAM",
18
23
  "license": "MIT",
19
24
  "peerDependencies": {
20
- "eslint": "^8.0.0 || ^9.0.0",
25
+ "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
21
26
  "@typescript-eslint/parser": "^6.0.0 || ^7.0.0 || ^8.0.0",
22
27
  "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0",
23
28
  "eslint-plugin-react": "^7.0.0 || ^8.0.0",
24
29
  "eslint-plugin-react-hooks": "^4.0.0 || ^5.0.0 || ^7.0.0",
25
30
  "eslint-plugin-import": "^2.0.0",
26
31
  "eslint-plugin-jsx-a11y": "^6.0.0",
27
- "eslint-config-prettier": "^9.0.0"
32
+ "eslint-config-prettier": "^8.0.0 || ^9.0.0"
33
+ },
34
+ "peerDependenciesMeta": {
35
+ "@eslint/js": {
36
+ "optional": true
37
+ },
38
+ "typescript-eslint": {
39
+ "optional": true
40
+ }
28
41
  },
29
42
  "engines": {
30
43
  "node": ">=18"