eslint-plugin-th-rules 1.20.1 → 1.20.3
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 +14 -0
- package/package.json +1 -1
- package/src/index.js +29 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.20.3](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.2...v1.20.3) (2026-01-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update dependencies in yarn.lock ([2059b35](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/2059b3503efb1515843d822f3d386d58666b1864))
|
|
7
|
+
|
|
8
|
+
## [1.20.2](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.1...v1.20.2) (2026-01-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* refactor config handling to use flatConfigs for better structure ([22d64f2](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/22d64f20a5d5b64ae0676d6afcd87e2790f5ef4f))
|
|
14
|
+
|
|
1
15
|
## [1.20.1](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.0...v1.20.1) (2026-01-06)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
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
|
|
|
@@ -5,8 +6,7 @@
|
|
|
5
6
|
|
|
6
7
|
const requireIndex = require('requireindex');
|
|
7
8
|
const globals = require('globals');
|
|
8
|
-
const
|
|
9
|
-
const security = require('eslint-plugin-security');
|
|
9
|
+
const {FlatCompat} = require('@eslint/eslintrc');
|
|
10
10
|
const reactPlugin = require('eslint-plugin-react');
|
|
11
11
|
const reactHooks = require('eslint-plugin-react-hooks');
|
|
12
12
|
const tseslint = require('typescript-eslint');
|
|
@@ -16,12 +16,18 @@ const plugin = {
|
|
|
16
16
|
configs: {},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
// Flattens configs so we never embed arrays inside arrays (avoids "Unexpected key '0'")
|
|
20
|
+
const asArray = value => (Array.isArray(value) ? value : [value]);
|
|
21
|
+
const flatConfigs = (...items) => items.flatMap(element => asArray(element));
|
|
22
|
+
|
|
23
|
+
// Converts legacy "extends"/eslintrc configs into flat config objects
|
|
24
|
+
const compat = new FlatCompat({
|
|
25
|
+
baseDirectory: __dirname,
|
|
26
|
+
});
|
|
27
|
+
|
|
19
28
|
const baseRecommended = {
|
|
20
29
|
plugins: {
|
|
21
30
|
'th-rules': plugin,
|
|
22
|
-
security,
|
|
23
|
-
react: reactPlugin,
|
|
24
|
-
'react-hooks': reactHooks,
|
|
25
31
|
},
|
|
26
32
|
languageOptions: {
|
|
27
33
|
ecmaVersion: 2024,
|
|
@@ -62,15 +68,15 @@ const baseRecommended = {
|
|
|
62
68
|
},
|
|
63
69
|
};
|
|
64
70
|
|
|
65
|
-
/** @type {import('eslint').Linter.
|
|
66
|
-
plugin.configs.recommended =
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
72
|
+
plugin.configs.recommended = flatConfigs(
|
|
73
|
+
// These are legacy configs -> convert them
|
|
74
|
+
compat.extends('plugin:sonarjs/recommended-legacy', 'plugin:security/recommended-legacy'),
|
|
69
75
|
baseRecommended,
|
|
70
|
-
|
|
76
|
+
);
|
|
71
77
|
|
|
72
|
-
plugin.configs['recommended-typescript'] =
|
|
73
|
-
|
|
78
|
+
plugin.configs['recommended-typescript'] = flatConfigs(
|
|
79
|
+
plugin.configs.recommended,
|
|
74
80
|
tseslint.configs.strictTypeChecked,
|
|
75
81
|
tseslint.configs.stylisticTypeChecked,
|
|
76
82
|
{
|
|
@@ -92,17 +98,22 @@ plugin.configs['recommended-typescript'] = [
|
|
|
92
98
|
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
93
99
|
},
|
|
94
100
|
},
|
|
95
|
-
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
plugin.configs['recommended-react'] = flatConfigs(
|
|
104
|
+
plugin.configs.recommended,
|
|
105
|
+
|
|
106
|
+
// React: flat config supported
|
|
107
|
+
reactPlugin.configs?.flat?.recommended ?? reactPlugin.configs?.recommended,
|
|
108
|
+
|
|
109
|
+
// React-hooks: if you suspect this is legacy in your version, swap to compat.extends('plugin:react-hooks/recommended')
|
|
110
|
+
reactHooks.configs?.['recommended-latest'] ?? reactHooks.configs?.recommended,
|
|
96
111
|
|
|
97
|
-
plugin.configs['recommended-react'] = [
|
|
98
|
-
...plugin.configs.recommended,
|
|
99
|
-
reactPlugin.configs.flat.recommended,
|
|
100
|
-
reactHooks.configs['recommended-latest'] ?? reactHooks.configs.recommended,
|
|
101
112
|
{
|
|
102
113
|
rules: {
|
|
103
114
|
'n/prefer-global/process': 'off',
|
|
104
115
|
},
|
|
105
116
|
},
|
|
106
|
-
|
|
117
|
+
);
|
|
107
118
|
|
|
108
119
|
module.exports = plugin;
|