eslint-config-mgz 1.0.8 → 1.0.11

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/flat-config.js +88 -73
  2. package/package.json +2 -2
  3. package/index.js +0 -27
package/flat-config.js CHANGED
@@ -1,80 +1,95 @@
1
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";
2
+ /**
3
+ * Universal ESLint config for TypeScript + React projects
4
+ * Supports ESLint v7, v8 (FlatCompat) and ESLint v9+ (native flat config)
5
+ */
9
6
 
10
- export default [
11
- // Игнорируем лишние файлы
12
- {
13
- ignores: [
14
- "dist/**",
15
- "build/**",
16
- "node_modules/**",
17
- ".eslintrc.*",
18
- ".prettierrc.*",
19
- "eslint.config.*",
20
- ],
21
- },
7
+ function isEslintV9Plus() {
8
+ try {
9
+ require.resolve("@eslint/js"); // ESLint v9+ package
10
+ return true;
11
+ } catch {
12
+ return false;
13
+ }
14
+ }
22
15
 
23
- // Базовые правила ESLint
24
- jsConfigs.recommended,
16
+ let config;
25
17
 
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
- },
18
+ if (isEslintV9Plus()) {
19
+ // ESLint v9+ flat config
20
+ const js = require("@eslint/js");
21
+ const tseslint = require("typescript-eslint");
22
+ const reactPlugin = require("eslint-plugin-react");
23
+ const reactHooks = require("eslint-plugin-react-hooks");
24
+ const importPlugin = require("eslint-plugin-import");
25
+ const jsxA11y = require("eslint-plugin-jsx-a11y");
44
26
 
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"] },
27
+ config = [
28
+ {
29
+ ignores: [
30
+ "dist/**",
31
+ "build/**",
32
+ "node_modules/**",
33
+ ".eslintrc.*",
34
+ ".prettierrc.*",
35
+ "eslint.config.*",
77
36
  ],
78
37
  },
79
- },
80
- ];
38
+ js.configs.recommended,
39
+ ...tseslint.configs.recommended,
40
+ {
41
+ files: ["**/*.{ts,tsx,js,jsx}"],
42
+ languageOptions: {
43
+ parser: tseslint.parser,
44
+ parserOptions: {
45
+ project: "./tsconfig.json",
46
+ ecmaVersion: "latest",
47
+ sourceType: "module",
48
+ },
49
+ },
50
+ plugins: {
51
+ "@typescript-eslint": tseslint.plugin,
52
+ react: reactPlugin,
53
+ "react-hooks": reactHooks,
54
+ import: importPlugin,
55
+ "jsx-a11y": jsxA11y,
56
+ },
57
+ rules: {
58
+ "no-alert": "error",
59
+ "no-console": "error",
60
+ "no-undef-init": "error",
61
+ "no-undefined": "error",
62
+ "no-var": "error",
63
+ "no-inline-comments": "off",
64
+ "no-use-before-define": "off",
65
+ "import/no-unresolved": "off",
66
+ "import/named": "off",
67
+ "react/react-in-jsx-scope": "off",
68
+ "react/display-name": "off",
69
+ "react/no-array-index-key": "warn",
70
+ "no-duplicate-imports": "warn",
71
+ "jsx-a11y/no-autofocus": "off",
72
+ "jsx-a11y/anchor-has-content": "off",
73
+ "jsx-a11y/heading-has-content": "off",
74
+ "react/prop-types": "off",
75
+ "react/no-unknown-property": [
76
+ "error",
77
+ { ignore: ["cmdk-input-wrapper", "cmdk-empty"] },
78
+ ],
79
+ },
80
+ },
81
+ ];
82
+ } else {
83
+ const { FlatCompat } = require("@eslint/eslintrc");
84
+ const baseConfig = require("./base");
85
+
86
+ const compat = new FlatCompat({
87
+ baseDirectory: __dirname,
88
+ recommendedConfig: require("eslint/conf/eslint-recommended"),
89
+ resolvePluginsRelativeTo: __dirname,
90
+ });
91
+
92
+ config = compat.config(baseConfig);
93
+ }
94
+
95
+ module.exports = config;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-config-mgz",
3
- "version": "1.0.8",
4
- "main": "index.js",
3
+ "version": "1.0.11",
4
+ "main": "flat-config.js",
5
5
  "type": "commonjs",
6
6
  "peerDependencies": {
7
7
  "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
package/index.js DELETED
@@ -1,27 +0,0 @@
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;