eslint-plugin-th-rules 1.19.3 → 1.20.0

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.
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "cSpell.words": [
3
3
  "sonarjs"
4
+ ],
5
+ "conventionalCommits.scopes": [
6
+ "eslint"
4
7
  ]
5
8
  }
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.20.0](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.19.3...v1.20.0) (2026-01-06)
2
+
3
+
4
+ ### Features
5
+
6
+ * **eslint:** :boom: migrated to ESLint flat configs ([0af8a5e](https://github.com/tomerh2001/eslint-plugin-th-rules/commit/0af8a5e49026af3145924363949cdb2978886dbf))
7
+
1
8
  ## [1.19.3](https://github.com/tomerh2001/eslint-plugin-th-rules/compare/v1.19.2...v1.19.3) (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.19.3",
3
+ "version": "1.20.0",
4
4
  "description": "A List of custom ESLint rules created by Tomer Horowitz",
5
5
  "keywords": [
6
6
  "eslint",
package/src/index.js CHANGED
@@ -2,60 +2,83 @@
2
2
  /* eslint-disable unicorn/prefer-module */
3
3
 
4
4
  'use strict';
5
+
5
6
  const requireIndex = require('requireindex');
7
+ const globals = require('globals');
8
+ const sonarjs = require('eslint-plugin-sonarjs');
9
+ const security = require('eslint-plugin-security');
10
+ const reactPlugin = require('eslint-plugin-react');
11
+ const reactHooks = require('eslint-plugin-react-hooks');
12
+ const tseslint = require('typescript-eslint');
6
13
 
7
- const configs = {
8
- recommended: {
9
- plugins: [
10
- 'th-rules',
11
- 'sonarjs',
12
- ],
13
- extends: [
14
- 'plugin:sonarjs/recommended-legacy',
15
- 'plugin:security/recommended-legacy',
16
- ],
17
- rules: {
18
- 'th-rules/no-destructuring': 'error',
19
- 'th-rules/no-default-export': 'error',
20
- 'th-rules/no-comments': 'error',
21
- 'th-rules/top-level-functions': 'error',
22
- 'th-rules/schemas-in-schemas-file': 'error',
23
- 'th-rules/types-in-dts': 'error',
24
- 'unicorn/prefer-module': 'warn',
25
- 'unicorn/filename-case': 'off',
26
- 'unicorn/no-array-callback-reference': 'off',
27
- 'import/extensions': 'off',
28
- 'unicorn/no-static-only-class': 'off',
29
- 'unicorn/no-await-expression-member': 'off',
30
- 'new-cap': 'off',
31
- 'no-await-in-loop': 'off',
32
- 'n/file-extension-in-import': 'off',
33
- 'import/no-cycle': 'off',
34
- camelcase: 'warn',
35
- 'sonarjs/mouse-events-a11y': 'off',
36
- 'sonarjs/no-unstable-nested-components': 'off',
37
- 'unicorn/prefer-global-this': 'off',
38
- 'unicorn/no-thenable': 'off',
39
- 'sonarjs/no-clear-text-protocols': 'off',
40
- },
41
- env: {
42
- node: true,
43
- es2024: true,
44
- jest: true,
14
+ const plugin = {
15
+ rules: requireIndex(`${__dirname}/rules`),
16
+ configs: {},
17
+ };
18
+
19
+ const baseRecommended = {
20
+ plugins: {
21
+ 'th-rules': plugin,
22
+ security,
23
+ react: reactPlugin,
24
+ 'react-hooks': reactHooks,
25
+ },
26
+ languageOptions: {
27
+ ecmaVersion: 2024,
28
+ globals: {
29
+ ...globals.node,
30
+ ...globals.es2024,
31
+ ...globals.jest,
45
32
  },
46
33
  },
34
+ settings: {
35
+ react: {version: 'detect'},
36
+ },
37
+ rules: {
38
+ 'th-rules/no-destructuring': 'error',
39
+ 'th-rules/no-default-export': 'error',
40
+ 'th-rules/no-comments': 'error',
41
+ 'th-rules/top-level-functions': 'error',
42
+ 'th-rules/schemas-in-schemas-file': 'error',
43
+ 'th-rules/types-in-dts': 'error',
44
+
45
+ 'unicorn/prefer-module': 'warn',
46
+ 'unicorn/filename-case': 'off',
47
+ 'unicorn/no-array-callback-reference': 'off',
48
+ 'import/extensions': 'off',
49
+ 'unicorn/no-static-only-class': 'off',
50
+ 'unicorn/no-await-expression-member': 'off',
51
+ 'new-cap': 'off',
52
+ 'no-await-in-loop': 'off',
53
+ 'n/file-extension-in-import': 'off',
54
+ 'import/no-cycle': 'off',
55
+ camelcase: 'warn',
56
+
57
+ 'sonarjs/mouse-events-a11y': 'off',
58
+ 'sonarjs/no-unstable-nested-components': 'off',
59
+ 'unicorn/prefer-global-this': 'off',
60
+ 'unicorn/no-thenable': 'off',
61
+ 'sonarjs/no-clear-text-protocols': 'off',
62
+ },
47
63
  };
48
64
 
49
- for (const configName of Object.keys(configs)) {
50
- configs[`${configName}-typescript`] = {
51
- ...configs[configName],
52
- extends: [
53
- 'plugin:@typescript-eslint/strict-type-checked',
54
- 'plugin:@typescript-eslint/stylistic-type-checked',
55
- ...configs[configName].extends,
56
- ],
65
+ plugin.configs.recommended = [
66
+ sonarjs.configs.recommended,
67
+ security.configs.recommended,
68
+ baseRecommended,
69
+ ];
70
+
71
+ plugin.configs['recommended-typescript'] = [
72
+ ...plugin.configs.recommended,
73
+ tseslint.configs.strictTypeChecked,
74
+ tseslint.configs.stylisticTypeChecked,
75
+ {
76
+ languageOptions: {
77
+ parserOptions: {
78
+ projectService: true,
79
+ },
80
+ },
57
81
  rules: {
58
- ...configs[configName].rules,
59
82
  '@typescript-eslint/naming-convention': 'warn',
60
83
  '@typescript-eslint/consistent-type-definitions': 'off',
61
84
  '@typescript-eslint/no-extraneous-class': 'off',
@@ -67,22 +90,18 @@ for (const configName of Object.keys(configs)) {
67
90
  '@typescript-eslint/no-unsafe-return': 'off',
68
91
  '@typescript-eslint/no-unsafe-argument': 'off',
69
92
  },
70
- };
71
- configs[`${configName}-react`] = {
72
- ...configs[configName],
73
- extends: [
74
- 'plugin:react/recommended',
75
- 'plugin:react-hooks/recommended',
76
- ...configs[configName].extends,
77
- ],
93
+ },
94
+ ];
95
+
96
+ plugin.configs['recommended-react'] = [
97
+ ...plugin.configs.recommended,
98
+ reactPlugin.configs.flat.recommended,
99
+ reactHooks.configs['recommended-latest'] ?? reactHooks.configs.recommended,
100
+ {
78
101
  rules: {
79
- ...configs[configName].rules,
80
102
  'n/prefer-global/process': 'off',
81
103
  },
82
- };
83
- }
104
+ },
105
+ ];
84
106
 
85
- module.exports = {
86
- rules: requireIndex(`${__dirname}/rules`),
87
- configs,
88
- };
107
+ module.exports = plugin;