@ivanmaxlogiudice/eslint-config 3.1.3 → 3.1.5
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/cli.js +63 -83
- package/dist/index.d.ts +804 -906
- package/dist/index.js +5 -5
- package/package.json +32 -35
package/dist/cli.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import * as p$4 from "@clack/prompts";
|
|
3
|
-
import * as p$3 from "@clack/prompts";
|
|
4
|
-
import * as p$2 from "@clack/prompts";
|
|
5
|
-
import * as p$1 from "@clack/prompts";
|
|
6
2
|
import * as p from "@clack/prompts";
|
|
7
|
-
import c from "
|
|
8
|
-
import
|
|
9
|
-
import { hideBin } from "yargs/helpers";
|
|
3
|
+
import c from "ansis";
|
|
4
|
+
import { cac } from "cac";
|
|
10
5
|
import fs from "node:fs";
|
|
11
6
|
import path from "node:path";
|
|
12
7
|
import fsp from "node:fs/promises";
|
|
@@ -16,8 +11,8 @@ import { execSync } from "node:child_process";
|
|
|
16
11
|
//#region package.json
|
|
17
12
|
var name = "@ivanmaxlogiudice/eslint-config";
|
|
18
13
|
var type = "module";
|
|
19
|
-
var version = "3.1.
|
|
20
|
-
var packageManager = "bun@1.2.
|
|
14
|
+
var version = "3.1.5";
|
|
15
|
+
var packageManager = "bun@1.2.16";
|
|
21
16
|
var description = "Personal ESLint config";
|
|
22
17
|
var license = "MIT";
|
|
23
18
|
var homepage = "https://github.com/ivanmaxlogiudice/eslint-config#readme";
|
|
@@ -60,58 +55,53 @@ var peerDependenciesMeta = {
|
|
|
60
55
|
};
|
|
61
56
|
var dependencies = {
|
|
62
57
|
"@antfu/install-pkg": "^1.1.0",
|
|
63
|
-
"@clack/prompts": "^0.
|
|
58
|
+
"@clack/prompts": "^0.11.0",
|
|
64
59
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
|
65
|
-
"@eslint/markdown": "^6.
|
|
60
|
+
"@eslint/markdown": "^6.5.0",
|
|
66
61
|
"@ivanmaxlogiudice/gitignore": "^0.0.2",
|
|
67
|
-
"@stylistic/eslint-plugin": "^4.
|
|
68
|
-
"@
|
|
69
|
-
"@typescript-eslint/
|
|
70
|
-
"@
|
|
71
|
-
"
|
|
62
|
+
"@stylistic/eslint-plugin": "^4.4.1",
|
|
63
|
+
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
64
|
+
"@typescript-eslint/parser": "^8.34.1",
|
|
65
|
+
"@vitest/eslint-plugin": "^1.2.7",
|
|
66
|
+
"ansis": "^4.1.0",
|
|
67
|
+
"cac": "^6.7.14",
|
|
72
68
|
"eslint-plugin-antfu": "^3.1.1",
|
|
73
|
-
"eslint-plugin-import-
|
|
74
|
-
"eslint-plugin-jsdoc": "^
|
|
75
|
-
"eslint-plugin-jsonc": "^2.20.
|
|
76
|
-
"eslint-plugin-n": "^17.
|
|
69
|
+
"eslint-plugin-import-lite": "^0.3.0",
|
|
70
|
+
"eslint-plugin-jsdoc": "^51.0.3",
|
|
71
|
+
"eslint-plugin-jsonc": "^2.20.1",
|
|
72
|
+
"eslint-plugin-n": "^17.20.0",
|
|
77
73
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
78
|
-
"eslint-plugin-perfectionist": "^4.
|
|
74
|
+
"eslint-plugin-perfectionist": "^4.15.0",
|
|
79
75
|
"eslint-plugin-unicorn": "^59.0.1",
|
|
80
76
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
81
|
-
"eslint-plugin-vue": "^10.
|
|
82
|
-
"globals": "^16.
|
|
77
|
+
"eslint-plugin-vue": "^10.2.0",
|
|
78
|
+
"globals": "^16.2.0",
|
|
83
79
|
"jsonc-eslint-parser": "^2.4.0",
|
|
84
80
|
"local-pkg": "^1.1.1",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"vue-eslint-parser": "^10.1.3",
|
|
88
|
-
"yargs": "^17.7.2"
|
|
81
|
+
"tsdown": "^0.12.8",
|
|
82
|
+
"vue-eslint-parser": "^10.1.3"
|
|
89
83
|
};
|
|
90
84
|
var devDependencies = {
|
|
91
|
-
"@eslint/config-inspector": "^1.0
|
|
92
|
-
"@types/node": "^
|
|
93
|
-
"@
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"eslint": "^9.26.0",
|
|
85
|
+
"@eslint/config-inspector": "^1.1.0",
|
|
86
|
+
"@types/node": "^24.0.3",
|
|
87
|
+
"@unocss/eslint-plugin": "^66.2.3",
|
|
88
|
+
"bumpp": "^10.2.0",
|
|
89
|
+
"bun-types": "^1.2.16",
|
|
90
|
+
"eslint": "^9.29.0",
|
|
98
91
|
"eslint-plugin-markdown": "^5.1.0",
|
|
99
|
-
"eslint-plugin-regexp": "^2.
|
|
92
|
+
"eslint-plugin-regexp": "^2.9.0",
|
|
100
93
|
"eslint-plugin-yml": "^1.18.0",
|
|
101
|
-
"eslint-typegen": "^2.
|
|
102
|
-
"
|
|
94
|
+
"eslint-typegen": "^2.2.0",
|
|
95
|
+
"nano-staged": "^0.8.0",
|
|
103
96
|
"simple-git-hooks": "^2.13.0",
|
|
104
97
|
"typescript": "^5.8.3",
|
|
105
98
|
"unbuild": "^3.5.0",
|
|
106
|
-
"vitest": "^3.
|
|
99
|
+
"vitest": "^3.2.4",
|
|
107
100
|
"yaml-eslint-parser": "^1.3.0"
|
|
108
101
|
};
|
|
109
|
-
var resolutions = {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
var simple_git_hooks = { "pre-commit": "npx lint-staged" };
|
|
114
|
-
var lint_staged = { "*": "eslint --fix" };
|
|
102
|
+
var resolutions = { "eslint": "^9.29.0" };
|
|
103
|
+
var simple_git_hooks = { "pre-commit": "./node_modules/.bin/nano-staged" };
|
|
104
|
+
var nano_staged = { "*": "eslint --fix" };
|
|
115
105
|
var package_default = {
|
|
116
106
|
name,
|
|
117
107
|
type,
|
|
@@ -136,7 +126,7 @@ var package_default = {
|
|
|
136
126
|
devDependencies,
|
|
137
127
|
resolutions,
|
|
138
128
|
"simple-git-hooks": simple_git_hooks,
|
|
139
|
-
"
|
|
129
|
+
"nano-staged": nano_staged
|
|
140
130
|
};
|
|
141
131
|
|
|
142
132
|
//#endregion
|
|
@@ -224,7 +214,7 @@ async function updateEslintFiles(result) {
|
|
|
224
214
|
const pathFlatConfig = path.join(cwd, configFileName);
|
|
225
215
|
const eslintIgnores = [];
|
|
226
216
|
if (fs.existsSync(pathESLintIgnore)) {
|
|
227
|
-
p
|
|
217
|
+
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
228
218
|
const patterns = parsePath(pathESLintIgnore);
|
|
229
219
|
eslintIgnores.push(...toFlatConfig(patterns).ignores);
|
|
230
220
|
}
|
|
@@ -236,11 +226,11 @@ async function updateEslintFiles(result) {
|
|
|
236
226
|
const additionalConfig = [];
|
|
237
227
|
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
238
228
|
await fsp.writeFile(pathFlatConfig, eslintConfigContent);
|
|
239
|
-
p
|
|
229
|
+
p.log.success(c.green`Created ${configFileName}`);
|
|
240
230
|
const files$1 = fs.readdirSync(cwd).sort();
|
|
241
231
|
const legacyConfig = [];
|
|
242
232
|
for (const file of files$1) if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) legacyConfig.push(file);
|
|
243
|
-
if (legacyConfig.length) p
|
|
233
|
+
if (legacyConfig.length) p.note(`${c.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
244
234
|
}
|
|
245
235
|
|
|
246
236
|
//#endregion
|
|
@@ -248,7 +238,7 @@ async function updateEslintFiles(result) {
|
|
|
248
238
|
async function updatePackageJson(result) {
|
|
249
239
|
const cwd = process.cwd();
|
|
250
240
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
251
|
-
p
|
|
241
|
+
p.log.step(c.cyan`Bumping @ivanmaxlogiudice/eslint-config to v${package_default.version}`);
|
|
252
242
|
const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
|
|
253
243
|
const pkg = JSON.parse(pkgContent);
|
|
254
244
|
pkg.devDependencies ??= {};
|
|
@@ -270,9 +260,9 @@ async function updatePackageJson(result) {
|
|
|
270
260
|
addedPackages.push(f);
|
|
271
261
|
}
|
|
272
262
|
}
|
|
273
|
-
if (addedPackages.length) p
|
|
263
|
+
if (addedPackages.length) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
274
264
|
await fsp.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
275
|
-
p
|
|
265
|
+
p.log.success(c.green`Changes wrote to package.json`);
|
|
276
266
|
}
|
|
277
267
|
|
|
278
268
|
//#endregion
|
|
@@ -285,14 +275,14 @@ async function updateVscodeSettings(result) {
|
|
|
285
275
|
if (!fs.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
|
|
286
276
|
if (!fs.existsSync(settingsPath)) {
|
|
287
277
|
await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
288
|
-
p
|
|
278
|
+
p.log.success(c.green`Created .vscode/settings.json`);
|
|
289
279
|
} else {
|
|
290
280
|
let settingsContent = await fsp.readFile(settingsPath, "utf8");
|
|
291
281
|
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
292
282
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
293
283
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
294
284
|
await fsp.writeFile(settingsPath, settingsContent, "utf-8");
|
|
295
|
-
p
|
|
285
|
+
p.log.success(c.green`Updated .vscode/settings.json`);
|
|
296
286
|
}
|
|
297
287
|
}
|
|
298
288
|
|
|
@@ -300,10 +290,10 @@ async function updateVscodeSettings(result) {
|
|
|
300
290
|
//#region src/cli/run.ts
|
|
301
291
|
async function run(options = {}) {
|
|
302
292
|
const argSkipPrompt = !!process.env.SKIP_PROMPT || options.yes;
|
|
303
|
-
const argTemplate = options.frameworks?.map((m) => m
|
|
304
|
-
const argExtra = options.extra?.map((m) => m
|
|
293
|
+
const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
|
|
294
|
+
const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
|
|
305
295
|
if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
306
|
-
p
|
|
296
|
+
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
|
|
307
297
|
return process.exit(1);
|
|
308
298
|
}
|
|
309
299
|
let result = {
|
|
@@ -313,10 +303,10 @@ async function run(options = {}) {
|
|
|
313
303
|
updateVscodeSettings: true
|
|
314
304
|
};
|
|
315
305
|
if (!argSkipPrompt) {
|
|
316
|
-
result = await p
|
|
306
|
+
result = await p.group({
|
|
317
307
|
uncommittedConfirmed: () => {
|
|
318
308
|
if (argSkipPrompt || isGitClean()) return Promise.resolve(true);
|
|
319
|
-
return p
|
|
309
|
+
return p.confirm({
|
|
320
310
|
initialValue: false,
|
|
321
311
|
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
|
322
312
|
});
|
|
@@ -325,7 +315,7 @@ async function run(options = {}) {
|
|
|
325
315
|
const isArgTemplateValid = typeof argTemplate === "string" && !!frameworks.includes(argTemplate);
|
|
326
316
|
if (!results.uncommittedConfirmed || isArgTemplateValid) return;
|
|
327
317
|
const message = !isArgTemplateValid && argTemplate ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
|
328
|
-
return p
|
|
318
|
+
return p.multiselect({
|
|
329
319
|
message: c.reset(message),
|
|
330
320
|
options: frameworkOptions,
|
|
331
321
|
required: false
|
|
@@ -335,7 +325,7 @@ async function run(options = {}) {
|
|
|
335
325
|
const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
|
|
336
326
|
if (!results.uncommittedConfirmed || isArgExtraValid) return;
|
|
337
327
|
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
338
|
-
return p
|
|
328
|
+
return p.multiselect({
|
|
339
329
|
message: c.reset(message),
|
|
340
330
|
options: extraOptions,
|
|
341
331
|
required: false
|
|
@@ -343,13 +333,13 @@ async function run(options = {}) {
|
|
|
343
333
|
},
|
|
344
334
|
updateVscodeSettings: ({ results }) => {
|
|
345
335
|
if (!results.uncommittedConfirmed) return;
|
|
346
|
-
return p
|
|
336
|
+
return p.confirm({
|
|
347
337
|
initialValue: true,
|
|
348
338
|
message: "Update .vscode/settings.json for better VS Code experience?"
|
|
349
339
|
});
|
|
350
340
|
}
|
|
351
341
|
}, { onCancel: () => {
|
|
352
|
-
p
|
|
342
|
+
p.cancel("Operation cancelled.");
|
|
353
343
|
process.exit(0);
|
|
354
344
|
} });
|
|
355
345
|
if (!result.uncommittedConfirmed) return process.exit(1);
|
|
@@ -357,39 +347,29 @@ async function run(options = {}) {
|
|
|
357
347
|
await updatePackageJson(result);
|
|
358
348
|
await updateEslintFiles(result);
|
|
359
349
|
await updateVscodeSettings(result);
|
|
360
|
-
p
|
|
361
|
-
p
|
|
350
|
+
p.log.success(c.green`Setup completed`);
|
|
351
|
+
p.outro(`Now you can update the dependencies by run ${c.blue`bun install`} and run ${c.blue`eslint --fix`}\n`);
|
|
362
352
|
}
|
|
363
353
|
|
|
364
354
|
//#endregion
|
|
365
355
|
//#region src/cli/index.ts
|
|
366
356
|
function header() {
|
|
367
357
|
console.log("\n");
|
|
368
|
-
p.intro(`${c.green
|
|
358
|
+
p.intro(`${c.green`@ivanmaxlogiudice/eslint-config `}${c.dim`v${package_default.version}`}`);
|
|
369
359
|
}
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
description: "Skip prompts and use default values",
|
|
373
|
-
type: "boolean"
|
|
374
|
-
}).option("template", {
|
|
375
|
-
alias: "t",
|
|
376
|
-
description: "Use the framework template for optimal customization: vue",
|
|
377
|
-
type: "string"
|
|
378
|
-
}).option("extra", {
|
|
379
|
-
alias: "e",
|
|
380
|
-
array: true,
|
|
381
|
-
description: "Use the extra utils: unocss",
|
|
382
|
-
type: "string"
|
|
383
|
-
}).help(), async (args) => {
|
|
360
|
+
const cli = cac("@ivanmaxlogiudice/eslint-config");
|
|
361
|
+
cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip prompts and use default values", { default: false }).option("--template, -t <template>", "Use the framework template for optimal customization: vue", { type: [] }).option("--extra, -e <extra>", "Use the extra utils: unocss", { type: [] }).action(async (args) => {
|
|
384
362
|
header();
|
|
385
363
|
try {
|
|
386
364
|
await run(args);
|
|
387
365
|
} catch (error) {
|
|
388
|
-
p.log.error(c.inverse
|
|
389
|
-
p.log.error(c.red
|
|
366
|
+
p.log.error(c.inverse.red` Failed to migrate `);
|
|
367
|
+
p.log.error(c.red`✘ ${String(error)}`);
|
|
390
368
|
process.exit(1);
|
|
391
369
|
}
|
|
392
|
-
})
|
|
393
|
-
|
|
370
|
+
});
|
|
371
|
+
cli.help();
|
|
372
|
+
cli.version(package_default.version);
|
|
373
|
+
cli.parse();
|
|
394
374
|
|
|
395
375
|
//#endregion
|