@jiakun-zhao/eslint-config 3.1.0 → 4.0.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.
package/dist/index.mjs CHANGED
@@ -1,27 +1,991 @@
1
- import antfu from '@antfu/eslint-config';
2
- import { isPackageExists } from 'local-pkg';
3
-
4
- const index = antfu({
5
- stylistic: {
6
- overrides: {
7
- "no-console": "warn",
8
- // typescript
9
- "ts/ban-ts-comment": "off",
10
- // unused-imports
11
- "unused-imports/no-unused-imports": "warn",
12
- // jsx
13
- "style/jsx-quotes": ["off", "prefer-single"],
14
- "style/jsx-one-expression-per-line": "off"
1
+ import { composer } from 'eslint-flat-config-utils';
2
+ import pluginStylistic from '@stylistic/eslint-plugin';
3
+ import pluginTypescript from '@typescript-eslint/eslint-plugin';
4
+ import pluginAntfu from 'eslint-plugin-antfu';
5
+ import pluginCommand from 'eslint-plugin-command';
6
+ import pluginImportX from 'eslint-plugin-import-x';
7
+ import pluginJsonc from 'eslint-plugin-jsonc';
8
+ import pluginPerfectionist from 'eslint-plugin-perfectionist';
9
+ import * as pluginRegExp from 'eslint-plugin-regexp';
10
+ import pluginUnicorn from 'eslint-plugin-unicorn';
11
+ import pluginUnusedImports from 'eslint-plugin-unused-imports';
12
+ import gitignore from 'eslint-config-flat-gitignore';
13
+ import globals from 'globals';
14
+
15
+ const indent = 2;
16
+ const ignores$1 = [
17
+ "**/node_modules",
18
+ "**/dist",
19
+ "**/package-lock.json",
20
+ "**/yarn.lock",
21
+ "**/pnpm-lock.yaml",
22
+ "**/bun.lockb",
23
+ "**/output",
24
+ "**/coverage",
25
+ "**/temp",
26
+ "**/.temp",
27
+ "**/tmp",
28
+ "**/.tmp",
29
+ "**/.history",
30
+ "**/.vitepress/cache",
31
+ "**/.nuxt",
32
+ "**/.next",
33
+ "**/.svelte-kit",
34
+ "**/.vercel",
35
+ "**/.changeset",
36
+ "**/.idea",
37
+ "**/.cache",
38
+ "**/.output",
39
+ "**/.vite-inspect",
40
+ "**/.yarn",
41
+ "**/vite.config.*.timestamp-*",
42
+ "**/CHANGELOG*.md",
43
+ "**/*.min.*",
44
+ "**/LICENSE*",
45
+ "**/__snapshots__",
46
+ "**/auto-import?(s).d.ts",
47
+ "**/components.d.ts"
48
+ ];
49
+ const packageJsonTopLevelOrder = [
50
+ "publisher",
51
+ "name",
52
+ "displayName",
53
+ "type",
54
+ "version",
55
+ "private",
56
+ "packageManager",
57
+ "description",
58
+ "author",
59
+ "contributors",
60
+ "license",
61
+ "funding",
62
+ "homepage",
63
+ "repository",
64
+ "bugs",
65
+ "keywords",
66
+ "categories",
67
+ "sideEffects",
68
+ "exports",
69
+ "main",
70
+ "module",
71
+ "unpkg",
72
+ "jsdelivr",
73
+ "types",
74
+ "typesVersions",
75
+ "bin",
76
+ "icon",
77
+ "files",
78
+ "engines",
79
+ "activationEvents",
80
+ "contributes",
81
+ "scripts",
82
+ "peerDependencies",
83
+ "peerDependenciesMeta",
84
+ "dependencies",
85
+ "optionalDependencies",
86
+ "devDependencies",
87
+ "pnpm",
88
+ "overrides",
89
+ "resolutions",
90
+ "husky",
91
+ "simple-git-hooks",
92
+ "lint-staged",
93
+ "eslintConfig"
94
+ ];
95
+
96
+ function antfu() {
97
+ return {
98
+ name: "antfu",
99
+ plugins: {
100
+ antfu: pluginAntfu
101
+ },
102
+ rules: {
103
+ "antfu/consistent-list-newline": ["warn", { JSXOpeningElement: false }],
104
+ "antfu/if-newline": "warn"
105
+ }
106
+ };
107
+ }
108
+
109
+ const tsParser = findParser(pluginTypescript);
110
+ const jsoncParser = findParser(pluginJsonc);
111
+ function findParser(plugin) {
112
+ const configs = Object.values(plugin.configs ?? {}).flat();
113
+ for (const config of configs) {
114
+ const parser = config.languageOptions?.parser;
115
+ if (parser)
116
+ return parser;
117
+ }
118
+ throw new Error(`Can not find parser in ${plugin.meta?.name}`);
119
+ }
120
+ async function findDynamicPlugin(name, key = "default") {
121
+ try {
122
+ return (await import(name))[key];
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ function createRule(rule) {
128
+ const { name, ...rest } = rule;
129
+ rest.meta.docs ??= {};
130
+ rest.meta.docs.url = `https://example.com/${name}`;
131
+ return rest;
132
+ }
133
+
134
+ async function astro() {
135
+ const pluginAstro = await findDynamicPlugin("eslint-plugin-astro");
136
+ return pluginAstro && createSharedAstroConfig(pluginAstro, {
137
+ "mine/no-blank-before-astro-element": "warn",
138
+ "mine/no-blank-in-astro-frontmatter-start": "warn"
139
+ });
140
+ }
141
+ function createSharedAstroConfig(plugin, rules = {}) {
142
+ return {
143
+ files: [
144
+ "**/*.astro"
145
+ ],
146
+ languageOptions: {
147
+ parser: findParser(plugin),
148
+ parserOptions: {
149
+ extraFileExtensions: [
150
+ ".astro"
151
+ ],
152
+ parser: tsParser
153
+ }
154
+ },
155
+ name: "astro",
156
+ plugins: {
157
+ astro: plugin
158
+ },
159
+ rules
160
+ };
161
+ }
162
+
163
+ function command() {
164
+ return {
165
+ name: "command",
166
+ plugins: {
167
+ command: pluginCommand
168
+ },
169
+ rules: {
170
+ "command/command": "warn"
171
+ }
172
+ };
173
+ }
174
+
175
+ function ignores(options) {
176
+ return [
177
+ gitignore({ ...options.gitignore, name: "ignores/gitignore" }),
178
+ { ignores: ignores$1, name: "ignores/antfu" },
179
+ options.ignores && { ignores: options.ignores, name: "ignores" }
180
+ ];
181
+ }
182
+
183
+ function importX() {
184
+ return {
185
+ name: "import-x",
186
+ plugins: {
187
+ "import-x": pluginImportX
188
+ },
189
+ rules: {
190
+ "import-x/consistent-type-specifier-style": ["warn", "prefer-top-level"],
191
+ "import-x/first": "warn",
192
+ "import-x/newline-after-import": ["warn", { count: 1 }],
193
+ "import-x/no-duplicates": "warn",
194
+ "import-x/no-mutable-exports": "warn",
195
+ "import-x/no-named-default": "warn",
196
+ "import-x/no-self-import": "warn",
197
+ "import-x/no-webpack-loader-syntax": "warn"
198
+ }
199
+ };
200
+ }
201
+
202
+ function javascript() {
203
+ return {
204
+ languageOptions: {
205
+ ecmaVersion: 2022,
206
+ globals: {
207
+ ...globals.browser,
208
+ ...globals.es2021,
209
+ ...globals.node,
210
+ document: "readonly",
211
+ navigator: "readonly",
212
+ window: "readonly"
213
+ },
214
+ parserOptions: {
215
+ ecmaFeatures: {
216
+ jsx: true
217
+ },
218
+ ecmaVersion: 2022,
219
+ sourceType: "module"
220
+ },
221
+ sourceType: "module"
222
+ },
223
+ name: "javascript",
224
+ rules: {
225
+ "array-callback-return": "error",
226
+ "block-scoped-var": "error",
227
+ "constructor-super": "error",
228
+ "default-case-last": "error",
229
+ "dot-notation": ["error", { allowKeywords: true }],
230
+ "eqeqeq": ["error", "smart"],
231
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
232
+ "no-alert": "error",
233
+ "no-array-constructor": "error",
234
+ "no-async-promise-executor": "error",
235
+ "no-caller": "error",
236
+ "no-case-declarations": "error",
237
+ "no-class-assign": "error",
238
+ "no-compare-neg-zero": "error",
239
+ "no-cond-assign": ["error", "always"],
240
+ "no-console": ["warn", { allow: ["warn", "error"] }],
241
+ "no-const-assign": "error",
242
+ "no-control-regex": "error",
243
+ "no-debugger": "error",
244
+ "no-delete-var": "error",
245
+ "no-dupe-args": "error",
246
+ "no-dupe-class-members": "error",
247
+ "no-dupe-keys": "error",
248
+ "no-duplicate-case": "error",
249
+ "no-empty": ["error", { allowEmptyCatch: true }],
250
+ "no-empty-character-class": "error",
251
+ "no-empty-pattern": "error",
252
+ "no-eval": "error",
253
+ "no-ex-assign": "error",
254
+ "no-extend-native": "error",
255
+ "no-extra-bind": "error",
256
+ "no-extra-boolean-cast": "error",
257
+ "no-fallthrough": "error",
258
+ "no-func-assign": "error",
259
+ "no-global-assign": "error",
260
+ "no-implied-eval": "error",
261
+ "no-import-assign": "error",
262
+ "no-invalid-regexp": "error",
263
+ "no-irregular-whitespace": "error",
264
+ "no-iterator": "error",
265
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
266
+ "no-lone-blocks": "error",
267
+ "no-loss-of-precision": "error",
268
+ "no-misleading-character-class": "error",
269
+ "no-multi-str": "error",
270
+ "no-new": "error",
271
+ "no-new-func": "error",
272
+ "no-new-native-nonconstructor": "error",
273
+ "no-new-wrappers": "error",
274
+ "no-obj-calls": "error",
275
+ "no-octal": "error",
276
+ "no-octal-escape": "error",
277
+ "no-proto": "error",
278
+ "no-prototype-builtins": "error",
279
+ "no-redeclare": ["error", { builtinGlobals: false }],
280
+ "no-regex-spaces": "error",
281
+ "no-restricted-globals": [
282
+ "error",
283
+ { message: "Use `globalThis` instead.", name: "global" },
284
+ { message: "Use `globalThis` instead.", name: "self" }
285
+ ],
286
+ "no-restricted-properties": [
287
+ "error",
288
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
289
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
290
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
291
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
292
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
293
+ ],
294
+ "no-restricted-syntax": ["error", "TSEnumDeclaration[const=true]", "TSExportAssignment"],
295
+ "no-self-assign": ["error", { props: true }],
296
+ "no-self-compare": "error",
297
+ "no-sequences": "error",
298
+ "no-shadow-restricted-names": "error",
299
+ "no-sparse-arrays": "error",
300
+ "no-template-curly-in-string": "error",
301
+ "no-this-before-super": "error",
302
+ "no-throw-literal": "error",
303
+ "no-undef": "error",
304
+ "no-undef-init": "error",
305
+ "no-unexpected-multiline": "error",
306
+ "no-unmodified-loop-condition": "error",
307
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
308
+ "no-unreachable": "error",
309
+ "no-unreachable-loop": "error",
310
+ "no-unsafe-finally": "error",
311
+ "no-unsafe-negation": "error",
312
+ "no-unused-expressions": ["error", { allowShortCircuit: true, allowTaggedTemplates: true, allowTernary: true }],
313
+ "no-unused-vars": ["error", { args: "none", caughtErrors: "none", ignoreRestSiblings: true, vars: "all" }],
314
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
315
+ "no-useless-backreference": "error",
316
+ "no-useless-call": "error",
317
+ "no-useless-catch": "error",
318
+ "no-useless-computed-key": "error",
319
+ "no-useless-constructor": "error",
320
+ "no-useless-rename": "error",
321
+ "no-useless-return": "error",
322
+ "no-var": "error",
323
+ "no-with": "error",
324
+ "object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
325
+ "one-var": ["error", { initialized: "never" }],
326
+ "prefer-arrow-callback": ["error", { allowNamedFunctions: false, allowUnboundThis: true }],
327
+ "prefer-const": "warn",
328
+ "prefer-exponentiation-operator": "error",
329
+ "prefer-promise-reject-errors": "error",
330
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
331
+ "prefer-rest-params": "error",
332
+ "prefer-spread": "error",
333
+ "prefer-template": "error",
334
+ "symbol-description": "error",
335
+ "unicode-bom": ["error", "never"],
336
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
337
+ "valid-typeof": ["error", { requireStringLiterals: true }],
338
+ "vars-on-top": "error",
339
+ "yoda": ["error", "never"]
340
+ }
341
+ };
342
+ }
343
+
344
+ function jsonc() {
345
+ return [
346
+ {
347
+ files: [
348
+ "**/*.json",
349
+ "**/*.jsonc",
350
+ "**/*.json5"
351
+ ],
352
+ languageOptions: {
353
+ parser: jsoncParser
354
+ },
355
+ name: "jsonc",
356
+ plugins: {
357
+ jsonc: pluginJsonc
358
+ },
359
+ rules: {
360
+ "jsonc/array-bracket-newline": ["warn", "consistent"],
361
+ "jsonc/array-bracket-spacing": ["warn", "never"],
362
+ "jsonc/array-element-newline": ["warn", "consistent"],
363
+ "jsonc/comma-dangle": ["warn", "never"],
364
+ "jsonc/comma-style": ["warn", "last"],
365
+ "jsonc/indent": ["warn", indent],
366
+ "jsonc/key-spacing": "warn",
367
+ "jsonc/no-sparse-arrays": "warn",
368
+ "jsonc/object-curly-newline": ["warn", { consistent: true }],
369
+ "jsonc/object-curly-spacing": ["warn", "always"]
370
+ }
371
+ }
372
+ ];
373
+ }
374
+
375
+ const version = "4.0.1";
376
+
377
+ const toString = (v) => Object.prototype.toString.call(v);
378
+ const isNull = (val) => toString(val) === "[object Null]";
379
+
380
+ function isFileStart(node) {
381
+ return node.range[0] === 0;
382
+ }
383
+ function isLineStart(node) {
384
+ return node.loc.start.column === 0;
385
+ }
386
+ function numOfBlankLines(left, right) {
387
+ return right.loc.start.line - left.loc.end.line;
388
+ }
389
+ function isFrontmatterToken(token) {
390
+ return token?.value === "---";
391
+ }
392
+
393
+ const name$2 = "no-blank-before-astro-element";
394
+ const _noBlankBeforeAstroElement = createRule({
395
+ name: name$2,
396
+ meta: {
397
+ docs: {
398
+ description: "Enforce no blank before astro element"
399
+ },
400
+ schema: [],
401
+ type: "layout",
402
+ fixable: "whitespace",
403
+ messages: {
404
+ unexpectedBlank: "Unexpected blank"
15
405
  }
16
406
  },
17
- vue: {
18
- overrides: {
19
- "vue/html-self-closing": "off",
20
- "vue/singleline-html-element-content-newline": "off",
21
- "vue/static-class-names-order": "warn"
407
+ create(context) {
408
+ return {
409
+ AstroFragment(node) {
410
+ const token = context.sourceCode.getTokenBefore(node);
411
+ if (isNull(token) && !isFileStart(node)) {
412
+ context.report({
413
+ fix: (fixer) => fixer.removeRange([0, node.range[0]]),
414
+ loc: { start: { line: 1, column: 0 }, end: node.loc.start },
415
+ messageId: "unexpectedBlank"
416
+ });
417
+ } else if (isFrontmatterToken(token) && (!isLineStart(node) || numOfBlankLines(token, node) !== 2)) {
418
+ context.report({
419
+ fix: (fixer) => fixer.replaceTextRange([token.range[1], node.range[0]], "\n\n"),
420
+ loc: { start: token.loc.end, end: node.loc.start },
421
+ messageId: "unexpectedBlank"
422
+ });
423
+ }
424
+ }
425
+ };
426
+ }
427
+ });
428
+
429
+ const name$1 = "no-blank-in-astro-frontmatter-start";
430
+ const _noBlankInAstroFrontmatterStart = createRule({
431
+ name: name$1,
432
+ meta: {
433
+ docs: {
434
+ description: "Enforce no blank in astro frontmatter start"
435
+ },
436
+ schema: [],
437
+ type: "layout",
438
+ fixable: "whitespace",
439
+ messages: {
440
+ unexpectedBlank: "Unexpected blank"
22
441
  }
23
442
  },
24
- astro: isPackageExists("eslint-plugin-astro")
443
+ create(context) {
444
+ return {
445
+ Program(node) {
446
+ const [first, next] = context.sourceCode.getFirstTokens(node, { count: 2 });
447
+ if (isFrontmatterToken(first) && next && next.loc.start.line !== 2) {
448
+ context.report({
449
+ fix: (fixer) => fixer.replaceTextRange([3, next.range[0]], "\n"),
450
+ loc: { start: { line: 1, column: 0 }, end: next.loc.start },
451
+ messageId: "unexpectedBlank"
452
+ });
453
+ }
454
+ }
455
+ };
456
+ }
25
457
  });
26
458
 
459
+ const name = "no-space-in-empty-block";
460
+ const _noSpaceInEmptyObject = createRule({
461
+ name,
462
+ meta: {
463
+ docs: {
464
+ description: "Enforce no space in empty object"
465
+ },
466
+ schema: [],
467
+ type: "layout",
468
+ fixable: "whitespace",
469
+ messages: {
470
+ unexpectedSpace: "Unexpected space in empty object"
471
+ }
472
+ },
473
+ create(context) {
474
+ return {
475
+ ObjectExpression(node) {
476
+ if (node.properties.length)
477
+ return;
478
+ const code = context.sourceCode.getText(node);
479
+ const replaceValue = "{}";
480
+ if (code !== replaceValue) {
481
+ context.report({
482
+ fix: (fixer) => fixer.replaceText(node, replaceValue),
483
+ messageId: "unexpectedSpace",
484
+ node
485
+ });
486
+ }
487
+ },
488
+ ExportNamedDeclaration(node) {
489
+ if (node.declaration || node.specifiers.length) {
490
+ return;
491
+ }
492
+ const code = context.sourceCode.getText(node);
493
+ const replaceValue = "export {}";
494
+ if (code !== replaceValue) {
495
+ context.report({
496
+ fix: (fixer) => fixer.replaceText(node, replaceValue),
497
+ messageId: "unexpectedSpace",
498
+ node
499
+ });
500
+ }
501
+ }
502
+ };
503
+ }
504
+ });
505
+
506
+ const rules = {
507
+ [name]: _noSpaceInEmptyObject,
508
+ [name$2]: _noBlankBeforeAstroElement,
509
+ [name$1]: _noBlankInAstroFrontmatterStart
510
+ };
511
+ const pluginMine = {
512
+ meta: {
513
+ name: "mine",
514
+ version
515
+ },
516
+ rules
517
+ };
518
+
519
+ function mine() {
520
+ return {
521
+ name: "mine",
522
+ plugins: {
523
+ mine: pluginMine
524
+ },
525
+ rules: {
526
+ "mine/no-space-in-empty-block": "warn"
527
+ }
528
+ };
529
+ }
530
+
531
+ function overrides() {
532
+ const configFileNames = ["eslint", "astro", "vite", "build", "uno", "unocss", "vitest"];
533
+ const extensions = ["js", "mjs", "cjs", "ts", "mts", "cts"];
534
+ return [
535
+ {
536
+ name: "override/sort-config-files",
537
+ files: [
538
+ ...configFileNames.reduce(
539
+ (acc, cur) => acc.concat(...extensions.map((ext) => `${cur}.config.${ext}`)),
540
+ []
541
+ )
542
+ ],
543
+ rules: {
544
+ "perfectionist/sort-objects": "warn"
545
+ }
546
+ },
547
+ {
548
+ name: "override/jsonc-sort",
549
+ files: [
550
+ "**/.vscode/settings.json",
551
+ "**/tsconfig.json"
552
+ ],
553
+ rules: {
554
+ "jsonc/sort-array-values": ["warn", { order: { type: "asc" }, pathPattern: ".*" }],
555
+ "jsonc/sort-keys": ["warn", { order: { type: "asc" }, pathPattern: ".*" }]
556
+ }
557
+ },
558
+ {
559
+ name: "override/package-json",
560
+ files: [
561
+ "**/package.json"
562
+ ],
563
+ rules: {
564
+ "style/no-multiple-empty-lines": ["warn", { max: 0 }],
565
+ "jsonc/sort-array-values": [
566
+ "warn",
567
+ { order: { type: "asc" }, pathPattern: "^files$" }
568
+ ],
569
+ "jsonc/sort-keys": [
570
+ "warn",
571
+ { order: packageJsonTopLevelOrder, pathPattern: "^$" },
572
+ { order: { type: "asc" }, pathPattern: "^(?:exports|scripts)" },
573
+ /* cSpell:disable-next-line */
574
+ { order: { type: "asc" }, pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$" }
575
+ ]
576
+ }
577
+ }
578
+ ];
579
+ }
580
+
581
+ function perfectionist() {
582
+ return {
583
+ name: "perfectionist",
584
+ plugins: {
585
+ perfectionist: pluginPerfectionist
586
+ },
587
+ rules: {
588
+ "perfectionist/sort-exports": ["warn", { order: "asc", type: "natural" }],
589
+ "perfectionist/sort-imports": ["warn", {
590
+ groups: ["type", ["parent-type", "sibling-type", "index-type", "internal-type"], "builtin", "external", "internal", ["parent", "sibling", "index"], "side-effect", "object", "unknown"],
591
+ newlinesBetween: "ignore",
592
+ order: "asc",
593
+ type: "natural"
594
+ }],
595
+ "perfectionist/sort-named-exports": ["warn", { order: "asc", type: "natural" }],
596
+ "perfectionist/sort-named-imports": ["warn", { order: "asc", type: "natural" }]
597
+ }
598
+ };
599
+ }
600
+
601
+ function regexp() {
602
+ return {
603
+ name: "regexp",
604
+ plugins: {
605
+ regexp: pluginRegExp
606
+ },
607
+ rules: {
608
+ "no-control-regex": "warn",
609
+ "no-empty-character-class": "off",
610
+ "no-invalid-regexp": "off",
611
+ "no-misleading-character-class": "warn",
612
+ "no-regex-spaces": "warn",
613
+ "no-useless-backreference": "off",
614
+ "prefer-regex-literals": "warn",
615
+ "regexp/confusing-quantifier": "warn",
616
+ "regexp/control-character-escape": "warn",
617
+ "regexp/match-any": "warn",
618
+ "regexp/negation": "warn",
619
+ "regexp/no-contradiction-with-assertion": "warn",
620
+ "regexp/no-dupe-characters-character-class": "warn",
621
+ "regexp/no-dupe-disjunctions": "warn",
622
+ "regexp/no-empty-alternative": "warn",
623
+ "regexp/no-empty-capturing-group": "warn",
624
+ "regexp/no-empty-character-class": "warn",
625
+ "regexp/no-empty-group": "warn",
626
+ "regexp/no-empty-lookarounds-assertion": "warn",
627
+ "regexp/no-empty-string-literal": "warn",
628
+ "regexp/no-escape-backspace": "warn",
629
+ "regexp/no-extra-lookaround-assertions": "warn",
630
+ "regexp/no-invalid-regexp": "warn",
631
+ "regexp/no-invisible-character": "warn",
632
+ "regexp/no-lazy-ends": "warn",
633
+ "regexp/no-legacy-features": "warn",
634
+ "regexp/no-misleading-capturing-group": "warn",
635
+ "regexp/no-misleading-unicode-character": "warn",
636
+ "regexp/no-missing-g-flag": "warn",
637
+ "regexp/no-non-standard-flag": "warn",
638
+ "regexp/no-obscure-range": "warn",
639
+ "regexp/no-optional-assertion": "warn",
640
+ "regexp/no-potentially-useless-backreference": "warn",
641
+ "regexp/no-super-linear-backtracking": "warn",
642
+ "regexp/no-trivially-nested-assertion": "warn",
643
+ "regexp/no-trivially-nested-quantifier": "warn",
644
+ "regexp/no-unused-capturing-group": "warn",
645
+ "regexp/no-useless-assertions": "warn",
646
+ "regexp/no-useless-backreference": "warn",
647
+ "regexp/no-useless-character-class": "warn",
648
+ "regexp/no-useless-dollar-replacements": "warn",
649
+ "regexp/no-useless-escape": "warn",
650
+ "regexp/no-useless-flag": "warn",
651
+ "regexp/no-useless-lazy": "warn",
652
+ "regexp/no-useless-non-capturing-group": "warn",
653
+ "regexp/no-useless-quantifier": "warn",
654
+ "regexp/no-useless-range": "warn",
655
+ "regexp/no-useless-set-operand": "warn",
656
+ "regexp/no-useless-string-literal": "warn",
657
+ "regexp/no-useless-two-nums-quantifier": "warn",
658
+ "regexp/no-zero-quantifier": "warn",
659
+ "regexp/optimal-lookaround-quantifier": "warn",
660
+ "regexp/optimal-quantifier-concatenation": "warn",
661
+ "regexp/prefer-character-class": "warn",
662
+ "regexp/prefer-d": "warn",
663
+ "regexp/prefer-plus-quantifier": "warn",
664
+ "regexp/prefer-predefined-assertion": "warn",
665
+ "regexp/prefer-question-quantifier": "warn",
666
+ "regexp/prefer-range": "warn",
667
+ "regexp/prefer-set-operation": "warn",
668
+ "regexp/prefer-star-quantifier": "warn",
669
+ "regexp/prefer-unicode-codepoint-escapes": "warn",
670
+ "regexp/prefer-w": "warn",
671
+ "regexp/simplify-set-operations": "warn",
672
+ "regexp/sort-flags": "warn",
673
+ "regexp/strict": "warn",
674
+ "regexp/use-ignore-case": "warn"
675
+ }
676
+ };
677
+ }
678
+
679
+ function stylistic() {
680
+ return {
681
+ name: "stylistic",
682
+ plugins: {
683
+ style: pluginStylistic
684
+ },
685
+ rules: {
686
+ "style/array-bracket-newline": ["warn", "consistent"],
687
+ "style/array-bracket-spacing": "warn",
688
+ "style/arrow-spacing": "warn",
689
+ "style/block-spacing": "warn",
690
+ "style/comma-dangle": ["warn", "always-multiline"],
691
+ "style/comma-spacing": "warn",
692
+ "style/comma-style": "warn",
693
+ "style/curly-newline": "warn",
694
+ "style/eol-last": "warn",
695
+ "style/function-call-spacing": "warn",
696
+ "style/implicit-arrow-linebreak": "warn",
697
+ "style/indent": ["warn", indent],
698
+ "style/indent-binary-ops": ["warn", indent],
699
+ "style/jsx-child-element-spacing": "warn",
700
+ "style/jsx-closing-bracket-location": "warn",
701
+ "style/jsx-closing-tag-location": "warn",
702
+ "style/jsx-curly-brace-presence": "warn",
703
+ "style/jsx-curly-newline": "warn",
704
+ "style/jsx-curly-spacing": ["warn", { children: { when: "always" }, when: "never" }],
705
+ "style/jsx-equals-spacing": "warn",
706
+ "style/jsx-max-props-per-line": "off",
707
+ "style/jsx-pascal-case": "warn",
708
+ "style/jsx-quotes": "warn",
709
+ "style/jsx-self-closing-comp": ["warn", { component: true, html: false }],
710
+ "style/jsx-tag-spacing": "warn",
711
+ "style/jsx-wrap-multilines": "warn",
712
+ "style/key-spacing": "warn",
713
+ "style/keyword-spacing": "warn",
714
+ "style/no-mixed-spaces-and-tabs": "warn",
715
+ "style/no-multi-spaces": "warn",
716
+ "style/no-multiple-empty-lines": ["warn", { max: 1, maxBOF: 0, maxEOF: 0 }],
717
+ "style/no-trailing-spaces": "warn",
718
+ "style/no-whitespace-before-property": "warn",
719
+ "style/nonblock-statement-body-position": ["warn", "below"],
720
+ "style/object-curly-newline": ["warn", { consistent: true }],
721
+ "style/object-curly-spacing": ["warn", "always"],
722
+ "style/operator-linebreak": ["warn", "before"],
723
+ "style/quote-props": ["warn", "consistent-as-needed"],
724
+ "style/quotes": ["warn", "single"],
725
+ "style/rest-spread-spacing": "warn",
726
+ "style/semi": ["warn", "never"],
727
+ "style/semi-spacing": "warn",
728
+ "style/space-before-blocks": "warn",
729
+ "style/space-before-function-paren": ["warn", "never"],
730
+ "style/space-in-parens": "warn",
731
+ "style/space-infix-ops": "warn",
732
+ "style/space-unary-ops": "warn",
733
+ "style/spaced-comment": ["warn", "always", { block: { balanced: true } }],
734
+ "style/type-annotation-spacing": "warn",
735
+ "style/type-generic-spacing": "warn",
736
+ "style/type-named-tuple-spacing": "warn"
737
+ }
738
+ };
739
+ }
740
+
741
+ function typescript() {
742
+ return [
743
+ {
744
+ files: [
745
+ "**/*.?([cm])ts",
746
+ "**/*.?([cm])tsx",
747
+ "**/*.vue"
748
+ ],
749
+ languageOptions: {
750
+ parser: tsParser,
751
+ parserOptions: {
752
+ extraFileExtensions: [".vue"],
753
+ sourceType: "module"
754
+ }
755
+ },
756
+ name: "typescript",
757
+ plugins: {
758
+ ts: pluginTypescript
759
+ },
760
+ rules: {
761
+ "constructor-super": "off",
762
+ "getter-return": "off",
763
+ "no-array-constructor": "off",
764
+ "no-class-assign": "off",
765
+ "no-const-assign": "off",
766
+ "no-dupe-args": "off",
767
+ "no-dupe-class-members": "off",
768
+ "no-dupe-keys": "off",
769
+ "no-func-assign": "off",
770
+ "no-import-assign": "off",
771
+ "no-new-native-nonconstructor": "off",
772
+ "no-new-symbol": "off",
773
+ "no-obj-calls": "off",
774
+ "no-redeclare": "off",
775
+ "no-setter-return": "off",
776
+ "no-this-before-super": "off",
777
+ "no-undef": "off",
778
+ "no-unreachable": "off",
779
+ "no-unsafe-negation": "off",
780
+ "no-unused-expressions": "off",
781
+ "no-unused-vars": "off",
782
+ "no-use-before-define": "off",
783
+ "no-useless-constructor": "off",
784
+ "no-var": "error",
785
+ "no-with": "off",
786
+ "prefer-const": "error",
787
+ "prefer-rest-params": "error",
788
+ "prefer-spread": "error",
789
+ "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
790
+ "ts/consistent-type-definitions": ["error", "interface"],
791
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, fixStyle: "separate-type-imports", prefer: "type-imports" }],
792
+ "ts/explicit-function-return-type": "off",
793
+ "ts/method-signature-style": ["error", "property"],
794
+ "ts/no-array-constructor": "error",
795
+ "ts/no-dupe-class-members": "error",
796
+ "ts/no-duplicate-enum-values": "error",
797
+ "ts/no-dynamic-delete": "off",
798
+ "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
799
+ "ts/no-explicit-any": "off",
800
+ "ts/no-extra-non-null-assertion": "error",
801
+ "ts/no-extraneous-class": "off",
802
+ "ts/no-import-type-side-effects": "error",
803
+ "ts/no-invalid-void-type": "off",
804
+ "ts/no-misused-new": "error",
805
+ "ts/no-namespace": "error",
806
+ "ts/no-non-null-asserted-nullish-coalescing": "error",
807
+ "ts/no-non-null-asserted-optional-chain": "error",
808
+ "ts/no-non-null-assertion": "off",
809
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
810
+ "ts/no-require-imports": "error",
811
+ "ts/no-this-alias": "error",
812
+ "ts/no-unnecessary-type-constraint": "error",
813
+ "ts/no-unsafe-declaration-merging": "error",
814
+ "ts/no-unsafe-function-type": "error",
815
+ "ts/no-unused-expressions": ["error", { allowShortCircuit: true, allowTaggedTemplates: true, allowTernary: true }],
816
+ "ts/no-unused-vars": "off",
817
+ "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
818
+ "ts/no-useless-constructor": "off",
819
+ "ts/no-wrapper-object-types": "error",
820
+ "ts/prefer-as-const": "error",
821
+ "ts/prefer-literal-enum-member": "error",
822
+ "ts/prefer-namespace-keyword": "error",
823
+ "ts/triple-slash-reference": "off",
824
+ "ts/unified-signatures": "off"
825
+ }
826
+ }
827
+ ];
828
+ }
829
+
830
+ function unicorn() {
831
+ return {
832
+ name: "unicorn",
833
+ plugins: {
834
+ unicorn: pluginUnicorn
835
+ },
836
+ rules: {
837
+ "unicorn/consistent-empty-array-spread": "warn",
838
+ "unicorn/error-message": "warn",
839
+ "unicorn/escape-case": "warn",
840
+ "unicorn/new-for-builtins": "warn",
841
+ "unicorn/no-instanceof-builtins": "warn",
842
+ "unicorn/no-new-array": "warn",
843
+ "unicorn/no-new-buffer": "warn",
844
+ "unicorn/number-literal-case": "warn",
845
+ "unicorn/prefer-dom-node-text-content": "warn",
846
+ "unicorn/prefer-includes": "warn",
847
+ "unicorn/prefer-node-protocol": "warn",
848
+ "unicorn/prefer-number-properties": "warn",
849
+ "unicorn/prefer-string-starts-ends-with": "warn",
850
+ "unicorn/prefer-type-error": "warn",
851
+ "unicorn/throw-new-error": "warn"
852
+ }
853
+ };
854
+ }
855
+
856
+ function unusedImports() {
857
+ return {
858
+ name: "unused-imports",
859
+ plugins: {
860
+ "unused-imports": pluginUnusedImports
861
+ },
862
+ rules: {
863
+ "unused-imports/no-unused-imports": "warn",
864
+ "unused-imports/no-unused-vars": [
865
+ "warn",
866
+ {
867
+ args: "after-used",
868
+ argsIgnorePattern: "^_",
869
+ ignoreRestSiblings: true,
870
+ vars: "all",
871
+ varsIgnorePattern: "^_"
872
+ }
873
+ ]
874
+ }
875
+ };
876
+ }
877
+
878
+ async function vue() {
879
+ const pluginVue = await findDynamicPlugin("eslint-plugin-vue");
880
+ return pluginVue && {
881
+ files: [
882
+ "**/*.vue"
883
+ ],
884
+ languageOptions: {
885
+ parser: findParser(pluginVue),
886
+ parserOptions: {
887
+ ecmaFeatures: {
888
+ jsx: true
889
+ },
890
+ extraFileExtensions: [
891
+ ".vue"
892
+ ],
893
+ globals: {
894
+ computed: "readonly",
895
+ defineEmits: "readonly",
896
+ defineExpose: "readonly",
897
+ defineProps: "readonly",
898
+ onMounted: "readonly",
899
+ onUnmounted: "readonly",
900
+ reactive: "readonly",
901
+ ref: "readonly",
902
+ shallowReactive: "readonly",
903
+ shallowRef: "readonly",
904
+ toRef: "readonly",
905
+ toRefs: "readonly",
906
+ watch: "readonly",
907
+ watchEffect: "readonly"
908
+ },
909
+ parser: tsParser,
910
+ sourceType: "module"
911
+ }
912
+ },
913
+ name: "vue",
914
+ plugins: {
915
+ vue: pluginVue
916
+ },
917
+ processor: pluginVue.processors?.[".vue"],
918
+ rules: {
919
+ ...pluginVue.configs["flat/essential"].map((c) => c.rules).reduce((acc, cur) => ({ ...acc, ...cur }), {}),
920
+ "vue/attribute-hyphenation": "warn",
921
+ "vue/attributes-order": ["warn", { alphabetical: true, order: ["UNIQUE", "DEFINITION", "CONDITIONALS", "LIST_RENDERING", "GLOBAL", "RENDER_MODIFIERS", "SLOT", "TWO_WAY_BINDING", "OTHER_DIRECTIVES", "CONTENT", "ATTR_SHORTHAND_BOOL", "ATTR_STATIC", "ATTR_DYNAMIC", "EVENTS"] }],
922
+ "vue/block-order": "warn",
923
+ "vue/block-tag-newline": "warn",
924
+ "vue/component-name-in-template-casing": "warn",
925
+ "vue/component-options-name-casing": ["warn", "PascalCase"],
926
+ "vue/custom-event-name-casing": ["warn", "kebab-case"],
927
+ "vue/define-emits-declaration": "warn",
928
+ "vue/define-macros-order": "warn",
929
+ "vue/define-props-declaration": "warn",
930
+ "vue/first-attribute-linebreak": "warn",
931
+ "vue/html-button-has-type": "warn",
932
+ "vue/html-closing-bracket-newline": "warn",
933
+ "vue/html-closing-bracket-spacing": "warn",
934
+ "vue/html-comment-content-newline": "warn",
935
+ "vue/html-comment-content-spacing": "warn",
936
+ "vue/html-comment-indent": ["warn", indent],
937
+ "vue/html-indent": ["warn", indent],
938
+ "vue/html-quotes": "warn",
939
+ "vue/html-self-closing": ["warn", { html: { component: "always", normal: "never", void: "never" }, math: "always", svg: "always" }],
940
+ "vue/mustache-interpolation-spacing": "warn",
941
+ "vue/no-import-compiler-macros": "warn",
942
+ "vue/no-multi-spaces": "warn",
943
+ "vue/no-ref-object-reactivity-loss": "warn",
944
+ "vue/no-spaces-around-equal-signs-in-attribute": "warn",
945
+ "vue/no-static-inline-styles": "warn",
946
+ "vue/no-template-shadow": "warn",
947
+ "vue/no-template-target-blank": "warn",
948
+ "vue/no-unused-refs": "warn",
949
+ "vue/no-use-v-else-with-v-for": "warn",
950
+ "vue/no-useless-mustaches": "warn",
951
+ "vue/no-useless-v-bind": "warn",
952
+ "vue/padding-line-between-blocks": "warn",
953
+ "vue/prefer-separate-static-class": "warn",
954
+ "vue/prefer-true-attribute-shorthand": "warn",
955
+ "vue/prefer-use-template-ref": "warn",
956
+ "vue/require-macro-variable-name": "warn",
957
+ "vue/require-typed-ref": "warn",
958
+ "vue/slot-name-casing": ["warn", "kebab-case"],
959
+ "vue/static-class-names-order": "warn",
960
+ "vue/v-bind-style": ["wran", "shorthand", { sameNameShorthand: "always" }],
961
+ "vue/v-for-delimiter-style": ["warn", "of"],
962
+ "vue/v-on-event-hyphenation": "warn",
963
+ "vue/v-on-handler-style": "warn",
964
+ "vue/v-on-style": "warn",
965
+ "vue/v-slot-style": "warn"
966
+ }
967
+ };
968
+ }
969
+
970
+ function index(options = {}) {
971
+ return composer(
972
+ ignores(options),
973
+ jsonc(),
974
+ javascript(),
975
+ typescript(),
976
+ astro(),
977
+ vue(),
978
+ stylistic(),
979
+ mine(),
980
+ unusedImports(),
981
+ perfectionist(),
982
+ antfu(),
983
+ importX(),
984
+ unicorn(),
985
+ regexp(),
986
+ command(),
987
+ overrides()
988
+ );
989
+ }
990
+
27
991
  export { index as default };