eslint-plugin-th-rules 1.20.1 → 1.20.2

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.20.2](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.1...v1.20.2) (2026-01-06)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * refactor config handling to use flatConfigs for better structure ([22d64f2](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/22d64f20a5d5b64ae0676d6afcd87e2790f5ef4f))
7
+
1
8
  ## [1.20.1](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.0...v1.20.1) (2026-01-06)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-th-rules",
3
- "version": "1.20.1",
3
+ "version": "1.20.2",
4
4
  "description": "A List of custom ESLint rules created by Tomer Horowitz",
5
5
  "keywords": [
6
6
  "eslint",
package/src/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable import-x/no-extraneous-dependencies */
1
2
  /* eslint-disable n/no-path-concat */
2
3
  /* eslint-disable unicorn/prefer-module */
3
4
 
@@ -16,9 +17,15 @@ const plugin = {
16
17
  configs: {},
17
18
  };
18
19
 
20
+ // Flattens configs so we never embed arrays inside arrays (avoids "Unexpected key '0'")
21
+ const asArray = value => (Array.isArray(value) ? value : [value]);
22
+ const flatConfigs = (...items) => items.flatMap(element => asArray(element));
23
+
19
24
  const baseRecommended = {
20
25
  plugins: {
21
26
  'th-rules': plugin,
27
+
28
+ // Only include plugin objects you reference directly in rules/settings.
22
29
  security,
23
30
  react: reactPlugin,
24
31
  'react-hooks': reactHooks,
@@ -62,20 +69,21 @@ const baseRecommended = {
62
69
  },
63
70
  };
64
71
 
65
- /** @type {import('eslint').Linter.Config[]} */
66
- plugin.configs.recommended = [
72
+ /** @type {import('eslint').Linter.FlatConfig[]} */
73
+ plugin.configs.recommended = flatConfigs(
67
74
  sonarjs.configs.recommended,
68
75
  security.configs.recommended,
69
76
  baseRecommended,
70
- ];
77
+ );
71
78
 
72
- plugin.configs['recommended-typescript'] = [
73
- ...plugin.configs.recommended,
79
+ plugin.configs['recommended-typescript'] = flatConfigs(
80
+ plugin.configs.recommended,
74
81
  tseslint.configs.strictTypeChecked,
75
82
  tseslint.configs.stylisticTypeChecked,
76
83
  {
77
84
  languageOptions: {
78
85
  parserOptions: {
86
+ // Typescript-eslint typed linting
79
87
  projectService: true,
80
88
  },
81
89
  },
@@ -92,17 +100,17 @@ plugin.configs['recommended-typescript'] = [
92
100
  '@typescript-eslint/no-unsafe-argument': 'off',
93
101
  },
94
102
  },
95
- ];
103
+ );
96
104
 
97
- plugin.configs['recommended-react'] = [
98
- ...plugin.configs.recommended,
99
- reactPlugin.configs.flat.recommended,
100
- reactHooks.configs['recommended-latest'] ?? reactHooks.configs.recommended,
105
+ plugin.configs['recommended-react'] = flatConfigs(
106
+ plugin.configs.recommended,
107
+ reactPlugin.configs?.flat?.recommended ?? reactPlugin.configs?.recommended,
108
+ reactHooks.configs?.['recommended-latest'] ?? reactHooks.configs?.recommended,
101
109
  {
102
110
  rules: {
103
111
  'n/prefer-global/process': 'off',
104
112
  },
105
113
  },
106
- ];
114
+ );
107
115
 
108
116
  module.exports = plugin;