@d3lm/lint-preset 1.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/LICENSE +21 -0
- package/README.md +242 -0
- package/dist/chunk-JM2XMNKF.js +612 -0
- package/dist/chunk-JM2XMNKF.js.map +1 -0
- package/dist/chunk-QDQNT3NA.cjs +612 -0
- package/dist/chunk-QDQNT3NA.cjs.map +1 -0
- package/dist/eslint.cjs +102 -0
- package/dist/eslint.cjs.map +1 -0
- package/dist/eslint.d.cts +17 -0
- package/dist/eslint.d.ts +17 -0
- package/dist/eslint.js +102 -0
- package/dist/eslint.js.map +1 -0
- package/dist/oxlint.cjs +59 -0
- package/dist/oxlint.cjs.map +1 -0
- package/dist/oxlint.d.cts +12 -0
- package/dist/oxlint.d.ts +12 -0
- package/dist/oxlint.js +59 -0
- package/dist/oxlint.js.map +1 -0
- package/dist/rules.cjs +857 -0
- package/dist/rules.cjs.map +1 -0
- package/dist/rules.d.cts +5 -0
- package/dist/rules.d.ts +5 -0
- package/dist/rules.js +857 -0
- package/dist/rules.js.map +1 -0
- package/dist/typescript-pI6S6Z22.d.cts +46 -0
- package/dist/typescript-pI6S6Z22.d.ts +46 -0
- package/package.json +83 -0
|
@@ -0,0 +1,612 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/configs/unicorn.ts
|
|
2
|
+
var unicornRulesOxlint = {
|
|
3
|
+
// correctness
|
|
4
|
+
"unicorn/no-await-in-promise-methods": "error",
|
|
5
|
+
"unicorn/no-empty-file": "warn",
|
|
6
|
+
"unicorn/no-invalid-fetch-options": "error",
|
|
7
|
+
"unicorn/no-invalid-remove-event-listener": "error",
|
|
8
|
+
"unicorn/no-new-array": "error",
|
|
9
|
+
"unicorn/no-single-promise-in-promise-methods": "error",
|
|
10
|
+
"unicorn/no-thenable": "error",
|
|
11
|
+
"unicorn/no-unnecessary-await": "error",
|
|
12
|
+
"unicorn/no-useless-fallback-in-spread": "error",
|
|
13
|
+
"unicorn/no-useless-length-check": "error",
|
|
14
|
+
"unicorn/no-useless-spread": "error",
|
|
15
|
+
"unicorn/prefer-set-size": "error",
|
|
16
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
17
|
+
// perf
|
|
18
|
+
"unicorn/prefer-array-find": "error",
|
|
19
|
+
"unicorn/prefer-array-flat-map": "error",
|
|
20
|
+
"unicorn/prefer-set-has": "error",
|
|
21
|
+
// restriction
|
|
22
|
+
"unicorn/no-abusive-eslint-disable": "error",
|
|
23
|
+
"unicorn/no-anonymous-default-export": "error",
|
|
24
|
+
"unicorn/no-array-for-each": "error",
|
|
25
|
+
"unicorn/no-array-reduce": "error",
|
|
26
|
+
"unicorn/no-document-cookie": "error",
|
|
27
|
+
"unicorn/no-magic-array-flat-depth": "error",
|
|
28
|
+
"unicorn/no-process-exit": "error",
|
|
29
|
+
"unicorn/no-useless-error-capture-stack-trace": "error",
|
|
30
|
+
"unicorn/prefer-modern-math-apis": "error",
|
|
31
|
+
"unicorn/prefer-module": "error",
|
|
32
|
+
"unicorn/prefer-node-protocol": "error",
|
|
33
|
+
"unicorn/prefer-number-properties": "error",
|
|
34
|
+
// suspicious
|
|
35
|
+
"unicorn/consistent-function-scoping": "error",
|
|
36
|
+
"unicorn/no-accessor-recursion": "error",
|
|
37
|
+
"unicorn/no-array-reverse": "error",
|
|
38
|
+
"unicorn/no-array-sort": "error",
|
|
39
|
+
"unicorn/no-instanceof-builtins": "error",
|
|
40
|
+
"unicorn/prefer-add-event-listener": "error",
|
|
41
|
+
"unicorn/require-module-specifiers": "error",
|
|
42
|
+
// pedantic
|
|
43
|
+
"unicorn/consistent-assert": "error",
|
|
44
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
45
|
+
"unicorn/escape-case": "error",
|
|
46
|
+
"unicorn/explicit-length-check": "error",
|
|
47
|
+
"unicorn/new-for-builtins": "error",
|
|
48
|
+
"unicorn/no-array-callback-reference": "error",
|
|
49
|
+
"unicorn/no-hex-escape": "error",
|
|
50
|
+
"unicorn/no-immediate-mutation": "error",
|
|
51
|
+
"unicorn/no-lonely-if": "error",
|
|
52
|
+
"unicorn/no-negation-in-equality-check": "error",
|
|
53
|
+
"unicorn/no-new-buffer": "error",
|
|
54
|
+
"unicorn/no-object-as-default-parameter": "error",
|
|
55
|
+
"unicorn/no-static-only-class": "error",
|
|
56
|
+
"unicorn/no-this-assignment": "error",
|
|
57
|
+
"unicorn/no-typeof-undefined": "error",
|
|
58
|
+
"unicorn/no-unnecessary-array-flat-depth": "error",
|
|
59
|
+
"unicorn/no-unnecessary-array-splice-count": "error",
|
|
60
|
+
"unicorn/no-unnecessary-slice-end": "error",
|
|
61
|
+
"unicorn/no-unreadable-iife": "error",
|
|
62
|
+
"unicorn/no-useless-promise-resolve-reject": "error",
|
|
63
|
+
"unicorn/no-useless-switch-case": "error",
|
|
64
|
+
"unicorn/prefer-array-flat": "error",
|
|
65
|
+
"unicorn/prefer-array-some": "error",
|
|
66
|
+
"unicorn/prefer-at": "error",
|
|
67
|
+
"unicorn/prefer-blob-reading-methods": "error",
|
|
68
|
+
"unicorn/prefer-code-point": "error",
|
|
69
|
+
"unicorn/prefer-date-now": "error",
|
|
70
|
+
"unicorn/prefer-dom-node-append": "error",
|
|
71
|
+
"unicorn/prefer-dom-node-dataset": "error",
|
|
72
|
+
"unicorn/prefer-dom-node-remove": "error",
|
|
73
|
+
"unicorn/prefer-event-target": "error",
|
|
74
|
+
"unicorn/prefer-math-min-max": "error",
|
|
75
|
+
"unicorn/prefer-math-trunc": "error",
|
|
76
|
+
"unicorn/prefer-native-coercion-functions": "error",
|
|
77
|
+
"unicorn/prefer-prototype-methods": "error",
|
|
78
|
+
"unicorn/prefer-query-selector": "error",
|
|
79
|
+
"unicorn/prefer-regexp-test": "error",
|
|
80
|
+
"unicorn/prefer-string-replace-all": "error",
|
|
81
|
+
"unicorn/prefer-string-slice": "error",
|
|
82
|
+
"unicorn/prefer-top-level-await": "error",
|
|
83
|
+
"unicorn/prefer-type-error": "error",
|
|
84
|
+
"unicorn/require-number-to-fixed-digits-argument": "error",
|
|
85
|
+
// style
|
|
86
|
+
"unicorn/catch-error-name": ["error", { name: "error" }],
|
|
87
|
+
"unicorn/consistent-date-clone": "error",
|
|
88
|
+
"unicorn/consistent-existence-index-check": "error",
|
|
89
|
+
"unicorn/consistent-template-literal-escape": "error",
|
|
90
|
+
"unicorn/empty-brace-spaces": "error",
|
|
91
|
+
"unicorn/error-message": "error",
|
|
92
|
+
"unicorn/no-array-method-this-argument": "error",
|
|
93
|
+
"unicorn/no-await-expression-member": "error",
|
|
94
|
+
"unicorn/no-console-spaces": "error",
|
|
95
|
+
"unicorn/no-unreadable-array-destructuring": "error",
|
|
96
|
+
"unicorn/no-useless-collection-argument": "error",
|
|
97
|
+
"unicorn/no-zero-fractions": "error",
|
|
98
|
+
"unicorn/numeric-separators-style": "error",
|
|
99
|
+
"unicorn/prefer-array-index-of": "error",
|
|
100
|
+
"unicorn/prefer-bigint-literals": "error",
|
|
101
|
+
"unicorn/prefer-class-fields": "error",
|
|
102
|
+
"unicorn/prefer-classlist-toggle": "error",
|
|
103
|
+
"unicorn/prefer-default-parameters": "error",
|
|
104
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
105
|
+
"unicorn/prefer-global-this": "error",
|
|
106
|
+
"unicorn/prefer-includes": "error",
|
|
107
|
+
"unicorn/prefer-keyboard-event-key": "error",
|
|
108
|
+
"unicorn/prefer-logical-operator-over-ternary": "error",
|
|
109
|
+
"unicorn/prefer-modern-dom-apis": "error",
|
|
110
|
+
"unicorn/prefer-negative-index": "error",
|
|
111
|
+
"unicorn/prefer-object-from-entries": "error",
|
|
112
|
+
"unicorn/prefer-optional-catch-binding": "error",
|
|
113
|
+
"unicorn/prefer-reflect-apply": "error",
|
|
114
|
+
"unicorn/prefer-response-static-json": "error",
|
|
115
|
+
"unicorn/prefer-spread": "error",
|
|
116
|
+
"unicorn/prefer-string-raw": "error",
|
|
117
|
+
"unicorn/prefer-string-trim-start-end": "error",
|
|
118
|
+
"unicorn/prefer-structured-clone": "error",
|
|
119
|
+
"unicorn/relative-url-style": "error",
|
|
120
|
+
"unicorn/require-array-join-separator": "error",
|
|
121
|
+
"unicorn/require-module-attributes": "error",
|
|
122
|
+
"unicorn/switch-case-braces": "error",
|
|
123
|
+
"unicorn/switch-case-break-position": "error",
|
|
124
|
+
"unicorn/text-encoding-identifier-case": "error",
|
|
125
|
+
"unicorn/throw-new-error": "error"
|
|
126
|
+
};
|
|
127
|
+
var unicornRulesJsPlugin = {
|
|
128
|
+
"unicornx/isolated-functions": "error",
|
|
129
|
+
"unicornx/no-for-loop": "error",
|
|
130
|
+
"unicornx/no-named-default": "error",
|
|
131
|
+
"unicornx/no-unnecessary-polyfills": "error",
|
|
132
|
+
"unicornx/prefer-export-from": "error",
|
|
133
|
+
"unicornx/prefer-simple-condition-first": "error",
|
|
134
|
+
"unicornx/prefer-single-call": "error",
|
|
135
|
+
"unicornx/prefer-switch": "error",
|
|
136
|
+
"unicornx/template-indent": "error",
|
|
137
|
+
/*
|
|
138
|
+
* Native port exists but only in oxlint's nursery category, which can't be
|
|
139
|
+
* enabled from config, so we run the JS original instead.
|
|
140
|
+
*/
|
|
141
|
+
"unicornx/no-useless-iterator-to-array": "error",
|
|
142
|
+
/*
|
|
143
|
+
* Oxlint's port hardcodes uppercase hexadecimal digits, which fights
|
|
144
|
+
* Prettier's lowercase formatting, so we run the JS original with the
|
|
145
|
+
* lowercase option instead.
|
|
146
|
+
*/
|
|
147
|
+
"unicornx/number-literal-case": ["error", { hexadecimalValue: "lowercase" }]
|
|
148
|
+
};
|
|
149
|
+
var unicornRulesEslint = {
|
|
150
|
+
"unicorn/expiring-todo-comments": "error"
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// src/configs/abbreviations.ts
|
|
154
|
+
var DEFAULT_ABBREVIATION_ALLOW_LIST = [
|
|
155
|
+
"fn",
|
|
156
|
+
"cb",
|
|
157
|
+
"err",
|
|
158
|
+
"prev",
|
|
159
|
+
"props",
|
|
160
|
+
"refs",
|
|
161
|
+
"ref",
|
|
162
|
+
"dev",
|
|
163
|
+
"i",
|
|
164
|
+
"env",
|
|
165
|
+
"arg",
|
|
166
|
+
"args"
|
|
167
|
+
];
|
|
168
|
+
var ABBREVIATION_REPLACEMENTS = {
|
|
169
|
+
ref: false,
|
|
170
|
+
refs: false,
|
|
171
|
+
dev: false,
|
|
172
|
+
dir: false,
|
|
173
|
+
ev: { event: true },
|
|
174
|
+
val: { value: true },
|
|
175
|
+
msg: { message: true },
|
|
176
|
+
el: { element: true },
|
|
177
|
+
elem: { element: true },
|
|
178
|
+
btn: { button: true },
|
|
179
|
+
cb: { callback: true },
|
|
180
|
+
fn: { function: true },
|
|
181
|
+
err: { error: true },
|
|
182
|
+
opts: { options: true },
|
|
183
|
+
cfg: { config: true },
|
|
184
|
+
obj: { object: true },
|
|
185
|
+
arr: { array: true },
|
|
186
|
+
str: { string: true },
|
|
187
|
+
num: { number: true },
|
|
188
|
+
curr: { current: true },
|
|
189
|
+
len: { length: true },
|
|
190
|
+
e: { event: true, error: true }
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// src/configs/javascript.ts
|
|
194
|
+
var jsFileExtensions = ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs"];
|
|
195
|
+
var paddingLineEntries = [
|
|
196
|
+
{
|
|
197
|
+
blankLine: "always",
|
|
198
|
+
prev: "*",
|
|
199
|
+
next: ["block", "block-like", "class", "const", "let"]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
blankLine: "always",
|
|
203
|
+
prev: "block",
|
|
204
|
+
next: "*"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
blankLine: "always",
|
|
208
|
+
prev: ["const"],
|
|
209
|
+
next: "*"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
blankLine: "always",
|
|
213
|
+
prev: ["let"],
|
|
214
|
+
next: "*"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
blankLine: "any",
|
|
218
|
+
prev: ["const"],
|
|
219
|
+
next: ["const"]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
blankLine: "any",
|
|
223
|
+
prev: ["let"],
|
|
224
|
+
next: ["let"]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
blankLine: "always",
|
|
228
|
+
prev: ["let"],
|
|
229
|
+
next: ["const"]
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
blankLine: "always",
|
|
233
|
+
prev: ["const"],
|
|
234
|
+
next: ["let"]
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
blankLine: "always",
|
|
238
|
+
prev: ["singleline-const"],
|
|
239
|
+
next: ["multiline-const"]
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
blankLine: "always",
|
|
243
|
+
prev: ["multiline-const"],
|
|
244
|
+
next: ["singleline-const"]
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
blankLine: "always",
|
|
248
|
+
prev: ["singleline-let"],
|
|
249
|
+
next: ["multiline-let"]
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
blankLine: "always",
|
|
253
|
+
prev: ["multiline-let"],
|
|
254
|
+
next: ["singleline-let"]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
blankLine: "any",
|
|
258
|
+
prev: ["case", "block", "block-like"],
|
|
259
|
+
next: ["case", "default"]
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
blankLine: "any",
|
|
263
|
+
prev: "*",
|
|
264
|
+
next: "break"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
blankLine: "always",
|
|
268
|
+
prev: "if",
|
|
269
|
+
next: "*"
|
|
270
|
+
},
|
|
271
|
+
/*
|
|
272
|
+
* Imports form a block: padded from anything that isn't an import, but
|
|
273
|
+
* consecutive imports can sit together. The same-type rule comes last so it
|
|
274
|
+
* wins over the surrounding `*` rules.
|
|
275
|
+
*/
|
|
276
|
+
{
|
|
277
|
+
blankLine: "always",
|
|
278
|
+
prev: "import",
|
|
279
|
+
next: "*"
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
blankLine: "always",
|
|
283
|
+
prev: "*",
|
|
284
|
+
next: "import"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
blankLine: "any",
|
|
288
|
+
prev: "import",
|
|
289
|
+
next: "import"
|
|
290
|
+
},
|
|
291
|
+
/*
|
|
292
|
+
* Exports form a block: padded from anything that isn't an export, but
|
|
293
|
+
* consecutive exports can sit together. The same-type rule comes last so it
|
|
294
|
+
* wins over the surrounding `*` rules.
|
|
295
|
+
*/
|
|
296
|
+
{
|
|
297
|
+
blankLine: "always",
|
|
298
|
+
prev: "export",
|
|
299
|
+
next: "*"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
blankLine: "always",
|
|
303
|
+
prev: "*",
|
|
304
|
+
next: "export"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
blankLine: "any",
|
|
308
|
+
prev: "export",
|
|
309
|
+
next: "export"
|
|
310
|
+
}
|
|
311
|
+
];
|
|
312
|
+
var jsdocTagLineOptions = ["always", { count: 1, startLines: 1, applyToEndTag: false }];
|
|
313
|
+
function jsRulesOxlint(options = {}) {
|
|
314
|
+
const { preventAbbreviations: preventAbbreviationsOptions } = options;
|
|
315
|
+
const {
|
|
316
|
+
inheritAllowList = true,
|
|
317
|
+
inheritReplacements = true,
|
|
318
|
+
allowList = [],
|
|
319
|
+
replacements = {}
|
|
320
|
+
} = _nullishCoalesce(preventAbbreviationsOptions, () => ( {}));
|
|
321
|
+
return {
|
|
322
|
+
"consistent-return": "error",
|
|
323
|
+
curly: ["error", "all"],
|
|
324
|
+
"arrow-body-style": "off",
|
|
325
|
+
"dot-notation": "error",
|
|
326
|
+
"no-debugger": "warn",
|
|
327
|
+
"no-unused-vars": "off",
|
|
328
|
+
"no-async-promise-executor": "error",
|
|
329
|
+
"no-case-declarations": "error",
|
|
330
|
+
"default-case-last": "error",
|
|
331
|
+
"no-cond-assign": "error",
|
|
332
|
+
"no-dynamic-delete": "off",
|
|
333
|
+
"no-unneeded-ternary": "error",
|
|
334
|
+
"object-shorthand": "error",
|
|
335
|
+
"no-constant-condition": ["error", { checkLoops: false }],
|
|
336
|
+
"@stylistic/padding-line-between-statements": ["error", ...paddingLineEntries],
|
|
337
|
+
"@stylistic/no-trailing-spaces": "error",
|
|
338
|
+
/*
|
|
339
|
+
* Indentation is owned by Prettier. Oxlint's @stylistic/indent port
|
|
340
|
+
* diverges from eslint-stylistic on edge cases (e.g., multiline object
|
|
341
|
+
* args inside ternaries), so we leave the rule off.
|
|
342
|
+
*/
|
|
343
|
+
"@stylistic/indent": "off",
|
|
344
|
+
"@stylistic/no-multiple-empty-lines": ["error", { max: 1 }],
|
|
345
|
+
"@stylistic/multiline-comment-style": ["error", "starred-block"],
|
|
346
|
+
"@stylistic/spaced-comment": [
|
|
347
|
+
"error",
|
|
348
|
+
"always",
|
|
349
|
+
{
|
|
350
|
+
block: { balanced: true }
|
|
351
|
+
}
|
|
352
|
+
],
|
|
353
|
+
"@stylistic/brace-style": ["error", "1tbs"],
|
|
354
|
+
"@stylistic/lines-around-comment": [
|
|
355
|
+
"error",
|
|
356
|
+
{
|
|
357
|
+
beforeBlockComment: true,
|
|
358
|
+
beforeLineComment: true,
|
|
359
|
+
allowBlockStart: true,
|
|
360
|
+
allowBlockEnd: false,
|
|
361
|
+
allowObjectStart: true,
|
|
362
|
+
allowObjectEnd: false,
|
|
363
|
+
allowArrayStart: true,
|
|
364
|
+
allowArrayEnd: true,
|
|
365
|
+
allowClassStart: true,
|
|
366
|
+
allowInterfaceStart: true,
|
|
367
|
+
allowInterfaceEnd: true,
|
|
368
|
+
allowEnumStart: true,
|
|
369
|
+
allowEnumEnd: true,
|
|
370
|
+
allowTypeStart: true,
|
|
371
|
+
allowTypeEnd: false
|
|
372
|
+
}
|
|
373
|
+
],
|
|
374
|
+
// unicorn recommended, split between native oxlint ports and JS originals
|
|
375
|
+
...unicornRulesOxlint,
|
|
376
|
+
...unicornRulesJsPlugin,
|
|
377
|
+
/*
|
|
378
|
+
* Oxlint's built-in `unicorn` / `jsdoc` plugins don't implement these,
|
|
379
|
+
* so we wire the original JS plugins under aliased names (see jsPlugins
|
|
380
|
+
* in `src/oxlint.ts`). Rule IDs use the alias, not the canonical prefix.
|
|
381
|
+
*/
|
|
382
|
+
"unicornx/prevent-abbreviations": [
|
|
383
|
+
"error",
|
|
384
|
+
{
|
|
385
|
+
replacements: inheritReplacements ? { ...ABBREVIATION_REPLACEMENTS, ...replacements } : replacements,
|
|
386
|
+
allowList: Object.fromEntries(
|
|
387
|
+
(inheritAllowList ? [...DEFAULT_ABBREVIATION_ALLOW_LIST, ...allowList] : allowList).map((name) => [
|
|
388
|
+
name,
|
|
389
|
+
true
|
|
390
|
+
])
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
],
|
|
394
|
+
"jsdocx/tag-lines": ["error", ...jsdocTagLineOptions]
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function jsRulesEslint(_options = {}) {
|
|
398
|
+
return {
|
|
399
|
+
"prefer-arrow-callback": "error",
|
|
400
|
+
"no-useless-assignment": "error"
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// src/configs/react.ts
|
|
405
|
+
var reactFileExtensions = ["**/*.jsx", "**/*.tsx"];
|
|
406
|
+
function resolveReactRuleOptions(options = false) {
|
|
407
|
+
if (options === false) {
|
|
408
|
+
return {
|
|
409
|
+
fastRefresh: false,
|
|
410
|
+
performance: false
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (options === true) {
|
|
414
|
+
return {
|
|
415
|
+
fastRefresh: true,
|
|
416
|
+
performance: true
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
fastRefresh: _nullishCoalesce(options.fastRefresh, () => ( true)),
|
|
421
|
+
performance: _nullishCoalesce(options.performance, () => ( true))
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function reactRulesOxlint(options = false) {
|
|
425
|
+
const resolvedOptions = resolveReactRuleOptions(options);
|
|
426
|
+
return {
|
|
427
|
+
"react/jsx-key": "error",
|
|
428
|
+
"react/jsx-no-duplicate-props": "error",
|
|
429
|
+
"react/no-children-prop": "error",
|
|
430
|
+
"react/no-danger-with-children": "error",
|
|
431
|
+
"react/void-dom-elements-no-children": "error",
|
|
432
|
+
"react/no-unknown-property": "error",
|
|
433
|
+
"react/style-prop-object": "error",
|
|
434
|
+
"react/button-has-type": "error",
|
|
435
|
+
"react/checked-requires-onchange-or-readonly": "error",
|
|
436
|
+
"react/forward-ref-uses-ref": "error",
|
|
437
|
+
"react/jsx-props-no-spread-multi": "error",
|
|
438
|
+
"react/jsx-no-script-url": "error",
|
|
439
|
+
"react/jsx-no-target-blank": "error",
|
|
440
|
+
"react/jsx-no-constructed-context-values": "error",
|
|
441
|
+
"react/no-unstable-nested-components": "error",
|
|
442
|
+
"react/no-array-index-key": "warn",
|
|
443
|
+
"react/no-object-type-as-default-prop": "warn",
|
|
444
|
+
"react/iframe-missing-sandbox": "error",
|
|
445
|
+
"react/no-danger": "warn",
|
|
446
|
+
...resolvedOptions.fastRefresh && {
|
|
447
|
+
"react/only-export-components": ["warn", { allowConstantExport: true }]
|
|
448
|
+
},
|
|
449
|
+
...resolvedOptions.performance && {
|
|
450
|
+
"react-perf/jsx-no-new-object-as-prop": "warn",
|
|
451
|
+
"react-perf/jsx-no-new-array-as-prop": "warn",
|
|
452
|
+
"react-perf/jsx-no-new-function-as-prop": "warn",
|
|
453
|
+
"react-perf/jsx-no-jsx-as-prop": "warn"
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
// src/configs/typescript.ts
|
|
459
|
+
var tsFileExtensions = ["**/*.ts", "**/*.tsx", "**/*.mts", "**/*.cts"];
|
|
460
|
+
var tsIgnoreDescriptionFormat = String.raw`^: TS\d+ because .+$`;
|
|
461
|
+
function tsRulesOxlint(options = {}) {
|
|
462
|
+
return {
|
|
463
|
+
...jsRulesOxlint(options),
|
|
464
|
+
/**
|
|
465
|
+
* Oxlint exposes typescript-eslint rules under its own `typescript/`
|
|
466
|
+
* namespace, so rule ids are prefixed `typescript/` rather than
|
|
467
|
+
* `@typescript-eslint/`.
|
|
468
|
+
*/
|
|
469
|
+
"typescript/no-unused-vars": [
|
|
470
|
+
"error",
|
|
471
|
+
{
|
|
472
|
+
argsIgnorePattern: "^_",
|
|
473
|
+
ignoreRestSiblings: true
|
|
474
|
+
}
|
|
475
|
+
],
|
|
476
|
+
"typescript/no-unnecessary-condition": "error",
|
|
477
|
+
"typescript/no-floating-promises": "error",
|
|
478
|
+
"typescript/no-non-null-assertion": "error",
|
|
479
|
+
"typescript/no-empty-function": "off",
|
|
480
|
+
"typescript/no-explicit-any": "off",
|
|
481
|
+
"typescript/no-base-to-string": "off",
|
|
482
|
+
"typescript/no-dynamic-delete": "off",
|
|
483
|
+
"typescript/no-extra-non-null-assertion": "error",
|
|
484
|
+
"typescript/no-non-null-asserted-optional-chain": "error",
|
|
485
|
+
"typescript/explicit-module-boundary-types": "off",
|
|
486
|
+
"typescript/ban-ts-comment": [
|
|
487
|
+
"error",
|
|
488
|
+
{
|
|
489
|
+
"ts-expect-error": { descriptionFormat: tsIgnoreDescriptionFormat },
|
|
490
|
+
"ts-ignore": { descriptionFormat: tsIgnoreDescriptionFormat },
|
|
491
|
+
"ts-nocheck": true,
|
|
492
|
+
"ts-check": false
|
|
493
|
+
}
|
|
494
|
+
],
|
|
495
|
+
"@stylistic/type-annotation-spacing": "error",
|
|
496
|
+
// comment handling conflicts with the padding-line heuristics
|
|
497
|
+
"@stylistic/lines-around-comment": "off"
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
function tsRulesEslint(options = {}) {
|
|
501
|
+
return {
|
|
502
|
+
...getESLintNamingConventionRule(options.namingConvention),
|
|
503
|
+
"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
|
|
504
|
+
"@typescript-eslint/no-dynamic-delete": "off",
|
|
505
|
+
"@typescript-eslint/array-type": "off",
|
|
506
|
+
"@typescript-eslint/require-await": "off",
|
|
507
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
508
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
509
|
+
"@typescript-eslint/prefer-nullish-coalescing": [
|
|
510
|
+
"error",
|
|
511
|
+
{
|
|
512
|
+
ignorePrimitives: true
|
|
513
|
+
}
|
|
514
|
+
],
|
|
515
|
+
"@typescript-eslint/no-unused-vars": [
|
|
516
|
+
"error",
|
|
517
|
+
{
|
|
518
|
+
argsIgnorePattern: "^_",
|
|
519
|
+
varsIgnorePattern: "^_",
|
|
520
|
+
caughtErrorsIgnorePattern: "^_",
|
|
521
|
+
destructuredArrayIgnorePattern: "^_",
|
|
522
|
+
ignoreRestSiblings: true
|
|
523
|
+
}
|
|
524
|
+
]
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
function getESLintNamingConventionRule(extensions) {
|
|
528
|
+
const oxlintRules = getNamingConventionRule(extensions);
|
|
529
|
+
return {
|
|
530
|
+
"@typescript-eslint/naming-convention": oxlintRules["typescript/naming-convention"]
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
function getNamingConventionRule(extensions) {
|
|
534
|
+
return {
|
|
535
|
+
"typescript/naming-convention": [
|
|
536
|
+
"error",
|
|
537
|
+
{
|
|
538
|
+
selector: ["variable"],
|
|
539
|
+
format: mergeFormat(["camelCase", "UPPER_CASE", "PascalCase"], _optionalChain([extensions, 'optionalAccess', _ => _.variable])),
|
|
540
|
+
leadingUnderscore: "allowSingleOrDouble",
|
|
541
|
+
trailingUnderscore: "forbid",
|
|
542
|
+
filter: {
|
|
543
|
+
regex: generateFilterRegex(["__dirname"], _optionalChain([extensions, 'optionalAccess', _2 => _2.variable, 'optionalAccess', _3 => _3.exceptions])),
|
|
544
|
+
match: false
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
selector: ["function"],
|
|
549
|
+
format: mergeFormat(["camelCase", "UPPER_CASE", "PascalCase"], _optionalChain([extensions, 'optionalAccess', _4 => _4.function])),
|
|
550
|
+
leadingUnderscore: "allowSingleOrDouble",
|
|
551
|
+
trailingUnderscore: "forbid",
|
|
552
|
+
filter: {
|
|
553
|
+
regex: generateFilterRegex(["__dirname"], _optionalChain([extensions, 'optionalAccess', _5 => _5.function, 'optionalAccess', _6 => _6.exceptions])),
|
|
554
|
+
match: false
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
selector: "parameter",
|
|
559
|
+
format: mergeFormat(["camelCase", "UPPER_CASE", "PascalCase"], _optionalChain([extensions, 'optionalAccess', _7 => _7.parameter])),
|
|
560
|
+
leadingUnderscore: "allow",
|
|
561
|
+
..._optionalChain([extensions, 'optionalAccess', _8 => _8.parameter, 'optionalAccess', _9 => _9.exceptions, 'optionalAccess', _10 => _10.length]) && {
|
|
562
|
+
filter: {
|
|
563
|
+
regex: generateFilterRegex([], extensions.parameter.exceptions),
|
|
564
|
+
match: false
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
selector: "typeLike",
|
|
570
|
+
format: mergeFormat(["PascalCase"], _optionalChain([extensions, 'optionalAccess', _11 => _11.typeLike])),
|
|
571
|
+
..._optionalChain([extensions, 'optionalAccess', _12 => _12.typeLike, 'optionalAccess', _13 => _13.exceptions, 'optionalAccess', _14 => _14.length]) && {
|
|
572
|
+
filter: {
|
|
573
|
+
regex: generateFilterRegex([], extensions.typeLike.exceptions),
|
|
574
|
+
match: false
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
selector: "memberLike",
|
|
580
|
+
modifiers: ["private"],
|
|
581
|
+
format: mergeFormat(["camelCase", "PascalCase"], _optionalChain([extensions, 'optionalAccess', _15 => _15.memberLike])),
|
|
582
|
+
leadingUnderscore: "require",
|
|
583
|
+
..._optionalChain([extensions, 'optionalAccess', _16 => _16.memberLike, 'optionalAccess', _17 => _17.exceptions, 'optionalAccess', _18 => _18.length]) && {
|
|
584
|
+
filter: {
|
|
585
|
+
regex: generateFilterRegex([], extensions.memberLike.exceptions),
|
|
586
|
+
match: false
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
]
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
function mergeFormat(defaults, extensions) {
|
|
594
|
+
return [.../* @__PURE__ */ new Set([..._nullishCoalesce(_optionalChain([extensions, 'optionalAccess', _19 => _19.inheritFormat]), () => ( true)) ? defaults : [], ..._nullishCoalesce(_optionalChain([extensions, 'optionalAccess', _20 => _20.format]), () => ( []))])];
|
|
595
|
+
}
|
|
596
|
+
function generateFilterRegex(defaults, extensions = []) {
|
|
597
|
+
return `^(${[...defaults, ...extensions].join("|")})$`;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
exports.unicornRulesEslint = unicornRulesEslint; exports.jsFileExtensions = jsFileExtensions; exports.jsRulesOxlint = jsRulesOxlint; exports.jsRulesEslint = jsRulesEslint; exports.reactFileExtensions = reactFileExtensions; exports.resolveReactRuleOptions = resolveReactRuleOptions; exports.reactRulesOxlint = reactRulesOxlint; exports.tsFileExtensions = tsFileExtensions; exports.tsRulesOxlint = tsRulesOxlint; exports.tsRulesEslint = tsRulesEslint;
|
|
612
|
+
//# sourceMappingURL=chunk-QDQNT3NA.cjs.map
|