eslint-config-mgz 1.0.5 → 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.
- package/README.md +12 -0
- package/flat-config.js +106 -8
- package/package.json +10 -2
package/README.md
CHANGED
|
@@ -33,15 +33,27 @@ Shared ESLint configuration for React + TypeScript projects
|
|
|
33
33
|
### 🚀 Установка
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
+
# ESLint v7-8 (обязательные)
|
|
36
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
|
|
37
41
|
```
|
|
38
42
|
|
|
39
43
|
```bash
|
|
44
|
+
# ESLint v7-8 (обязательные)
|
|
40
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
|
|
41
49
|
```
|
|
42
50
|
|
|
43
51
|
```bash
|
|
52
|
+
# ESLint v7-8 (обязательные)
|
|
44
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
|
|
45
57
|
```
|
|
46
58
|
|
|
47
59
|
---
|
package/flat-config.js
CHANGED
|
@@ -1,12 +1,110 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Universal config for ESLint v7+
|
|
2
|
+
// Automatically detects ESLint version and returns appropriate format
|
|
2
3
|
// Usage: import config from 'eslint-config-mgz/flat-config';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
}
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
baseDirectory: __dirname,
|
|
9
|
-
resolvePluginsRelativeTo: __dirname,
|
|
10
|
-
});
|
|
17
|
+
let config;
|
|
11
18
|
|
|
12
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-mgz",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Shared ESLint config for React + TypeScript projects",
|
|
5
5
|
"main": "base.js",
|
|
6
6
|
"files": [
|
|
@@ -29,7 +29,15 @@
|
|
|
29
29
|
"eslint-plugin-react-hooks": "^4.0.0 || ^5.0.0 || ^7.0.0",
|
|
30
30
|
"eslint-plugin-import": "^2.0.0",
|
|
31
31
|
"eslint-plugin-jsx-a11y": "^6.0.0",
|
|
32
|
-
"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
|
+
}
|
|
33
41
|
},
|
|
34
42
|
"engines": {
|
|
35
43
|
"node": ">=18"
|