@antfu/eslint-config 1.0.0-beta.2 → 1.0.0-beta.22

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.cjs ADDED
@@ -0,0 +1,1602 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ GLOB_ALL_SRC: () => GLOB_ALL_SRC,
34
+ GLOB_CSS: () => GLOB_CSS,
35
+ GLOB_EXCLUDE: () => GLOB_EXCLUDE,
36
+ GLOB_HTML: () => GLOB_HTML,
37
+ GLOB_JS: () => GLOB_JS,
38
+ GLOB_JSON: () => GLOB_JSON,
39
+ GLOB_JSON5: () => GLOB_JSON5,
40
+ GLOB_JSONC: () => GLOB_JSONC,
41
+ GLOB_JSX: () => GLOB_JSX,
42
+ GLOB_LESS: () => GLOB_LESS,
43
+ GLOB_MARKDOWN: () => GLOB_MARKDOWN,
44
+ GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
45
+ GLOB_SCSS: () => GLOB_SCSS,
46
+ GLOB_SRC: () => GLOB_SRC,
47
+ GLOB_SRC_EXT: () => GLOB_SRC_EXT,
48
+ GLOB_STYLE: () => GLOB_STYLE,
49
+ GLOB_TESTS: () => GLOB_TESTS,
50
+ GLOB_TS: () => GLOB_TS,
51
+ GLOB_TSX: () => GLOB_TSX,
52
+ GLOB_VUE: () => GLOB_VUE,
53
+ GLOB_YAML: () => GLOB_YAML,
54
+ antfu: () => antfu,
55
+ combine: () => combine,
56
+ comments: () => comments,
57
+ default: () => src_default,
58
+ ignores: () => ignores,
59
+ imports: () => imports,
60
+ javascript: () => javascript,
61
+ jsdoc: () => jsdoc,
62
+ jsonc: () => jsonc,
63
+ markdown: () => markdown,
64
+ node: () => node,
65
+ parserJsonc: () => import_jsonc_eslint_parser.default,
66
+ parserTs: () => parserTs,
67
+ parserVue: () => import_vue_eslint_parser.default,
68
+ parserYaml: () => import_yaml_eslint_parser.default,
69
+ pluginAntfu: () => import_eslint_plugin_antfu.default,
70
+ pluginComments: () => import_eslint_plugin_eslint_comments.default,
71
+ pluginImport: () => pluginImport,
72
+ pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
73
+ pluginJsonc: () => pluginJsonc,
74
+ pluginMarkdown: () => import_eslint_plugin_markdown.default,
75
+ pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
76
+ pluginNode: () => import_eslint_plugin_n.default,
77
+ pluginStylistic: () => import_eslint_plugin.default,
78
+ pluginTs: () => import_eslint_plugin2.default,
79
+ pluginUnicorn: () => import_eslint_plugin_unicorn.default,
80
+ pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
81
+ pluginVitest: () => import_eslint_plugin_vitest.default,
82
+ pluginVue: () => import_eslint_plugin_vue.default,
83
+ pluginYaml: () => pluginYaml,
84
+ recordRulesState: () => recordRulesState,
85
+ recordRulesStateConfigs: () => recordRulesStateConfigs,
86
+ renameRules: () => renameRules,
87
+ sortPackageJson: () => sortPackageJson,
88
+ sortTsconfig: () => sortTsconfig,
89
+ stylistic: () => stylistic,
90
+ test: () => test,
91
+ typescript: () => typescript,
92
+ unicorn: () => unicorn,
93
+ vue: () => vue,
94
+ warnUnnecessaryOffRules: () => warnUnnecessaryOffRules,
95
+ yaml: () => yaml
96
+ });
97
+ module.exports = __toCommonJS(src_exports);
98
+
99
+ // src/factory.ts
100
+ var import_node_process2 = __toESM(require("process"), 1);
101
+ var import_node_fs = __toESM(require("fs"), 1);
102
+ var import_local_pkg = require("local-pkg");
103
+ var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
104
+
105
+ // src/plugins.ts
106
+ var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
107
+ var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
108
+ var pluginImport = __toESM(require("eslint-plugin-i"), 1);
109
+ var import_eslint_plugin_jsdoc = __toESM(require("eslint-plugin-jsdoc"), 1);
110
+ var pluginJsonc = __toESM(require("eslint-plugin-jsonc"), 1);
111
+ var import_eslint_plugin_markdown = __toESM(require("eslint-plugin-markdown"), 1);
112
+ var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
113
+ var import_eslint_plugin = __toESM(require("@stylistic/eslint-plugin"), 1);
114
+ var import_eslint_plugin2 = __toESM(require("@typescript-eslint/eslint-plugin"), 1);
115
+ var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
116
+ var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
117
+ var import_eslint_plugin_vue = __toESM(require("eslint-plugin-vue"), 1);
118
+ var pluginYaml = __toESM(require("eslint-plugin-yml"), 1);
119
+ var import_eslint_plugin_no_only_tests = __toESM(require("eslint-plugin-no-only-tests"), 1);
120
+ var import_eslint_plugin_vitest = __toESM(require("eslint-plugin-vitest"), 1);
121
+ var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
122
+ var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
123
+ var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
124
+ var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
125
+
126
+ // src/configs/comments.ts
127
+ function comments() {
128
+ return [
129
+ {
130
+ name: "antfu:eslint-comments",
131
+ plugins: {
132
+ "eslint-comments": import_eslint_plugin_eslint_comments.default
133
+ },
134
+ rules: {
135
+ "eslint-comments/no-aggregating-enable": "error",
136
+ "eslint-comments/no-duplicate-disable": "error",
137
+ "eslint-comments/no-unlimited-disable": "error",
138
+ "eslint-comments/no-unused-enable": "error"
139
+ }
140
+ }
141
+ ];
142
+ }
143
+
144
+ // src/globs.ts
145
+ var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
146
+ var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
147
+ var GLOB_JS = "**/*.?([cm])js";
148
+ var GLOB_JSX = "**/*.?([cm])jsx";
149
+ var GLOB_TS = "**/*.?([cm])ts";
150
+ var GLOB_TSX = "**/*.?([cm])tsx";
151
+ var GLOB_STYLE = "**/*.{c,le,sc}ss";
152
+ var GLOB_CSS = "**/*.css";
153
+ var GLOB_LESS = "**/*.less";
154
+ var GLOB_SCSS = "**/*.scss";
155
+ var GLOB_JSON = "**/*.json";
156
+ var GLOB_JSON5 = "**/*.json5";
157
+ var GLOB_JSONC = "**/*.jsonc";
158
+ var GLOB_MARKDOWN = "**/*.md";
159
+ var GLOB_VUE = "**/*.vue";
160
+ var GLOB_YAML = "**/*.y?(a)ml";
161
+ var GLOB_HTML = "**/*.htm?(l)";
162
+ var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
163
+ var GLOB_TESTS = [
164
+ `**/__tests__/**/*.${GLOB_SRC_EXT}`,
165
+ `**/*.spec.${GLOB_SRC_EXT}`,
166
+ `**/*.test.${GLOB_SRC_EXT}`,
167
+ `**/*.bench.${GLOB_SRC_EXT}`,
168
+ `**/*.benchmark.${GLOB_SRC_EXT}`
169
+ ];
170
+ var GLOB_ALL_SRC = [
171
+ GLOB_SRC,
172
+ GLOB_STYLE,
173
+ GLOB_JSON,
174
+ GLOB_JSON5,
175
+ GLOB_MARKDOWN,
176
+ GLOB_VUE,
177
+ GLOB_YAML,
178
+ GLOB_HTML
179
+ ];
180
+ var GLOB_EXCLUDE = [
181
+ "**/node_modules",
182
+ "**/dist",
183
+ "**/package-lock.json",
184
+ "**/yarn.lock",
185
+ "**/pnpm-lock.yaml",
186
+ "**/bun.lockb",
187
+ "**/output",
188
+ "**/coverage",
189
+ "**/temp",
190
+ "**/.vitepress/cache",
191
+ "**/.nuxt",
192
+ "**/.vercel",
193
+ "**/.changeset",
194
+ "**/.idea",
195
+ "**/.cache",
196
+ "**/.output",
197
+ "**/.vite-inspect",
198
+ "**/CHANGELOG*.md",
199
+ "**/*.min.*",
200
+ "**/LICENSE*",
201
+ "**/__snapshots__",
202
+ "**/auto-import?(s).d.ts",
203
+ "**/components.d.ts"
204
+ ];
205
+
206
+ // src/configs/ignores.ts
207
+ function ignores() {
208
+ return [
209
+ {
210
+ ignores: GLOB_EXCLUDE
211
+ }
212
+ ];
213
+ }
214
+
215
+ // src/configs/imports.ts
216
+ function imports(options = {}) {
217
+ const {
218
+ stylistic: stylistic2 = true
219
+ } = options;
220
+ return [
221
+ {
222
+ name: "antfu:imports",
223
+ plugins: {
224
+ antfu: import_eslint_plugin_antfu.default,
225
+ import: pluginImport
226
+ },
227
+ rules: {
228
+ "antfu/import-dedupe": "error",
229
+ "antfu/no-import-node-modules-by-path": "error",
230
+ "import/first": "error",
231
+ "import/no-duplicates": "error",
232
+ "import/no-mutable-exports": "error",
233
+ "import/no-named-default": "error",
234
+ "import/no-self-import": "error",
235
+ "import/no-webpack-loader-syntax": "error",
236
+ "import/order": "error",
237
+ ...stylistic2 ? {
238
+ "import/newline-after-import": ["error", { considerComments: true, count: 1 }]
239
+ } : {}
240
+ }
241
+ }
242
+ ];
243
+ }
244
+
245
+ // src/configs/javascript.ts
246
+ var import_globals = __toESM(require("globals"), 1);
247
+
248
+ // src/flags.ts
249
+ var OFF = 0;
250
+
251
+ // src/configs/javascript.ts
252
+ function javascript(options = {}) {
253
+ const {
254
+ isInEditor = false,
255
+ overrides = {}
256
+ } = options;
257
+ return [
258
+ {
259
+ languageOptions: {
260
+ ecmaVersion: 2022,
261
+ globals: {
262
+ ...import_globals.default.browser,
263
+ ...import_globals.default.es2021,
264
+ ...import_globals.default.node,
265
+ document: "readonly",
266
+ navigator: "readonly",
267
+ window: "readonly"
268
+ },
269
+ parserOptions: {
270
+ ecmaFeatures: {
271
+ jsx: true
272
+ },
273
+ ecmaVersion: 2022,
274
+ sourceType: "module"
275
+ },
276
+ sourceType: "module"
277
+ },
278
+ name: "antfu:javascript",
279
+ plugins: {
280
+ "antfu": import_eslint_plugin_antfu.default,
281
+ "unused-imports": import_eslint_plugin_unused_imports.default
282
+ },
283
+ rules: {
284
+ "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
285
+ "array-callback-return": "error",
286
+ "arrow-parens": ["error", "as-needed", { requireForBlockBody: true }],
287
+ "block-scoped-var": "error",
288
+ "constructor-super": "error",
289
+ "default-case-last": "error",
290
+ "dot-notation": ["error", { allowKeywords: true }],
291
+ "eqeqeq": ["error", "smart"],
292
+ "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
293
+ "no-alert": "error",
294
+ "no-array-constructor": "error",
295
+ "no-async-promise-executor": "error",
296
+ "no-caller": "error",
297
+ "no-case-declarations": "error",
298
+ "no-class-assign": "error",
299
+ "no-compare-neg-zero": "error",
300
+ "no-cond-assign": ["error", "always"],
301
+ "no-console": ["error", { allow: ["warn", "error"] }],
302
+ "no-const-assign": "error",
303
+ "no-control-regex": "error",
304
+ "no-debugger": "error",
305
+ "no-delete-var": "error",
306
+ "no-dupe-args": "error",
307
+ "no-dupe-class-members": "error",
308
+ "no-dupe-keys": "error",
309
+ "no-duplicate-case": "error",
310
+ "no-empty": ["error", { allowEmptyCatch: true }],
311
+ "no-empty-character-class": "error",
312
+ "no-empty-pattern": "error",
313
+ "no-eval": "error",
314
+ "no-ex-assign": "error",
315
+ "no-extend-native": "error",
316
+ "no-extra-bind": "error",
317
+ "no-extra-boolean-cast": "error",
318
+ "no-fallthrough": "error",
319
+ "no-func-assign": "error",
320
+ "no-global-assign": "error",
321
+ "no-implied-eval": "error",
322
+ "no-import-assign": "error",
323
+ "no-invalid-regexp": "error",
324
+ "no-invalid-this": "error",
325
+ "no-irregular-whitespace": "error",
326
+ "no-iterator": "error",
327
+ "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
328
+ "no-lone-blocks": "error",
329
+ "no-loss-of-precision": "error",
330
+ "no-misleading-character-class": "error",
331
+ "no-multi-str": "error",
332
+ "no-new": "error",
333
+ "no-new-func": "error",
334
+ "no-new-object": "error",
335
+ "no-new-symbol": "error",
336
+ "no-new-wrappers": "error",
337
+ "no-obj-calls": "error",
338
+ "no-octal": "error",
339
+ "no-octal-escape": "error",
340
+ "no-proto": "error",
341
+ "no-prototype-builtins": "error",
342
+ "no-redeclare": ["error", { builtinGlobals: false }],
343
+ "no-regex-spaces": "error",
344
+ "no-restricted-globals": [
345
+ "error",
346
+ { message: "Use `globalThis` instead.", name: "global" },
347
+ { message: "Use `globalThis` instead.", name: "self" }
348
+ ],
349
+ "no-restricted-properties": [
350
+ "error",
351
+ { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
352
+ { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
353
+ { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
354
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
355
+ { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
356
+ ],
357
+ "no-restricted-syntax": [
358
+ "error",
359
+ "DebuggerStatement",
360
+ "LabeledStatement",
361
+ "WithStatement",
362
+ "TSEnumDeclaration[const=true]",
363
+ "TSExportAssignment"
364
+ ],
365
+ "no-self-assign": ["error", { props: true }],
366
+ "no-self-compare": "error",
367
+ "no-sequences": "error",
368
+ "no-shadow-restricted-names": "error",
369
+ "no-sparse-arrays": "error",
370
+ "no-template-curly-in-string": "error",
371
+ "no-this-before-super": "error",
372
+ "no-throw-literal": "error",
373
+ "no-undef": "error",
374
+ "no-undef-init": "error",
375
+ "no-unexpected-multiline": "error",
376
+ "no-unmodified-loop-condition": "error",
377
+ "no-unneeded-ternary": ["error", { defaultAssignment: false }],
378
+ "no-unreachable": "error",
379
+ "no-unreachable-loop": "error",
380
+ "no-unsafe-finally": "error",
381
+ "no-unsafe-negation": "error",
382
+ "no-unused-expressions": ["error", {
383
+ allowShortCircuit: true,
384
+ allowTaggedTemplates: true,
385
+ allowTernary: true
386
+ }],
387
+ "no-unused-vars": ["error", {
388
+ args: "none",
389
+ caughtErrors: "none",
390
+ ignoreRestSiblings: true,
391
+ vars: "all"
392
+ }],
393
+ "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
394
+ "no-useless-backreference": "error",
395
+ "no-useless-call": "error",
396
+ "no-useless-catch": "error",
397
+ "no-useless-computed-key": "error",
398
+ "no-useless-constructor": "error",
399
+ "no-useless-rename": "error",
400
+ "no-useless-return": "error",
401
+ "no-var": "error",
402
+ "no-void": "error",
403
+ "no-with": "error",
404
+ "object-shorthand": [
405
+ "error",
406
+ "always",
407
+ {
408
+ avoidQuotes: true,
409
+ ignoreConstructors: false
410
+ }
411
+ ],
412
+ "one-var": ["error", { initialized: "never" }],
413
+ "prefer-arrow-callback": [
414
+ "error",
415
+ {
416
+ allowNamedFunctions: false,
417
+ allowUnboundThis: true
418
+ }
419
+ ],
420
+ "prefer-const": [
421
+ "error",
422
+ {
423
+ destructuring: "all",
424
+ ignoreReadBeforeAssign: true
425
+ }
426
+ ],
427
+ "prefer-exponentiation-operator": "error",
428
+ "prefer-promise-reject-errors": "error",
429
+ "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
430
+ "prefer-rest-params": "error",
431
+ "prefer-spread": "error",
432
+ "prefer-template": "error",
433
+ "sort-imports": [
434
+ "error",
435
+ {
436
+ allowSeparatedGroups: false,
437
+ ignoreCase: false,
438
+ ignoreDeclarationSort: true,
439
+ ignoreMemberSort: false,
440
+ memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
441
+ }
442
+ ],
443
+ "symbol-description": "error",
444
+ "unicode-bom": ["error", "never"],
445
+ "unused-imports/no-unused-imports": isInEditor ? OFF : "error",
446
+ "unused-imports/no-unused-vars": [
447
+ "error",
448
+ { args: "after-used", argsIgnorePattern: "^_", vars: "all", varsIgnorePattern: "^_" }
449
+ ],
450
+ "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
451
+ "valid-typeof": ["error", { requireStringLiterals: true }],
452
+ "vars-on-top": "error",
453
+ "yoda": ["error", "never"],
454
+ ...overrides
455
+ }
456
+ },
457
+ {
458
+ files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
459
+ name: "antfu:scripts-overrides",
460
+ rules: {
461
+ "no-console": OFF
462
+ }
463
+ }
464
+ ];
465
+ }
466
+
467
+ // src/configs/jsdoc.ts
468
+ function jsdoc(options = {}) {
469
+ const {
470
+ stylistic: stylistic2 = true
471
+ } = options;
472
+ return [
473
+ {
474
+ name: "antfu:jsdoc",
475
+ plugins: {
476
+ jsdoc: import_eslint_plugin_jsdoc.default
477
+ },
478
+ rules: {
479
+ "jsdoc/check-access": "warn",
480
+ "jsdoc/check-param-names": "warn",
481
+ "jsdoc/check-property-names": "warn",
482
+ "jsdoc/check-types": "warn",
483
+ "jsdoc/empty-tags": "warn",
484
+ "jsdoc/implements-on-classes": "warn",
485
+ "jsdoc/no-defaults": "warn",
486
+ "jsdoc/no-multi-asterisks": "warn",
487
+ "jsdoc/require-param-name": "warn",
488
+ "jsdoc/require-property": "warn",
489
+ "jsdoc/require-property-description": "warn",
490
+ "jsdoc/require-property-name": "warn",
491
+ "jsdoc/require-returns-check": "warn",
492
+ "jsdoc/require-returns-description": "warn",
493
+ "jsdoc/require-yields-check": "warn",
494
+ ...stylistic2 ? {
495
+ "jsdoc/check-alignment": "warn",
496
+ "jsdoc/multiline-blocks": "warn"
497
+ } : {}
498
+ }
499
+ }
500
+ ];
501
+ }
502
+
503
+ // src/configs/jsonc.ts
504
+ function jsonc(options = {}) {
505
+ const {
506
+ stylistic: stylistic2 = true,
507
+ overrides = {}
508
+ } = options;
509
+ const {
510
+ indent = 2
511
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
512
+ return [
513
+ {
514
+ name: "antfu:jsonc:setup",
515
+ plugins: {
516
+ jsonc: pluginJsonc
517
+ }
518
+ },
519
+ {
520
+ files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
521
+ languageOptions: {
522
+ parser: import_jsonc_eslint_parser.default
523
+ },
524
+ name: "antfu:jsonc:rules",
525
+ rules: {
526
+ "jsonc/no-bigint-literals": "error",
527
+ "jsonc/no-binary-expression": "error",
528
+ "jsonc/no-binary-numeric-literals": "error",
529
+ "jsonc/no-dupe-keys": "error",
530
+ "jsonc/no-escape-sequence-in-identifier": "error",
531
+ "jsonc/no-floating-decimal": "error",
532
+ "jsonc/no-hexadecimal-numeric-literals": "error",
533
+ "jsonc/no-infinity": "error",
534
+ "jsonc/no-multi-str": "error",
535
+ "jsonc/no-nan": "error",
536
+ "jsonc/no-number-props": "error",
537
+ "jsonc/no-numeric-separators": "error",
538
+ "jsonc/no-octal": "error",
539
+ "jsonc/no-octal-escape": "error",
540
+ "jsonc/no-octal-numeric-literals": "error",
541
+ "jsonc/no-parenthesized": "error",
542
+ "jsonc/no-plus-sign": "error",
543
+ "jsonc/no-regexp-literals": "error",
544
+ "jsonc/no-sparse-arrays": "error",
545
+ "jsonc/no-template-literals": "error",
546
+ "jsonc/no-undefined-value": "error",
547
+ "jsonc/no-unicode-codepoint-escapes": "error",
548
+ "jsonc/no-useless-escape": "error",
549
+ "jsonc/space-unary-ops": "error",
550
+ "jsonc/valid-json-number": "error",
551
+ "jsonc/vue-custom-block/no-parsing-error": "error",
552
+ ...stylistic2 ? {
553
+ "jsonc/array-bracket-spacing": ["error", "never"],
554
+ "jsonc/comma-dangle": ["error", "never"],
555
+ "jsonc/comma-style": ["error", "last"],
556
+ "jsonc/indent": ["error", indent],
557
+ "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
558
+ "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
559
+ "jsonc/object-curly-spacing": ["error", "always"],
560
+ "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
561
+ "jsonc/quote-props": "error",
562
+ "jsonc/quotes": "error"
563
+ } : {},
564
+ ...overrides
565
+ }
566
+ }
567
+ ];
568
+ }
569
+
570
+ // src/configs/markdown.ts
571
+ function markdown(options = {}) {
572
+ const {
573
+ componentExts = [],
574
+ overrides = {}
575
+ } = options;
576
+ return [
577
+ {
578
+ name: "antfu:markdown:setup",
579
+ plugins: {
580
+ markdown: import_eslint_plugin_markdown.default
581
+ }
582
+ },
583
+ {
584
+ files: [GLOB_MARKDOWN],
585
+ name: "antfu:markdown:processor",
586
+ processor: "markdown/markdown"
587
+ },
588
+ {
589
+ files: [
590
+ GLOB_MARKDOWN_CODE,
591
+ ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
592
+ ],
593
+ languageOptions: {
594
+ parserOptions: {
595
+ ecmaFeatures: {
596
+ impliedStrict: true
597
+ }
598
+ }
599
+ },
600
+ name: "antfu:markdown:rules",
601
+ rules: {
602
+ "antfu/no-cjs-exports": OFF,
603
+ "antfu/no-ts-export-equal": OFF,
604
+ "no-alert": OFF,
605
+ "no-console": OFF,
606
+ "no-undef": OFF,
607
+ "no-unused-expressions": OFF,
608
+ "no-unused-vars": OFF,
609
+ "node/prefer-global/process": OFF,
610
+ "style/comma-dangle": OFF,
611
+ "style/eol-last": OFF,
612
+ "ts/consistent-type-imports": OFF,
613
+ "ts/no-namespace": OFF,
614
+ "ts/no-redeclare": OFF,
615
+ "ts/no-require-imports": OFF,
616
+ "ts/no-unused-vars": OFF,
617
+ "ts/no-use-before-define": OFF,
618
+ "ts/no-var-requires": OFF,
619
+ "unicode-bom": "off",
620
+ "unused-imports/no-unused-imports": OFF,
621
+ "unused-imports/no-unused-vars": OFF,
622
+ // Type aware rules
623
+ ...{
624
+ "ts/await-thenable": OFF,
625
+ "ts/dot-notation": OFF,
626
+ "ts/no-floating-promises": OFF,
627
+ "ts/no-for-in-array": OFF,
628
+ "ts/no-implied-eval": OFF,
629
+ "ts/no-misused-promises": OFF,
630
+ "ts/no-throw-literal": OFF,
631
+ "ts/no-unnecessary-type-assertion": OFF,
632
+ "ts/no-unsafe-argument": OFF,
633
+ "ts/no-unsafe-assignment": OFF,
634
+ "ts/no-unsafe-call": OFF,
635
+ "ts/no-unsafe-member-access": OFF,
636
+ "ts/no-unsafe-return": OFF,
637
+ "ts/restrict-plus-operands": OFF,
638
+ "ts/restrict-template-expressions": OFF,
639
+ "ts/unbound-method": OFF
640
+ },
641
+ ...overrides
642
+ }
643
+ }
644
+ ];
645
+ }
646
+
647
+ // src/configs/node.ts
648
+ function node() {
649
+ return [
650
+ {
651
+ name: "antfu:node",
652
+ plugins: {
653
+ node: import_eslint_plugin_n.default
654
+ },
655
+ rules: {
656
+ "node/handle-callback-err": ["error", "^(err|error)$"],
657
+ "node/no-deprecated-api": "error",
658
+ "node/no-exports-assign": "error",
659
+ "node/no-new-require": "error",
660
+ "node/no-path-concat": "error",
661
+ "node/prefer-global/buffer": ["error", "never"],
662
+ "node/prefer-global/process": ["error", "never"],
663
+ "node/process-exit-as-throw": "error"
664
+ }
665
+ }
666
+ ];
667
+ }
668
+
669
+ // src/configs/sort.ts
670
+ function sortPackageJson() {
671
+ return [
672
+ {
673
+ files: ["**/package.json"],
674
+ name: "antfu:sort-package-json",
675
+ rules: {
676
+ "jsonc/sort-array-values": [
677
+ "error",
678
+ {
679
+ order: { type: "asc" },
680
+ pathPattern: "^files$"
681
+ }
682
+ ],
683
+ "jsonc/sort-keys": [
684
+ "error",
685
+ {
686
+ order: [
687
+ "publisher",
688
+ "name",
689
+ "displayName",
690
+ "type",
691
+ "version",
692
+ "private",
693
+ "packageManager",
694
+ "description",
695
+ "author",
696
+ "license",
697
+ "funding",
698
+ "homepage",
699
+ "repository",
700
+ "bugs",
701
+ "keywords",
702
+ "categories",
703
+ "sideEffects",
704
+ "exports",
705
+ "main",
706
+ "module",
707
+ "unpkg",
708
+ "jsdelivr",
709
+ "types",
710
+ "typesVersions",
711
+ "bin",
712
+ "icon",
713
+ "files",
714
+ "engines",
715
+ "activationEvents",
716
+ "contributes",
717
+ "scripts",
718
+ "peerDependencies",
719
+ "peerDependenciesMeta",
720
+ "dependencies",
721
+ "optionalDependencies",
722
+ "devDependencies",
723
+ "pnpm",
724
+ "overrides",
725
+ "resolutions",
726
+ "husky",
727
+ "simple-git-hooks",
728
+ "lint-staged",
729
+ "eslintConfig"
730
+ ],
731
+ pathPattern: "^$"
732
+ },
733
+ {
734
+ order: { type: "asc" },
735
+ pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies$"
736
+ },
737
+ {
738
+ order: { type: "asc" },
739
+ pathPattern: "^resolutions$"
740
+ },
741
+ {
742
+ order: { type: "asc" },
743
+ pathPattern: "^pnpm.overrides$"
744
+ },
745
+ {
746
+ order: [
747
+ "types",
748
+ "import",
749
+ "require",
750
+ "default"
751
+ ],
752
+ pathPattern: "^exports.*$"
753
+ }
754
+ ]
755
+ }
756
+ }
757
+ ];
758
+ }
759
+ function sortTsconfig() {
760
+ return [
761
+ {
762
+ files: ["**/tsconfig.json", "**/tsconfig.*.json"],
763
+ name: "antfu:sort-tsconfig",
764
+ rules: {
765
+ "jsonc/sort-keys": [
766
+ "error",
767
+ {
768
+ order: [
769
+ "extends",
770
+ "compilerOptions",
771
+ "references",
772
+ "files",
773
+ "include",
774
+ "exclude"
775
+ ],
776
+ pathPattern: "^$"
777
+ },
778
+ {
779
+ order: [
780
+ /* Projects */
781
+ "incremental",
782
+ "composite",
783
+ "tsBuildInfoFile",
784
+ "disableSourceOfProjectReferenceRedirect",
785
+ "disableSolutionSearching",
786
+ "disableReferencedProjectLoad",
787
+ /* Language and Environment */
788
+ "target",
789
+ "jsx",
790
+ "jsxFactory",
791
+ "jsxFragmentFactory",
792
+ "jsxImportSource",
793
+ "lib",
794
+ "moduleDetection",
795
+ "noLib",
796
+ "reactNamespace",
797
+ "useDefineForClassFields",
798
+ "emitDecoratorMetadata",
799
+ "experimentalDecorators",
800
+ /* Modules */
801
+ "baseUrl",
802
+ "rootDir",
803
+ "rootDirs",
804
+ "customConditions",
805
+ "module",
806
+ "moduleResolution",
807
+ "moduleSuffixes",
808
+ "noResolve",
809
+ "paths",
810
+ "resolveJsonModule",
811
+ "resolvePackageJsonExports",
812
+ "resolvePackageJsonImports",
813
+ "typeRoots",
814
+ "types",
815
+ "allowArbitraryExtensions",
816
+ "allowImportingTsExtensions",
817
+ "allowUmdGlobalAccess",
818
+ /* JavaScript Support */
819
+ "allowJs",
820
+ "checkJs",
821
+ "maxNodeModuleJsDepth",
822
+ /* Type Checking */
823
+ "strict",
824
+ "strictBindCallApply",
825
+ "strictFunctionTypes",
826
+ "strictNullChecks",
827
+ "strictPropertyInitialization",
828
+ "allowUnreachableCode",
829
+ "allowUnusedLabels",
830
+ "alwaysStrict",
831
+ "exactOptionalPropertyTypes",
832
+ "noFallthroughCasesInSwitch",
833
+ "noImplicitAny",
834
+ "noImplicitOverride",
835
+ "noImplicitReturns",
836
+ "noImplicitThis",
837
+ "noPropertyAccessFromIndexSignature",
838
+ "noUncheckedIndexedAccess",
839
+ "noUnusedLocals",
840
+ "noUnusedParameters",
841
+ "useUnknownInCatchVariables",
842
+ /* Emit */
843
+ "declaration",
844
+ "declarationDir",
845
+ "declarationMap",
846
+ "downlevelIteration",
847
+ "emitBOM",
848
+ "emitDeclarationOnly",
849
+ "importHelpers",
850
+ "importsNotUsedAsValues",
851
+ "inlineSourceMap",
852
+ "inlineSources",
853
+ "mapRoot",
854
+ "newLine",
855
+ "noEmit",
856
+ "noEmitHelpers",
857
+ "noEmitOnError",
858
+ "outDir",
859
+ "outFile",
860
+ "preserveConstEnums",
861
+ "preserveValueImports",
862
+ "removeComments",
863
+ "sourceMap",
864
+ "sourceRoot",
865
+ "stripInternal",
866
+ /* Interop Constraints */
867
+ "allowSyntheticDefaultImports",
868
+ "esModuleInterop",
869
+ "forceConsistentCasingInFileNames",
870
+ "isolatedModules",
871
+ "preserveSymlinks",
872
+ "verbatimModuleSyntax",
873
+ /* Completeness */
874
+ "skipDefaultLibCheck",
875
+ "skipLibCheck"
876
+ ],
877
+ pathPattern: "^compilerOptions$"
878
+ }
879
+ ]
880
+ }
881
+ }
882
+ ];
883
+ }
884
+
885
+ // src/configs/stylistic.ts
886
+ function stylistic(options = {}) {
887
+ const {
888
+ indent = 2,
889
+ quotes = "single"
890
+ } = options;
891
+ return [
892
+ {
893
+ name: "antfu:stylistic",
894
+ plugins: {
895
+ antfu: import_eslint_plugin_antfu.default,
896
+ style: import_eslint_plugin.default
897
+ },
898
+ rules: {
899
+ "antfu/consistent-list-newline": "error",
900
+ "antfu/if-newline": "error",
901
+ "antfu/top-level-function": "error",
902
+ "curly": ["error", "multi-or-nest", "consistent"],
903
+ "style/array-bracket-spacing": ["error", "never"],
904
+ "style/arrow-spacing": ["error", { after: true, before: true }],
905
+ "style/block-spacing": ["error", "always"],
906
+ "style/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
907
+ "style/comma-dangle": ["error", "always-multiline"],
908
+ "style/comma-spacing": ["error", { after: true, before: false }],
909
+ "style/comma-style": ["error", "last"],
910
+ "style/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
911
+ "style/dot-location": ["error", "property"],
912
+ "style/eol-last": "error",
913
+ "style/indent": ["error", indent, {
914
+ ArrayExpression: 1,
915
+ CallExpression: { arguments: 1 },
916
+ FunctionDeclaration: { body: 1, parameters: 1 },
917
+ FunctionExpression: { body: 1, parameters: 1 },
918
+ ImportDeclaration: 1,
919
+ MemberExpression: 1,
920
+ ObjectExpression: 1,
921
+ SwitchCase: 1,
922
+ VariableDeclarator: 1,
923
+ flatTernaryExpressions: false,
924
+ ignoreComments: false,
925
+ ignoredNodes: [
926
+ "TemplateLiteral *",
927
+ "JSXElement",
928
+ "JSXElement > *",
929
+ "JSXAttribute",
930
+ "JSXIdentifier",
931
+ "JSXNamespacedName",
932
+ "JSXMemberExpression",
933
+ "JSXSpreadAttribute",
934
+ "JSXExpressionContainer",
935
+ "JSXOpeningElement",
936
+ "JSXClosingElement",
937
+ "JSXFragment",
938
+ "JSXOpeningFragment",
939
+ "JSXClosingFragment",
940
+ "JSXText",
941
+ "JSXEmptyExpression",
942
+ "JSXSpreadChild",
943
+ "TSTypeParameterInstantiation",
944
+ "FunctionExpression > .params[decorators.length > 0]",
945
+ "FunctionExpression > .params > :matches(Decorator, :not(:first-child))",
946
+ "ClassBody.body > PropertyDefinition[decorators.length > 0] > .key"
947
+ ],
948
+ offsetTernaryExpressions: true,
949
+ outerIIFEBody: 1
950
+ }],
951
+ "style/jsx-quotes": "error",
952
+ "style/key-spacing": ["error", { afterColon: true, beforeColon: false }],
953
+ "style/keyword-spacing": ["error", { after: true, before: true }],
954
+ "style/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
955
+ "style/max-statements-per-line": ["error", { max: 1 }],
956
+ "style/member-delimiter-style": ["error", { multiline: { delimiter: "none" } }],
957
+ "style/multiline-ternary": ["error", "always-multiline"],
958
+ "style/new-parens": "error",
959
+ "style/no-extra-parens": ["error", "functions"],
960
+ "style/no-floating-decimal": "error",
961
+ "style/no-mixed-operators": ["error", {
962
+ allowSamePrecedence: true,
963
+ groups: [
964
+ ["==", "!=", "===", "!==", ">", ">=", "<", "<="],
965
+ ["&&", "||"],
966
+ ["in", "instanceof"]
967
+ ]
968
+ }],
969
+ "style/no-mixed-spaces-and-tabs": "error",
970
+ "style/no-multi-spaces": "error",
971
+ "style/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
972
+ "style/no-tabs": indent === "tab" ? "off" : "error",
973
+ "style/no-trailing-spaces": "error",
974
+ "style/no-whitespace-before-property": "error",
975
+ "style/object-curly-spacing": ["error", "always"],
976
+ "style/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
977
+ "style/operator-linebreak": ["error", "before"],
978
+ "style/padded-blocks": ["error", { blocks: "never", classes: "never", switches: "never" }],
979
+ "style/quote-props": ["error", "consistent-as-needed"],
980
+ "style/quotes": ["error", quotes, { allowTemplateLiterals: true, avoidEscape: false }],
981
+ "style/rest-spread-spacing": ["error", "never"],
982
+ "style/semi": ["error", "never"],
983
+ "style/semi-spacing": ["error", { after: true, before: false }],
984
+ "style/space-before-blocks": ["error", "always"],
985
+ "style/space-before-function-paren": ["error", { anonymous: "always", asyncArrow: "always", named: "never" }],
986
+ "style/space-in-parens": ["error", "never"],
987
+ "style/space-infix-ops": "error",
988
+ "style/space-unary-ops": ["error", { nonwords: false, words: true }],
989
+ "style/spaced-comment": ["error", "always", {
990
+ block: {
991
+ balanced: true,
992
+ exceptions: ["*"],
993
+ markers: ["!"]
994
+ },
995
+ line: {
996
+ exceptions: ["/", "#"],
997
+ markers: ["/"]
998
+ }
999
+ }],
1000
+ "style/template-curly-spacing": "error",
1001
+ "style/template-tag-spacing": ["error", "never"],
1002
+ "style/type-annotation-spacing": ["error", {}],
1003
+ "style/wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
1004
+ "style/yield-star-spacing": ["error", "both"]
1005
+ }
1006
+ }
1007
+ ];
1008
+ }
1009
+
1010
+ // src/configs/typescript.ts
1011
+ var import_node_process = __toESM(require("process"), 1);
1012
+
1013
+ // src/utils.ts
1014
+ function combine(...configs) {
1015
+ return configs.flatMap((config) => Array.isArray(config) ? config : [config]);
1016
+ }
1017
+ function renameRules(rules, from, to) {
1018
+ return Object.fromEntries(
1019
+ Object.entries(rules).map(([key, value]) => {
1020
+ if (key.startsWith(from))
1021
+ return [to + key.slice(from.length), value];
1022
+ return [key, value];
1023
+ })
1024
+ );
1025
+ }
1026
+ var rulesOn = /* @__PURE__ */ new Set();
1027
+ var rulesOff = /* @__PURE__ */ new Set();
1028
+ function recordRulesStateConfigs(configs) {
1029
+ for (const config of configs)
1030
+ recordRulesState(config.rules ?? {});
1031
+ return configs;
1032
+ }
1033
+ function recordRulesState(rules) {
1034
+ for (const [key, value] of Object.entries(rules ?? {})) {
1035
+ const firstValue = Array.isArray(value) ? value[0] : value;
1036
+ if (firstValue == null)
1037
+ continue;
1038
+ if (firstValue === "off" || firstValue === 0)
1039
+ rulesOff.add(key);
1040
+ else
1041
+ rulesOn.add(key);
1042
+ }
1043
+ return rules;
1044
+ }
1045
+ function warnUnnecessaryOffRules() {
1046
+ const unnecessaryOffRules = [...rulesOff].filter((key) => !rulesOn.has(key));
1047
+ for (const off of unnecessaryOffRules)
1048
+ console.warn(`[eslint] rule \`${off}\` is never turned on, you can remove the rule from your config`);
1049
+ }
1050
+
1051
+ // src/configs/typescript.ts
1052
+ function typescript(options) {
1053
+ const {
1054
+ componentExts = [],
1055
+ overrides = {},
1056
+ parserOptions = {},
1057
+ tsconfigPath
1058
+ } = options ?? {};
1059
+ const typeAwareRules = {
1060
+ "dot-notation": OFF,
1061
+ "no-implied-eval": OFF,
1062
+ "no-throw-literal": OFF,
1063
+ "ts/await-thenable": "error",
1064
+ "ts/dot-notation": ["error", { allowKeywords: true }],
1065
+ "ts/no-floating-promises": "error",
1066
+ "ts/no-for-in-array": "error",
1067
+ "ts/no-implied-eval": "error",
1068
+ "ts/no-misused-promises": "error",
1069
+ "ts/no-throw-literal": "error",
1070
+ "ts/no-unnecessary-type-assertion": "error",
1071
+ "ts/no-unsafe-argument": "error",
1072
+ "ts/no-unsafe-assignment": "error",
1073
+ "ts/no-unsafe-call": "error",
1074
+ "ts/no-unsafe-member-access": "error",
1075
+ "ts/no-unsafe-return": "error",
1076
+ "ts/restrict-plus-operands": "error",
1077
+ "ts/restrict-template-expressions": "error",
1078
+ "ts/unbound-method": "error"
1079
+ };
1080
+ return [
1081
+ {
1082
+ // Install the plugins without globs, so they can be configured separately.
1083
+ name: "antfu:typescript:setup",
1084
+ plugins: {
1085
+ antfu: import_eslint_plugin_antfu.default,
1086
+ import: pluginImport,
1087
+ ts: import_eslint_plugin2.default
1088
+ }
1089
+ },
1090
+ {
1091
+ files: [
1092
+ GLOB_SRC,
1093
+ ...componentExts.map((ext) => `**/*.${ext}`)
1094
+ ],
1095
+ languageOptions: {
1096
+ parser: parserTs,
1097
+ parserOptions: {
1098
+ sourceType: "module",
1099
+ ...tsconfigPath ? {
1100
+ project: [tsconfigPath],
1101
+ tsconfigRootDir: import_node_process.default.cwd()
1102
+ } : {},
1103
+ ...parserOptions
1104
+ }
1105
+ },
1106
+ name: "antfu:typescript:rules",
1107
+ rules: {
1108
+ ...renameRules(
1109
+ import_eslint_plugin2.default.configs["eslint-recommended"].overrides[0].rules,
1110
+ "@typescript-eslint/",
1111
+ "ts/"
1112
+ ),
1113
+ ...renameRules(
1114
+ import_eslint_plugin2.default.configs.strict.rules,
1115
+ "@typescript-eslint/",
1116
+ "ts/"
1117
+ ),
1118
+ "antfu/generic-spacing": "error",
1119
+ "antfu/named-tuple-spacing": "error",
1120
+ "antfu/no-cjs-exports": "error",
1121
+ "no-dupe-class-members": OFF,
1122
+ "no-invalid-this": OFF,
1123
+ "no-loss-of-precision": OFF,
1124
+ "no-redeclare": OFF,
1125
+ "no-use-before-define": OFF,
1126
+ "no-useless-constructor": OFF,
1127
+ "ts/ban-ts-comment": ["error", { "ts-ignore": "allow-with-description" }],
1128
+ "ts/ban-types": ["error", { types: { Function: false } }],
1129
+ "ts/consistent-type-definitions": ["error", "interface"],
1130
+ "ts/consistent-type-imports": ["error", { disallowTypeAnnotations: false, prefer: "type-imports" }],
1131
+ "ts/no-dupe-class-members": "error",
1132
+ "ts/no-dynamic-delete": OFF,
1133
+ "ts/no-explicit-any": OFF,
1134
+ "ts/no-extraneous-class": OFF,
1135
+ "ts/no-invalid-this": "error",
1136
+ "ts/no-invalid-void-type": OFF,
1137
+ "ts/no-loss-of-precision": "error",
1138
+ "ts/no-non-null-assertion": OFF,
1139
+ "ts/no-redeclare": "error",
1140
+ "ts/no-require-imports": "error",
1141
+ "ts/no-unused-vars": OFF,
1142
+ "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
1143
+ "ts/no-useless-constructor": OFF,
1144
+ "ts/prefer-ts-expect-error": "error",
1145
+ "ts/triple-slash-reference": OFF,
1146
+ "ts/unified-signatures": OFF,
1147
+ ...tsconfigPath ? typeAwareRules : {},
1148
+ ...overrides
1149
+ }
1150
+ },
1151
+ {
1152
+ files: ["**/*.d.ts"],
1153
+ name: "antfu:typescript:dts-overrides",
1154
+ rules: {
1155
+ "eslint-comments/no-unlimited-disable": OFF,
1156
+ "import/no-duplicates": OFF,
1157
+ "no-restricted-syntax": OFF,
1158
+ "unused-imports/no-unused-vars": OFF
1159
+ }
1160
+ },
1161
+ {
1162
+ files: ["**/*.{test,spec}.ts?(x)"],
1163
+ name: "antfu:typescript:tests-overrides",
1164
+ rules: {
1165
+ "no-unused-expressions": OFF
1166
+ }
1167
+ },
1168
+ {
1169
+ files: ["**/*.js", "**/*.cjs"],
1170
+ name: "antfu:typescript:javascript-overrides",
1171
+ rules: {
1172
+ "ts/no-require-imports": OFF,
1173
+ "ts/no-var-requires": OFF
1174
+ }
1175
+ }
1176
+ ];
1177
+ }
1178
+
1179
+ // src/configs/unicorn.ts
1180
+ function unicorn() {
1181
+ return [
1182
+ {
1183
+ name: "antfu:unicorn",
1184
+ plugins: {
1185
+ unicorn: import_eslint_plugin_unicorn.default
1186
+ },
1187
+ rules: {
1188
+ // Pass error message when throwing errors
1189
+ "unicorn/error-message": "error",
1190
+ // Uppercase regex escapes
1191
+ "unicorn/escape-case": "error",
1192
+ // Array.isArray instead of instanceof
1193
+ "unicorn/no-instanceof-array": "error",
1194
+ // Ban `new Array` as `Array` constructor's params are ambiguous
1195
+ "unicorn/no-new-array": "error",
1196
+ // Prevent deprecated `new Buffer()`
1197
+ "unicorn/no-new-buffer": "error",
1198
+ // Lowercase number formatting for octal, hex, binary (0x1'error' instead of 0X1'error')
1199
+ "unicorn/number-literal-case": "error",
1200
+ // textContent instead of innerText
1201
+ "unicorn/prefer-dom-node-text-content": "error",
1202
+ // includes over indexOf when checking for existence
1203
+ "unicorn/prefer-includes": "error",
1204
+ // Prefer using the node: protocol
1205
+ "unicorn/prefer-node-protocol": "error",
1206
+ // Prefer using number properties like `Number.isNaN` rather than `isNaN`
1207
+ "unicorn/prefer-number-properties": "error",
1208
+ // String methods startsWith/endsWith instead of more complicated stuff
1209
+ "unicorn/prefer-string-starts-ends-with": "error",
1210
+ // Enforce throwing type error when throwing error while checking typeof
1211
+ "unicorn/prefer-type-error": "error",
1212
+ // Use new when throwing error
1213
+ "unicorn/throw-new-error": "error"
1214
+ }
1215
+ }
1216
+ ];
1217
+ }
1218
+
1219
+ // src/configs/vue.ts
1220
+ function vue(options = {}) {
1221
+ const {
1222
+ overrides = {},
1223
+ stylistic: stylistic2 = true
1224
+ } = options;
1225
+ const {
1226
+ indent = 2
1227
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1228
+ return [
1229
+ {
1230
+ name: "antfu:vue:setup",
1231
+ plugins: {
1232
+ vue: import_eslint_plugin_vue.default
1233
+ }
1234
+ },
1235
+ {
1236
+ files: [GLOB_VUE],
1237
+ languageOptions: {
1238
+ parser: import_vue_eslint_parser.default,
1239
+ parserOptions: {
1240
+ ecmaFeatures: {
1241
+ jsx: true
1242
+ },
1243
+ extraFileExtensions: [".vue"],
1244
+ parser: options.typescript ? parserTs : null,
1245
+ sourceType: "module"
1246
+ }
1247
+ },
1248
+ name: "antfu:vue:rules",
1249
+ processor: import_eslint_plugin_vue.default.processors[".vue"],
1250
+ rules: {
1251
+ ...import_eslint_plugin_vue.default.configs.base.rules,
1252
+ ...import_eslint_plugin_vue.default.configs["vue3-essential"].rules,
1253
+ ...import_eslint_plugin_vue.default.configs["vue3-strongly-recommended"].rules,
1254
+ ...import_eslint_plugin_vue.default.configs["vue3-recommended"].rules,
1255
+ "node/prefer-global/process": OFF,
1256
+ "vue/block-order": ["error", {
1257
+ order: ["script", "template", "style"]
1258
+ }],
1259
+ "vue/component-name-in-template-casing": ["error", "PascalCase"],
1260
+ "vue/component-options-name-casing": ["error", "PascalCase"],
1261
+ "vue/custom-event-name-casing": ["error", "camelCase"],
1262
+ "vue/define-macros-order": ["error", {
1263
+ order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
1264
+ }],
1265
+ "vue/dot-location": ["error", "property"],
1266
+ "vue/dot-notation": ["error", { allowKeywords: true }],
1267
+ "vue/eqeqeq": ["error", "smart"],
1268
+ "vue/html-indent": ["error", indent],
1269
+ "vue/html-quotes": ["error", "double"],
1270
+ "vue/max-attributes-per-line": OFF,
1271
+ "vue/multi-word-component-names": OFF,
1272
+ "vue/no-dupe-keys": OFF,
1273
+ "vue/no-empty-pattern": "error",
1274
+ "vue/no-extra-parens": ["error", "functions"],
1275
+ "vue/no-irregular-whitespace": "error",
1276
+ "vue/no-loss-of-precision": "error",
1277
+ "vue/no-restricted-syntax": [
1278
+ "error",
1279
+ "DebuggerStatement",
1280
+ "LabeledStatement",
1281
+ "WithStatement"
1282
+ ],
1283
+ "vue/no-restricted-v-bind": ["error", "/^v-/"],
1284
+ "vue/no-setup-props-reactivity-loss": OFF,
1285
+ "vue/no-sparse-arrays": "error",
1286
+ "vue/no-unused-refs": "error",
1287
+ "vue/no-useless-v-bind": "error",
1288
+ "vue/no-v-html": OFF,
1289
+ "vue/object-shorthand": [
1290
+ "error",
1291
+ "always",
1292
+ {
1293
+ avoidQuotes: true,
1294
+ ignoreConstructors: false
1295
+ }
1296
+ ],
1297
+ "vue/prefer-separate-static-class": "error",
1298
+ "vue/prefer-template": "error",
1299
+ "vue/require-default-prop": OFF,
1300
+ "vue/require-prop-types": OFF,
1301
+ "vue/space-infix-ops": "error",
1302
+ "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
1303
+ ...stylistic2 ? {
1304
+ "vue/array-bracket-spacing": ["error", "never"],
1305
+ "vue/arrow-spacing": ["error", { after: true, before: true }],
1306
+ "vue/block-spacing": ["error", "always"],
1307
+ "vue/block-tag-newline": ["error", {
1308
+ multiline: "always",
1309
+ singleline: "always"
1310
+ }],
1311
+ "vue/brace-style": ["error", "stroustrup", { allowSingleLine: true }],
1312
+ "vue/comma-dangle": ["error", "always-multiline"],
1313
+ "vue/comma-spacing": ["error", { after: true, before: false }],
1314
+ "vue/comma-style": ["error", "last"],
1315
+ "vue/html-comment-content-spacing": ["error", "always", {
1316
+ exceptions: ["-"]
1317
+ }],
1318
+ "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1319
+ "vue/keyword-spacing": ["error", { after: true, before: true }],
1320
+ "vue/object-curly-newline": OFF,
1321
+ "vue/object-curly-spacing": ["error", "always"],
1322
+ "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1323
+ "vue/operator-linebreak": ["error", "before"],
1324
+ "vue/padding-line-between-blocks": ["error", "always"],
1325
+ "vue/quote-props": ["error", "consistent-as-needed"],
1326
+ "vue/space-in-parens": ["error", "never"],
1327
+ "vue/template-curly-spacing": "error"
1328
+ } : {},
1329
+ ...overrides
1330
+ }
1331
+ }
1332
+ ];
1333
+ }
1334
+
1335
+ // src/configs/yaml.ts
1336
+ function yaml(options = {}) {
1337
+ const {
1338
+ overrides = {},
1339
+ stylistic: stylistic2 = true
1340
+ } = options;
1341
+ const {
1342
+ indent = 2,
1343
+ quotes = "single"
1344
+ } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1345
+ return [
1346
+ {
1347
+ name: "antfu:yaml:setup",
1348
+ plugins: {
1349
+ yaml: pluginYaml
1350
+ }
1351
+ },
1352
+ {
1353
+ files: [GLOB_YAML],
1354
+ languageOptions: {
1355
+ parser: import_yaml_eslint_parser.default
1356
+ },
1357
+ name: "antfu:yaml:rules",
1358
+ rules: {
1359
+ "style/spaced-comment": OFF,
1360
+ "yaml/block-mapping": "error",
1361
+ "yaml/block-sequence": "error",
1362
+ "yaml/no-empty-key": "error",
1363
+ "yaml/no-empty-sequence-entry": "error",
1364
+ "yaml/no-irregular-whitespace": "error",
1365
+ "yaml/plain-scalar": "error",
1366
+ "yaml/vue-custom-block/no-parsing-error": "error",
1367
+ ...stylistic2 ? {
1368
+ "yaml/block-mapping-question-indicator-newline": "error",
1369
+ "yaml/block-sequence-hyphen-indicator-newline": "error",
1370
+ "yaml/flow-mapping-curly-newline": "error",
1371
+ "yaml/flow-mapping-curly-spacing": "error",
1372
+ "yaml/flow-sequence-bracket-newline": "error",
1373
+ "yaml/flow-sequence-bracket-spacing": "error",
1374
+ "yaml/indent": ["error", indent === "tab" ? 2 : indent],
1375
+ "yaml/key-spacing": "error",
1376
+ "yaml/no-tab-indent": "error",
1377
+ "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
1378
+ "yaml/spaced-comment": "error"
1379
+ } : {},
1380
+ ...overrides
1381
+ }
1382
+ }
1383
+ ];
1384
+ }
1385
+
1386
+ // src/configs/test.ts
1387
+ function test(options = {}) {
1388
+ const {
1389
+ isInEditor = false,
1390
+ overrides = {}
1391
+ } = options;
1392
+ return [
1393
+ {
1394
+ name: "antfu:test:setup",
1395
+ plugins: {
1396
+ test: {
1397
+ ...import_eslint_plugin_vitest.default,
1398
+ rules: {
1399
+ ...import_eslint_plugin_vitest.default.rules,
1400
+ // extend `test/no-only-tests` rule
1401
+ ...import_eslint_plugin_no_only_tests.default.rules
1402
+ }
1403
+ }
1404
+ }
1405
+ },
1406
+ {
1407
+ files: GLOB_TESTS,
1408
+ name: "antfu:test:rules",
1409
+ rules: {
1410
+ "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1411
+ "test/no-identical-title": "error",
1412
+ "test/no-only-tests": isInEditor ? OFF : "error",
1413
+ "test/prefer-hooks-in-order": "error",
1414
+ "test/prefer-lowercase-title": "error",
1415
+ ...overrides
1416
+ }
1417
+ }
1418
+ ];
1419
+ }
1420
+
1421
+ // src/factory.ts
1422
+ var flatConfigProps = [
1423
+ "files",
1424
+ "ignores",
1425
+ "languageOptions",
1426
+ "linterOptions",
1427
+ "processor",
1428
+ "plugins",
1429
+ "rules",
1430
+ "settings"
1431
+ ];
1432
+ var VuePackages = [
1433
+ "vue",
1434
+ "nuxt",
1435
+ "vitepress",
1436
+ "@slidev/cli"
1437
+ ];
1438
+ function antfu(options = {}, ...userConfigs) {
1439
+ const {
1440
+ isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE) && !import_node_process2.default.env.CI),
1441
+ vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i)),
1442
+ typescript: enableTypeScript = (0, import_local_pkg.isPackageExists)("typescript"),
1443
+ stylistic: enableStylistic = true,
1444
+ gitignore: enableGitignore = true,
1445
+ overrides = {},
1446
+ componentExts = []
1447
+ } = options;
1448
+ const configs = [];
1449
+ if (enableGitignore) {
1450
+ if (typeof enableGitignore !== "boolean") {
1451
+ configs.push([(0, import_eslint_config_flat_gitignore.default)(enableGitignore)]);
1452
+ } else {
1453
+ if (import_node_fs.default.existsSync(".gitignore"))
1454
+ configs.push([(0, import_eslint_config_flat_gitignore.default)()]);
1455
+ }
1456
+ }
1457
+ configs.push(
1458
+ ignores(),
1459
+ javascript({
1460
+ isInEditor,
1461
+ overrides: overrides.javascript
1462
+ }),
1463
+ comments(),
1464
+ node(),
1465
+ jsdoc({
1466
+ stylistic: enableStylistic
1467
+ }),
1468
+ imports({
1469
+ stylistic: enableStylistic
1470
+ }),
1471
+ unicorn()
1472
+ );
1473
+ if (enableVue)
1474
+ componentExts.push("vue");
1475
+ if (enableTypeScript) {
1476
+ configs.push(typescript({
1477
+ ...typeof enableTypeScript !== "boolean" ? enableTypeScript : {},
1478
+ componentExts,
1479
+ overrides: overrides.typescript
1480
+ }));
1481
+ }
1482
+ if (enableStylistic) {
1483
+ configs.push(stylistic(
1484
+ typeof enableStylistic === "boolean" ? {} : enableStylistic
1485
+ ));
1486
+ }
1487
+ if (options.test ?? true) {
1488
+ configs.push(test({
1489
+ isInEditor,
1490
+ overrides: overrides.test
1491
+ }));
1492
+ }
1493
+ if (enableVue) {
1494
+ configs.push(vue({
1495
+ overrides: overrides.vue,
1496
+ stylistic: enableStylistic,
1497
+ typescript: !!enableTypeScript
1498
+ }));
1499
+ }
1500
+ if (options.jsonc ?? true) {
1501
+ configs.push(
1502
+ jsonc({
1503
+ overrides: overrides.jsonc,
1504
+ stylistic: enableStylistic
1505
+ }),
1506
+ sortPackageJson(),
1507
+ sortTsconfig()
1508
+ );
1509
+ }
1510
+ if (options.yaml ?? true) {
1511
+ configs.push(yaml({
1512
+ overrides: overrides.yaml,
1513
+ stylistic: enableStylistic
1514
+ }));
1515
+ }
1516
+ if (options.markdown ?? true) {
1517
+ configs.push(markdown({
1518
+ componentExts,
1519
+ overrides: overrides.markdown
1520
+ }));
1521
+ }
1522
+ const fusedConfig = flatConfigProps.reduce((acc, key) => {
1523
+ if (key in options)
1524
+ acc[key] = options[key];
1525
+ return acc;
1526
+ }, {});
1527
+ if (Object.keys(fusedConfig).length)
1528
+ configs.push([fusedConfig]);
1529
+ const merged = combine(
1530
+ ...configs,
1531
+ ...userConfigs
1532
+ );
1533
+ return merged;
1534
+ }
1535
+
1536
+ // src/index.ts
1537
+ var src_default = antfu;
1538
+ // Annotate the CommonJS export names for ESM import in node:
1539
+ 0 && (module.exports = {
1540
+ GLOB_ALL_SRC,
1541
+ GLOB_CSS,
1542
+ GLOB_EXCLUDE,
1543
+ GLOB_HTML,
1544
+ GLOB_JS,
1545
+ GLOB_JSON,
1546
+ GLOB_JSON5,
1547
+ GLOB_JSONC,
1548
+ GLOB_JSX,
1549
+ GLOB_LESS,
1550
+ GLOB_MARKDOWN,
1551
+ GLOB_MARKDOWN_CODE,
1552
+ GLOB_SCSS,
1553
+ GLOB_SRC,
1554
+ GLOB_SRC_EXT,
1555
+ GLOB_STYLE,
1556
+ GLOB_TESTS,
1557
+ GLOB_TS,
1558
+ GLOB_TSX,
1559
+ GLOB_VUE,
1560
+ GLOB_YAML,
1561
+ antfu,
1562
+ combine,
1563
+ comments,
1564
+ ignores,
1565
+ imports,
1566
+ javascript,
1567
+ jsdoc,
1568
+ jsonc,
1569
+ markdown,
1570
+ node,
1571
+ parserJsonc,
1572
+ parserTs,
1573
+ parserVue,
1574
+ parserYaml,
1575
+ pluginAntfu,
1576
+ pluginComments,
1577
+ pluginImport,
1578
+ pluginJsdoc,
1579
+ pluginJsonc,
1580
+ pluginMarkdown,
1581
+ pluginNoOnlyTests,
1582
+ pluginNode,
1583
+ pluginStylistic,
1584
+ pluginTs,
1585
+ pluginUnicorn,
1586
+ pluginUnusedImports,
1587
+ pluginVitest,
1588
+ pluginVue,
1589
+ pluginYaml,
1590
+ recordRulesState,
1591
+ recordRulesStateConfigs,
1592
+ renameRules,
1593
+ sortPackageJson,
1594
+ sortTsconfig,
1595
+ stylistic,
1596
+ test,
1597
+ typescript,
1598
+ unicorn,
1599
+ vue,
1600
+ warnUnnecessaryOffRules,
1601
+ yaml
1602
+ });