eslint-config-mgz 1.0.7 → 1.0.9

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 (2) hide show
  1. package/flat-config.js +42 -38
  2. package/package.json +4 -33
package/flat-config.js CHANGED
@@ -1,13 +1,12 @@
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
+ /**
3
+ * Universal ESLint config for projects using TypeScript + React
4
+ * Works with ESLint v7, v8 (FlatCompat) and ESLint v9+ (native flat config)
5
+ */
4
6
 
5
7
  function isEslintV9Plus() {
6
8
  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");
9
+ require.resolve("@eslint/js"); // ESLint v9+ package
11
10
  return true;
12
11
  } catch {
13
12
  return false;
@@ -17,9 +16,13 @@ function isEslintV9Plus() {
17
16
  let config;
18
17
 
19
18
  if (isEslintV9Plus()) {
20
- // ESLint v9+ - Use native flat config
21
- const js = require("@eslint/js");
19
+ // ESLint v9+ flat config
20
+ const { flat } = require("@eslint/js");
22
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");
23
26
 
24
27
  config = [
25
28
  {
@@ -32,10 +35,10 @@ if (isEslintV9Plus()) {
32
35
  "eslint.config.*",
33
36
  ],
34
37
  },
35
- js.configs.recommended,
38
+ flat.configs.recommended,
36
39
  ...tseslint.configs.recommended,
37
40
  {
38
- files: ["**/*.{js,jsx,ts,tsx}"],
41
+ files: ["**/*.{ts,tsx,js,jsx}"],
39
42
  languageOptions: {
40
43
  parser: tseslint.parser,
41
44
  parserOptions: {
@@ -46,29 +49,12 @@ if (isEslintV9Plus()) {
46
49
  },
47
50
  plugins: {
48
51
  "@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"),
52
+ react: reactPlugin,
53
+ "react-hooks": reactHooks,
54
+ import: importPlugin,
55
+ "jsx-a11y": jsxA11y,
53
56
  },
54
57
  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
58
  // General rules
73
59
  "no-alert": "error",
74
60
  "no-console": "error",
@@ -79,28 +65,46 @@ if (isEslintV9Plus()) {
79
65
  "no-use-before-define": "off",
80
66
  "no-duplicate-imports": "warn",
81
67
 
82
- // TypeScript specific
68
+ // TypeScript
83
69
  "@typescript-eslint/no-unused-vars": "warn",
84
70
  "@typescript-eslint/no-explicit-any": "warn",
85
71
  "@typescript-eslint/prefer-const": "error",
86
72
 
87
- // Custom rules for unknown properties
73
+ // React
74
+ "react/react-in-jsx-scope": "off",
75
+ "react/display-name": "off",
76
+ "react/prop-types": "off",
77
+ "react/no-array-index-key": "warn",
78
+
79
+ // React Hooks
80
+ "react-hooks/rules-of-hooks": "error",
81
+ "react-hooks/exhaustive-deps": "warn",
82
+
83
+ // Import plugin
84
+ "import/no-unresolved": "off",
85
+ "import/named": "off",
86
+
87
+ // JSX A11y
88
+ "jsx-a11y/no-autofocus": "off",
89
+ "jsx-a11y/anchor-has-content": "off",
90
+ "jsx-a11y/heading-has-content": "off",
91
+
92
+ // Custom unknown props
88
93
  "react/no-unknown-property": [
89
94
  "error",
90
- {
91
- ignore: ["cmdk-input-wrapper", "cmdk-empty"],
92
- },
95
+ { ignore: ["cmdk-input-wrapper", "cmdk-empty"] },
93
96
  ],
94
97
  },
95
98
  },
96
99
  ];
97
100
  } else {
98
- // ESLint v7-8 - Use legacy config with FlatCompat
101
+ // ESLint v7-8 - legacy config with FlatCompat
99
102
  const { FlatCompat } = require("@eslint/eslintrc");
100
103
  const baseConfig = require("./base");
101
104
 
102
105
  const compat = new FlatCompat({
103
106
  baseDirectory: __dirname,
107
+ recommendedConfig: require("eslint/conf/eslint-recommended"),
104
108
  resolvePluginsRelativeTo: __dirname,
105
109
  });
106
110
 
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.9",
4
+ "main": "flat-config.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
  }