@dhzh/eslint-config 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +21 -22
- package/dist/cli.cjs +78 -47
- package/dist/cli.js +78 -47
- package/dist/index.cjs +197 -83
- package/dist/index.d.cts +6819 -3582
- package/dist/index.d.ts +6819 -3582
- package/dist/index.js +197 -84
- package/package.json +39 -31
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2022-PRESENT Easton Zheng
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
# @dhzh/eslint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://npmjs.com/package/@antfu/eslint-config)
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
> `Special Statement`: This project comes from [`@antfu/eslint-config`](https://github.com/antfu/eslint-config). The two are almost the same, with only some differences to meet personal needs. In order to seek convenience and prevent some conflicts between the upstream branch and my own changes after forking, I chose to copy instead of fork.
|
|
6
|
+
|
|
7
|
+
Differences from [@antfu/eslint-config](./README-antfu.md):
|
|
8
|
+
|
|
9
|
+
1. With semi: `semi: true`.
|
|
10
|
+
2. Always arrow parens: `arrowParens: true`.
|
|
11
|
+
3. Explicitly use `1tbs` as brace style: `braceStyle: '1tbs'`.
|
|
12
|
+
4. Disabled antfu's top level function rule: `'antfu/top-level-function': 'off'`.
|
|
13
|
+
5. Always curly: `'curly': ['error', 'all']`.
|
|
6
14
|
|
|
7
15
|
## Usage
|
|
8
16
|
|
|
9
|
-
### Wizard
|
|
17
|
+
### Starter Wizard
|
|
10
18
|
|
|
11
|
-
|
|
12
|
-
|
|
19
|
+
We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
|
|
20
|
+
|
|
21
|
+
```shell
|
|
22
|
+
pnpm dlx @dhzh/eslint-config@latest
|
|
13
23
|
```
|
|
14
24
|
|
|
15
|
-
### Install
|
|
25
|
+
### Manual Install
|
|
26
|
+
|
|
27
|
+
If you prefer to set up manually:
|
|
16
28
|
|
|
17
29
|
```bash
|
|
18
30
|
pnpm i -D eslint @dhzh/eslint-config
|
|
19
31
|
```
|
|
20
32
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
With [`"type": "module"`](https://nodejs.org/api/packages.html#type) in `package.json` (recommended):
|
|
33
|
+
And create `eslint.config.mjs` in your project root:
|
|
24
34
|
|
|
25
35
|
```js
|
|
26
|
-
// eslint.config.
|
|
36
|
+
// eslint.config.mjs
|
|
27
37
|
import dhzh from '@dhzh/eslint-config';
|
|
28
38
|
|
|
29
39
|
export default dhzh();
|
|
30
40
|
```
|
|
31
41
|
|
|
32
|
-
With CJS:
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
// eslint.config.js
|
|
36
|
-
const dhzh = require('@dhzh/eslint-config').default;
|
|
37
|
-
|
|
38
|
-
module.exports = dhzh();
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
More details, you can see [README-antfu](./README-antfu.md).
|
|
42
|
-
|
|
43
42
|
## License
|
|
44
43
|
|
|
45
|
-
[MIT](./LICENSE) License ©
|
|
44
|
+
[MIT](./LICENSE) License © 2022-PRESENT [Easton Zheng](https://github.com/eastonzh)
|
package/dist/cli.cjs
CHANGED
|
@@ -48,13 +48,14 @@ var import_picocolors = __toESM(require("picocolors"), 1);
|
|
|
48
48
|
var package_default = {
|
|
49
49
|
name: "@dhzh/eslint-config",
|
|
50
50
|
type: "module",
|
|
51
|
-
version: "0.
|
|
52
|
-
packageManager: "pnpm@8.15.
|
|
51
|
+
version: "0.2.0",
|
|
52
|
+
packageManager: "pnpm@8.15.7",
|
|
53
53
|
description: "Easton's ESLint config",
|
|
54
54
|
author: "Easton Zheng <dhzhme@gmail.com>",
|
|
55
55
|
license: "MIT",
|
|
56
56
|
homepage: "https://github.com/eastonzh/eslint-config",
|
|
57
57
|
keywords: [
|
|
58
|
+
"eslint",
|
|
58
59
|
"eslint-config"
|
|
59
60
|
],
|
|
60
61
|
exports: {
|
|
@@ -73,7 +74,8 @@ var package_default = {
|
|
|
73
74
|
scripts: {
|
|
74
75
|
build: "nr typegen && tsup --format esm,cjs --clean --dts",
|
|
75
76
|
stub: "tsup --format esm",
|
|
76
|
-
dev: "
|
|
77
|
+
dev: "npx @eslint/config-inspector --config eslint.config.ts",
|
|
78
|
+
"build:inspector": "pnpm build && npx @eslint/config-inspector build",
|
|
77
79
|
watch: "tsup --format esm,cjs --watch",
|
|
78
80
|
lint: "eslint .",
|
|
79
81
|
typegen: "esno scripts/typegen.ts",
|
|
@@ -89,7 +91,8 @@ var package_default = {
|
|
|
89
91
|
eslint: ">=8.40.0",
|
|
90
92
|
"eslint-plugin-astro": "^0.31.4",
|
|
91
93
|
"eslint-plugin-format": ">=0.1.0",
|
|
92
|
-
"eslint-plugin-
|
|
94
|
+
"eslint-plugin-solid": "^0.13.2",
|
|
95
|
+
"eslint-plugin-svelte": ">=2.35.1",
|
|
93
96
|
"prettier-plugin-astro": "^0.13.0",
|
|
94
97
|
"prettier-plugin-slidev": "^1.0.5",
|
|
95
98
|
"svelte-eslint-parser": "^0.33.1"
|
|
@@ -107,6 +110,9 @@ var package_default = {
|
|
|
107
110
|
"eslint-plugin-format": {
|
|
108
111
|
optional: true
|
|
109
112
|
},
|
|
113
|
+
"eslint-plugin-solid": {
|
|
114
|
+
optional: true
|
|
115
|
+
},
|
|
110
116
|
"eslint-plugin-svelte": {
|
|
111
117
|
optional: true
|
|
112
118
|
},
|
|
@@ -124,29 +130,29 @@ var package_default = {
|
|
|
124
130
|
"@antfu/install-pkg": "^0.3.2",
|
|
125
131
|
"@clack/prompts": "^0.7.0",
|
|
126
132
|
"@stylistic/eslint-plugin": "^1.7.0",
|
|
127
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
128
|
-
"@typescript-eslint/parser": "^7.
|
|
129
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
130
|
-
"eslint-flat-config-utils": "^0.
|
|
133
|
+
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
134
|
+
"@typescript-eslint/parser": "^7.6.0",
|
|
135
|
+
"eslint-config-flat-gitignore": "^0.1.5",
|
|
136
|
+
"eslint-flat-config-utils": "^0.2.3",
|
|
131
137
|
"eslint-merge-processors": "^0.1.0",
|
|
132
138
|
"eslint-plugin-antfu": "^2.1.2",
|
|
133
139
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
134
|
-
"eslint-plugin-import-x": "^0.
|
|
135
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
136
|
-
"eslint-plugin-jsonc": "^2.
|
|
140
|
+
"eslint-plugin-import-x": "^0.5.0",
|
|
141
|
+
"eslint-plugin-jsdoc": "^48.2.3",
|
|
142
|
+
"eslint-plugin-jsonc": "^2.15.1",
|
|
137
143
|
"eslint-plugin-markdown": "^4.0.1",
|
|
138
|
-
"eslint-plugin-n": "^
|
|
144
|
+
"eslint-plugin-n": "^17.2.1",
|
|
139
145
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
140
|
-
"eslint-plugin-perfectionist": "^2.
|
|
146
|
+
"eslint-plugin-perfectionist": "^2.9.0",
|
|
141
147
|
"eslint-plugin-react": "^7.34.1",
|
|
142
148
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
143
149
|
"eslint-plugin-react-refresh": "^0.4.6",
|
|
144
|
-
"eslint-plugin-toml": "^0.
|
|
145
|
-
"eslint-plugin-unicorn": "^
|
|
150
|
+
"eslint-plugin-toml": "^0.11.0",
|
|
151
|
+
"eslint-plugin-unicorn": "^52.0.0",
|
|
146
152
|
"eslint-plugin-unused-imports": "^3.1.0",
|
|
147
|
-
"eslint-plugin-vitest": "^0.
|
|
148
|
-
"eslint-plugin-vue": "^9.
|
|
149
|
-
"eslint-plugin-yml": "^1.
|
|
153
|
+
"eslint-plugin-vitest": "^0.5.3",
|
|
154
|
+
"eslint-plugin-vue": "^9.25.0",
|
|
155
|
+
"eslint-plugin-yml": "^1.14.0",
|
|
150
156
|
"eslint-processor-vue-blocks": "^0.1.1",
|
|
151
157
|
globals: "^15.0.0",
|
|
152
158
|
"jsonc-eslint-parser": "^2.4.0",
|
|
@@ -162,21 +168,23 @@ var package_default = {
|
|
|
162
168
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
163
169
|
"@antfu/ni": "^0.21.12",
|
|
164
170
|
"@dhzh/eslint-config": "workspace:*",
|
|
171
|
+
"@eslint/config-inspector": "^0.4.6",
|
|
165
172
|
"@stylistic/eslint-plugin-migrate": "^1.7.0",
|
|
166
|
-
"@types/eslint": "^8.56.
|
|
173
|
+
"@types/eslint": "^8.56.9",
|
|
167
174
|
"@types/fs-extra": "^11.0.4",
|
|
168
|
-
"@types/node": "^20.
|
|
175
|
+
"@types/node": "^20.12.7",
|
|
169
176
|
"@types/prompts": "^2.4.9",
|
|
170
177
|
"@types/yargs": "^17.0.32",
|
|
171
|
-
"@unocss/eslint-plugin": "^0.
|
|
172
|
-
"astro-eslint-parser": "^0.
|
|
178
|
+
"@unocss/eslint-plugin": "^0.59.2",
|
|
179
|
+
"astro-eslint-parser": "^0.17.0",
|
|
173
180
|
bumpp: "^9.4.0",
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"eslint-plugin-astro": "^0.
|
|
181
|
+
"bundle-require": "^4.0.2",
|
|
182
|
+
eslint: "^9.0.0",
|
|
183
|
+
"eslint-plugin-astro": "^0.34.0",
|
|
177
184
|
"eslint-plugin-format": "^0.1.0",
|
|
185
|
+
"eslint-plugin-solid": "^0.13.2",
|
|
178
186
|
"eslint-plugin-svelte": "2.36.0-next.13",
|
|
179
|
-
"eslint-typegen": "^0.
|
|
187
|
+
"eslint-typegen": "^0.2.3",
|
|
180
188
|
esno: "^4.7.0",
|
|
181
189
|
execa: "^8.0.1",
|
|
182
190
|
"fast-glob": "^3.3.2",
|
|
@@ -186,11 +194,11 @@ var package_default = {
|
|
|
186
194
|
"prettier-plugin-slidev": "^1.0.5",
|
|
187
195
|
rimraf: "^5.0.5",
|
|
188
196
|
"simple-git-hooks": "^2.11.1",
|
|
189
|
-
svelte: "^4.2.
|
|
190
|
-
"svelte-eslint-parser": "^0.
|
|
197
|
+
svelte: "^4.2.14",
|
|
198
|
+
"svelte-eslint-parser": "^0.34.1",
|
|
191
199
|
tsup: "^8.0.2",
|
|
192
|
-
typescript: "^5.4.
|
|
193
|
-
vitest: "^1.
|
|
200
|
+
typescript: "^5.4.5",
|
|
201
|
+
vitest: "^1.5.0",
|
|
194
202
|
vue: "^3.4.21"
|
|
195
203
|
},
|
|
196
204
|
"simple-git-hooks": {
|
|
@@ -263,6 +271,10 @@ var frameworkOptions = [
|
|
|
263
271
|
label: import_picocolors.default.magenta("Astro"),
|
|
264
272
|
value: "astro"
|
|
265
273
|
},
|
|
274
|
+
{
|
|
275
|
+
label: import_picocolors.default.cyan("Solid"),
|
|
276
|
+
value: "solid"
|
|
277
|
+
},
|
|
266
278
|
{
|
|
267
279
|
label: import_picocolors.default.blue("Slidev"),
|
|
268
280
|
value: "slidev"
|
|
@@ -290,6 +302,9 @@ var dependenciesMap = {
|
|
|
290
302
|
slidev: [
|
|
291
303
|
"prettier-plugin-slidev"
|
|
292
304
|
],
|
|
305
|
+
solid: [
|
|
306
|
+
"eslint-plugin-solid"
|
|
307
|
+
],
|
|
293
308
|
svelte: [
|
|
294
309
|
"eslint-plugin-svelte",
|
|
295
310
|
"svelte-eslint-parser"
|
|
@@ -343,8 +358,9 @@ async function updatePackageJson(result) {
|
|
|
343
358
|
"eslint-plugin-format",
|
|
344
359
|
result.frameworks.includes("astro") ? "prettier-plugin-astro" : null
|
|
345
360
|
].forEach((f) => {
|
|
346
|
-
if (!f)
|
|
361
|
+
if (!f) {
|
|
347
362
|
return;
|
|
363
|
+
}
|
|
348
364
|
pkg.devDependencies[f] = package_default.devDependencies[f];
|
|
349
365
|
addedPackages.push(f);
|
|
350
366
|
});
|
|
@@ -369,8 +385,9 @@ async function updatePackageJson(result) {
|
|
|
369
385
|
});
|
|
370
386
|
}
|
|
371
387
|
}
|
|
372
|
-
if (addedPackages.length)
|
|
388
|
+
if (addedPackages.length) {
|
|
373
389
|
p.note(`${import_picocolors2.default.dim(addedPackages.join(", "))}`, "Added packages");
|
|
390
|
+
}
|
|
374
391
|
await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
375
392
|
p.log.success(import_picocolors2.default.green(`Changes wrote to package.json`));
|
|
376
393
|
}
|
|
@@ -398,21 +415,26 @@ async function updateEslintFiles(result) {
|
|
|
398
415
|
const parsed = (0, import_parse_gitignore.default)(content);
|
|
399
416
|
const globs = parsed.globs();
|
|
400
417
|
for (const glob of globs) {
|
|
401
|
-
if (glob.type === "ignore")
|
|
418
|
+
if (glob.type === "ignore") {
|
|
402
419
|
eslintIgnores.push(...glob.patterns);
|
|
403
|
-
else if (glob.type === "unignore")
|
|
420
|
+
} else if (glob.type === "unignore") {
|
|
404
421
|
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
422
|
+
}
|
|
405
423
|
}
|
|
406
424
|
}
|
|
407
425
|
const configLines = [];
|
|
408
|
-
if (eslintIgnores.length)
|
|
426
|
+
if (eslintIgnores.length) {
|
|
409
427
|
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
410
|
-
|
|
428
|
+
}
|
|
429
|
+
if (result.extra.includes("formatter")) {
|
|
411
430
|
configLines.push(`formatters: true,`);
|
|
412
|
-
|
|
431
|
+
}
|
|
432
|
+
if (result.extra.includes("unocss")) {
|
|
413
433
|
configLines.push(`unocss: true,`);
|
|
414
|
-
|
|
434
|
+
}
|
|
435
|
+
for (const framework of result.frameworks) {
|
|
415
436
|
configLines.push(`${framework}: true,`);
|
|
437
|
+
}
|
|
416
438
|
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
417
439
|
const additionalConfig = [];
|
|
418
440
|
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
@@ -421,11 +443,13 @@ async function updateEslintFiles(result) {
|
|
|
421
443
|
const files = import_node_fs.default.readdirSync(cwd);
|
|
422
444
|
const legacyConfig = [];
|
|
423
445
|
files.forEach((file) => {
|
|
424
|
-
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
|
446
|
+
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) {
|
|
425
447
|
legacyConfig.push(file);
|
|
448
|
+
}
|
|
426
449
|
});
|
|
427
|
-
if (legacyConfig.length)
|
|
450
|
+
if (legacyConfig.length) {
|
|
428
451
|
p2.note(`${import_picocolors3.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
452
|
+
}
|
|
429
453
|
}
|
|
430
454
|
|
|
431
455
|
// src/cli/stages/update-vscode-settings.ts
|
|
@@ -437,12 +461,14 @@ var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
|
437
461
|
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
438
462
|
async function updateVscodeSettings(result) {
|
|
439
463
|
const cwd = import_node_process3.default.cwd();
|
|
440
|
-
if (!result.updateVscodeSettings)
|
|
464
|
+
if (!result.updateVscodeSettings) {
|
|
441
465
|
return;
|
|
466
|
+
}
|
|
442
467
|
const dotVscodePath = import_node_path3.default.join(cwd, ".vscode");
|
|
443
468
|
const settingsPath = import_node_path3.default.join(dotVscodePath, "settings.json");
|
|
444
|
-
if (!import_node_fs2.default.existsSync(dotVscodePath))
|
|
469
|
+
if (!import_node_fs2.default.existsSync(dotVscodePath)) {
|
|
445
470
|
await import_promises3.default.mkdir(dotVscodePath, { recursive: true });
|
|
471
|
+
}
|
|
446
472
|
if (!import_node_fs2.default.existsSync(settingsPath)) {
|
|
447
473
|
await import_promises3.default.writeFile(settingsPath, `{${vscodeSettingsString}}
|
|
448
474
|
`, "utf-8");
|
|
@@ -476,8 +502,9 @@ async function run(options = {}) {
|
|
|
476
502
|
if (!argSkipPrompt) {
|
|
477
503
|
result = await p4.group({
|
|
478
504
|
uncommittedConfirmed: () => {
|
|
479
|
-
if (argSkipPrompt || isGitClean())
|
|
505
|
+
if (argSkipPrompt || isGitClean()) {
|
|
480
506
|
return Promise.resolve(true);
|
|
507
|
+
}
|
|
481
508
|
return p4.confirm({
|
|
482
509
|
initialValue: false,
|
|
483
510
|
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
@@ -485,8 +512,9 @@ async function run(options = {}) {
|
|
|
485
512
|
},
|
|
486
513
|
frameworks: ({ results }) => {
|
|
487
514
|
const isArgTemplateValid = typeof argTemplate === "string" && !!frameworks.includes(argTemplate);
|
|
488
|
-
if (!results.uncommittedConfirmed || isArgTemplateValid)
|
|
515
|
+
if (!results.uncommittedConfirmed || isArgTemplateValid) {
|
|
489
516
|
return;
|
|
517
|
+
}
|
|
490
518
|
const message = !isArgTemplateValid && argTemplate ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
|
491
519
|
return p4.multiselect({
|
|
492
520
|
message: import_picocolors5.default.reset(message),
|
|
@@ -496,8 +524,9 @@ async function run(options = {}) {
|
|
|
496
524
|
},
|
|
497
525
|
extra: ({ results }) => {
|
|
498
526
|
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
|
|
499
|
-
if (!results.uncommittedConfirmed || isArgExtraValid)
|
|
527
|
+
if (!results.uncommittedConfirmed || isArgExtraValid) {
|
|
500
528
|
return;
|
|
529
|
+
}
|
|
501
530
|
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
502
531
|
return p4.multiselect({
|
|
503
532
|
message: import_picocolors5.default.reset(message),
|
|
@@ -506,8 +535,9 @@ async function run(options = {}) {
|
|
|
506
535
|
});
|
|
507
536
|
},
|
|
508
537
|
updateVscodeSettings: ({ results }) => {
|
|
509
|
-
if (!results.uncommittedConfirmed)
|
|
538
|
+
if (!results.uncommittedConfirmed) {
|
|
510
539
|
return;
|
|
540
|
+
}
|
|
511
541
|
return p4.confirm({
|
|
512
542
|
initialValue: true,
|
|
513
543
|
message: "Update .vscode/settings.json for better VS Code experience?"
|
|
@@ -519,8 +549,9 @@ async function run(options = {}) {
|
|
|
519
549
|
import_node_process4.default.exit(0);
|
|
520
550
|
}
|
|
521
551
|
});
|
|
522
|
-
if (!result.uncommittedConfirmed)
|
|
552
|
+
if (!result.uncommittedConfirmed) {
|
|
523
553
|
return import_node_process4.default.exit(1);
|
|
554
|
+
}
|
|
524
555
|
}
|
|
525
556
|
await updatePackageJson(result);
|
|
526
557
|
await updateEslintFiles(result);
|
package/dist/cli.js
CHANGED
|
@@ -19,13 +19,14 @@ import c from "picocolors";
|
|
|
19
19
|
var package_default = {
|
|
20
20
|
name: "@dhzh/eslint-config",
|
|
21
21
|
type: "module",
|
|
22
|
-
version: "0.
|
|
23
|
-
packageManager: "pnpm@8.15.
|
|
22
|
+
version: "0.2.0",
|
|
23
|
+
packageManager: "pnpm@8.15.7",
|
|
24
24
|
description: "Easton's ESLint config",
|
|
25
25
|
author: "Easton Zheng <dhzhme@gmail.com>",
|
|
26
26
|
license: "MIT",
|
|
27
27
|
homepage: "https://github.com/eastonzh/eslint-config",
|
|
28
28
|
keywords: [
|
|
29
|
+
"eslint",
|
|
29
30
|
"eslint-config"
|
|
30
31
|
],
|
|
31
32
|
exports: {
|
|
@@ -44,7 +45,8 @@ var package_default = {
|
|
|
44
45
|
scripts: {
|
|
45
46
|
build: "nr typegen && tsup --format esm,cjs --clean --dts",
|
|
46
47
|
stub: "tsup --format esm",
|
|
47
|
-
dev: "
|
|
48
|
+
dev: "npx @eslint/config-inspector --config eslint.config.ts",
|
|
49
|
+
"build:inspector": "pnpm build && npx @eslint/config-inspector build",
|
|
48
50
|
watch: "tsup --format esm,cjs --watch",
|
|
49
51
|
lint: "eslint .",
|
|
50
52
|
typegen: "esno scripts/typegen.ts",
|
|
@@ -60,7 +62,8 @@ var package_default = {
|
|
|
60
62
|
eslint: ">=8.40.0",
|
|
61
63
|
"eslint-plugin-astro": "^0.31.4",
|
|
62
64
|
"eslint-plugin-format": ">=0.1.0",
|
|
63
|
-
"eslint-plugin-
|
|
65
|
+
"eslint-plugin-solid": "^0.13.2",
|
|
66
|
+
"eslint-plugin-svelte": ">=2.35.1",
|
|
64
67
|
"prettier-plugin-astro": "^0.13.0",
|
|
65
68
|
"prettier-plugin-slidev": "^1.0.5",
|
|
66
69
|
"svelte-eslint-parser": "^0.33.1"
|
|
@@ -78,6 +81,9 @@ var package_default = {
|
|
|
78
81
|
"eslint-plugin-format": {
|
|
79
82
|
optional: true
|
|
80
83
|
},
|
|
84
|
+
"eslint-plugin-solid": {
|
|
85
|
+
optional: true
|
|
86
|
+
},
|
|
81
87
|
"eslint-plugin-svelte": {
|
|
82
88
|
optional: true
|
|
83
89
|
},
|
|
@@ -95,29 +101,29 @@ var package_default = {
|
|
|
95
101
|
"@antfu/install-pkg": "^0.3.2",
|
|
96
102
|
"@clack/prompts": "^0.7.0",
|
|
97
103
|
"@stylistic/eslint-plugin": "^1.7.0",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^7.
|
|
99
|
-
"@typescript-eslint/parser": "^7.
|
|
100
|
-
"eslint-config-flat-gitignore": "^0.1.
|
|
101
|
-
"eslint-flat-config-utils": "^0.
|
|
104
|
+
"@typescript-eslint/eslint-plugin": "^7.6.0",
|
|
105
|
+
"@typescript-eslint/parser": "^7.6.0",
|
|
106
|
+
"eslint-config-flat-gitignore": "^0.1.5",
|
|
107
|
+
"eslint-flat-config-utils": "^0.2.3",
|
|
102
108
|
"eslint-merge-processors": "^0.1.0",
|
|
103
109
|
"eslint-plugin-antfu": "^2.1.2",
|
|
104
110
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
105
|
-
"eslint-plugin-import-x": "^0.
|
|
106
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
107
|
-
"eslint-plugin-jsonc": "^2.
|
|
111
|
+
"eslint-plugin-import-x": "^0.5.0",
|
|
112
|
+
"eslint-plugin-jsdoc": "^48.2.3",
|
|
113
|
+
"eslint-plugin-jsonc": "^2.15.1",
|
|
108
114
|
"eslint-plugin-markdown": "^4.0.1",
|
|
109
|
-
"eslint-plugin-n": "^
|
|
115
|
+
"eslint-plugin-n": "^17.2.1",
|
|
110
116
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
111
|
-
"eslint-plugin-perfectionist": "^2.
|
|
117
|
+
"eslint-plugin-perfectionist": "^2.9.0",
|
|
112
118
|
"eslint-plugin-react": "^7.34.1",
|
|
113
119
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
114
120
|
"eslint-plugin-react-refresh": "^0.4.6",
|
|
115
|
-
"eslint-plugin-toml": "^0.
|
|
116
|
-
"eslint-plugin-unicorn": "^
|
|
121
|
+
"eslint-plugin-toml": "^0.11.0",
|
|
122
|
+
"eslint-plugin-unicorn": "^52.0.0",
|
|
117
123
|
"eslint-plugin-unused-imports": "^3.1.0",
|
|
118
|
-
"eslint-plugin-vitest": "^0.
|
|
119
|
-
"eslint-plugin-vue": "^9.
|
|
120
|
-
"eslint-plugin-yml": "^1.
|
|
124
|
+
"eslint-plugin-vitest": "^0.5.3",
|
|
125
|
+
"eslint-plugin-vue": "^9.25.0",
|
|
126
|
+
"eslint-plugin-yml": "^1.14.0",
|
|
121
127
|
"eslint-processor-vue-blocks": "^0.1.1",
|
|
122
128
|
globals: "^15.0.0",
|
|
123
129
|
"jsonc-eslint-parser": "^2.4.0",
|
|
@@ -133,21 +139,23 @@ var package_default = {
|
|
|
133
139
|
"@antfu/eslint-plugin-prettier": "^5.0.1-1",
|
|
134
140
|
"@antfu/ni": "^0.21.12",
|
|
135
141
|
"@dhzh/eslint-config": "workspace:*",
|
|
142
|
+
"@eslint/config-inspector": "^0.4.6",
|
|
136
143
|
"@stylistic/eslint-plugin-migrate": "^1.7.0",
|
|
137
|
-
"@types/eslint": "^8.56.
|
|
144
|
+
"@types/eslint": "^8.56.9",
|
|
138
145
|
"@types/fs-extra": "^11.0.4",
|
|
139
|
-
"@types/node": "^20.
|
|
146
|
+
"@types/node": "^20.12.7",
|
|
140
147
|
"@types/prompts": "^2.4.9",
|
|
141
148
|
"@types/yargs": "^17.0.32",
|
|
142
|
-
"@unocss/eslint-plugin": "^0.
|
|
143
|
-
"astro-eslint-parser": "^0.
|
|
149
|
+
"@unocss/eslint-plugin": "^0.59.2",
|
|
150
|
+
"astro-eslint-parser": "^0.17.0",
|
|
144
151
|
bumpp: "^9.4.0",
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"eslint-plugin-astro": "^0.
|
|
152
|
+
"bundle-require": "^4.0.2",
|
|
153
|
+
eslint: "^9.0.0",
|
|
154
|
+
"eslint-plugin-astro": "^0.34.0",
|
|
148
155
|
"eslint-plugin-format": "^0.1.0",
|
|
156
|
+
"eslint-plugin-solid": "^0.13.2",
|
|
149
157
|
"eslint-plugin-svelte": "2.36.0-next.13",
|
|
150
|
-
"eslint-typegen": "^0.
|
|
158
|
+
"eslint-typegen": "^0.2.3",
|
|
151
159
|
esno: "^4.7.0",
|
|
152
160
|
execa: "^8.0.1",
|
|
153
161
|
"fast-glob": "^3.3.2",
|
|
@@ -157,11 +165,11 @@ var package_default = {
|
|
|
157
165
|
"prettier-plugin-slidev": "^1.0.5",
|
|
158
166
|
rimraf: "^5.0.5",
|
|
159
167
|
"simple-git-hooks": "^2.11.1",
|
|
160
|
-
svelte: "^4.2.
|
|
161
|
-
"svelte-eslint-parser": "^0.
|
|
168
|
+
svelte: "^4.2.14",
|
|
169
|
+
"svelte-eslint-parser": "^0.34.1",
|
|
162
170
|
tsup: "^8.0.2",
|
|
163
|
-
typescript: "^5.4.
|
|
164
|
-
vitest: "^1.
|
|
171
|
+
typescript: "^5.4.5",
|
|
172
|
+
vitest: "^1.5.0",
|
|
165
173
|
vue: "^3.4.21"
|
|
166
174
|
},
|
|
167
175
|
"simple-git-hooks": {
|
|
@@ -234,6 +242,10 @@ var frameworkOptions = [
|
|
|
234
242
|
label: c.magenta("Astro"),
|
|
235
243
|
value: "astro"
|
|
236
244
|
},
|
|
245
|
+
{
|
|
246
|
+
label: c.cyan("Solid"),
|
|
247
|
+
value: "solid"
|
|
248
|
+
},
|
|
237
249
|
{
|
|
238
250
|
label: c.blue("Slidev"),
|
|
239
251
|
value: "slidev"
|
|
@@ -261,6 +273,9 @@ var dependenciesMap = {
|
|
|
261
273
|
slidev: [
|
|
262
274
|
"prettier-plugin-slidev"
|
|
263
275
|
],
|
|
276
|
+
solid: [
|
|
277
|
+
"eslint-plugin-solid"
|
|
278
|
+
],
|
|
264
279
|
svelte: [
|
|
265
280
|
"eslint-plugin-svelte",
|
|
266
281
|
"svelte-eslint-parser"
|
|
@@ -314,8 +329,9 @@ async function updatePackageJson(result) {
|
|
|
314
329
|
"eslint-plugin-format",
|
|
315
330
|
result.frameworks.includes("astro") ? "prettier-plugin-astro" : null
|
|
316
331
|
].forEach((f) => {
|
|
317
|
-
if (!f)
|
|
332
|
+
if (!f) {
|
|
318
333
|
return;
|
|
334
|
+
}
|
|
319
335
|
pkg.devDependencies[f] = package_default.devDependencies[f];
|
|
320
336
|
addedPackages.push(f);
|
|
321
337
|
});
|
|
@@ -340,8 +356,9 @@ async function updatePackageJson(result) {
|
|
|
340
356
|
});
|
|
341
357
|
}
|
|
342
358
|
}
|
|
343
|
-
if (addedPackages.length)
|
|
359
|
+
if (addedPackages.length) {
|
|
344
360
|
p.note(`${c2.dim(addedPackages.join(", "))}`, "Added packages");
|
|
361
|
+
}
|
|
345
362
|
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
346
363
|
p.log.success(c2.green(`Changes wrote to package.json`));
|
|
347
364
|
}
|
|
@@ -369,21 +386,26 @@ async function updateEslintFiles(result) {
|
|
|
369
386
|
const parsed = parse(content);
|
|
370
387
|
const globs = parsed.globs();
|
|
371
388
|
for (const glob of globs) {
|
|
372
|
-
if (glob.type === "ignore")
|
|
389
|
+
if (glob.type === "ignore") {
|
|
373
390
|
eslintIgnores.push(...glob.patterns);
|
|
374
|
-
else if (glob.type === "unignore")
|
|
391
|
+
} else if (glob.type === "unignore") {
|
|
375
392
|
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
393
|
+
}
|
|
376
394
|
}
|
|
377
395
|
}
|
|
378
396
|
const configLines = [];
|
|
379
|
-
if (eslintIgnores.length)
|
|
397
|
+
if (eslintIgnores.length) {
|
|
380
398
|
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
381
|
-
|
|
399
|
+
}
|
|
400
|
+
if (result.extra.includes("formatter")) {
|
|
382
401
|
configLines.push(`formatters: true,`);
|
|
383
|
-
|
|
402
|
+
}
|
|
403
|
+
if (result.extra.includes("unocss")) {
|
|
384
404
|
configLines.push(`unocss: true,`);
|
|
385
|
-
|
|
405
|
+
}
|
|
406
|
+
for (const framework of result.frameworks) {
|
|
386
407
|
configLines.push(`${framework}: true,`);
|
|
408
|
+
}
|
|
387
409
|
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
388
410
|
const additionalConfig = [];
|
|
389
411
|
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
@@ -392,11 +414,13 @@ async function updateEslintFiles(result) {
|
|
|
392
414
|
const files = fs.readdirSync(cwd);
|
|
393
415
|
const legacyConfig = [];
|
|
394
416
|
files.forEach((file) => {
|
|
395
|
-
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
|
417
|
+
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) {
|
|
396
418
|
legacyConfig.push(file);
|
|
419
|
+
}
|
|
397
420
|
});
|
|
398
|
-
if (legacyConfig.length)
|
|
421
|
+
if (legacyConfig.length) {
|
|
399
422
|
p2.note(`${c3.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
423
|
+
}
|
|
400
424
|
}
|
|
401
425
|
|
|
402
426
|
// src/cli/stages/update-vscode-settings.ts
|
|
@@ -408,12 +432,14 @@ import c4 from "picocolors";
|
|
|
408
432
|
import * as p3 from "@clack/prompts";
|
|
409
433
|
async function updateVscodeSettings(result) {
|
|
410
434
|
const cwd = process3.cwd();
|
|
411
|
-
if (!result.updateVscodeSettings)
|
|
435
|
+
if (!result.updateVscodeSettings) {
|
|
412
436
|
return;
|
|
437
|
+
}
|
|
413
438
|
const dotVscodePath = path3.join(cwd, ".vscode");
|
|
414
439
|
const settingsPath = path3.join(dotVscodePath, "settings.json");
|
|
415
|
-
if (!fs2.existsSync(dotVscodePath))
|
|
440
|
+
if (!fs2.existsSync(dotVscodePath)) {
|
|
416
441
|
await fsp3.mkdir(dotVscodePath, { recursive: true });
|
|
442
|
+
}
|
|
417
443
|
if (!fs2.existsSync(settingsPath)) {
|
|
418
444
|
await fsp3.writeFile(settingsPath, `{${vscodeSettingsString}}
|
|
419
445
|
`, "utf-8");
|
|
@@ -447,8 +473,9 @@ async function run(options = {}) {
|
|
|
447
473
|
if (!argSkipPrompt) {
|
|
448
474
|
result = await p4.group({
|
|
449
475
|
uncommittedConfirmed: () => {
|
|
450
|
-
if (argSkipPrompt || isGitClean())
|
|
476
|
+
if (argSkipPrompt || isGitClean()) {
|
|
451
477
|
return Promise.resolve(true);
|
|
478
|
+
}
|
|
452
479
|
return p4.confirm({
|
|
453
480
|
initialValue: false,
|
|
454
481
|
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
@@ -456,8 +483,9 @@ async function run(options = {}) {
|
|
|
456
483
|
},
|
|
457
484
|
frameworks: ({ results }) => {
|
|
458
485
|
const isArgTemplateValid = typeof argTemplate === "string" && !!frameworks.includes(argTemplate);
|
|
459
|
-
if (!results.uncommittedConfirmed || isArgTemplateValid)
|
|
486
|
+
if (!results.uncommittedConfirmed || isArgTemplateValid) {
|
|
460
487
|
return;
|
|
488
|
+
}
|
|
461
489
|
const message = !isArgTemplateValid && argTemplate ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
|
462
490
|
return p4.multiselect({
|
|
463
491
|
message: c5.reset(message),
|
|
@@ -467,8 +495,9 @@ async function run(options = {}) {
|
|
|
467
495
|
},
|
|
468
496
|
extra: ({ results }) => {
|
|
469
497
|
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
|
|
470
|
-
if (!results.uncommittedConfirmed || isArgExtraValid)
|
|
498
|
+
if (!results.uncommittedConfirmed || isArgExtraValid) {
|
|
471
499
|
return;
|
|
500
|
+
}
|
|
472
501
|
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
473
502
|
return p4.multiselect({
|
|
474
503
|
message: c5.reset(message),
|
|
@@ -477,8 +506,9 @@ async function run(options = {}) {
|
|
|
477
506
|
});
|
|
478
507
|
},
|
|
479
508
|
updateVscodeSettings: ({ results }) => {
|
|
480
|
-
if (!results.uncommittedConfirmed)
|
|
509
|
+
if (!results.uncommittedConfirmed) {
|
|
481
510
|
return;
|
|
511
|
+
}
|
|
482
512
|
return p4.confirm({
|
|
483
513
|
initialValue: true,
|
|
484
514
|
message: "Update .vscode/settings.json for better VS Code experience?"
|
|
@@ -490,8 +520,9 @@ async function run(options = {}) {
|
|
|
490
520
|
process4.exit(0);
|
|
491
521
|
}
|
|
492
522
|
});
|
|
493
|
-
if (!result.uncommittedConfirmed)
|
|
523
|
+
if (!result.uncommittedConfirmed) {
|
|
494
524
|
return process4.exit(1);
|
|
525
|
+
}
|
|
495
526
|
}
|
|
496
527
|
await updatePackageJson(result);
|
|
497
528
|
await updateEslintFiles(result);
|