Repository navigation
Expand file tree
/
Copy patheslint.dogfooding.config.js
More file actions
274 lines (270 loc) · 7.87 KB
/
Copy patheslint.dogfooding.config.js
File metadata and controls
274 lines (270 loc) · 7.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
/*
Run all unicorn rules on codebase
*/
/*
! If you're making a new rule, you can ignore this before review.
*/
import eslintPluginUnicorn from './index.js';
const config = [
eslintPluginUnicorn.configs.all,
disableExternalRules([
// If external rules need to be disabled, add the rule name here.
'n/no-unsupported-features/es-syntax',
'eslint-plugin/require-meta-default-options',
'@stylistic/max-len',
'internal/prefer-context-on',
'node-test/no-duplicate-assertions',
'node-test/require-assertion',
]),
{
linterOptions: {
reportUnusedDisableDirectives: false,
},
},
{
ignores: [
'coverage',
'.ai-temporary',
'test/integration/fixtures',
'test/integration/fixtures-local',
],
},
{
rules: {
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1109#issuecomment-782689255
'unicorn/consistent-destructuring': 'off',
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/2341
'unicorn/escape-case': 'off',
'unicorn/prefer-unicode-code-point-escapes': 'off',
'unicorn/prefer-short-escape-sequences': 'off',
// Buggy
'unicorn/custom-error-definition': 'off',
'unicorn/consistent-function-scoping': 'off',
// Annoying
'unicorn/no-asterisk-prefix-in-documentation-comments': 'off',
'unicorn/no-manually-wrapped-comments': 'off',
'unicorn/single-line-block-comment-style': 'off',
'unicorn/no-keyword-prefix': 'off',
'unicorn/no-array-front-mutation': 'off',
'unicorn/no-invalid-argument-count': 'off',
'unicorn/no-unreadable-for-of-expression': 'off',
// Internal AST walkers intentionally use empty iterable fallbacks.
'unicorn/iteration-fallback-style': 'off',
'unicorn/try-complexity': 'off',
'unicorn/consistent-boolean-name': 'off',
// Recursive AST/tree walkers are intentional in rule implementation code.
'unicorn/no-useless-recursion': 'off',
// Disabled violations remain intentional in this codebase.
'unicorn/prefer-continue': 'off',
'unicorn/prefer-early-return': 'off',
'unicorn/prefer-minimal-ternary': 'off',
'unicorn/prefer-simple-condition-first': 'off',
'unicorn/prefer-simplified-conditions': 'off',
// Internal code intentionally retains boolean ternaries where they make conditional return values clearer.
'unicorn/prefer-logical-operator-over-ternary': 'off',
'unicorn/prefer-ternary': 'off',
// Existing rule implementations keep independent guard clauses for readability.
'unicorn/prefer-combined-guards': 'off',
// Many existing internal utilities intentionally export declarations separately.
'unicorn/default-export-style': 'off',
// The plugin intentionally keeps a few internal barrel files for shared utilities and rule exports.
'unicorn/no-barrel-files': 'off',
// This opt-in style is not applied to the existing codebase.
'unicorn/consistent-arrow-return-style': 'off',
// Internal helpers intentionally retain explicit dependencies and recursive default parameters.
'unicorn/no-unnecessary-parameters': 'off',
'unicorn/no-unnecessary-default-arguments': 'off',
// TODO: Enable when targeting Node.js 26.
'unicorn/prefer-iterator-concat': 'off',
'unicorn/prefer-temporal': 'off',
},
},
{
files: [
'rules/consistent-boolean-name.js',
'rules/no-loop-iterable-mutation.js',
'rules/prefer-math-constants.js',
'test/catch-error-name.js',
],
rules: {
// Internal fallback expressions intentionally handle null and other falsy values.
'unicorn/prefer-default-parameters': 'off',
},
},
{
files: [
'rules/utils/global-reference-tracker.js',
],
rules: {
// This module intentionally mutates its own exported class during setup.
'unicorn/no-top-level-side-effects': 'off',
},
},
{
files: [
'test/integration/projects.js',
'test/utils/test.js',
],
rules: {
// The project list is built, and `node:test` is configured, when the module is loaded.
'unicorn/no-top-level-side-effects': 'off',
},
},
{
files: [
'test/package.js',
'test/unit/boolean.js',
],
rules: {
// These tests intentionally use module-scoped capture variables across setup callbacks.
'unicorn/no-top-level-assignment-in-function': 'off',
},
},
{
files: ['test/expiring-todo-comments.js'],
rules: {
// This test creates its temporary resource directory at runtime.
'unicorn/no-missing-local-resource': 'off',
},
},
{
files: [
'rules/no-unnecessary-default-arguments.js',
'test/unit/get-primitive-literal-value.js',
'test/prefer-continue.js',
'test/prefer-early-return.js',
'test/prefer-ternary-readability.js',
'test/prefer-ternary.js',
'test/prefer-ternary-destructuring.js',
],
rules: {
// Literal readers test JavaScript's `null` value, and RuleTester uses it to assert that a problem is not autofixable.
'unicorn/no-null': 'off',
},
},
{
files: [
'.eslint-doc-generatorrc.js',
],
rules: {
// Keep the conventional eslint-doc-generator config filename.
'unicorn/name-replacements': 'off',
},
},
{
files: [
'rules/no-unused-properties.js',
],
rules: {
// `specialProtoPropertyKey` intentionally spells out `__proto__` as `Proto`, not `Prototype`.
'unicorn/name-replacements': 'off',
},
},
{
files: [
'rules/comment-content.js',
'rules/consistent-assert.js',
'rules/no-for-each.js',
'rules/no-array-reduce.js',
'rules/no-declarations-before-early-exit.js',
'rules/no-error-property-assignment.js',
'rules/no-redundant-comparison.js',
'rules/no-unnecessary-polyfills.js',
'rules/prefer-math-min-max.js',
'rules/prefer-private-class-fields.js',
'scripts/internal-rules/fix-snapshot-test.js',
'test/utils/snapshot-rule-tester.js',
],
rules: {
// Existing implementations intentionally use nested control flow in a few places.
'unicorn/no-break-in-nested-loop': 'off',
},
},
{
files: [
'rules/no-url-in-search-params.js',
'test/no-url-in-search-params.js',
],
rules: {
// The public rule name uses the URLSearchParams API spelling.
'unicorn/name-replacements': ['error', {checkFilenames: false}],
},
},
{
files: ['test/no-url-in-search-params.js'],
rules: {
// The runtime test deliberately demonstrates parsing a full URL incorrectly.
'unicorn/no-url-in-search-params': 'off',
},
},
{
// Intentional HTTP examples are used in tests.
files: [
'test/prefer-https.js',
'test/no-url-in-search-params.js',
'test/string-content.js',
],
rules: {
'unicorn/prefer-https': 'off',
},
},
{
files: [
'**/*.js',
],
rules: {
'unicorn/prefer-module': 'off',
'unicorn/prefer-import-meta-properties': 'off', // We can enable this rule when we drop support for Node.js v18.
},
},
{
files: [
'test/**/*.js',
],
rules: {
// Test files contain source-code fixtures in template literals.
'unicorn/no-incorrect-template-string-interpolation': 'off',
},
},
{
files: [
'scripts/rename-rule.js',
],
rules: {
// Exports are intentionally kept for unit tests.
'unicorn/no-exports-in-scripts': 'off',
},
},
{
files: [
'rules/prefer-bigint-literals.js',
],
rules: {
// `Number.isInteger` is intentional here: large integers beyond the safe range are exactly what bigint literals are for.
'unicorn/prefer-number-is-safe-integer': 'off',
},
},
{
files: [
'rules/ast/call-or-new-expression.js',
'rules/ast/is-member-expression.js',
'rules/no-static-only-class.js',
],
rules: {
// These files have a few multi-condition guard clauses where `prefer-boolean-return` produces harder-to-read double negatives.
'unicorn/prefer-boolean-return': 'off',
},
},
];
// Create rule to allow inline config to disable
function disableExternalRules(rules) {
const plugins = {};
for (const rule of rules) {
const [pluginName, ...rest] = rule.split('/');
const ruleName = rest.join('/');
plugins[pluginName] ??= {rules: {}};
plugins[pluginName].rules[ruleName] ??= {};
}
return {plugins};
}
export default config;