eslint-config-fabulator 6.1.0 → 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 +15 -0
- package/index.js +96 -12
- package/package.json +9 -3
- package/renovate.json +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
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
|
+
|
|
4
19
|
## v6.1.0 (2026-11-24)
|
|
5
20
|
### Fixed
|
|
6
21
|
- [2742a44](https://github.com/fabulator/eslint-config-fabulator/commit/2742a444067a61841fc50c7eea53a9c95446ce73) Apply Vitest rules only in projects that use Vitest (#247)
|
package/index.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import comments from '@eslint-community/eslint-plugin-eslint-comments/configs';
|
|
3
4
|
import eslintReact from '@eslint-react/eslint-plugin';
|
|
4
5
|
import js from '@eslint/js';
|
|
5
6
|
import vitest from '@vitest/eslint-plugin';
|
|
6
7
|
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
|
|
7
|
-
import arrayFunc from 'eslint-plugin-array-func';
|
|
8
8
|
import { createNodeResolver, importX } from 'eslint-plugin-import-x';
|
|
9
9
|
import jsxA11y from 'eslint-plugin-jsx-a11y-x';
|
|
10
10
|
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
11
11
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
12
|
+
import unicorn from 'eslint-plugin-unicorn';
|
|
12
13
|
import { defineConfig } from 'eslint/config';
|
|
13
14
|
import globals from 'globals';
|
|
14
15
|
import tseslint from 'typescript-eslint';
|
|
@@ -16,6 +17,29 @@ import tseslint from 'typescript-eslint';
|
|
|
16
17
|
const JSX_FILES = ['**/*.jsx'];
|
|
17
18
|
const TSX_FILES = ['**/*.tsx'];
|
|
18
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
|
+
];
|
|
19
43
|
|
|
20
44
|
/**
|
|
21
45
|
* Vitest rules make sense only in projects that test with Vitest. Elsewhere (e.g. `node:test`)
|
|
@@ -61,17 +85,70 @@ const warningsToErrors = (rules) =>
|
|
|
61
85
|
|
|
62
86
|
const config = defineConfig([
|
|
63
87
|
{
|
|
64
|
-
extends: [
|
|
65
|
-
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
|
+
},
|
|
66
108
|
},
|
|
67
109
|
{
|
|
68
110
|
extends: [js.configs.recommended],
|
|
69
|
-
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
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
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
|
+
},
|
|
70
147
|
},
|
|
71
148
|
...(usesVitest
|
|
72
149
|
? [
|
|
73
150
|
{
|
|
74
|
-
files:
|
|
151
|
+
files: TEST_FILES,
|
|
75
152
|
extends: [vitest.configs.recommended],
|
|
76
153
|
},
|
|
77
154
|
]
|
|
@@ -91,7 +168,8 @@ const config = defineConfig([
|
|
|
91
168
|
},
|
|
92
169
|
],
|
|
93
170
|
'import-x/no-mutable-exports': 'error',
|
|
94
|
-
|
|
171
|
+
// Unlimited depth is slow on large projects, longer cycles are rare.
|
|
172
|
+
'import-x/no-cycle': ['error', { maxDepth: 10, ignoreExternal: true }],
|
|
95
173
|
'import-x/no-relative-packages': 'error',
|
|
96
174
|
'import-x/no-self-import': 'error',
|
|
97
175
|
'import-x/order': ['error', { 'newlines-between': 'never' }],
|
|
@@ -152,14 +230,18 @@ const config = defineConfig([
|
|
|
152
230
|
allowNever: false,
|
|
153
231
|
},
|
|
154
232
|
],
|
|
155
|
-
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
|
|
156
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
157
233
|
'@typescript-eslint/no-empty-function': 'off',
|
|
158
|
-
'@typescript-eslint/no-unused-vars': '
|
|
234
|
+
'@typescript-eslint/no-unused-vars': ['error', UNUSED_VARS_OPTIONS],
|
|
159
235
|
'@typescript-eslint/no-empty-object-type': 'off',
|
|
160
|
-
|
|
236
|
+
// Prefers `value!` over `value as T`, which contradicts `no-non-null-assertion`.
|
|
237
|
+
'@typescript-eslint/non-nullable-type-assertion-style': 'off',
|
|
161
238
|
'@typescript-eslint/prefer-optional-chain': 'error',
|
|
162
|
-
'@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',
|
|
163
245
|
},
|
|
164
246
|
},
|
|
165
247
|
{
|
|
@@ -187,11 +269,13 @@ const config = defineConfig([
|
|
|
187
269
|
singleQuote: true,
|
|
188
270
|
},
|
|
189
271
|
],
|
|
272
|
+
// eslint-config-prettier turns `curly` off, but `all` does not conflict with Prettier.
|
|
273
|
+
curly: ['error', 'all'],
|
|
190
274
|
},
|
|
191
275
|
},
|
|
192
276
|
]);
|
|
193
277
|
|
|
194
|
-
// 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
|
|
195
279
|
export default config.map((item) =>
|
|
196
280
|
item.rules ? { ...item, rules: warningsToErrors(item.rules) } : item,
|
|
197
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"
|