@antfu/eslint-config 1.2.0 → 2.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/README.md +19 -18
- package/dist/cli.cjs +12 -13
- package/dist/cli.js +12 -13
- package/dist/index.cjs +103 -113
- package/dist/index.d.cts +35 -53
- package/dist/index.d.ts +35 -53
- package/dist/index.js +110 -101
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -87,13 +87,13 @@ For example:
|
|
|
87
87
|
|
|
88
88
|
### Migration
|
|
89
89
|
|
|
90
|
-
We provided an experimental
|
|
90
|
+
We provided an experimental CLI tool to help you migrate from the legacy config to the new flat config.
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
|
-
npx @antfu/eslint-config
|
|
93
|
+
npx @antfu/eslint-config@latest
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
Before running the migration, make sure to commit your changes first.
|
|
96
|
+
Before running the migration, make sure to commit your unsaved changes first.
|
|
97
97
|
|
|
98
98
|
## VS Code support (auto fix)
|
|
99
99
|
|
|
@@ -223,6 +223,7 @@ We don't recommend using this style in general usages, as there are shared optio
|
|
|
223
223
|
```js
|
|
224
224
|
// eslint.config.js
|
|
225
225
|
import {
|
|
226
|
+
combine,
|
|
226
227
|
comments,
|
|
227
228
|
ignores,
|
|
228
229
|
imports,
|
|
@@ -240,21 +241,21 @@ import {
|
|
|
240
241
|
yaml,
|
|
241
242
|
} from '@antfu/eslint-config'
|
|
242
243
|
|
|
243
|
-
export default
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
244
|
+
export default combine(
|
|
245
|
+
ignores(),
|
|
246
|
+
javascript(/* Options */),
|
|
247
|
+
comments(),
|
|
248
|
+
node(),
|
|
249
|
+
jsdoc(),
|
|
250
|
+
imports(),
|
|
251
|
+
unicorn(),
|
|
252
|
+
typescript(/* Options */),
|
|
253
|
+
stylistic(),
|
|
254
|
+
vue(),
|
|
255
|
+
jsonc(),
|
|
256
|
+
yaml(),
|
|
257
|
+
markdown(),
|
|
258
|
+
)
|
|
258
259
|
```
|
|
259
260
|
|
|
260
261
|
</details>
|
package/dist/cli.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
|
46
46
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
47
47
|
|
|
48
48
|
// package.json
|
|
49
|
-
var version = "
|
|
49
|
+
var version = "2.0.0";
|
|
50
50
|
|
|
51
51
|
// src/cli/constants.ts
|
|
52
52
|
var ARROW = import_picocolors.default.cyan("\u2192");
|
|
@@ -107,9 +107,9 @@ function isGitClean() {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// src/cli/run.ts
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
async function run(options = {}) {
|
|
111
|
+
const SKIP_PROMPT = !!import_node_process.default.env.SKIP_PROMPT || options.yes;
|
|
112
|
+
const SKIP_GIT_CHECK = !!import_node_process.default.env.SKIP_GIT_CHECK;
|
|
113
113
|
const cwd = import_node_process.default.cwd();
|
|
114
114
|
const pathFlatConfig = import_node_path.default.join(cwd, "eslint.config.js");
|
|
115
115
|
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
@@ -125,6 +125,8 @@ async function run() {
|
|
|
125
125
|
const pkg = JSON.parse(pkgContent);
|
|
126
126
|
pkg.devDependencies ?? (pkg.devDependencies = {});
|
|
127
127
|
pkg.devDependencies["@antfu/eslint-config"] = `^${version}`;
|
|
128
|
+
if (!pkg.devDependencies.eslint)
|
|
129
|
+
pkg.devDependencies.eslint = "^8";
|
|
128
130
|
await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
129
131
|
console.log(import_picocolors2.default.green(`${CHECK} changes wrote to package.json`));
|
|
130
132
|
const eslintIgnores = [];
|
|
@@ -221,22 +223,19 @@ function header() {
|
|
|
221
223
|
${import_picocolors3.default.green(`@antfu/eslint-config `)}${import_picocolors3.default.dim(`v${version}`)}`);
|
|
222
224
|
}
|
|
223
225
|
var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process2.default.argv)).scriptName("@antfu/eslint-config").usage("").command(
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
(args) => args.help(),
|
|
227
|
-
async (
|
|
226
|
+
"*",
|
|
227
|
+
"Run the initialization or migration",
|
|
228
|
+
(args) => args.option("yes", { alias: "y", description: "Skip prompts and use default values", type: "boolean" }).help(),
|
|
229
|
+
async (args) => {
|
|
228
230
|
header();
|
|
229
231
|
console.log();
|
|
230
232
|
try {
|
|
231
|
-
await run();
|
|
233
|
+
await run(args);
|
|
232
234
|
} catch (error) {
|
|
233
235
|
console.error(import_picocolors3.default.inverse(import_picocolors3.default.red(" Failed to migrate ")));
|
|
234
236
|
console.error(import_picocolors3.default.red(`${CROSS} ${String(error)}`));
|
|
235
237
|
import_node_process2.default.exit(1);
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
|
-
).
|
|
239
|
-
header();
|
|
240
|
-
instance.showHelp();
|
|
241
|
-
}).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
|
|
240
|
+
).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
|
|
242
241
|
instance.help().argv;
|
package/dist/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import parse from "parse-gitignore";
|
|
|
17
17
|
import c from "picocolors";
|
|
18
18
|
|
|
19
19
|
// package.json
|
|
20
|
-
var version = "
|
|
20
|
+
var version = "2.0.0";
|
|
21
21
|
|
|
22
22
|
// src/cli/constants.ts
|
|
23
23
|
var ARROW = c.cyan("\u2192");
|
|
@@ -78,9 +78,9 @@ function isGitClean() {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
// src/cli/run.ts
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
async function run(options = {}) {
|
|
82
|
+
const SKIP_PROMPT = !!process.env.SKIP_PROMPT || options.yes;
|
|
83
|
+
const SKIP_GIT_CHECK = !!process.env.SKIP_GIT_CHECK;
|
|
84
84
|
const cwd = process.cwd();
|
|
85
85
|
const pathFlatConfig = path.join(cwd, "eslint.config.js");
|
|
86
86
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
@@ -96,6 +96,8 @@ async function run() {
|
|
|
96
96
|
const pkg = JSON.parse(pkgContent);
|
|
97
97
|
pkg.devDependencies ?? (pkg.devDependencies = {});
|
|
98
98
|
pkg.devDependencies["@antfu/eslint-config"] = `^${version}`;
|
|
99
|
+
if (!pkg.devDependencies.eslint)
|
|
100
|
+
pkg.devDependencies.eslint = "^8";
|
|
99
101
|
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
100
102
|
console.log(c2.green(`${CHECK} changes wrote to package.json`));
|
|
101
103
|
const eslintIgnores = [];
|
|
@@ -192,22 +194,19 @@ function header() {
|
|
|
192
194
|
${c3.green(`@antfu/eslint-config `)}${c3.dim(`v${version}`)}`);
|
|
193
195
|
}
|
|
194
196
|
var instance = yargs(hideBin(process2.argv)).scriptName("@antfu/eslint-config").usage("").command(
|
|
195
|
-
"
|
|
196
|
-
"
|
|
197
|
-
(args) => args.help(),
|
|
198
|
-
async (
|
|
197
|
+
"*",
|
|
198
|
+
"Run the initialization or migration",
|
|
199
|
+
(args) => args.option("yes", { alias: "y", description: "Skip prompts and use default values", type: "boolean" }).help(),
|
|
200
|
+
async (args) => {
|
|
199
201
|
header();
|
|
200
202
|
console.log();
|
|
201
203
|
try {
|
|
202
|
-
await run();
|
|
204
|
+
await run(args);
|
|
203
205
|
} catch (error) {
|
|
204
206
|
console.error(c3.inverse(c3.red(" Failed to migrate ")));
|
|
205
207
|
console.error(c3.red(`${CROSS} ${String(error)}`));
|
|
206
208
|
process2.exit(1);
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
|
-
).
|
|
210
|
-
header();
|
|
211
|
-
instance.showHelp();
|
|
212
|
-
}).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
|
|
211
|
+
).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
|
|
213
212
|
instance.help().argv;
|
package/dist/index.cjs
CHANGED
|
@@ -57,32 +57,13 @@ __export(src_exports, {
|
|
|
57
57
|
default: () => src_default,
|
|
58
58
|
ignores: () => ignores,
|
|
59
59
|
imports: () => imports,
|
|
60
|
+
interopDefault: () => interopDefault,
|
|
60
61
|
javascript: () => javascript,
|
|
61
62
|
jsdoc: () => jsdoc,
|
|
62
63
|
jsonc: () => jsonc,
|
|
63
64
|
markdown: () => markdown,
|
|
64
65
|
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
66
|
perfectionist: () => perfectionist,
|
|
70
|
-
pluginAntfu: () => import_eslint_plugin_antfu.default,
|
|
71
|
-
pluginComments: () => import_eslint_plugin_eslint_comments.default,
|
|
72
|
-
pluginImport: () => pluginImport,
|
|
73
|
-
pluginJsdoc: () => import_eslint_plugin_jsdoc.default,
|
|
74
|
-
pluginJsonc: () => pluginJsonc,
|
|
75
|
-
pluginMarkdown: () => import_eslint_plugin_markdown.default,
|
|
76
|
-
pluginNoOnlyTests: () => import_eslint_plugin_no_only_tests.default,
|
|
77
|
-
pluginNode: () => import_eslint_plugin_n.default,
|
|
78
|
-
pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
|
|
79
|
-
pluginStylistic: () => import_eslint_plugin.default,
|
|
80
|
-
pluginTs: () => import_eslint_plugin2.default,
|
|
81
|
-
pluginUnicorn: () => import_eslint_plugin_unicorn.default,
|
|
82
|
-
pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
|
|
83
|
-
pluginVitest: () => import_eslint_plugin_vitest.default,
|
|
84
|
-
pluginVue: () => import_eslint_plugin_vue.default,
|
|
85
|
-
pluginYaml: () => pluginYaml,
|
|
86
67
|
renameRules: () => renameRules,
|
|
87
68
|
sortPackageJson: () => sortPackageJson,
|
|
88
69
|
sortTsconfig: () => sortTsconfig,
|
|
@@ -100,32 +81,18 @@ module.exports = __toCommonJS(src_exports);
|
|
|
100
81
|
var import_node_process2 = __toESM(require("process"), 1);
|
|
101
82
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
102
83
|
var import_local_pkg = require("local-pkg");
|
|
103
|
-
var import_eslint_config_flat_gitignore = __toESM(require("eslint-config-flat-gitignore"), 1);
|
|
104
84
|
|
|
105
85
|
// src/plugins.ts
|
|
106
86
|
var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
|
|
107
87
|
var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
|
|
108
88
|
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
89
|
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
90
|
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
116
91
|
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
92
|
var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
|
|
122
|
-
var parserTs = __toESM(require("@typescript-eslint/parser"), 1);
|
|
123
|
-
var import_vue_eslint_parser = __toESM(require("vue-eslint-parser"), 1);
|
|
124
|
-
var import_yaml_eslint_parser = __toESM(require("yaml-eslint-parser"), 1);
|
|
125
|
-
var import_jsonc_eslint_parser = __toESM(require("jsonc-eslint-parser"), 1);
|
|
126
93
|
|
|
127
94
|
// src/configs/comments.ts
|
|
128
|
-
function comments() {
|
|
95
|
+
async function comments() {
|
|
129
96
|
return [
|
|
130
97
|
{
|
|
131
98
|
name: "antfu:eslint-comments",
|
|
@@ -210,7 +177,7 @@ var GLOB_EXCLUDE = [
|
|
|
210
177
|
];
|
|
211
178
|
|
|
212
179
|
// src/configs/ignores.ts
|
|
213
|
-
function ignores() {
|
|
180
|
+
async function ignores() {
|
|
214
181
|
return [
|
|
215
182
|
{
|
|
216
183
|
ignores: GLOB_EXCLUDE
|
|
@@ -219,7 +186,7 @@ function ignores() {
|
|
|
219
186
|
}
|
|
220
187
|
|
|
221
188
|
// src/configs/imports.ts
|
|
222
|
-
function imports(options = {}) {
|
|
189
|
+
async function imports(options = {}) {
|
|
223
190
|
const {
|
|
224
191
|
stylistic: stylistic2 = true
|
|
225
192
|
} = options;
|
|
@@ -250,7 +217,7 @@ function imports(options = {}) {
|
|
|
250
217
|
|
|
251
218
|
// src/configs/javascript.ts
|
|
252
219
|
var import_globals = __toESM(require("globals"), 1);
|
|
253
|
-
function javascript(options = {}) {
|
|
220
|
+
async function javascript(options = {}) {
|
|
254
221
|
const {
|
|
255
222
|
isInEditor = false,
|
|
256
223
|
overrides = {}
|
|
@@ -467,7 +434,7 @@ function javascript(options = {}) {
|
|
|
467
434
|
}
|
|
468
435
|
|
|
469
436
|
// src/configs/jsdoc.ts
|
|
470
|
-
function jsdoc(options = {}) {
|
|
437
|
+
async function jsdoc(options = {}) {
|
|
471
438
|
const {
|
|
472
439
|
stylistic: stylistic2 = true
|
|
473
440
|
} = options;
|
|
@@ -475,7 +442,8 @@ function jsdoc(options = {}) {
|
|
|
475
442
|
{
|
|
476
443
|
name: "antfu:jsdoc",
|
|
477
444
|
plugins: {
|
|
478
|
-
|
|
445
|
+
// @ts-expect-error missing types
|
|
446
|
+
jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
|
|
479
447
|
},
|
|
480
448
|
rules: {
|
|
481
449
|
"jsdoc/check-access": "warn",
|
|
@@ -502,8 +470,30 @@ function jsdoc(options = {}) {
|
|
|
502
470
|
];
|
|
503
471
|
}
|
|
504
472
|
|
|
473
|
+
// src/utils.ts
|
|
474
|
+
async function combine(...configs) {
|
|
475
|
+
const resolved = await Promise.all(configs);
|
|
476
|
+
return resolved.flat();
|
|
477
|
+
}
|
|
478
|
+
function renameRules(rules, from, to) {
|
|
479
|
+
return Object.fromEntries(
|
|
480
|
+
Object.entries(rules).map(([key, value]) => {
|
|
481
|
+
if (key.startsWith(from))
|
|
482
|
+
return [to + key.slice(from.length), value];
|
|
483
|
+
return [key, value];
|
|
484
|
+
})
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
function toArray(value) {
|
|
488
|
+
return Array.isArray(value) ? value : [value];
|
|
489
|
+
}
|
|
490
|
+
async function interopDefault(m) {
|
|
491
|
+
const resolved = await m;
|
|
492
|
+
return resolved.default || resolved;
|
|
493
|
+
}
|
|
494
|
+
|
|
505
495
|
// src/configs/jsonc.ts
|
|
506
|
-
function jsonc(options = {}) {
|
|
496
|
+
async function jsonc(options = {}) {
|
|
507
497
|
const {
|
|
508
498
|
overrides = {},
|
|
509
499
|
stylistic: stylistic2 = true
|
|
@@ -511,6 +501,13 @@ function jsonc(options = {}) {
|
|
|
511
501
|
const {
|
|
512
502
|
indent = 2
|
|
513
503
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
504
|
+
const [
|
|
505
|
+
pluginJsonc,
|
|
506
|
+
parserJsonc
|
|
507
|
+
] = await Promise.all([
|
|
508
|
+
interopDefault(import("eslint-plugin-jsonc")),
|
|
509
|
+
interopDefault(import("jsonc-eslint-parser"))
|
|
510
|
+
]);
|
|
514
511
|
return [
|
|
515
512
|
{
|
|
516
513
|
name: "antfu:jsonc:setup",
|
|
@@ -521,7 +518,7 @@ function jsonc(options = {}) {
|
|
|
521
518
|
{
|
|
522
519
|
files: [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
523
520
|
languageOptions: {
|
|
524
|
-
parser:
|
|
521
|
+
parser: parserJsonc
|
|
525
522
|
},
|
|
526
523
|
name: "antfu:jsonc:rules",
|
|
527
524
|
rules: {
|
|
@@ -570,7 +567,7 @@ function jsonc(options = {}) {
|
|
|
570
567
|
}
|
|
571
568
|
|
|
572
569
|
// src/configs/markdown.ts
|
|
573
|
-
function markdown(options = {}) {
|
|
570
|
+
async function markdown(options = {}) {
|
|
574
571
|
const {
|
|
575
572
|
componentExts = [],
|
|
576
573
|
overrides = {}
|
|
@@ -579,7 +576,8 @@ function markdown(options = {}) {
|
|
|
579
576
|
{
|
|
580
577
|
name: "antfu:markdown:setup",
|
|
581
578
|
plugins: {
|
|
582
|
-
|
|
579
|
+
// @ts-expect-error missing types
|
|
580
|
+
markdown: await interopDefault(import("eslint-plugin-markdown"))
|
|
583
581
|
}
|
|
584
582
|
},
|
|
585
583
|
{
|
|
@@ -651,7 +649,7 @@ function markdown(options = {}) {
|
|
|
651
649
|
}
|
|
652
650
|
|
|
653
651
|
// src/configs/node.ts
|
|
654
|
-
function node() {
|
|
652
|
+
async function node() {
|
|
655
653
|
return [
|
|
656
654
|
{
|
|
657
655
|
name: "antfu:node",
|
|
@@ -673,7 +671,7 @@ function node() {
|
|
|
673
671
|
}
|
|
674
672
|
|
|
675
673
|
// src/configs/sort.ts
|
|
676
|
-
function sortPackageJson() {
|
|
674
|
+
async function sortPackageJson() {
|
|
677
675
|
return [
|
|
678
676
|
{
|
|
679
677
|
files: ["**/package.json"],
|
|
@@ -889,14 +887,15 @@ function sortTsconfig() {
|
|
|
889
887
|
}
|
|
890
888
|
|
|
891
889
|
// src/configs/stylistic.ts
|
|
892
|
-
function stylistic(options = {}) {
|
|
890
|
+
async function stylistic(options = {}) {
|
|
893
891
|
const {
|
|
894
892
|
indent = 2,
|
|
895
893
|
jsx = true,
|
|
896
894
|
quotes = "single",
|
|
897
895
|
semi = false
|
|
898
896
|
} = options;
|
|
899
|
-
const
|
|
897
|
+
const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
|
|
898
|
+
const config = pluginStylistic.configs.customize({
|
|
900
899
|
flat: true,
|
|
901
900
|
indent,
|
|
902
901
|
jsx,
|
|
@@ -909,7 +908,7 @@ function stylistic(options = {}) {
|
|
|
909
908
|
name: "antfu:stylistic",
|
|
910
909
|
plugins: {
|
|
911
910
|
antfu: import_eslint_plugin_antfu.default,
|
|
912
|
-
style:
|
|
911
|
+
style: pluginStylistic
|
|
913
912
|
},
|
|
914
913
|
rules: {
|
|
915
914
|
...config.rules,
|
|
@@ -925,26 +924,7 @@ function stylistic(options = {}) {
|
|
|
925
924
|
|
|
926
925
|
// src/configs/typescript.ts
|
|
927
926
|
var import_node_process = __toESM(require("process"), 1);
|
|
928
|
-
|
|
929
|
-
// src/utils.ts
|
|
930
|
-
function combine(...configs) {
|
|
931
|
-
return configs.flat();
|
|
932
|
-
}
|
|
933
|
-
function renameRules(rules, from, to) {
|
|
934
|
-
return Object.fromEntries(
|
|
935
|
-
Object.entries(rules).map(([key, value]) => {
|
|
936
|
-
if (key.startsWith(from))
|
|
937
|
-
return [to + key.slice(from.length), value];
|
|
938
|
-
return [key, value];
|
|
939
|
-
})
|
|
940
|
-
);
|
|
941
|
-
}
|
|
942
|
-
function toArray(value) {
|
|
943
|
-
return Array.isArray(value) ? value : [value];
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
// src/configs/typescript.ts
|
|
947
|
-
function typescript(options) {
|
|
927
|
+
async function typescript(options) {
|
|
948
928
|
const {
|
|
949
929
|
componentExts = [],
|
|
950
930
|
overrides = {},
|
|
@@ -972,14 +952,20 @@ function typescript(options) {
|
|
|
972
952
|
"ts/unbound-method": "error"
|
|
973
953
|
};
|
|
974
954
|
const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
|
|
955
|
+
const [
|
|
956
|
+
pluginTs,
|
|
957
|
+
parserTs
|
|
958
|
+
] = await Promise.all([
|
|
959
|
+
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
960
|
+
interopDefault(import("@typescript-eslint/parser"))
|
|
961
|
+
]);
|
|
975
962
|
return [
|
|
976
963
|
{
|
|
977
964
|
// Install the plugins without globs, so they can be configured separately.
|
|
978
965
|
name: "antfu:typescript:setup",
|
|
979
966
|
plugins: {
|
|
980
967
|
antfu: import_eslint_plugin_antfu.default,
|
|
981
|
-
|
|
982
|
-
ts: import_eslint_plugin2.default
|
|
968
|
+
ts: pluginTs
|
|
983
969
|
}
|
|
984
970
|
},
|
|
985
971
|
{
|
|
@@ -1002,12 +988,12 @@ function typescript(options) {
|
|
|
1002
988
|
name: "antfu:typescript:rules",
|
|
1003
989
|
rules: {
|
|
1004
990
|
...renameRules(
|
|
1005
|
-
|
|
991
|
+
pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
1006
992
|
"@typescript-eslint/",
|
|
1007
993
|
"ts/"
|
|
1008
994
|
),
|
|
1009
995
|
...renameRules(
|
|
1010
|
-
|
|
996
|
+
pluginTs.configs.strict.rules,
|
|
1011
997
|
"@typescript-eslint/",
|
|
1012
998
|
"ts/"
|
|
1013
999
|
),
|
|
@@ -1073,7 +1059,7 @@ function typescript(options) {
|
|
|
1073
1059
|
}
|
|
1074
1060
|
|
|
1075
1061
|
// src/configs/unicorn.ts
|
|
1076
|
-
function unicorn() {
|
|
1062
|
+
async function unicorn() {
|
|
1077
1063
|
return [
|
|
1078
1064
|
{
|
|
1079
1065
|
name: "antfu:unicorn",
|
|
@@ -1113,7 +1099,7 @@ function unicorn() {
|
|
|
1113
1099
|
}
|
|
1114
1100
|
|
|
1115
1101
|
// src/configs/vue.ts
|
|
1116
|
-
function vue(options = {}) {
|
|
1102
|
+
async function vue(options = {}) {
|
|
1117
1103
|
const {
|
|
1118
1104
|
overrides = {},
|
|
1119
1105
|
stylistic: stylistic2 = true
|
|
@@ -1121,33 +1107,41 @@ function vue(options = {}) {
|
|
|
1121
1107
|
const {
|
|
1122
1108
|
indent = 2
|
|
1123
1109
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1110
|
+
const [
|
|
1111
|
+
pluginVue,
|
|
1112
|
+
parserVue
|
|
1113
|
+
] = await Promise.all([
|
|
1114
|
+
// @ts-expect-error missing types
|
|
1115
|
+
interopDefault(import("eslint-plugin-vue")),
|
|
1116
|
+
interopDefault(import("vue-eslint-parser"))
|
|
1117
|
+
]);
|
|
1124
1118
|
return [
|
|
1125
1119
|
{
|
|
1126
1120
|
name: "antfu:vue:setup",
|
|
1127
1121
|
plugins: {
|
|
1128
|
-
vue:
|
|
1122
|
+
vue: pluginVue
|
|
1129
1123
|
}
|
|
1130
1124
|
},
|
|
1131
1125
|
{
|
|
1132
1126
|
files: [GLOB_VUE],
|
|
1133
1127
|
languageOptions: {
|
|
1134
|
-
parser:
|
|
1128
|
+
parser: parserVue,
|
|
1135
1129
|
parserOptions: {
|
|
1136
1130
|
ecmaFeatures: {
|
|
1137
1131
|
jsx: true
|
|
1138
1132
|
},
|
|
1139
1133
|
extraFileExtensions: [".vue"],
|
|
1140
|
-
parser: options.typescript ?
|
|
1134
|
+
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1141
1135
|
sourceType: "module"
|
|
1142
1136
|
}
|
|
1143
1137
|
},
|
|
1144
1138
|
name: "antfu:vue:rules",
|
|
1145
|
-
processor:
|
|
1139
|
+
processor: pluginVue.processors[".vue"],
|
|
1146
1140
|
rules: {
|
|
1147
|
-
...
|
|
1148
|
-
...
|
|
1149
|
-
...
|
|
1150
|
-
...
|
|
1141
|
+
...pluginVue.configs.base.rules,
|
|
1142
|
+
...pluginVue.configs["vue3-essential"].rules,
|
|
1143
|
+
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1144
|
+
...pluginVue.configs["vue3-recommended"].rules,
|
|
1151
1145
|
"node/prefer-global/process": "off",
|
|
1152
1146
|
"vue/block-order": ["error", {
|
|
1153
1147
|
order: ["script", "template", "style"]
|
|
@@ -1230,7 +1224,7 @@ function vue(options = {}) {
|
|
|
1230
1224
|
}
|
|
1231
1225
|
|
|
1232
1226
|
// src/configs/yaml.ts
|
|
1233
|
-
function yaml(options = {}) {
|
|
1227
|
+
async function yaml(options = {}) {
|
|
1234
1228
|
const {
|
|
1235
1229
|
overrides = {},
|
|
1236
1230
|
stylistic: stylistic2 = true
|
|
@@ -1239,6 +1233,13 @@ function yaml(options = {}) {
|
|
|
1239
1233
|
indent = 2,
|
|
1240
1234
|
quotes = "single"
|
|
1241
1235
|
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1236
|
+
const [
|
|
1237
|
+
pluginYaml,
|
|
1238
|
+
parserYaml
|
|
1239
|
+
] = await Promise.all([
|
|
1240
|
+
interopDefault(import("eslint-plugin-yml")),
|
|
1241
|
+
interopDefault(import("yaml-eslint-parser"))
|
|
1242
|
+
]);
|
|
1242
1243
|
return [
|
|
1243
1244
|
{
|
|
1244
1245
|
name: "antfu:yaml:setup",
|
|
@@ -1249,7 +1250,7 @@ function yaml(options = {}) {
|
|
|
1249
1250
|
{
|
|
1250
1251
|
files: [GLOB_YAML],
|
|
1251
1252
|
languageOptions: {
|
|
1252
|
-
parser:
|
|
1253
|
+
parser: parserYaml
|
|
1253
1254
|
},
|
|
1254
1255
|
name: "antfu:yaml:rules",
|
|
1255
1256
|
rules: {
|
|
@@ -1281,21 +1282,29 @@ function yaml(options = {}) {
|
|
|
1281
1282
|
}
|
|
1282
1283
|
|
|
1283
1284
|
// src/configs/test.ts
|
|
1284
|
-
function test(options = {}) {
|
|
1285
|
+
async function test(options = {}) {
|
|
1285
1286
|
const {
|
|
1286
1287
|
isInEditor = false,
|
|
1287
1288
|
overrides = {}
|
|
1288
1289
|
} = options;
|
|
1290
|
+
const [
|
|
1291
|
+
pluginVitest,
|
|
1292
|
+
pluginNoOnlyTests
|
|
1293
|
+
] = await Promise.all([
|
|
1294
|
+
interopDefault(import("eslint-plugin-vitest")),
|
|
1295
|
+
// @ts-expect-error missing types
|
|
1296
|
+
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
1297
|
+
]);
|
|
1289
1298
|
return [
|
|
1290
1299
|
{
|
|
1291
1300
|
name: "antfu:test:setup",
|
|
1292
1301
|
plugins: {
|
|
1293
1302
|
test: {
|
|
1294
|
-
...
|
|
1303
|
+
...pluginVitest,
|
|
1295
1304
|
rules: {
|
|
1296
|
-
...
|
|
1305
|
+
...pluginVitest.rules,
|
|
1297
1306
|
// extend `test/no-only-tests` rule
|
|
1298
|
-
...
|
|
1307
|
+
...pluginNoOnlyTests.rules
|
|
1299
1308
|
}
|
|
1300
1309
|
}
|
|
1301
1310
|
}
|
|
@@ -1317,7 +1326,7 @@ function test(options = {}) {
|
|
|
1317
1326
|
}
|
|
1318
1327
|
|
|
1319
1328
|
// src/configs/perfectionist.ts
|
|
1320
|
-
function perfectionist() {
|
|
1329
|
+
async function perfectionist() {
|
|
1321
1330
|
return [
|
|
1322
1331
|
{
|
|
1323
1332
|
name: "antfu:perfectionist",
|
|
@@ -1345,7 +1354,7 @@ var VuePackages = [
|
|
|
1345
1354
|
"vitepress",
|
|
1346
1355
|
"@slidev/cli"
|
|
1347
1356
|
];
|
|
1348
|
-
function antfu(options = {}, ...userConfigs) {
|
|
1357
|
+
async function antfu(options = {}, ...userConfigs) {
|
|
1349
1358
|
const {
|
|
1350
1359
|
componentExts = [],
|
|
1351
1360
|
gitignore: enableGitignore = true,
|
|
@@ -1360,10 +1369,10 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
1360
1369
|
const configs = [];
|
|
1361
1370
|
if (enableGitignore) {
|
|
1362
1371
|
if (typeof enableGitignore !== "boolean") {
|
|
1363
|
-
configs.push(
|
|
1372
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1364
1373
|
} else {
|
|
1365
1374
|
if (import_node_fs.default.existsSync(".gitignore"))
|
|
1366
|
-
configs.push(
|
|
1375
|
+
configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
|
|
1367
1376
|
}
|
|
1368
1377
|
}
|
|
1369
1378
|
configs.push(
|
|
@@ -1474,32 +1483,13 @@ var src_default = antfu;
|
|
|
1474
1483
|
comments,
|
|
1475
1484
|
ignores,
|
|
1476
1485
|
imports,
|
|
1486
|
+
interopDefault,
|
|
1477
1487
|
javascript,
|
|
1478
1488
|
jsdoc,
|
|
1479
1489
|
jsonc,
|
|
1480
1490
|
markdown,
|
|
1481
1491
|
node,
|
|
1482
|
-
parserJsonc,
|
|
1483
|
-
parserTs,
|
|
1484
|
-
parserVue,
|
|
1485
|
-
parserYaml,
|
|
1486
1492
|
perfectionist,
|
|
1487
|
-
pluginAntfu,
|
|
1488
|
-
pluginComments,
|
|
1489
|
-
pluginImport,
|
|
1490
|
-
pluginJsdoc,
|
|
1491
|
-
pluginJsonc,
|
|
1492
|
-
pluginMarkdown,
|
|
1493
|
-
pluginNoOnlyTests,
|
|
1494
|
-
pluginNode,
|
|
1495
|
-
pluginPerfectionist,
|
|
1496
|
-
pluginStylistic,
|
|
1497
|
-
pluginTs,
|
|
1498
|
-
pluginUnicorn,
|
|
1499
|
-
pluginUnusedImports,
|
|
1500
|
-
pluginVitest,
|
|
1501
|
-
pluginVue,
|
|
1502
|
-
pluginYaml,
|
|
1503
1493
|
renameRules,
|
|
1504
1494
|
sortPackageJson,
|
|
1505
1495
|
sortTsconfig,
|