eslint-config-fabulator 6.0.1 → 7.0.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.
- package/CHANGELOG.md +25 -0
- package/index.js +117 -13
- package/package.json +9 -3
- package/renovate.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
|
|
4
|
+
## v7.0.0 (2026-11-24)
|
|
5
|
+
### Changed
|
|
6
|
+
- [8bea450](https://github.com/fabulator/eslint-config-fabulator/commit/8bea450257b43d720a863cc94087c1f4d15bf818) BREAKING Stricter rules, unicorn instead of array-func, disable comments require description (#248)
|
|
7
|
+
|
|
8
|
+
- eslint-plugin-unicorn recommended (minus opinionated rules) replaces eslint-plugin-array-func
|
|
9
|
+
- @eslint-community/eslint-plugin-eslint-comments: disable comments need a description, key rules can't be disabled
|
|
10
|
+
- no-unused-vars in TS, no-non-null-assertion, prefer-nullish-coalescing, switch-exhaustiveness-check,
|
|
11
|
+
consistent-type-imports/exports, explicit-module-boundary-types
|
|
12
|
+
- core: eqeqeq, curly, no-nested-ternary, no-param-reassign, prefer-const, prefer-template, object-shorthand
|
|
13
|
+
- size limits: max-lines, max-lines-per-function, complexity, max-depth
|
|
14
|
+
- import-x/no-cycle limited to maxDepth 10
|
|
15
|
+
- tests with fixtures (npm test), package.json files field
|
|
16
|
+
|
|
17
|
+
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
|
18
|
+
|
|
19
|
+
## v6.1.0 (2026-11-24)
|
|
20
|
+
### Fixed
|
|
21
|
+
- [2742a44](https://github.com/fabulator/eslint-config-fabulator/commit/2742a444067a61841fc50c7eea53a9c95446ce73) Apply Vitest rules only in projects that use Vitest (#247)
|
|
22
|
+
|
|
23
|
+
Projects testing with node:test got Vitest errors on *.test.js files and the autofix
|
|
24
|
+
rewrote node:test imports to vitest. Vitest rules are now enabled only when vitest
|
|
25
|
+
is resolvable from the project root.
|
|
26
|
+
|
|
27
|
+
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
|
28
|
+
|
|
4
29
|
## v6.0.1 (2026-11-24)
|
|
5
30
|
### Fixed
|
|
6
31
|
- [3fd8792](https://github.com/fabulator/eslint-config-fabulator/commit/3fd8792ad28c313952e9e0d127fa1f5f655bee95) Publish to npm via trusted publishing (#245)
|
package/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
|
|
1
4
|
import eslintReact from '@eslint-react/eslint-plugin';
|
|
2
5
|
import js from '@eslint/js';
|
|
3
6
|
import vitest from '@vitest/eslint-plugin';
|
|
4
7
|
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
5
|
-
import arrayFunc from 'eslint-plugin-array-func';
|
|
6
8
|
import { createNodeResolver, importX } from 'eslint-plugin-import-x';
|
|
7
9
|
import jsxA11y from 'eslint-plugin-jsx-a11y-x';
|
|
8
10
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
9
11
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
12
|
+
import unicorn from 'eslint-plugin-unicorn';
|
|
10
13
|
import { defineConfig } from 'eslint/config';
|
|
11
14
|
import globals from 'globals';
|
|
12
15
|
import tseslint from 'typescript-eslint';
|
|
@@ -14,6 +17,43 @@ import tseslint from 'typescript-eslint';
|
|
|
14
17
|
const JSX_FILES = ['**/*.jsx'];
|
|
15
18
|
const TSX_FILES = ['**/*.tsx'];
|
|
16
19
|
const TS_FILES = ['**/*.{ts,tsx,mts,cts}'];
|
|
20
|
+
const TEST_FILES = ['**/*.test.{js,ts,jsx,tsx}'];
|
|
21
|
+
|
|
22
|
+
// `_` prefix marks intentionally unused bindings, rest siblings omit properties from objects.
|
|
23
|
+
const UNUSED_VARS_OPTIONS = {
|
|
24
|
+
argsIgnorePattern: '^_',
|
|
25
|
+
caughtErrorsIgnorePattern: '^_',
|
|
26
|
+
destructuredArrayIgnorePattern: '^_',
|
|
27
|
+
ignoreRestSiblings: true,
|
|
28
|
+
varsIgnorePattern: '^_',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// Rules that guard type safety and React correctness – an `eslint-disable` comment must not
|
|
32
|
+
// silence them, the code has to be fixed instead.
|
|
33
|
+
const UNDISABLEABLE_RULES = [
|
|
34
|
+
'@typescript-eslint/ban-ts-comment',
|
|
35
|
+
'@typescript-eslint/no-explicit-any',
|
|
36
|
+
'@typescript-eslint/no-floating-promises',
|
|
37
|
+
'@typescript-eslint/no-misused-promises',
|
|
38
|
+
'@typescript-eslint/no-unsafe-*',
|
|
39
|
+
'@eslint-community/eslint-comments/*',
|
|
40
|
+
'prettier/prettier',
|
|
41
|
+
'react-hooks/rules-of-hooks',
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Vitest rules make sense only in projects that test with Vitest. Elsewhere (e.g. `node:test`)
|
|
46
|
+
* they would report false positives and their autofix would rewrite imports to `vitest`.
|
|
47
|
+
* ESLint runs from the project root, so Vitest is resolved from there.
|
|
48
|
+
*/
|
|
49
|
+
const usesVitest = (() => {
|
|
50
|
+
try {
|
|
51
|
+
createRequire(path.join(process.cwd(), 'package.json')).resolve('vitest');
|
|
52
|
+
return true;
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
})();
|
|
17
57
|
|
|
18
58
|
// Rules covered by eslint-plugin-react-hooks (official, React Compiler based) are
|
|
19
59
|
// turned off in @eslint-react so that each problem is reported only once.
|
|
@@ -45,17 +85,74 @@ const warningsToErrors = (rules) =>
|
|
|
45
85
|
|
|
46
86
|
const config = defineConfig([
|
|
47
87
|
{
|
|
48
|
-
extends: [
|
|
49
|
-
rules: {
|
|
88
|
+
extends: [unicorn.configs.recommended],
|
|
89
|
+
rules: {
|
|
90
|
+
// Opinionated naming – conflicts with React (PascalCase components, `props`, `e`, `ref`).
|
|
91
|
+
'unicorn/consistent-boolean-name': 'off',
|
|
92
|
+
'unicorn/filename-case': 'off',
|
|
93
|
+
'unicorn/name-replacements': 'off',
|
|
94
|
+
// React, DOM and JSON APIs use `null`, TypeScript distinguishes it from `undefined`.
|
|
95
|
+
'unicorn/no-null': 'off',
|
|
96
|
+
'unicorn/no-useless-undefined': 'off',
|
|
97
|
+
// Taste, not correctness.
|
|
98
|
+
'unicorn/no-array-reduce': 'off',
|
|
99
|
+
// Entry points and config files legitimately have side effects.
|
|
100
|
+
'unicorn/no-top-level-side-effects': 'off',
|
|
101
|
+
// TypeScript `private` (incl. constructor parameter properties used by DI) is fine.
|
|
102
|
+
'unicorn/prefer-private-class-fields': 'off',
|
|
103
|
+
// Standard JSDoc ` * ` prefixes, generated by editors.
|
|
104
|
+
'unicorn/no-asterisk-prefix-in-documentation-comments': 'off',
|
|
105
|
+
// Core `no-nested-ternary` is stricter (no nesting at all).
|
|
106
|
+
'unicorn/no-nested-ternary': 'off',
|
|
107
|
+
},
|
|
50
108
|
},
|
|
51
109
|
{
|
|
52
110
|
extends: [js.configs.recommended],
|
|
53
|
-
rules: {
|
|
111
|
+
rules: {
|
|
112
|
+
'no-irregular-whitespace': 'off',
|
|
113
|
+
'no-console': 'error',
|
|
114
|
+
'no-unused-vars': ['error', UNUSED_VARS_OPTIONS],
|
|
115
|
+
eqeqeq: ['error', 'always'],
|
|
116
|
+
'no-nested-ternary': 'error',
|
|
117
|
+
'no-param-reassign': 'error',
|
|
118
|
+
'object-shorthand': 'error',
|
|
119
|
+
'prefer-const': 'error',
|
|
120
|
+
'prefer-template': 'error',
|
|
121
|
+
// Small units are easier to review and cheaper to read for AI agents (less context).
|
|
122
|
+
complexity: ['error', 15],
|
|
123
|
+
'max-depth': ['error', 4],
|
|
124
|
+
'max-lines': [
|
|
125
|
+
'error',
|
|
126
|
+
{ max: 300, skipBlankLines: true, skipComments: true },
|
|
127
|
+
],
|
|
128
|
+
'max-lines-per-function': [
|
|
129
|
+
'error',
|
|
130
|
+
{ max: 80, skipBlankLines: true, skipComments: true },
|
|
131
|
+
],
|
|
132
|
+
},
|
|
54
133
|
},
|
|
55
134
|
{
|
|
56
|
-
files:
|
|
57
|
-
|
|
135
|
+
files: TEST_FILES,
|
|
136
|
+
rules: { 'max-lines-per-function': 'off' },
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
extends: [comments.recommended],
|
|
140
|
+
rules: {
|
|
141
|
+
'@eslint-community/eslint-comments/require-description': 'error',
|
|
142
|
+
'@eslint-community/eslint-comments/no-restricted-disable': [
|
|
143
|
+
'error',
|
|
144
|
+
...UNDISABLEABLE_RULES,
|
|
145
|
+
],
|
|
146
|
+
},
|
|
58
147
|
},
|
|
148
|
+
...(usesVitest
|
|
149
|
+
? [
|
|
150
|
+
{
|
|
151
|
+
files: TEST_FILES,
|
|
152
|
+
extends: [vitest.configs.recommended],
|
|
153
|
+
},
|
|
154
|
+
]
|
|
155
|
+
: []),
|
|
59
156
|
{
|
|
60
157
|
extends: [importX.flatConfigs.recommended],
|
|
61
158
|
rules: {
|
|
@@ -71,7 +168,8 @@ const config = defineConfig([
|
|
|
71
168
|
},
|
|
72
169
|
],
|
|
73
170
|
'import-x/no-mutable-exports': 'error',
|
|
74
|
-
|
|
171
|
+
// Unlimited depth is slow on large projects, longer cycles are rare.
|
|
172
|
+
'import-x/no-cycle': ['error', { maxDepth: 10, ignoreExternal: true }],
|
|
75
173
|
'import-x/no-relative-packages': 'error',
|
|
76
174
|
'import-x/no-self-import': 'error',
|
|
77
175
|
'import-x/order': ['error', { 'newlines-between': 'never' }],
|
|
@@ -132,14 +230,18 @@ const config = defineConfig([
|
|
|
132
230
|
allowNever: false,
|
|
133
231
|
},
|
|
134
232
|
],
|
|
135
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
|
136
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
137
233
|
'@typescript-eslint/no-empty-function': 'off',
|
|
138
|
-
'@typescript-eslint/no-unused-vars': '
|
|
234
|
+
'@typescript-eslint/no-unused-vars': ['error', UNUSED_VARS_OPTIONS],
|
|
139
235
|
'@typescript-eslint/no-empty-object-type': 'off',
|
|
140
|
-
|
|
236
|
+
// Prefers `value!` over `value as T`, which contradicts `no-non-null-assertion`.
|
|
237
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
|
141
238
|
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
142
|
-
'@typescript-eslint/
|
|
239
|
+
'@typescript-eslint/consistent-type-exports': 'error',
|
|
240
|
+
'@typescript-eslint/consistent-type-imports': 'error',
|
|
241
|
+
// Explicit signatures let readers (and AI agents) understand a module without its implementation.
|
|
242
|
+
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
243
|
+
'@typescript-eslint/no-import-type-side-effects': 'error',
|
|
244
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
143
245
|
},
|
|
144
246
|
},
|
|
145
247
|
{
|
|
@@ -167,11 +269,13 @@ const config = defineConfig([
|
|
|
167
269
|
singleQuote: true,
|
|
168
270
|
},
|
|
169
271
|
],
|
|
272
|
+
// eslint-config-prettier turns `curly` off, but `all` does not conflict with Prettier.
|
|
273
|
+
curly: ['error', 'all'],
|
|
170
274
|
},
|
|
171
275
|
},
|
|
172
276
|
]);
|
|
173
277
|
|
|
174
|
-
// eslint-disable-next-line import-x/no-default-export
|
|
278
|
+
// eslint-disable-next-line import-x/no-default-export -- ESLint loads shareable configs via default export
|
|
175
279
|
export default config.map((item) =>
|
|
176
280
|
item.rules ? { ...item, rules: warningsToErrors(item.rules) } : item,
|
|
177
281
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-fabulator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Shared ESLint config for fabulator projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -19,22 +19,28 @@
|
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"author": "Michal Ozogán <michal@ozogan.eu>",
|
|
21
21
|
"main": "index.js",
|
|
22
|
+
"files": [
|
|
23
|
+
"index.js",
|
|
24
|
+
"CHANGELOG.md"
|
|
25
|
+
],
|
|
22
26
|
"scripts": {
|
|
23
|
-
"lint": "eslint ./ --ext .js --config index.js",
|
|
27
|
+
"lint": "eslint ./ --ext .js --config index.js --ignore-pattern test/fixtures/",
|
|
24
28
|
"lint:fix": "npm run lint -- --fix",
|
|
29
|
+
"test": "node --test test/",
|
|
25
30
|
"release": "semantic-release"
|
|
26
31
|
},
|
|
27
32
|
"dependencies": {
|
|
33
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.8.1",
|
|
28
34
|
"@eslint-react/eslint-plugin": "^5.30.6",
|
|
29
35
|
"@eslint/js": "^10.0.1",
|
|
30
36
|
"@vitest/eslint-plugin": "^1.6.28",
|
|
31
37
|
"eslint-config-prettier": "^10.1.8",
|
|
32
38
|
"eslint-import-resolver-typescript": "^4.4.5",
|
|
33
|
-
"eslint-plugin-array-func": "5.1.1",
|
|
34
39
|
"eslint-plugin-import-x": "^4.18.1",
|
|
35
40
|
"eslint-plugin-jsx-a11y-x": "^0.2.0",
|
|
36
41
|
"eslint-plugin-prettier": "^5.5.7",
|
|
37
42
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
43
|
+
"eslint-plugin-unicorn": "^80.0.0",
|
|
38
44
|
"globals": "^17.14.0",
|
|
39
45
|
"prettier": "^3.10.1",
|
|
40
46
|
"typescript-eslint": "^8.74.0"
|