eslint-config-mgz 1.0.7 → 1.0.8

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 +74 -104
  2. package/index.js +27 -0
  3. package/package.json +4 -33
package/flat-config.js CHANGED
@@ -1,110 +1,80 @@
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';
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";
4
9
 
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
- }
10
+ export default [
11
+ // Игнорируем лишние файлы
12
+ {
13
+ ignores: [
14
+ "dist/**",
15
+ "build/**",
16
+ "node_modules/**",
17
+ ".eslintrc.*",
18
+ ".prettierrc.*",
19
+ "eslint.config.*",
20
+ ],
21
+ },
16
22
 
17
- let config;
23
+ // Базовые правила ESLint
24
+ jsConfigs.recommended,
18
25
 
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
- ],
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",
94
35
  },
95
36
  },
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
- }
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
+ },
109
44
 
110
- module.exports = config;
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 CHANGED
@@ -1,26 +1,8 @@
1
1
  {
2
2
  "name": "eslint-config-mgz",
3
- "version": "1.0.7",
4
- "description": "Shared ESLint config for React + TypeScript projects",
5
- "main": "base.js",
6
- "files": [
7
- "README.md",
8
- "base.js",
9
- "flat-config.js"
10
- ],
11
- "readme": "README.md",
12
- "exports": {
13
- ".": "./base.js",
14
- "./flat-config": "./flat-config.js"
15
- },
16
- "keywords": [
17
- "eslint",
18
- "typescript",
19
- "react",
20
- "shared-config"
21
- ],
22
- "author": "DSRC TEAM",
23
- "license": "MIT",
3
+ "version": "1.0.8",
4
+ "main": "index.js",
5
+ "type": "commonjs",
24
6
  "peerDependencies": {
25
7
  "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0",
26
8
  "@typescript-eslint/parser": "^6.0.0 || ^7.0.0 || ^8.0.0",
@@ -29,17 +11,6 @@
29
11
  "eslint-plugin-react-hooks": "^4.0.0 || ^5.0.0 || ^7.0.0",
30
12
  "eslint-plugin-import": "^2.0.0",
31
13
  "eslint-plugin-jsx-a11y": "^6.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
- }
41
- },
42
- "engines": {
43
- "node": ">=18"
14
+ "eslint-config-prettier": "^9.0.0"
44
15
  }
45
16
  }