@wistia/oxlint-config 0.8.2 → 0.9.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/rules/unicorn.mjs +519 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wistia/oxlint-config",
3
- "version": "0.8.2",
3
+ "version": "0.9.1",
4
4
  "description": "Wistia's Oxlint configurations",
5
5
  "packageManager": "yarn@4.14.1",
6
6
  "type": "module",
package/rules/unicorn.mjs CHANGED
@@ -1,14 +1,160 @@
1
1
  export const unicornRules = {
2
- plugins: [],
2
+ plugins: ['unicorn'],
3
3
  rules: {
4
+ // Enforce a consistent identifier name for catch clause errors
5
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/catch-error-name.html
6
+ // Decision: too prescriptive about local variable naming
7
+ 'unicorn/catch-error-name': 'off',
8
+
9
+ // Enforce passing a message argument to assert functions
10
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/consistent-assert.html
11
+ 'unicorn/consistent-assert': 'error',
12
+
13
+ // Prefer `new Date(date)` over `new Date(date.getTime())` for cloning Date objects
14
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/consistent-date-clone.html
15
+ 'unicorn/consistent-date-clone': 'error',
16
+
17
+ // Prefer consistent style for spreading empty arrays
18
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/consistent-empty-array-spread.html
19
+ 'unicorn/consistent-empty-array-spread': 'error',
20
+
21
+ // Enforce consistent style of `index === -1` for non-existence and `index !== -1` for existence
22
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/consistent-existence-index-check.html
23
+ 'unicorn/consistent-existence-index-check': 'error',
24
+
25
+ // Move function declarations to the highest possible scope
26
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/consistent-function-scoping.html
27
+ // Decision: too noisy; flags functions that close over locals and would hurt readability if hoisted
28
+ 'unicorn/consistent-function-scoping': 'off',
29
+
30
+ // Enforce consistent escape style in template literals
31
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/consistent-template-literal-escape.html
32
+ 'unicorn/consistent-template-literal-escape': 'error',
33
+
34
+ // Enforce a specific structure for custom error classes
35
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/custom-error-definition.html
36
+ // Decision: too prescriptive about Error subclass shape
37
+ 'unicorn/custom-error-definition': 'off',
38
+
39
+ // Enforce no spaces between braces in empty blocks
40
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/empty-brace-spaces.html
41
+ // Decision: formatter territory
42
+ 'unicorn/empty-brace-spaces': 'off',
43
+
44
+ // Enforce passing a `message` value when creating built-in errors
45
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/error-message.html
46
+ 'unicorn/error-message': 'error',
47
+
48
+ // Require escape sequences to use uppercase or lowercase values
49
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/escape-case.html
50
+ // Decision: formatter territory
51
+ 'unicorn/escape-case': 'off',
52
+
53
+ // Enforce explicitly comparing `length` or `size` property of a value
54
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/explicit-length-check.html
55
+ 'unicorn/explicit-length-check': 'error',
56
+
57
+ // Enforce a case style for filenames
58
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/filename-case.html
59
+ // Decision: project-specific; consumers enforce their own filename conventions
60
+ 'unicorn/filename-case': 'off',
61
+
62
+ // Enforce specific import styles per module
63
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/import-style.html
64
+ // Override built-in defaults: this rule ships preferring default imports
65
+ // for `chalk`, `path`, and `node:path`. We require named imports instead.
66
+ 'unicorn/import-style': [
67
+ 'error',
68
+ {
69
+ styles: {
70
+ 'node:path': { named: true, default: false },
71
+ path: { named: true, default: false },
72
+ chalk: { named: true, default: false },
73
+ },
74
+ },
75
+ ],
76
+
77
+ // Require `new` when creating an object using a built-in constructor
78
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/new-for-builtins.html
79
+ 'unicorn/new-for-builtins': 'error',
80
+
81
+ // Disallow blanket `eslint-disable` comments
82
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-abusive-eslint-disable.html
83
+ 'unicorn/no-abusive-eslint-disable': 'error',
84
+
85
+ // Disallow accessor properties that recursively call themselves
86
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-accessor-recursion.html
87
+ 'unicorn/no-accessor-recursion': 'error',
88
+
89
+ // Disallow anonymous functions and classes as default exports
90
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-anonymous-default-export.html
91
+ // Decision: anonymous default exports are a common pattern (React components, re-export shims)
92
+ 'unicorn/no-anonymous-default-export': 'off',
93
+
94
+ // Prevent passing a function reference directly to iterator methods (subtle arity/index bugs)
95
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-callback-reference.html
96
+ 'unicorn/no-array-callback-reference': 'error',
97
+
98
+ // Prefer `for...of` over `Array#forEach`
99
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-for-each.html
100
+ // Decision: `Array#forEach` is a legitimate iteration pattern
101
+ 'unicorn/no-array-for-each': 'off',
102
+
103
+ // Disallow using the `this` argument in array methods
104
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-method-this-argument.html
105
+ 'unicorn/no-array-method-this-argument': 'error',
106
+
107
+ // Disallow `Array#reduce()` and `Array#reduceRight()`
108
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-reduce.html
109
+ // Decision: `reduce` is a legitimate functional pattern
110
+ 'unicorn/no-array-reduce': 'off',
111
+
112
+ // Disallow in-place `Array#reverse()` (use `Array#toReversed()`)
113
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-reverse.html
114
+ 'unicorn/no-array-reverse': 'error',
115
+
116
+ // Disallow in-place `Array#sort()` (use `Array#toSorted()`)
117
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-sort.html
118
+ 'unicorn/no-array-sort': 'error',
119
+
120
+ // Disallow member access from `await` expressions
121
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-await-expression-member.html
122
+ 'unicorn/no-await-expression-member': 'error',
123
+
4
124
  // Disallow using await in Promise.all/race/etc. array arguments
5
125
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-await-in-promise-methods.html
6
126
  'unicorn/no-await-in-promise-methods': 'error',
7
127
 
128
+ // Do not use leading/trailing space between `console.log` parameters
129
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-console-spaces.html
130
+ // Decision: formatter territory
131
+ 'unicorn/no-console-spaces': 'off',
132
+
133
+ // Disallow direct use of `document.cookie`
134
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-document-cookie.html
135
+ 'unicorn/no-document-cookie': 'error',
136
+
8
137
  // Disallow empty files
9
138
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-empty-file.html
10
139
  'unicorn/no-empty-file': 'error',
11
140
 
141
+ // Enforce the use of Unicode escapes instead of hexadecimal escapes
142
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-hex-escape.html
143
+ // Decision: formatter territory
144
+ 'unicorn/no-hex-escape': 'off',
145
+
146
+ // Disallow `if` statements that always mutate the same variable
147
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-immediate-mutation.html
148
+ 'unicorn/no-immediate-mutation': 'error',
149
+
150
+ // Disallow `instanceof Array` (use `Array.isArray`)
151
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-instanceof-array.html
152
+ 'unicorn/no-instanceof-array': 'error',
153
+
154
+ // Disallow `instanceof` with built-in classes that have safer alternatives
155
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-instanceof-builtins.html
156
+ 'unicorn/no-instanceof-builtins': 'error',
157
+
12
158
  // Disallow invalid options in fetch() calls
13
159
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-invalid-fetch-options.html
14
160
  'unicorn/no-invalid-fetch-options': 'error',
@@ -17,40 +163,412 @@ export const unicornRules = {
17
163
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-invalid-remove-event-listener.html
18
164
  'unicorn/no-invalid-remove-event-listener': 'error',
19
165
 
166
+ // Disallow passing `length` as the `end` argument of `Array#slice()`
167
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-length-as-slice-end.html
168
+ 'unicorn/no-length-as-slice-end': 'error',
169
+
170
+ // Disallow `if` statements as the only statement in `if` blocks without `else`
171
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-lonely-if.html
172
+ // Decision: stylistic; nested `if` sometimes reads better than `else if`
173
+ 'unicorn/no-lonely-if': 'off',
174
+
175
+ // Disallow a magic number as the `depth` argument in `Array#flat()`
176
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-magic-array-flat-depth.html
177
+ 'unicorn/no-magic-array-flat-depth': 'error',
178
+
179
+ // Disallow negated conditions
180
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-negated-condition.html
181
+ // Decision: stylistic; negated conditions are sometimes clearer
182
+ 'unicorn/no-negated-condition': 'off',
183
+
184
+ // Disallow negated expressions on the left of equality checks
185
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-negation-in-equality-check.html
186
+ 'unicorn/no-negation-in-equality-check': 'error',
187
+
188
+ // Disallow nested ternary expressions
189
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-nested-ternary.html
190
+ // Decision: stylistic; formatter handles readability
191
+ 'unicorn/no-nested-ternary': 'off',
192
+
20
193
  // Disallow new Array() (use Array.from or [...] instead)
21
194
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-new-array.html
22
195
  'unicorn/no-new-array': 'error',
23
196
 
197
+ // Disallow `new Buffer()` (deprecated in Node.js)
198
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-new-buffer.html
199
+ 'unicorn/no-new-buffer': 'error',
200
+
201
+ // Disallow the use of the `null` literal
202
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-null.html
203
+ // Decision: null is widely used in JSON, DOM APIs, and library returns; banning is impractical
204
+ 'unicorn/no-null': 'off',
205
+
206
+ // Disallow the use of objects as default parameters
207
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-object-as-default-parameter.html
208
+ 'unicorn/no-object-as-default-parameter': 'error',
209
+
210
+ // Disallow `process.exit()` (use throw)
211
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-process-exit.html
212
+ // Decision: handled by n/no-process-exit which already enforces this with appropriate exemptions
213
+ 'unicorn/no-process-exit': 'off',
214
+
24
215
  // Disallow passing single-element arrays to Promise.all/race/etc.
25
216
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-single-promise-in-promise-methods.html
26
217
  'unicorn/no-single-promise-in-promise-methods': 'error',
27
218
 
219
+ // Disallow classes that only have static members
220
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-static-only-class.html
221
+ 'unicorn/no-static-only-class': 'error',
222
+
28
223
  // Disallow thenable objects (confuses await/Promise behavior)
29
224
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-thenable.html
30
225
  'unicorn/no-thenable': 'error',
31
226
 
227
+ // Disallow assigning `this` to a variable
228
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-this-assignment.html
229
+ 'unicorn/no-this-assignment': 'error',
230
+
231
+ // Disallow comparing with `typeof x === "undefined"`
232
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-typeof-undefined.html
233
+ // Decision: stylistic; both forms are commonly used
234
+ 'unicorn/no-typeof-undefined': 'off',
235
+
236
+ // Disallow unnecessary `depth` argument to `Array#flat()`
237
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-flat-depth.html
238
+ 'unicorn/no-unnecessary-array-flat-depth': 'error',
239
+
240
+ // Disallow unnecessary `count` argument to `Array#splice()`
241
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unnecessary-array-splice-count.html
242
+ 'unicorn/no-unnecessary-array-splice-count': 'error',
243
+
32
244
  // Disallow unnecessary await on non-Promise values
33
245
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unnecessary-await.html
34
246
  'unicorn/no-unnecessary-await': 'error',
35
247
 
248
+ // Disallow unnecessary `end` argument to `String#slice()`
249
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unnecessary-slice-end.html
250
+ 'unicorn/no-unnecessary-slice-end': 'error',
251
+
252
+ // Disallow unreadable array destructuring
253
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unreadable-array-destructuring.html
254
+ // Decision: stylistic
255
+ 'unicorn/no-unreadable-array-destructuring': 'off',
256
+
257
+ // Disallow unreadable IIFEs
258
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-unreadable-iife.html
259
+ // Decision: stylistic
260
+ 'unicorn/no-unreadable-iife': 'off',
261
+
262
+ // Disallow passing single-element collections to functions accepting iterables
263
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-collection-argument.html
264
+ 'unicorn/no-useless-collection-argument': 'error',
265
+
266
+ // Disallow unnecessary `Error.captureStackTrace(...)` calls
267
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-error-capture-stack-trace.html
268
+ 'unicorn/no-useless-error-capture-stack-trace': 'error',
269
+
36
270
  // Disallow useless fallback in spread (e.g. ...obj || {})
37
271
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-fallback-in-spread.html
38
272
  'unicorn/no-useless-fallback-in-spread': 'error',
39
273
 
274
+ // Disallow useless conversion of iterable to array
275
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-iterator-to-array.html
276
+ 'unicorn/no-useless-iterator-to-array': 'error',
277
+
40
278
  // Disallow useless length checks before array operations
41
279
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-length-check.html
42
280
  'unicorn/no-useless-length-check': 'error',
43
281
 
282
+ // Disallow returning/yielding `Promise.resolve` / `Promise.reject` in async functions
283
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-promise-resolve-reject.html
284
+ 'unicorn/no-useless-promise-resolve-reject': 'error',
285
+
44
286
  // Disallow useless spread operators
45
287
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-spread.html
46
288
  'unicorn/no-useless-spread': 'error',
47
289
 
290
+ // Disallow useless `case` in `switch` statements
291
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-switch-case.html
292
+ 'unicorn/no-useless-switch-case': 'error',
293
+
294
+ // Disallow explicit `undefined` arguments and default parameter values
295
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-useless-undefined.html
296
+ // Decision: stylistic; explicit `undefined` is sometimes clearer at call sites
297
+ 'unicorn/no-useless-undefined': 'off',
298
+
299
+ // Disallow number literals with zero fractions or dangling dots
300
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-zero-fractions.html
301
+ // Decision: formatter territory
302
+ 'unicorn/no-zero-fractions': 'off',
303
+
304
+ // Enforce consistent case for number literal prefixes and suffixes
305
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/number-literal-case.html
306
+ // Decision: formatter territory
307
+ 'unicorn/number-literal-case': 'off',
308
+
309
+ // Enforce a style for numeric separators
310
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/numeric-separators-style.html
311
+ // Decision: formatter territory
312
+ 'unicorn/numeric-separators-style': 'off',
313
+
314
+ // Prefer `.addEventListener()` and `.removeEventListener()` over `on`-functions
315
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-add-event-listener.html
316
+ 'unicorn/prefer-add-event-listener': 'error',
317
+
318
+ // Prefer `Array#find()` and `Array#findLast()` over the first/last element from `.filter()`
319
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-array-find.html
320
+ 'unicorn/prefer-array-find': 'error',
321
+
322
+ // Prefer `Array#flat()` over legacy techniques
323
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-array-flat.html
324
+ 'unicorn/prefer-array-flat': 'error',
325
+
326
+ // Prefer `.flatMap(…)` over `.map(…).flat()`
327
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-array-flat-map.html
328
+ 'unicorn/prefer-array-flat-map': 'error',
329
+
330
+ // Prefer `Array#indexOf()` over `Array#findIndex()` for primitive equality
331
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-array-index-of.html
332
+ 'unicorn/prefer-array-index-of': 'error',
333
+
334
+ // Prefer `.some(…)` over `.find(…)`/`.findIndex(…)`/etc. for boolean checks
335
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-array-some.html
336
+ 'unicorn/prefer-array-some': 'error',
337
+
338
+ // Prefer `.at(…)` for index access
339
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-at.html
340
+ 'unicorn/prefer-at': 'error',
341
+
342
+ // Prefer BigInt literals over `BigInt()`
343
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-bigint-literals.html
344
+ 'unicorn/prefer-bigint-literals': 'error',
345
+
346
+ // Prefer `Blob#text()` / `Blob#bytes()` over `FileReader#readAs*`
347
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-blob-reading-methods.html
348
+ 'unicorn/prefer-blob-reading-methods': 'error',
349
+
350
+ // Prefer class field declarations over assigning in the constructor
351
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-class-fields.html
352
+ 'unicorn/prefer-class-fields': 'error',
353
+
354
+ // Prefer `.classList.toggle()` over manual class toggling
355
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-classlist-toggle.html
356
+ 'unicorn/prefer-classlist-toggle': 'error',
357
+
358
+ // Prefer `String#codePointAt(…)` over `String#charCodeAt(…)`
359
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-code-point.html
360
+ 'unicorn/prefer-code-point': 'error',
361
+
362
+ // Prefer `Date.now()` over `new Date().getTime()`
363
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-date-now.html
364
+ 'unicorn/prefer-date-now': 'error',
365
+
366
+ // Prefer default parameters over reassignment
367
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-default-parameters.html
368
+ 'unicorn/prefer-default-parameters': 'error',
369
+
370
+ // Prefer `Node#append()` over `Node#appendChild()`
371
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-append.html
372
+ 'unicorn/prefer-dom-node-append': 'error',
373
+
374
+ // Prefer using `.dataset` on DOM nodes over `.setAttribute(…)`
375
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-dataset.html
376
+ 'unicorn/prefer-dom-node-dataset': 'error',
377
+
378
+ // Prefer `childNode.remove()` over `parentNode.removeChild(childNode)`
379
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-remove.html
380
+ 'unicorn/prefer-dom-node-remove': 'error',
381
+
382
+ // Prefer `.textContent` over `.innerText`
383
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-dom-node-text-content.html
384
+ 'unicorn/prefer-dom-node-text-content': 'error',
385
+
386
+ // Prefer `EventTarget` over `EventEmitter`
387
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-event-target.html
388
+ // Decision: EventTarget vs EventEmitter is architectural; let consumers choose
389
+ 'unicorn/prefer-event-target': 'off',
390
+
391
+ // Prefer `globalThis` over `window` / `self` / `global`
392
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-global-this.html
393
+ // Decision: we should consider enabling this in the future but it will involve a lot of refactoring
394
+ 'unicorn/prefer-global-this': 'off',
395
+
396
+ // Prefer `import.meta.{dirname,filename}` over CJS-equivalent constructions
397
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-import-meta-properties.html
398
+ 'unicorn/prefer-import-meta-properties': 'error',
399
+
400
+ // Prefer `.includes(…)` over `.indexOf(…) !== -1`
401
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-includes.html
402
+ 'unicorn/prefer-includes': 'error',
403
+
404
+ // Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`
405
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-keyboard-event-key.html
406
+ 'unicorn/prefer-keyboard-event-key': 'error',
407
+
408
+ // Prefer logical operators (`||`/`??`) over ternaries for fallbacks
409
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-logical-operator-over-ternary.html
410
+ 'unicorn/prefer-logical-operator-over-ternary': 'error',
411
+
412
+ // Prefer `Math.min()` / `Math.max()` over ternary expressions
413
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-math-min-max.html
414
+ 'unicorn/prefer-math-min-max': 'error',
415
+
416
+ // Prefer `Math.trunc(…)` over bitwise integer truncation
417
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-math-trunc.html
418
+ 'unicorn/prefer-math-trunc': 'error',
419
+
420
+ // Prefer modern DOM APIs (e.g. `Element#replaceWith()`)
421
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-modern-dom-apis.html
422
+ 'unicorn/prefer-modern-dom-apis': 'error',
423
+
424
+ // Prefer modern `Math` methods (e.g. `Math.log2`, `Math.cbrt`, …)
425
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-modern-math-apis.html
426
+ 'unicorn/prefer-modern-math-apis': 'error',
427
+
428
+ // Prefer ESM over CommonJS
429
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-module.html
430
+ // Decision: consumers may still ship CommonJS; let them opt in via their own config
431
+ 'unicorn/prefer-module': 'off',
432
+
433
+ // Prefer native coercion functions (e.g. `Boolean(value)` over `!!value`)
434
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-native-coercion-functions.html
435
+ 'unicorn/prefer-native-coercion-functions': 'error',
436
+
437
+ // Prefer negative index over `.length - x` in `.slice()` and `.at()`
438
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-negative-index.html
439
+ 'unicorn/prefer-negative-index': 'error',
440
+
441
+ // Prefer using the `node:` protocol when importing Node.js builtins
442
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-node-protocol.html
443
+ 'unicorn/prefer-node-protocol': 'error',
444
+
445
+ // Prefer `Number.parseInt()` / `Number.parseFloat()` / `Number.isNaN()` over their global counterparts
446
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-number-properties.html
447
+ 'unicorn/prefer-number-properties': 'error',
448
+
449
+ // Prefer `Object.fromEntries(…)` over building objects via `.reduce(…)`
450
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-object-from-entries.html
451
+ 'unicorn/prefer-object-from-entries': 'error',
452
+
453
+ // Prefer omitting the catch binding parameter when unused
454
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-optional-catch-binding.html
455
+ 'unicorn/prefer-optional-catch-binding': 'error',
456
+
457
+ // Prefer borrowing methods from the prototype instead of an instance
458
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-prototype-methods.html
459
+ 'unicorn/prefer-prototype-methods': 'error',
460
+
461
+ // Prefer `.querySelector(…)` over `.getElementById(…)` / `.getElementsByClassName(…)`
462
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-query-selector.html
463
+ // Decision: `getElementById` is the standard fast path; not worth refactoring away
464
+ 'unicorn/prefer-query-selector': 'off',
465
+
466
+ // Prefer `Reflect.apply(…)` over `Function.prototype.apply.call(…)`
467
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-reflect-apply.html
468
+ 'unicorn/prefer-reflect-apply': 'error',
469
+
470
+ // Prefer `RegExp#test()` over `String#match()` and `RegExp#exec()` for booleans
471
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-regexp-test.html
472
+ 'unicorn/prefer-regexp-test': 'error',
473
+
474
+ // Prefer `Response.json(…)` over `new Response(JSON.stringify(…))`
475
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-response-static-json.html
476
+ 'unicorn/prefer-response-static-json': 'error',
477
+
478
+ // Prefer `Set#has(…)` over `Array#includes(…)` when membership checks repeat
479
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-set-has.html
480
+ 'unicorn/prefer-set-has': 'error',
481
+
48
482
  // Prefer Set#size over converting to array and checking length
49
483
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-set-size.html
50
484
  'unicorn/prefer-set-size': 'error',
51
485
 
486
+ // Prefer the spread operator over `Array.from(…)` etc.
487
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-spread.html
488
+ 'unicorn/prefer-spread': 'error',
489
+
490
+ // Prefer `String.raw(…)` over manually escaped strings
491
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-raw.html
492
+ // Decision: `String.raw` is niche and easy to misread
493
+ 'unicorn/prefer-string-raw': 'off',
494
+
495
+ // Prefer `String#replaceAll(…)` over global regex replace
496
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-replace-all.html
497
+ 'unicorn/prefer-string-replace-all': 'error',
498
+
499
+ // Prefer `String#slice(…)` over deprecated `substr`/`substring`
500
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-slice.html
501
+ 'unicorn/prefer-string-slice': 'error',
502
+
52
503
  // Prefer String#startsWith/endsWith over regex or slice comparisons
53
504
  // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-starts-ends-with.html
54
505
  'unicorn/prefer-string-starts-ends-with': 'error',
506
+
507
+ // Prefer `String#trimStart()`/`trimEnd()` over deprecated `trimLeft()`/`trimRight()`
508
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-string-trim-start-end.html
509
+ 'unicorn/prefer-string-trim-start-end': 'error',
510
+
511
+ // Prefer `structuredClone(…)` over `JSON.parse(JSON.stringify(…))`
512
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-structured-clone.html
513
+ 'unicorn/prefer-structured-clone': 'error',
514
+
515
+ // Prefer ternary expressions over short `if-else` returns/assignments
516
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-ternary.html
517
+ // Decision: stylistic; clarity over compactness
518
+ 'unicorn/prefer-ternary': 'off',
519
+
520
+ // Prefer top-level `await` over wrapping module entrypoints in async IIFEs
521
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-top-level-await.html
522
+ // Decision: not all consumer modules support TLA; opt-in per consumer
523
+ 'unicorn/prefer-top-level-await': 'off',
524
+
525
+ // Enforce `throw new TypeError(…)` for type-related errors
526
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-type-error.html
527
+ 'unicorn/prefer-type-error': 'error',
528
+
529
+ // Enforce a consistent style for `./` prefixes in relative URLs
530
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/relative-url-style.html
531
+ // Decision: stylistic; both forms are widely used
532
+ 'unicorn/relative-url-style': 'off',
533
+
534
+ // Require explicit separator argument for `Array#join(…)`
535
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/require-array-join-separator.html
536
+ // Decision: the default `,` separator is widely understood; explicit argument is noise
537
+ 'unicorn/require-array-join-separator': 'off',
538
+
539
+ // Require import attributes for non-JS module imports (JSON modules etc.)
540
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/require-module-attributes.html
541
+ 'unicorn/require-module-attributes': 'error',
542
+
543
+ // Require one module specifier per `import` declaration
544
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/require-module-specifiers.html
545
+ 'unicorn/require-module-specifiers': 'error',
546
+
547
+ // Require explicit `digits` argument for `Number#toFixed(…)`
548
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/require-number-to-fixed-digits-argument.html
549
+ 'unicorn/require-number-to-fixed-digits-argument': 'error',
550
+
551
+ // Require explicit `targetOrigin` for `window.postMessage(…)`
552
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/require-post-message-target-origin.html
553
+ 'unicorn/require-post-message-target-origin': 'error',
554
+
555
+ // Enforce consistent brace style for switch cases
556
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/switch-case-braces.html
557
+ // Decision: formatter territory
558
+ 'unicorn/switch-case-braces': 'off',
559
+
560
+ // Enforce consistent break position in switch cases
561
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/switch-case-break-position.html
562
+ // Decision: formatter territory
563
+ 'unicorn/switch-case-break-position': 'off',
564
+
565
+ // Enforce consistent case for text encoding identifiers (e.g. `'utf-8'` vs `'utf8'`)
566
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/text-encoding-identifier-case.html
567
+ // Decision: both spellings are universally accepted by APIs
568
+ 'unicorn/text-encoding-identifier-case': 'off',
569
+
570
+ // Require `new` when throwing built-in errors
571
+ // https://oxc.rs/docs/guide/usage/linter/rules/unicorn/throw-new-error.html
572
+ 'unicorn/throw-new-error': 'error',
55
573
  },
56
574
  };