@zhangyu1818/oxlint-config 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/dist/index.js ADDED
@@ -0,0 +1,989 @@
1
+ // src/oxlint/index.ts
2
+ import { isPackageExists as isPackageExists2 } from "local-pkg";
3
+
4
+ // src/shared/ignore-patterns.ts
5
+ var defaultIgnorePatterns = [
6
+ "**/node_modules",
7
+ "**/dist",
8
+ "**/package-lock.json",
9
+ "**/yarn.lock",
10
+ "**/pnpm-lock.yaml",
11
+ "**/bun.lockb",
12
+ "**/output",
13
+ "**/coverage",
14
+ "**/temp",
15
+ "**/.temp",
16
+ "**/tmp",
17
+ "**/.tmp",
18
+ "**/.history",
19
+ "**/.vitepress/cache",
20
+ "**/.nuxt",
21
+ "**/.next",
22
+ "**/.vercel",
23
+ "**/.changeset",
24
+ "**/.idea",
25
+ "**/.cache",
26
+ "**/.output",
27
+ "**/.vite-inspect",
28
+ "**/.yarn",
29
+ "**/CHANGELOG*.md",
30
+ "**/*.min.*",
31
+ "**/LICENSE*",
32
+ "**/__snapshots__",
33
+ "**/auto-import.d.ts",
34
+ "**/auto-imports.d.ts",
35
+ "**/components.d.ts",
36
+ "tests/fixtures/**"
37
+ ];
38
+
39
+ // src/oxlint/presets/imports.ts
40
+ var importRules = {
41
+ "import/first": "error",
42
+ "import/no-duplicates": ["error", { "prefer-inline": true }],
43
+ "import/no-mutable-exports": "error",
44
+ "import/no-named-default": "error",
45
+ "import/no-self-import": "error",
46
+ "import/no-webpack-loader-syntax": "error"
47
+ };
48
+
49
+ // src/oxlint/presets/javascript.ts
50
+ var javascriptRules = {
51
+ "accessor-pairs": [
52
+ "error",
53
+ {
54
+ enforceForClassMembers: true,
55
+ setWithoutGet: true
56
+ }
57
+ ],
58
+ "array-callback-return": "error",
59
+ "block-scoped-var": "error",
60
+ "constructor-super": "error",
61
+ "default-case-last": "error",
62
+ eqeqeq: ["error", "smart"],
63
+ "new-cap": [
64
+ "error",
65
+ {
66
+ capIsNew: false,
67
+ newIsCap: true,
68
+ properties: true
69
+ }
70
+ ],
71
+ "no-alert": "error",
72
+ "no-array-constructor": "error",
73
+ "no-async-promise-executor": "error",
74
+ "no-caller": "error",
75
+ "no-case-declarations": "error",
76
+ "no-class-assign": "error",
77
+ "no-compare-neg-zero": "error",
78
+ "no-cond-assign": ["error", "always"],
79
+ "no-console": [
80
+ "error",
81
+ {
82
+ allow: ["warn", "error"]
83
+ }
84
+ ],
85
+ "no-const-assign": "error",
86
+ "no-control-regex": "error",
87
+ "no-debugger": "error",
88
+ "no-delete-var": "error",
89
+ "no-dupe-class-members": "error",
90
+ "no-dupe-keys": "error",
91
+ "no-duplicate-case": "error",
92
+ "no-empty": ["error", { allowEmptyCatch: true }],
93
+ "no-empty-character-class": "error",
94
+ "no-empty-pattern": "error",
95
+ "no-eval": "error",
96
+ "no-ex-assign": "error",
97
+ "no-extend-native": "error",
98
+ "no-extra-bind": "error",
99
+ "no-extra-boolean-cast": "error",
100
+ "no-fallthrough": "error",
101
+ "no-func-assign": "error",
102
+ "no-global-assign": "error",
103
+ "no-import-assign": "error",
104
+ "no-invalid-regexp": "error",
105
+ "no-irregular-whitespace": "error",
106
+ "no-iterator": "error",
107
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
108
+ "no-lone-blocks": "error",
109
+ "no-loss-of-precision": "error",
110
+ "no-misleading-character-class": "error",
111
+ "no-multi-str": "error",
112
+ "no-new": "error",
113
+ "no-new-func": "error",
114
+ "no-new-native-nonconstructor": "error",
115
+ "no-new-wrappers": "error",
116
+ "no-obj-calls": "error",
117
+ "no-proto": "error",
118
+ "no-prototype-builtins": "error",
119
+ "no-redeclare": ["error", { builtinGlobals: false }],
120
+ "no-regex-spaces": "error",
121
+ "no-restricted-globals": [
122
+ "error",
123
+ {
124
+ message: "Use `globalThis` instead.",
125
+ name: "global"
126
+ },
127
+ {
128
+ message: "Use `globalThis` instead.",
129
+ name: "self"
130
+ }
131
+ ],
132
+ "no-self-assign": ["error", { props: true }],
133
+ "no-self-compare": "error",
134
+ "no-sequences": "error",
135
+ "no-shadow-restricted-names": "error",
136
+ "no-sparse-arrays": "error",
137
+ "no-template-curly-in-string": "error",
138
+ "no-this-before-super": "error",
139
+ "no-throw-literal": "error",
140
+ "no-undef": "error",
141
+ "no-unmodified-loop-condition": "error",
142
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
143
+ "no-unreachable": "error",
144
+ "no-unsafe-finally": "error",
145
+ "no-unsafe-negation": "error",
146
+ "no-unused-expressions": [
147
+ "error",
148
+ {
149
+ allowTaggedTemplates: true,
150
+ allowTernary: true
151
+ }
152
+ ],
153
+ "no-unused-vars": [
154
+ "error",
155
+ {
156
+ args: "none",
157
+ caughtErrors: "none",
158
+ vars: "all"
159
+ }
160
+ ],
161
+ "no-use-before-define": [
162
+ "error",
163
+ {
164
+ classes: false,
165
+ functions: false,
166
+ variables: true
167
+ }
168
+ ],
169
+ "no-useless-backreference": "error",
170
+ "no-useless-call": "error",
171
+ "no-useless-catch": "error",
172
+ "no-useless-computed-key": "error",
173
+ "no-useless-constructor": "error",
174
+ "no-useless-rename": "error",
175
+ "no-useless-return": "error",
176
+ "no-var": "error",
177
+ "no-with": "error",
178
+ "object-shorthand": [
179
+ "error",
180
+ "always",
181
+ {
182
+ avoidExplicitReturnArrows: true,
183
+ avoidQuotes: true
184
+ }
185
+ ],
186
+ "prefer-const": ["error", { destructuring: "all" }],
187
+ "prefer-exponentiation-operator": "error",
188
+ "prefer-promise-reject-errors": "error",
189
+ "prefer-rest-params": "error",
190
+ "prefer-spread": "error",
191
+ "prefer-template": "error",
192
+ "symbol-description": "error",
193
+ "unicode-bom": ["error", "never"],
194
+ "use-isnan": [
195
+ "error",
196
+ {
197
+ enforceForIndexOf: true,
198
+ enforceForSwitchCase: true
199
+ }
200
+ ],
201
+ "valid-typeof": ["error", { requireStringLiterals: true }],
202
+ "vars-on-top": "error",
203
+ yoda: ["error", "never"]
204
+ };
205
+
206
+ // src/oxlint/presets/next.ts
207
+ var nextjsRules = {
208
+ "nextjs/google-font-display": "warn",
209
+ "nextjs/google-font-preconnect": "warn",
210
+ "nextjs/inline-script-id": "error",
211
+ "nextjs/next-script-for-ga": "warn",
212
+ "nextjs/no-assign-module-variable": "error",
213
+ "nextjs/no-async-client-component": "warn",
214
+ "nextjs/no-before-interactive-script-outside-document": "warn",
215
+ "nextjs/no-css-tags": "warn",
216
+ "nextjs/no-document-import-in-page": "error",
217
+ "nextjs/no-duplicate-head": "error",
218
+ "nextjs/no-head-element": "warn",
219
+ "nextjs/no-head-import-in-document": "error",
220
+ "nextjs/no-html-link-for-pages": "off",
221
+ "nextjs/no-img-element": "warn",
222
+ "nextjs/no-page-custom-font": "warn",
223
+ "nextjs/no-script-component-in-head": "error",
224
+ "nextjs/no-styled-jsx-in-document": "warn",
225
+ "nextjs/no-sync-scripts": "error",
226
+ "nextjs/no-title-in-document-head": "warn",
227
+ "nextjs/no-typos": "warn",
228
+ "nextjs/no-unwanted-polyfillio": "warn"
229
+ };
230
+
231
+ // src/oxlint/presets/node.ts
232
+ var nodeRules = {
233
+ "node/handle-callback-err": ["error", "^(err|error)$"],
234
+ "node/no-exports-assign": "error",
235
+ "node/no-new-require": "error",
236
+ "node/no-path-concat": "error"
237
+ };
238
+
239
+ // src/oxlint/presets/react.ts
240
+ import { isPackageExists } from "local-pkg";
241
+ var jsxA11yRules = {
242
+ "jsx-a11y/alt-text": "error",
243
+ "jsx-a11y/anchor-ambiguous-text": "off",
244
+ "jsx-a11y/anchor-has-content": "error",
245
+ "jsx-a11y/anchor-is-valid": "error",
246
+ "jsx-a11y/aria-activedescendant-has-tabindex": "error",
247
+ "jsx-a11y/aria-props": "error",
248
+ "jsx-a11y/aria-proptypes": "error",
249
+ "jsx-a11y/aria-role": "error",
250
+ "jsx-a11y/aria-unsupported-elements": "error",
251
+ "jsx-a11y/autocomplete-valid": "error",
252
+ "jsx-a11y/click-events-have-key-events": "error",
253
+ "jsx-a11y/heading-has-content": "error",
254
+ "jsx-a11y/html-has-lang": "error",
255
+ "jsx-a11y/iframe-has-title": "error",
256
+ "jsx-a11y/img-redundant-alt": "error",
257
+ "jsx-a11y/label-has-associated-control": "error",
258
+ "jsx-a11y/media-has-caption": "error",
259
+ "jsx-a11y/mouse-events-have-key-events": "error",
260
+ "jsx-a11y/no-access-key": "error",
261
+ "jsx-a11y/no-autofocus": "error",
262
+ "jsx-a11y/no-distracting-elements": "error",
263
+ "jsx-a11y/no-noninteractive-tabindex": [
264
+ "error",
265
+ {
266
+ allowExpressionValues: true,
267
+ roles: ["tabpanel"],
268
+ tags: []
269
+ }
270
+ ],
271
+ "jsx-a11y/no-redundant-roles": "error",
272
+ "jsx-a11y/no-static-element-interactions": [
273
+ "error",
274
+ {
275
+ allowExpressionValues: true,
276
+ handlers: [
277
+ "onClick",
278
+ "onMouseDown",
279
+ "onMouseUp",
280
+ "onKeyPress",
281
+ "onKeyDown",
282
+ "onKeyUp"
283
+ ]
284
+ }
285
+ ],
286
+ "jsx-a11y/role-has-required-aria-props": "error",
287
+ "jsx-a11y/role-supports-aria-props": "error",
288
+ "jsx-a11y/scope": "error",
289
+ "jsx-a11y/tabindex-no-positive": "error"
290
+ };
291
+ var baseReactRules = {
292
+ "react/exhaustive-deps": "warn",
293
+ "react/jsx-boolean-value": "error",
294
+ "react/jsx-curly-brace-presence": [
295
+ "error",
296
+ {
297
+ children: "never",
298
+ propElementValues: "always",
299
+ props: "never"
300
+ }
301
+ ],
302
+ "react/jsx-key": "error",
303
+ "react/jsx-no-comment-textnodes": "error",
304
+ "react/jsx-no-duplicate-props": "error",
305
+ "react/jsx-no-target-blank": "error",
306
+ "react/jsx-no-undef": "error",
307
+ "react/jsx-no-useless-fragment": "error",
308
+ "react/no-array-index-key": "warn",
309
+ "react/no-children-prop": "error",
310
+ "react/no-danger-with-children": "error",
311
+ "react/no-direct-mutation-state": "error",
312
+ "react/no-find-dom-node": "error",
313
+ "react/no-is-mounted": "error",
314
+ "react/no-render-return-value": "error",
315
+ "react/no-string-refs": "error",
316
+ "react/no-unknown-property": "error",
317
+ "react/no-unescaped-entities": "error",
318
+ "react/react-in-jsx-scope": "off",
319
+ "react/require-render-return": "error",
320
+ "react/rules-of-hooks": "error",
321
+ "react/self-closing-comp": [
322
+ "error",
323
+ {
324
+ component: true,
325
+ html: true
326
+ }
327
+ ],
328
+ "react/void-dom-elements-no-children": "error"
329
+ };
330
+ function createReactRules(options, nextEnabled) {
331
+ const framework = options.framework ?? {};
332
+ const next = framework.next ?? nextEnabled;
333
+ const vite = framework.vite ?? isPackageExists("vite");
334
+ return {
335
+ ...baseReactRules,
336
+ "react/only-export-components": [
337
+ "warn",
338
+ {
339
+ allowConstantExport: vite,
340
+ allowExportNames: next ? [
341
+ "dynamic",
342
+ "dynamicParams",
343
+ "revalidate",
344
+ "fetchCache",
345
+ "runtime",
346
+ "preferredRegion",
347
+ "maxDuration",
348
+ "generateStaticParams",
349
+ "metadata",
350
+ "generateMetadata",
351
+ "viewport",
352
+ "generateViewport"
353
+ ] : []
354
+ }
355
+ ]
356
+ };
357
+ }
358
+
359
+ // src/oxlint/presets/react-agent-rules.ts
360
+ import { existsSync } from "fs";
361
+ import { fileURLToPath } from "url";
362
+ function resolveReactAgentRulesPluginPath() {
363
+ const sourcePluginPath = fileURLToPath(
364
+ new URL("../../react-agent-rules.ts", import.meta.url)
365
+ );
366
+ if (existsSync(sourcePluginPath)) {
367
+ return sourcePluginPath;
368
+ }
369
+ return fileURLToPath(new URL("./react-agent-rules.js", import.meta.url));
370
+ }
371
+ var reactAgentRulesPlugin = resolveReactAgentRulesPluginPath();
372
+ var reactAgentRules = {
373
+ "react-agent-rules/effect-empty-deps-only": "error",
374
+ "react-agent-rules/no-forward-ref": "error",
375
+ "react-agent-rules/no-manual-memoization": "error"
376
+ };
377
+
378
+ // src/oxlint/presets/test.ts
379
+ var vitestRules = {
380
+ "no-unused-expressions": "off",
381
+ "vitest/expect-expect": "error",
382
+ "vitest/no-commented-out-tests": "error",
383
+ "vitest/no-conditional-expect": "error",
384
+ "vitest/no-disabled-tests": "warn",
385
+ "vitest/no-focused-tests": "error",
386
+ "vitest/no-identical-title": "error",
387
+ "vitest/no-import-node-test": "error",
388
+ "vitest/no-interpolation-in-snapshots": "error",
389
+ "vitest/no-mocks-import": "error",
390
+ "vitest/no-standalone-expect": "error",
391
+ "vitest/no-unneeded-async-expect-function": "error",
392
+ "vitest/prefer-called-exactly-once-with": "error",
393
+ "vitest/require-local-test-context-for-concurrent-snapshots": "error",
394
+ "vitest/valid-describe-callback": "error",
395
+ "vitest/valid-expect": "error",
396
+ "vitest/valid-expect-in-promise": "error",
397
+ "vitest/valid-title": "error"
398
+ };
399
+
400
+ // src/oxlint/presets/typescript.ts
401
+ var typeScriptRules = {
402
+ "no-throw-literal": "off",
403
+ "no-undef": "off",
404
+ "no-unused-vars": "error",
405
+ "typescript/adjacent-overload-signatures": "off",
406
+ "typescript/array-type": "error",
407
+ "typescript/await-thenable": "warn",
408
+ "typescript/ban-ts-comment": [
409
+ "error",
410
+ {
411
+ minimumDescriptionLength: 3,
412
+ "ts-check": false,
413
+ "ts-expect-error": "allow-with-description",
414
+ "ts-ignore": true,
415
+ "ts-nocheck": true
416
+ }
417
+ ],
418
+ "typescript/consistent-generic-constructors": "error",
419
+ "typescript/consistent-indexed-object-style": "error",
420
+ "typescript/consistent-type-definitions": "warn",
421
+ "typescript/consistent-type-exports": [
422
+ "error",
423
+ {
424
+ fixMixedExportsWithInlineTypeSpecifier: true
425
+ }
426
+ ],
427
+ "typescript/consistent-type-imports": [
428
+ "error",
429
+ {
430
+ disallowTypeAnnotations: false,
431
+ fixStyle: "separate-type-imports",
432
+ prefer: "type-imports"
433
+ }
434
+ ],
435
+ "typescript/dot-notation": ["error", { allowKeywords: true }],
436
+ "typescript/no-implied-eval": "error",
437
+ "typescript/no-array-delete": "error",
438
+ "typescript/no-base-to-string": "error",
439
+ "typescript/no-duplicate-enum-values": "error",
440
+ "typescript/no-duplicate-type-constituents": "error",
441
+ "typescript/no-dynamic-delete": "error",
442
+ "typescript/no-empty-interface": "error",
443
+ "typescript/no-empty-object-type": "error",
444
+ "typescript/no-explicit-any": "warn",
445
+ "typescript/no-extra-non-null-assertion": "error",
446
+ "typescript/no-extraneous-class": "error",
447
+ "typescript/no-for-in-array": "error",
448
+ "typescript/no-import-type-side-effects": "error",
449
+ "typescript/no-invalid-void-type": "error",
450
+ "typescript/no-meaningless-void-operator": "error",
451
+ "typescript/no-misused-new": "error",
452
+ "typescript/no-misused-promises": "error",
453
+ "typescript/no-mixed-enums": "error",
454
+ "typescript/no-namespace": "error",
455
+ "typescript/no-non-null-asserted-nullish-coalescing": "error",
456
+ "typescript/no-non-null-asserted-optional-chain": "error",
457
+ "typescript/no-non-null-assertion": "off",
458
+ "typescript/no-redundant-type-constituents": "error",
459
+ "typescript/no-this-alias": "error",
460
+ "typescript/no-unnecessary-boolean-literal-compare": "error",
461
+ "typescript/no-unnecessary-condition": "error",
462
+ "typescript/no-unnecessary-template-expression": "error",
463
+ "typescript/no-unnecessary-type-arguments": "error",
464
+ "typescript/no-unnecessary-type-assertion": "error",
465
+ "typescript/no-unnecessary-type-constraint": "error",
466
+ "typescript/no-unsafe-declaration-merging": "error",
467
+ "typescript/no-unsafe-function-type": "error",
468
+ "typescript/no-useless-empty-export": "error",
469
+ "typescript/no-var-requires": "error",
470
+ "typescript/no-wrapper-object-types": "error",
471
+ "typescript/non-nullable-type-assertion-style": "error",
472
+ "typescript/only-throw-error": "error",
473
+ "typescript/prefer-as-const": "error",
474
+ "typescript/prefer-literal-enum-member": "error",
475
+ "typescript/prefer-optional-chain": "error",
476
+ "typescript/triple-slash-reference": "warn",
477
+ "typescript/unified-signatures": "error"
478
+ };
479
+
480
+ // src/oxlint/presets/unicorn.ts
481
+ var unicornRules = {
482
+ "unicorn/consistent-empty-array-spread": "error",
483
+ "unicorn/consistent-function-scoping": "error",
484
+ "unicorn/error-message": "error",
485
+ "unicorn/escape-case": "error",
486
+ "unicorn/explicit-length-check": ["error", { "non-zero": "not-equal" }],
487
+ "unicorn/new-for-builtins": "error",
488
+ "unicorn/no-anonymous-default-export": "error",
489
+ "unicorn/no-await-expression-member": "error",
490
+ "unicorn/no-await-in-promise-methods": "error",
491
+ "unicorn/no-instanceof-builtins": "error",
492
+ "unicorn/no-new-array": "error",
493
+ "unicorn/no-new-buffer": "error",
494
+ "unicorn/no-useless-length-check": "error",
495
+ "unicorn/no-useless-spread": "error",
496
+ "unicorn/prefer-dom-node-text-content": "error",
497
+ "unicorn/prefer-includes": "error",
498
+ "unicorn/prefer-modern-dom-apis": "error",
499
+ "unicorn/prefer-node-protocol": "error",
500
+ "unicorn/prefer-number-properties": "error",
501
+ "unicorn/prefer-query-selector": "error",
502
+ "unicorn/prefer-string-raw": "error",
503
+ "unicorn/prefer-string-starts-ends-with": "error",
504
+ "unicorn/prefer-type-error": "error",
505
+ "unicorn/throw-new-error": "error"
506
+ };
507
+
508
+ // src/shared/utils.ts
509
+ function resolvePreset(preset, defaultEnabled) {
510
+ if (typeof preset === "boolean" || preset == null) {
511
+ return {
512
+ enabled: preset ?? defaultEnabled,
513
+ options: void 0
514
+ };
515
+ }
516
+ return {
517
+ enabled: preset.enabled ?? true,
518
+ options: preset.options
519
+ };
520
+ }
521
+ function dedupe(values) {
522
+ return [...new Set(values)];
523
+ }
524
+
525
+ // src/oxlint/shared.ts
526
+ var scriptFiles = [
527
+ "scripts/**/*.js",
528
+ "scripts/**/*.mjs",
529
+ "scripts/**/*.cjs",
530
+ "scripts/**/*.jsx",
531
+ "scripts/**/*.ts",
532
+ "scripts/**/*.mts",
533
+ "scripts/**/*.cts",
534
+ "scripts/**/*.tsx",
535
+ "cli.js",
536
+ "cli.mjs",
537
+ "cli.cjs",
538
+ "cli.jsx",
539
+ "cli.ts",
540
+ "cli.mts",
541
+ "cli.cts",
542
+ "cli.tsx"
543
+ ];
544
+ var tsFiles = [
545
+ "**/*.ts",
546
+ "**/*.mts",
547
+ "**/*.cts",
548
+ "**/*.tsx",
549
+ "**/*.mtsx",
550
+ "**/*.ctsx"
551
+ ];
552
+ var sourceFiles = [
553
+ "**/*.js",
554
+ "**/*.mjs",
555
+ "**/*.cjs",
556
+ "**/*.jsx",
557
+ "**/*.ts",
558
+ "**/*.mts",
559
+ "**/*.cts",
560
+ "**/*.tsx",
561
+ "**/*.mtsx",
562
+ "**/*.ctsx"
563
+ ];
564
+ var componentFiles = ["**/*.jsx", "**/*.tsx", "**/*.mtsx", "**/*.ctsx"];
565
+ var dtsFiles = ["**/*.d.ts", "**/*.d.mts", "**/*.d.cts"];
566
+ var jsRequireFiles = ["**/*.js", "**/*.cjs"];
567
+ var testFiles = [
568
+ "**/__tests__/**/*.js",
569
+ "**/__tests__/**/*.mjs",
570
+ "**/__tests__/**/*.cjs",
571
+ "**/__tests__/**/*.jsx",
572
+ "**/__tests__/**/*.ts",
573
+ "**/__tests__/**/*.mts",
574
+ "**/__tests__/**/*.cts",
575
+ "**/__tests__/**/*.tsx",
576
+ "**/__tests__/**/*.mtsx",
577
+ "**/__tests__/**/*.ctsx",
578
+ "**/*.spec.js",
579
+ "**/*.spec.mjs",
580
+ "**/*.spec.cjs",
581
+ "**/*.spec.jsx",
582
+ "**/*.spec.ts",
583
+ "**/*.spec.mts",
584
+ "**/*.spec.cts",
585
+ "**/*.spec.tsx",
586
+ "**/*.spec.mtsx",
587
+ "**/*.spec.ctsx",
588
+ "**/*.test.js",
589
+ "**/*.test.mjs",
590
+ "**/*.test.cjs",
591
+ "**/*.test.jsx",
592
+ "**/*.test.ts",
593
+ "**/*.test.mts",
594
+ "**/*.test.cts",
595
+ "**/*.test.tsx",
596
+ "**/*.test.mtsx",
597
+ "**/*.test.ctsx",
598
+ "**/*.bench.js",
599
+ "**/*.bench.mjs",
600
+ "**/*.bench.cjs",
601
+ "**/*.bench.jsx",
602
+ "**/*.bench.ts",
603
+ "**/*.bench.mts",
604
+ "**/*.bench.cts",
605
+ "**/*.bench.tsx",
606
+ "**/*.bench.mtsx",
607
+ "**/*.bench.ctsx",
608
+ "**/*.benchmark.js",
609
+ "**/*.benchmark.mjs",
610
+ "**/*.benchmark.cjs",
611
+ "**/*.benchmark.jsx",
612
+ "**/*.benchmark.ts",
613
+ "**/*.benchmark.mts",
614
+ "**/*.benchmark.cts",
615
+ "**/*.benchmark.tsx",
616
+ "**/*.benchmark.mtsx",
617
+ "**/*.benchmark.ctsx"
618
+ ];
619
+ function resolveRulePreset(preset, defaultEnabled) {
620
+ const resolved = resolvePreset(preset, defaultEnabled);
621
+ return {
622
+ ...resolved,
623
+ rules: typeof preset === "boolean" || preset == null ? {} : preset.rules ?? {}
624
+ };
625
+ }
626
+ function resolveIgnorePreset(preset, defaultEnabled) {
627
+ if (typeof preset === "boolean" || preset == null) {
628
+ return {
629
+ enabled: preset ?? defaultEnabled,
630
+ patterns: []
631
+ };
632
+ }
633
+ return {
634
+ enabled: preset.enabled ?? defaultEnabled,
635
+ patterns: preset.patterns ?? []
636
+ };
637
+ }
638
+ function mergeRules(...entries) {
639
+ return Object.assign({}, ...entries);
640
+ }
641
+ function appendPlugin(plugins, plugin) {
642
+ if (!plugins.includes(plugin)) {
643
+ plugins.push(plugin);
644
+ }
645
+ }
646
+ function pruneOverride(override) {
647
+ const result = {
648
+ files: override.files
649
+ };
650
+ if (override.env && Object.keys(override.env).length !== 0) {
651
+ result.env = override.env;
652
+ }
653
+ if (override.jsPlugins && override.jsPlugins.length !== 0) {
654
+ result.jsPlugins = override.jsPlugins;
655
+ }
656
+ if (override.plugins && override.plugins.length !== 0) {
657
+ result.plugins = override.plugins;
658
+ }
659
+ if (override.rules && Object.keys(override.rules).length !== 0) {
660
+ result.rules = override.rules;
661
+ }
662
+ return result.rules || result.plugins || result.jsPlugins || result.env ? result : null;
663
+ }
664
+
665
+ // src/oxlint/index.ts
666
+ var defaultOxlintPresets = {
667
+ ignores: true,
668
+ imports: true,
669
+ javascript: true,
670
+ next: isPackageExists2("next"),
671
+ node: false,
672
+ react: isPackageExists2("react"),
673
+ reactAgentRules: isPackageExists2("react"),
674
+ test: isPackageExists2("vitest"),
675
+ typescript: isPackageExists2("typescript"),
676
+ unicorn: true
677
+ };
678
+ function defineOxlintConfig(options = {}) {
679
+ const presets = {
680
+ ...defaultOxlintPresets,
681
+ ...options.presets
682
+ };
683
+ const ignorePreset = resolveIgnorePreset(presets.ignores, true);
684
+ const importPreset = resolveRulePreset(presets.imports, true);
685
+ const javascriptPreset = resolveRulePreset(presets.javascript, true);
686
+ const nextPreset = resolveRulePreset(presets.next, defaultOxlintPresets.next);
687
+ const nodePreset = resolveRulePreset(presets.node, false);
688
+ const reactPreset = resolveRulePreset(
689
+ presets.react,
690
+ defaultOxlintPresets.react
691
+ );
692
+ const reactAgentRulesPreset = resolveRulePreset(presets.reactAgentRules, false);
693
+ const testPreset = resolveRulePreset(presets.test, defaultOxlintPresets.test);
694
+ const typeScriptPreset = resolveRulePreset(
695
+ presets.typescript,
696
+ defaultOxlintPresets.typescript
697
+ );
698
+ const unicornPreset = resolveRulePreset(presets.unicorn, true);
699
+ const plugins = [];
700
+ const rules = mergeRules(
701
+ {
702
+ "max-lines": [
703
+ "error",
704
+ {
705
+ max: 300,
706
+ skipBlankLines: true,
707
+ skipComments: true
708
+ }
709
+ ]
710
+ },
711
+ unicornPreset.enabled ? unicornRules : void 0,
712
+ unicornPreset.rules,
713
+ importPreset.enabled ? importRules : void 0,
714
+ importPreset.rules,
715
+ javascriptPreset.enabled ? javascriptRules : void 0,
716
+ javascriptPreset.rules,
717
+ nodePreset.enabled ? nodeRules : void 0,
718
+ nodePreset.rules,
719
+ reactAgentRulesPreset.enabled ? reactAgentRules : void 0,
720
+ reactAgentRulesPreset.rules,
721
+ options.rules
722
+ );
723
+ if (unicornPreset.enabled) {
724
+ appendPlugin(plugins, "unicorn");
725
+ }
726
+ if (importPreset.enabled) {
727
+ appendPlugin(plugins, "import");
728
+ }
729
+ if (typeScriptPreset.enabled) {
730
+ appendPlugin(plugins, "typescript");
731
+ }
732
+ if (nodePreset.enabled) {
733
+ appendPlugin(plugins, "node");
734
+ }
735
+ const overrides = [];
736
+ if (javascriptPreset.enabled) {
737
+ overrides.push({
738
+ files: scriptFiles,
739
+ rules: {
740
+ "no-console": "off"
741
+ }
742
+ });
743
+ }
744
+ if (typeScriptPreset.enabled) {
745
+ overrides.push({
746
+ files: tsFiles,
747
+ rules: mergeRules(typeScriptRules, typeScriptPreset.rules)
748
+ });
749
+ overrides.push({
750
+ files: dtsFiles,
751
+ rules: {
752
+ "import/no-duplicates": "off"
753
+ }
754
+ });
755
+ overrides.push({
756
+ files: jsRequireFiles,
757
+ rules: {
758
+ "typescript/no-require-imports": "off",
759
+ "typescript/no-var-requires": "off"
760
+ }
761
+ });
762
+ }
763
+ overrides.push({
764
+ files: componentFiles,
765
+ rules: {
766
+ "max-lines": [
767
+ "error",
768
+ {
769
+ max: 200,
770
+ skipBlankLines: true,
771
+ skipComments: true
772
+ }
773
+ ]
774
+ }
775
+ });
776
+ if (reactPreset.enabled || nextPreset.enabled) {
777
+ const reactOptions = reactPreset.options ?? {};
778
+ const a11y = reactOptions.a11y ?? true;
779
+ const overridePlugins = [];
780
+ const reactRules = reactPreset.enabled ? createReactRules(reactOptions, nextPreset.enabled) : {};
781
+ const nextRules = nextPreset.enabled ? nextjsRules : {};
782
+ const mergedRules = mergeRules(
783
+ reactRules,
784
+ a11y && reactPreset.enabled ? jsxA11yRules : void 0,
785
+ nextRules,
786
+ reactAgentRulesPreset.enabled ? {
787
+ "react/exhaustive-deps": "off"
788
+ } : void 0,
789
+ reactPreset.rules,
790
+ nextPreset.rules
791
+ );
792
+ if (reactPreset.enabled) {
793
+ appendPlugin(overridePlugins, "react");
794
+ }
795
+ if (reactPreset.enabled && a11y) {
796
+ appendPlugin(overridePlugins, "jsx-a11y");
797
+ }
798
+ if (nextPreset.enabled) {
799
+ appendPlugin(overridePlugins, "nextjs");
800
+ }
801
+ const override = pruneOverride({
802
+ files: sourceFiles,
803
+ plugins: overridePlugins,
804
+ rules: mergedRules
805
+ });
806
+ if (override) {
807
+ overrides.push(override);
808
+ }
809
+ }
810
+ overrides.push({
811
+ files: testFiles,
812
+ plugins: testPreset.enabled ? ["vitest"] : void 0,
813
+ rules: mergeRules(
814
+ {
815
+ "max-lines": [
816
+ "error",
817
+ {
818
+ max: 500,
819
+ skipBlankLines: true,
820
+ skipComments: true
821
+ }
822
+ ]
823
+ },
824
+ testPreset.enabled ? vitestRules : void 0,
825
+ testPreset.rules
826
+ )
827
+ });
828
+ const config = {
829
+ $schema: "./node_modules/oxlint/configuration_schema.json",
830
+ categories: {
831
+ correctness: "off",
832
+ ...options.categories ?? {}
833
+ },
834
+ env: {
835
+ browser: true,
836
+ builtin: true,
837
+ es2024: true,
838
+ node: true,
839
+ ...options.env ?? {}
840
+ },
841
+ ignorePatterns: ignorePreset.enabled ? dedupe([
842
+ ...defaultIgnorePatterns,
843
+ ...ignorePreset.patterns,
844
+ ...options.ignorePatterns ?? []
845
+ ]) : options.ignorePatterns,
846
+ jsPlugins: reactAgentRulesPreset.enabled ? [reactAgentRulesPlugin, ...options.jsPlugins ?? []] : options.jsPlugins,
847
+ overrides: [...overrides, ...options.overrides ?? []].map(pruneOverride).filter((override) => override !== null),
848
+ plugins,
849
+ rules,
850
+ settings: options.settings
851
+ };
852
+ if (typeScriptPreset.enabled) {
853
+ config.options = {
854
+ typeAware: typeScriptPreset.options?.typeAware ?? true
855
+ };
856
+ }
857
+ if (!config.ignorePatterns || config.ignorePatterns.length === 0) {
858
+ delete config.ignorePatterns;
859
+ }
860
+ if (!config.overrides || config.overrides.length === 0) {
861
+ delete config.overrides;
862
+ }
863
+ if (!config.jsPlugins || config.jsPlugins.length === 0) {
864
+ delete config.jsPlugins;
865
+ }
866
+ if (!config.plugins || config.plugins.length === 0) {
867
+ delete config.plugins;
868
+ }
869
+ if (!config.rules || Object.keys(config.rules).length === 0) {
870
+ delete config.rules;
871
+ }
872
+ if (!config.settings || Object.keys(config.settings).length === 0) {
873
+ delete config.settings;
874
+ }
875
+ return config;
876
+ }
877
+ var defineConfig = defineOxlintConfig;
878
+
879
+ // src/oxfmt/presets/imports.ts
880
+ var defaultSortImports = {
881
+ customGroups: [
882
+ {
883
+ elementNamePattern: ["next", "next/**"],
884
+ groupName: "next"
885
+ },
886
+ {
887
+ elementNamePattern: ["react", "react-dom", "react-dom/**"],
888
+ groupName: "react"
889
+ },
890
+ {
891
+ elementNamePattern: ["three", "three/**"],
892
+ groupName: "three"
893
+ },
894
+ {
895
+ elementNamePattern: ["@react-three/**"],
896
+ groupName: "reactThree"
897
+ }
898
+ ],
899
+ groups: [
900
+ "value-builtin",
901
+ "next",
902
+ "react",
903
+ "three",
904
+ "reactThree",
905
+ "value-external",
906
+ "value-internal",
907
+ ["value-index", "value-sibling", "value-parent"],
908
+ "type-builtin",
909
+ "type-external",
910
+ "type-internal",
911
+ ["type-index", "type-sibling", "type-parent"],
912
+ "style",
913
+ "side_effect",
914
+ "side_effect_style",
915
+ "unknown"
916
+ ],
917
+ ignoreCase: false,
918
+ internalPattern: ["^@/.*", "^~/.*"],
919
+ newlinesBetween: true,
920
+ order: "asc",
921
+ partitionByComment: false,
922
+ partitionByNewline: false,
923
+ sortSideEffects: true
924
+ };
925
+
926
+ // src/oxfmt/presets/package-json.ts
927
+ var defaultSortPackageJson = {
928
+ sortScripts: false
929
+ };
930
+
931
+ // src/oxfmt/presets/tailwindcss.ts
932
+ var defaultTailwindSort = {
933
+ functions: ["clsx", "cn", "cva", "tw"]
934
+ };
935
+
936
+ // src/oxfmt/index.ts
937
+ var defaultOxfmtPresets = {
938
+ imports: true,
939
+ packageJson: true,
940
+ tailwindcss: false
941
+ };
942
+ function defineOxfmtConfig(options = {}) {
943
+ const presets = {
944
+ ...defaultOxfmtPresets,
945
+ ...options.presets
946
+ };
947
+ const importsPreset = resolvePreset(presets.imports, true);
948
+ const packageJsonPreset = resolvePreset(presets.packageJson, true);
949
+ const tailwindPreset = resolvePreset(presets.tailwindcss, false);
950
+ const sortImports = importsPreset.enabled ? {
951
+ ...defaultSortImports,
952
+ ...importsPreset.options
953
+ } : false;
954
+ const sortPackageJson = packageJsonPreset.enabled ? {
955
+ ...defaultSortPackageJson,
956
+ ...packageJsonPreset.options
957
+ } : false;
958
+ const sortTailwindcss = tailwindPreset.enabled ? {
959
+ ...defaultTailwindSort,
960
+ ...tailwindPreset.options
961
+ } : false;
962
+ return {
963
+ $schema: "./node_modules/oxfmt/configuration_schema.json",
964
+ endOfLine: options.endOfLine ?? "lf",
965
+ ignorePatterns: dedupe([
966
+ ...defaultIgnorePatterns,
967
+ ...options.ignorePatterns ?? []
968
+ ]),
969
+ overrides: options.overrides,
970
+ printWidth: options.printWidth ?? 80,
971
+ semi: options.semi ?? false,
972
+ singleQuote: options.singleQuote ?? true,
973
+ sortImports,
974
+ sortPackageJson,
975
+ sortTailwindcss,
976
+ tabWidth: options.tabWidth ?? 2,
977
+ trailingComma: options.trailingComma ?? "all",
978
+ useTabs: options.useTabs ?? false
979
+ };
980
+ }
981
+ export {
982
+ defaultIgnorePatterns,
983
+ defaultOxfmtPresets,
984
+ defaultOxlintPresets,
985
+ defaultSortImports,
986
+ defineConfig,
987
+ defineOxfmtConfig,
988
+ defineOxlintConfig
989
+ };