eslint-plugin-th-rules 1.20.2 → 1.20.4
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 +35 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.20.4](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.3...v1.20.4) (2026-01-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* fixed xo error ([056e708](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/056e7083ac33a4727b8664ac28b6838d5070de3f))
|
|
7
|
+
|
|
8
|
+
## [1.20.3](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.2...v1.20.3) (2026-01-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* update dependencies in yarn.lock ([2059b35](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/2059b3503efb1515843d822f3d386d58666b1864))
|
|
14
|
+
|
|
1
15
|
## [1.20.2](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.1...v1.20.2) (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/order */
|
|
1
2
|
/* eslint-disable import-x/no-extraneous-dependencies */
|
|
2
3
|
/* eslint-disable n/no-path-concat */
|
|
3
4
|
/* eslint-disable unicorn/prefer-module */
|
|
@@ -6,12 +7,18 @@
|
|
|
6
7
|
|
|
7
8
|
const requireIndex = require('requireindex');
|
|
8
9
|
const globals = require('globals');
|
|
9
|
-
const
|
|
10
|
-
const security = require('eslint-plugin-security');
|
|
10
|
+
const {FlatCompat} = require('@eslint/eslintrc');
|
|
11
11
|
const reactPlugin = require('eslint-plugin-react');
|
|
12
12
|
const reactHooks = require('eslint-plugin-react-hooks');
|
|
13
13
|
const tseslint = require('typescript-eslint');
|
|
14
14
|
|
|
15
|
+
// Plugins referenced by rule names in this config
|
|
16
|
+
const unicornPlugin = require('eslint-plugin-unicorn');
|
|
17
|
+
const importPlugin = require('eslint-plugin-import');
|
|
18
|
+
const nPlugin = require('eslint-plugin-n');
|
|
19
|
+
const sonarjsPlugin = require('eslint-plugin-sonarjs');
|
|
20
|
+
const securityPlugin = require('eslint-plugin-security');
|
|
21
|
+
|
|
15
22
|
const plugin = {
|
|
16
23
|
rules: requireIndex(`${__dirname}/rules`),
|
|
17
24
|
configs: {},
|
|
@@ -21,17 +28,30 @@ const plugin = {
|
|
|
21
28
|
const asArray = value => (Array.isArray(value) ? value : [value]);
|
|
22
29
|
const flatConfigs = (...items) => items.flatMap(element => asArray(element));
|
|
23
30
|
|
|
31
|
+
// Converts legacy "extends"/eslintrc configs into flat config objects
|
|
32
|
+
const compat = new FlatCompat({
|
|
33
|
+
baseDirectory: __dirname,
|
|
34
|
+
});
|
|
35
|
+
|
|
24
36
|
const baseRecommended = {
|
|
25
37
|
plugins: {
|
|
38
|
+
// Local rules
|
|
26
39
|
'th-rules': plugin,
|
|
27
40
|
|
|
28
|
-
//
|
|
29
|
-
|
|
41
|
+
// Third-party plugins used by rule names below
|
|
42
|
+
unicorn: unicornPlugin,
|
|
43
|
+
import: importPlugin,
|
|
44
|
+
n: nPlugin,
|
|
45
|
+
sonarjs: sonarjsPlugin,
|
|
46
|
+
security: securityPlugin,
|
|
47
|
+
|
|
48
|
+
// Included so consumers can use react/react-hooks rules as well
|
|
30
49
|
react: reactPlugin,
|
|
31
50
|
'react-hooks': reactHooks,
|
|
32
51
|
},
|
|
33
52
|
languageOptions: {
|
|
34
53
|
ecmaVersion: 2024,
|
|
54
|
+
sourceType: 'module',
|
|
35
55
|
globals: {
|
|
36
56
|
...globals.node,
|
|
37
57
|
...globals.es2024,
|
|
@@ -71,19 +91,21 @@ const baseRecommended = {
|
|
|
71
91
|
|
|
72
92
|
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
73
93
|
plugin.configs.recommended = flatConfigs(
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
// Legacy configs -> convert them
|
|
95
|
+
compat.extends('plugin:sonarjs/recommended-legacy', 'plugin:security/recommended-legacy'),
|
|
76
96
|
baseRecommended,
|
|
77
97
|
);
|
|
78
98
|
|
|
79
99
|
plugin.configs['recommended-typescript'] = flatConfigs(
|
|
80
100
|
plugin.configs.recommended,
|
|
101
|
+
|
|
102
|
+
// Typescript-eslint exports flat configs (arrays of flat config objects)
|
|
81
103
|
tseslint.configs.strictTypeChecked,
|
|
82
104
|
tseslint.configs.stylisticTypeChecked,
|
|
105
|
+
|
|
83
106
|
{
|
|
84
107
|
languageOptions: {
|
|
85
108
|
parserOptions: {
|
|
86
|
-
// Typescript-eslint typed linting
|
|
87
109
|
projectService: true,
|
|
88
110
|
},
|
|
89
111
|
},
|
|
@@ -104,8 +126,12 @@ plugin.configs['recommended-typescript'] = flatConfigs(
|
|
|
104
126
|
|
|
105
127
|
plugin.configs['recommended-react'] = flatConfigs(
|
|
106
128
|
plugin.configs.recommended,
|
|
107
|
-
|
|
108
|
-
|
|
129
|
+
|
|
130
|
+
// IMPORTANT: Always use compat here so we never accidentally inject eslintrc-style
|
|
131
|
+
// { plugins: ["react"] } into flat config (which causes the exact error you hit).
|
|
132
|
+
compat.extends('plugin:react/recommended'),
|
|
133
|
+
compat.extends('plugin:react-hooks/recommended'),
|
|
134
|
+
|
|
109
135
|
{
|
|
110
136
|
rules: {
|
|
111
137
|
'n/prefer-global/process': 'off',
|