eslint-plugin-th-rules 1.20.3 → 1.20.5
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/.github/workflows/main.yml +14 -11
- package/CHANGELOG.md +14 -0
- package/package.json +6 -3
- package/scripts/verify.mjs +16 -0
- package/src/index.js +29 -7
|
@@ -3,16 +3,16 @@ name: Semantic Versioning
|
|
|
3
3
|
on:
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
|
-
|
|
6
|
+
- main
|
|
7
7
|
|
|
8
8
|
jobs:
|
|
9
9
|
release:
|
|
10
10
|
runs-on: ubuntu-latest
|
|
11
11
|
permissions:
|
|
12
|
-
contents: write
|
|
13
|
-
issues: write
|
|
14
|
-
pull-requests: write
|
|
15
|
-
id-token: write
|
|
12
|
+
contents: write
|
|
13
|
+
issues: write
|
|
14
|
+
pull-requests: write
|
|
15
|
+
id-token: write
|
|
16
16
|
|
|
17
17
|
steps:
|
|
18
18
|
- name: Checkout
|
|
@@ -20,15 +20,18 @@ jobs:
|
|
|
20
20
|
|
|
21
21
|
- name: Setup Bun
|
|
22
22
|
uses: oven-sh/setup-bun@v1
|
|
23
|
-
|
|
24
|
-
- name: Install Dependencies
|
|
25
|
-
run: bun i --dev
|
|
26
23
|
|
|
27
24
|
- name: Setup Node.js environment
|
|
28
|
-
uses: actions/setup-node@v4
|
|
25
|
+
uses: actions/setup-node@v4
|
|
29
26
|
with:
|
|
30
|
-
node-version: "
|
|
31
|
-
|
|
27
|
+
node-version: "22.x"
|
|
28
|
+
|
|
29
|
+
- name: Install Dependencies
|
|
30
|
+
run: bun install --dev
|
|
31
|
+
|
|
32
|
+
- name: Verify ESLint flat configs
|
|
33
|
+
run: node ./scripts/verify.mjs
|
|
34
|
+
|
|
32
35
|
- name: Semantic Release
|
|
33
36
|
run: bunx semantic-release
|
|
34
37
|
env:
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.20.5](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.4...v1.20.5) (2026-01-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update GitHub Actions workflow and add ESLint verification script ([9e3c40e](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/9e3c40ee1c5500589e5463d997c832165666e6f6))
|
|
7
|
+
|
|
8
|
+
## [1.20.4](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.3...v1.20.4) (2026-01-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fixed xo error ([056e708](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/056e7083ac33a4727b8664ac28b6838d5070de3f))
|
|
14
|
+
|
|
1
15
|
## [1.20.3](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.20.2...v1.20.3) (2026-01-06)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-th-rules",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.5",
|
|
4
4
|
"description": "A List of custom ESLint rules created by Tomer Horowitz",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -19,15 +19,20 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/eslint-parser": "^7.28.5",
|
|
22
|
+
"@eslint/eslintrc": "^3.3.3",
|
|
22
23
|
"eslint-config-jsdoc": "^15.4.0",
|
|
23
24
|
"eslint-config-xo": "^0.49.0",
|
|
24
25
|
"eslint-config-xo-react": "^0.29.0",
|
|
26
|
+
"eslint-plugin-import": "^2.32.0",
|
|
25
27
|
"eslint-plugin-jsdoc": "^61.5.0",
|
|
28
|
+
"eslint-plugin-n": "^17.23.1",
|
|
26
29
|
"eslint-plugin-react": "^7.37.5",
|
|
27
30
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
28
31
|
"eslint-plugin-react-native": "^5.0.0",
|
|
29
32
|
"eslint-plugin-security": "^3.0.1",
|
|
30
33
|
"eslint-plugin-sonarjs": "^3.0.5",
|
|
34
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
35
|
+
"globals": "^17.0.0",
|
|
31
36
|
"requireindex": "^1.2.0"
|
|
32
37
|
},
|
|
33
38
|
"devDependencies": {
|
|
@@ -48,9 +53,7 @@
|
|
|
48
53
|
"eslint-doc-generator": "^3.0.2",
|
|
49
54
|
"eslint-plugin-eslint-plugin": "^7.2.0",
|
|
50
55
|
"eslint-plugin-node": "^11.1.0",
|
|
51
|
-
"eslint-plugin-sonarjs": "^3.0.5",
|
|
52
56
|
"eslint-plugin-th-rules": "1.19.3",
|
|
53
|
-
"eslint-plugin-unicorn": "^62.0.0",
|
|
54
57
|
"mocha": "^11.7.5",
|
|
55
58
|
"npm-run-all": "^4.1.5",
|
|
56
59
|
"typescript": "^5.9.3",
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {ESLint} from 'eslint';
|
|
2
|
+
import thRules from '../src/index.js';
|
|
3
|
+
|
|
4
|
+
const run = async (name, config) => {
|
|
5
|
+
const eslint = new ESLint({
|
|
6
|
+
overrideConfigFile: true,
|
|
7
|
+
overrideConfig: config,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const results = await eslint.lintText('const x = 1;\n', {filePath: 'fixtures/test.js'});
|
|
11
|
+
console.log(`OK: ${name} (${results[0].messages.length} messages)`);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
await run('recommended', thRules.configs.recommended);
|
|
15
|
+
await run('recommended-typescript', thRules.configs['recommended-typescript']);
|
|
16
|
+
await run('recommended-react', thRules.configs['recommended-react']);
|
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 */
|
|
@@ -11,6 +12,13 @@ const reactPlugin = require('eslint-plugin-react');
|
|
|
11
12
|
const reactHooks = require('eslint-plugin-react-hooks');
|
|
12
13
|
const tseslint = require('typescript-eslint');
|
|
13
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
|
+
|
|
14
22
|
const plugin = {
|
|
15
23
|
rules: requireIndex(`${__dirname}/rules`),
|
|
16
24
|
configs: {},
|
|
@@ -27,10 +35,23 @@ const compat = new FlatCompat({
|
|
|
27
35
|
|
|
28
36
|
const baseRecommended = {
|
|
29
37
|
plugins: {
|
|
38
|
+
// Local rules
|
|
30
39
|
'th-rules': plugin,
|
|
40
|
+
|
|
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
|
|
49
|
+
react: reactPlugin,
|
|
50
|
+
'react-hooks': reactHooks,
|
|
31
51
|
},
|
|
32
52
|
languageOptions: {
|
|
33
53
|
ecmaVersion: 2024,
|
|
54
|
+
sourceType: 'module',
|
|
34
55
|
globals: {
|
|
35
56
|
...globals.node,
|
|
36
57
|
...globals.es2024,
|
|
@@ -48,7 +69,6 @@ const baseRecommended = {
|
|
|
48
69
|
'th-rules/schemas-in-schemas-file': 'error',
|
|
49
70
|
'th-rules/types-in-dts': 'error',
|
|
50
71
|
|
|
51
|
-
'unicorn/prefer-module': 'warn',
|
|
52
72
|
'unicorn/filename-case': 'off',
|
|
53
73
|
'unicorn/no-array-callback-reference': 'off',
|
|
54
74
|
'import/extensions': 'off',
|
|
@@ -70,15 +90,18 @@ const baseRecommended = {
|
|
|
70
90
|
|
|
71
91
|
/** @type {import('eslint').Linter.FlatConfig[]} */
|
|
72
92
|
plugin.configs.recommended = flatConfigs(
|
|
73
|
-
//
|
|
93
|
+
// Legacy configs -> convert them
|
|
74
94
|
compat.extends('plugin:sonarjs/recommended-legacy', 'plugin:security/recommended-legacy'),
|
|
75
95
|
baseRecommended,
|
|
76
96
|
);
|
|
77
97
|
|
|
78
98
|
plugin.configs['recommended-typescript'] = flatConfigs(
|
|
79
99
|
plugin.configs.recommended,
|
|
100
|
+
|
|
101
|
+
// Typescript-eslint exports flat configs (arrays of flat config objects)
|
|
80
102
|
tseslint.configs.strictTypeChecked,
|
|
81
103
|
tseslint.configs.stylisticTypeChecked,
|
|
104
|
+
|
|
82
105
|
{
|
|
83
106
|
languageOptions: {
|
|
84
107
|
parserOptions: {
|
|
@@ -103,11 +126,10 @@ plugin.configs['recommended-typescript'] = flatConfigs(
|
|
|
103
126
|
plugin.configs['recommended-react'] = flatConfigs(
|
|
104
127
|
plugin.configs.recommended,
|
|
105
128
|
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
reactHooks.configs?.['recommended-latest'] ?? reactHooks.configs?.recommended,
|
|
129
|
+
// IMPORTANT: Always use compat here so we never accidentally inject eslintrc-style
|
|
130
|
+
// { plugins: ["react"] } into flat config (which causes the exact error you hit).
|
|
131
|
+
compat.extends('plugin:react/recommended'),
|
|
132
|
+
compat.extends('plugin:react-hooks/recommended'),
|
|
111
133
|
|
|
112
134
|
{
|
|
113
135
|
rules: {
|