@2030/eslint-config 0.0.8 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs ADDED
@@ -0,0 +1,613 @@
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 __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+
26
+ // src/cli.ts
27
+ var cli_exports = {};
28
+ module.exports = __toCommonJS(cli_exports);
29
+
30
+ // src/cli/index.ts
31
+ var import_node_process5 = __toESM(require("process"), 1);
32
+ var import_picocolors6 = __toESM(require("picocolors"), 1);
33
+ var import_helpers = require("yargs/helpers");
34
+ var import_yargs = __toESM(require("yargs"), 1);
35
+ var p5 = __toESM(require("@clack/prompts"), 1);
36
+
37
+ // src/cli/run.ts
38
+ var import_node_fs3 = __toESM(require("fs"), 1);
39
+ var import_node_path4 = __toESM(require("path"), 1);
40
+ var import_node_process4 = __toESM(require("process"), 1);
41
+ var import_picocolors5 = __toESM(require("picocolors"), 1);
42
+ var p4 = __toESM(require("@clack/prompts"), 1);
43
+
44
+ // src/cli/constants.ts
45
+ var import_picocolors = __toESM(require("picocolors"), 1);
46
+
47
+ // package.json
48
+ var package_default = {
49
+ name: "@2030/eslint-config",
50
+ type: "module",
51
+ version: "1.0.0-beta.1",
52
+ description: "Shareable ESLint config for conventional coding style",
53
+ author: "Dai Jun <zijun2030@163.com>",
54
+ license: "MIT",
55
+ homepage: "https://github.com/Jun2030/eslint-config",
56
+ keywords: [
57
+ "eslint-config"
58
+ ],
59
+ exports: {
60
+ ".": {
61
+ import: "./dist/index.js",
62
+ require: "./dist/index.cjs"
63
+ }
64
+ },
65
+ main: "./dist/index.js",
66
+ types: "./dist/index.d.ts",
67
+ bin: "./bin/index.js",
68
+ files: [
69
+ "bin",
70
+ "dist"
71
+ ],
72
+ scripts: {
73
+ build: "nr typegen && tsup --format esm,cjs --clean --dts",
74
+ stub: "tsup --format esm",
75
+ dev: "npx @eslint/config-inspector --config eslint.config.ts",
76
+ "build:inspector": "pnpm build && npx @eslint/config-inspector build",
77
+ watch: "tsup --format esm,cjs --watch",
78
+ lint: "eslint --flag unstable_ts_config .",
79
+ typegen: "esno scripts/typegen.ts",
80
+ prepack: "nr build",
81
+ release: "bumpp && pnpm publish",
82
+ test: "vitest",
83
+ typecheck: "tsc --noEmit",
84
+ prepare: "simple-git-hooks"
85
+ },
86
+ peerDependencies: {
87
+ "@eslint-react/eslint-plugin": "^1.12.1",
88
+ "@prettier/plugin-xml": "^3.4.1",
89
+ "@unocss/eslint-plugin": "^0.62.3",
90
+ "astro-eslint-parser": "^1.0.2",
91
+ eslint: "^9.9.1",
92
+ "eslint-plugin-astro": "^1.2.3",
93
+ "eslint-plugin-format": "^0.1.2",
94
+ "eslint-plugin-react-hooks": "^4.6.2",
95
+ "eslint-plugin-react-refresh": "^0.4.11",
96
+ "eslint-plugin-solid": "^0.14.2",
97
+ "eslint-plugin-svelte": "^2.43.0",
98
+ "prettier-plugin-astro": "^0.14.1",
99
+ "prettier-plugin-slidev": "^1.0.5",
100
+ "svelte-eslint-parser": "^0.41.0"
101
+ },
102
+ peerDependenciesMeta: {
103
+ "@eslint-react/eslint-plugin": {
104
+ optional: true
105
+ },
106
+ "@prettier/plugin-xml": {
107
+ optional: true
108
+ },
109
+ "@unocss/eslint-plugin": {
110
+ optional: true
111
+ },
112
+ "astro-eslint-parser": {
113
+ optional: true
114
+ },
115
+ "eslint-plugin-astro": {
116
+ optional: true
117
+ },
118
+ "eslint-plugin-format": {
119
+ optional: true
120
+ },
121
+ "eslint-plugin-react-hooks": {
122
+ optional: true
123
+ },
124
+ "eslint-plugin-react-refresh": {
125
+ optional: true
126
+ },
127
+ "eslint-plugin-solid": {
128
+ optional: true
129
+ },
130
+ "eslint-plugin-svelte": {
131
+ optional: true
132
+ },
133
+ "prettier-plugin-astro": {
134
+ optional: true
135
+ },
136
+ "prettier-plugin-slidev": {
137
+ optional: true
138
+ },
139
+ "svelte-eslint-parser": {
140
+ optional: true
141
+ }
142
+ },
143
+ dependencies: {
144
+ "@antfu/install-pkg": "^0.4.1",
145
+ "@clack/prompts": "^0.7.0",
146
+ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
147
+ "@stylistic/eslint-plugin": "^2.6.4",
148
+ "@typescript-eslint/eslint-plugin": "^8.3.0",
149
+ "@typescript-eslint/parser": "^8.3.0",
150
+ "@vitest/eslint-plugin": "^1.0.5",
151
+ "eslint-config-flat-gitignore": "^0.1.8",
152
+ "eslint-flat-config-utils": "^0.3.1",
153
+ "eslint-merge-processors": "^0.1.0",
154
+ "eslint-plugin-antfu": "^2.3.6",
155
+ "eslint-plugin-command": "^0.2.3",
156
+ "eslint-plugin-import-x": "^4.0.0",
157
+ "eslint-plugin-jsdoc": "^50.2.2",
158
+ "eslint-plugin-jsonc": "^2.16.0",
159
+ "eslint-plugin-markdown": "^5.1.0",
160
+ "eslint-plugin-n": "^17.10.2",
161
+ "eslint-plugin-no-only-tests": "^3.3.0",
162
+ "eslint-plugin-perfectionist": "^3.2.0",
163
+ "eslint-plugin-regexp": "^2.6.0",
164
+ "eslint-plugin-toml": "^0.11.1",
165
+ "eslint-plugin-unicorn": "^55.0.0",
166
+ "eslint-plugin-unused-imports": "^4.1.3",
167
+ "eslint-plugin-vue": "^9.27.0",
168
+ "eslint-plugin-yml": "^1.14.0",
169
+ "eslint-processor-vue-blocks": "^0.1.2",
170
+ globals: "^15.9.0",
171
+ "jsonc-eslint-parser": "^2.4.0",
172
+ "local-pkg": "^0.5.0",
173
+ "parse-gitignore": "^2.0.0",
174
+ picocolors: "^1.0.1",
175
+ "toml-eslint-parser": "^0.10.0",
176
+ "vue-eslint-parser": "^9.4.3",
177
+ "yaml-eslint-parser": "^1.2.3",
178
+ yargs: "^17.7.2"
179
+ },
180
+ devDependencies: {
181
+ "@2030/eslint-config": "workspace:*",
182
+ "@antfu/ni": "^0.22.4",
183
+ "@eslint-react/eslint-plugin": "^1.12.1",
184
+ "@eslint/config-inspector": "^0.5.4",
185
+ "@prettier/plugin-xml": "^3.4.1",
186
+ "@stylistic/eslint-plugin-migrate": "^2.6.4",
187
+ "@types/eslint": "^9.6.1",
188
+ "@types/fs-extra": "^11.0.4",
189
+ "@types/node": "^22.5.0",
190
+ "@types/prompts": "^2.4.9",
191
+ "@types/yargs": "^17.0.33",
192
+ "@unocss/eslint-plugin": "^0.62.3",
193
+ "astro-eslint-parser": "^1.0.2",
194
+ bumpp: "^9.5.2",
195
+ eslint: "^9.9.1",
196
+ "eslint-plugin-astro": "^1.2.3",
197
+ "eslint-plugin-format": "^0.1.2",
198
+ "eslint-plugin-react-hooks": "^4.6.2",
199
+ "eslint-plugin-react-refresh": "^0.4.11",
200
+ "eslint-plugin-solid": "^0.14.2",
201
+ "eslint-plugin-svelte": "^2.43.0",
202
+ "eslint-typegen": "^0.3.1",
203
+ esno: "^4.7.0",
204
+ execa: "^9.3.1",
205
+ "fast-glob": "^3.3.2",
206
+ "fs-extra": "^11.2.0",
207
+ jiti: "^1.21.6",
208
+ "lint-staged": "^15.2.9",
209
+ "prettier-plugin-astro": "^0.14.1",
210
+ "prettier-plugin-slidev": "^1.0.5",
211
+ rimraf: "^6.0.1",
212
+ "simple-git-hooks": "^2.11.1",
213
+ svelte: "^4.2.19",
214
+ "svelte-eslint-parser": "^0.41.0",
215
+ tsup: "^8.2.4",
216
+ tsx: "^4.18.0",
217
+ typescript: "^5.5.4",
218
+ vitest: "^2.0.5",
219
+ vue: "^3.4.38"
220
+ },
221
+ resolutions: {
222
+ "@eslint-community/eslint-utils": "^4.4.0",
223
+ "@typescript-eslint/utils": "^8.3.0",
224
+ eslint: "^9.9.1",
225
+ tsx: "^4.18.0"
226
+ },
227
+ "simple-git-hooks": {
228
+ "pre-commit": "npx lint-staged"
229
+ },
230
+ "lint-staged": {
231
+ "*": "eslint --flag unstable_ts_config --fix"
232
+ }
233
+ };
234
+
235
+ // src/cli/constants.ts
236
+ var vscodeSettingsString = `
237
+ // Disable the default formatter, use eslint instead
238
+ "prettier.enable": false,
239
+ "editor.formatOnSave": false,
240
+
241
+ // Auto fix
242
+ "editor.codeActionsOnSave": {
243
+ "source.fixAll.eslint": "explicit",
244
+ "source.organizeImports": "never"
245
+ },
246
+
247
+ // Silent the stylistic rules in you IDE, but still auto fix them
248
+ "eslint.rules.customizations": [
249
+ { "rule": "style/*", "severity": "off", "fixable": true },
250
+ { "rule": "format/*", "severity": "off", "fixable": true },
251
+ { "rule": "*-indent", "severity": "off", "fixable": true },
252
+ { "rule": "*-spacing", "severity": "off", "fixable": true },
253
+ { "rule": "*-spaces", "severity": "off", "fixable": true },
254
+ { "rule": "*-order", "severity": "off", "fixable": true },
255
+ { "rule": "*-dangle", "severity": "off", "fixable": true },
256
+ { "rule": "*-newline", "severity": "off", "fixable": true },
257
+ { "rule": "*quotes", "severity": "off", "fixable": true },
258
+ { "rule": "*semi", "severity": "off", "fixable": true }
259
+ ],
260
+
261
+ // Enable eslint for all supported languages
262
+ "eslint.validate": [
263
+ "javascript",
264
+ "javascriptreact",
265
+ "typescript",
266
+ "typescriptreact",
267
+ "vue",
268
+ "html",
269
+ "markdown",
270
+ "json",
271
+ "jsonc",
272
+ "yaml",
273
+ "toml",
274
+ "xml",
275
+ "gql",
276
+ "graphql",
277
+ "astro",
278
+ "css",
279
+ "less",
280
+ "scss",
281
+ "pcss",
282
+ "postcss"
283
+ ]
284
+ `;
285
+ var frameworkOptions = [
286
+ {
287
+ label: import_picocolors.default.green("Vue"),
288
+ value: "vue"
289
+ },
290
+ {
291
+ label: import_picocolors.default.cyan("React"),
292
+ value: "react"
293
+ },
294
+ {
295
+ label: import_picocolors.default.red("Svelte"),
296
+ value: "svelte"
297
+ },
298
+ {
299
+ label: import_picocolors.default.magenta("Astro"),
300
+ value: "astro"
301
+ },
302
+ {
303
+ label: import_picocolors.default.cyan("Solid"),
304
+ value: "solid"
305
+ },
306
+ {
307
+ label: import_picocolors.default.blue("Slidev"),
308
+ value: "slidev"
309
+ }
310
+ ];
311
+ var frameworks = frameworkOptions.map(({ value }) => value);
312
+ var extraOptions = [
313
+ {
314
+ hint: "Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)",
315
+ label: import_picocolors.default.red("Formatter"),
316
+ value: "formatter"
317
+ },
318
+ {
319
+ label: import_picocolors.default.cyan("UnoCSS"),
320
+ value: "unocss"
321
+ }
322
+ ];
323
+ var extra = extraOptions.map(({ value }) => value);
324
+ var dependenciesMap = {
325
+ astro: [
326
+ "eslint-plugin-astro",
327
+ "astro-eslint-parser"
328
+ ],
329
+ react: [
330
+ "@eslint-react/eslint-plugin",
331
+ "eslint-plugin-react-hooks",
332
+ "eslint-plugin-react-refresh"
333
+ ],
334
+ slidev: [
335
+ "prettier-plugin-slidev"
336
+ ],
337
+ solid: [
338
+ "eslint-plugin-solid"
339
+ ],
340
+ svelte: [
341
+ "eslint-plugin-svelte",
342
+ "svelte-eslint-parser"
343
+ ],
344
+ vue: []
345
+ };
346
+
347
+ // src/cli/utils.ts
348
+ var import_node_child_process = require("child_process");
349
+ function isGitClean() {
350
+ try {
351
+ (0, import_node_child_process.execSync)("git diff-index --quiet HEAD --");
352
+ return true;
353
+ } catch {
354
+ return false;
355
+ }
356
+ }
357
+ function getEslintConfigContent(mainConfig, additionalConfigs) {
358
+ return `
359
+ import jun from '@2030/eslint-config'
360
+
361
+ export default jun({
362
+ ${mainConfig}
363
+ }${additionalConfigs?.map((config) => `,{
364
+ ${config}
365
+ }`)})
366
+ `.trimStart();
367
+ }
368
+
369
+ // src/cli/stages/update-package-json.ts
370
+ var import_node_path = __toESM(require("path"), 1);
371
+ var import_promises = __toESM(require("fs/promises"), 1);
372
+ var import_node_process = __toESM(require("process"), 1);
373
+ var import_picocolors2 = __toESM(require("picocolors"), 1);
374
+ var p = __toESM(require("@clack/prompts"), 1);
375
+ async function updatePackageJson(result) {
376
+ const cwd = import_node_process.default.cwd();
377
+ const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
378
+ p.log.step(import_picocolors2.default.cyan(`Bumping @2030/eslint-config to v${package_default.version}`));
379
+ const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
380
+ const pkg = JSON.parse(pkgContent);
381
+ pkg.devDependencies ??= {};
382
+ pkg.devDependencies["@2030/eslint-config"] = `^${package_default.version}`;
383
+ pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
384
+ const addedPackages = [];
385
+ if (result.extra.length) {
386
+ result.extra.forEach((item) => {
387
+ switch (item) {
388
+ case "formatter":
389
+ [
390
+ "eslint-plugin-format",
391
+ result.frameworks.includes("astro") ? "prettier-plugin-astro" : null
392
+ ].forEach((f) => {
393
+ if (!f)
394
+ return;
395
+ pkg.devDependencies[f] = package_default.devDependencies[f];
396
+ addedPackages.push(f);
397
+ });
398
+ break;
399
+ case "unocss":
400
+ [
401
+ "@unocss/eslint-plugin"
402
+ ].forEach((f) => {
403
+ pkg.devDependencies[f] = package_default.devDependencies[f];
404
+ addedPackages.push(f);
405
+ });
406
+ break;
407
+ }
408
+ });
409
+ }
410
+ for (const framework of result.frameworks) {
411
+ const deps = dependenciesMap[framework];
412
+ if (deps) {
413
+ deps.forEach((f) => {
414
+ pkg.devDependencies[f] = package_default.devDependencies[f];
415
+ addedPackages.push(f);
416
+ });
417
+ }
418
+ }
419
+ if (addedPackages.length)
420
+ p.note(`${import_picocolors2.default.dim(addedPackages.join(", "))}`, "Added packages");
421
+ await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
422
+ p.log.success(import_picocolors2.default.green(`Changes wrote to package.json`));
423
+ }
424
+
425
+ // src/cli/stages/update-eslint-files.ts
426
+ var import_node_fs = __toESM(require("fs"), 1);
427
+ var import_promises2 = __toESM(require("fs/promises"), 1);
428
+ var import_node_process2 = __toESM(require("process"), 1);
429
+ var import_node_path2 = __toESM(require("path"), 1);
430
+ var import_picocolors3 = __toESM(require("picocolors"), 1);
431
+ var p2 = __toESM(require("@clack/prompts"), 1);
432
+ var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
433
+ async function updateEslintFiles(result) {
434
+ const cwd = import_node_process2.default.cwd();
435
+ const pathESLintIgnore = import_node_path2.default.join(cwd, ".eslintignore");
436
+ const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
437
+ const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
438
+ const pkg = JSON.parse(pkgContent);
439
+ const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
440
+ const pathFlatConfig = import_node_path2.default.join(cwd, configFileName);
441
+ const eslintIgnores = [];
442
+ if (import_node_fs.default.existsSync(pathESLintIgnore)) {
443
+ p2.log.step(import_picocolors3.default.cyan(`Migrating existing .eslintignore`));
444
+ const content = await import_promises2.default.readFile(pathESLintIgnore, "utf-8");
445
+ const parsed = (0, import_parse_gitignore.default)(content);
446
+ const globs = parsed.globs();
447
+ for (const glob of globs) {
448
+ if (glob.type === "ignore")
449
+ eslintIgnores.push(...glob.patterns);
450
+ else if (glob.type === "unignore")
451
+ eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
452
+ }
453
+ }
454
+ const configLines = [];
455
+ if (eslintIgnores.length)
456
+ configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
457
+ if (result.extra.includes("formatter"))
458
+ configLines.push(`formatters: true,`);
459
+ if (result.extra.includes("unocss"))
460
+ configLines.push(`unocss: true,`);
461
+ for (const framework of result.frameworks)
462
+ configLines.push(`${framework}: true,`);
463
+ const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
464
+ const additionalConfig = [];
465
+ const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
466
+ await import_promises2.default.writeFile(pathFlatConfig, eslintConfigContent);
467
+ p2.log.success(import_picocolors3.default.green(`Created ${configFileName}`));
468
+ const files = import_node_fs.default.readdirSync(cwd);
469
+ const legacyConfig = [];
470
+ files.forEach((file) => {
471
+ if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
472
+ legacyConfig.push(file);
473
+ });
474
+ if (legacyConfig.length)
475
+ p2.note(`${import_picocolors3.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
476
+ }
477
+
478
+ // src/cli/stages/update-vscode-settings.ts
479
+ var import_node_path3 = __toESM(require("path"), 1);
480
+ var import_promises3 = __toESM(require("fs/promises"), 1);
481
+ var import_node_fs2 = __toESM(require("fs"), 1);
482
+ var import_node_process3 = __toESM(require("process"), 1);
483
+ var import_picocolors4 = __toESM(require("picocolors"), 1);
484
+ var p3 = __toESM(require("@clack/prompts"), 1);
485
+ async function updateVscodeSettings(result) {
486
+ const cwd = import_node_process3.default.cwd();
487
+ if (!result.updateVscodeSettings)
488
+ return;
489
+ const dotVscodePath = import_node_path3.default.join(cwd, ".vscode");
490
+ const settingsPath = import_node_path3.default.join(dotVscodePath, "settings.json");
491
+ if (!import_node_fs2.default.existsSync(dotVscodePath))
492
+ await import_promises3.default.mkdir(dotVscodePath, { recursive: true });
493
+ if (!import_node_fs2.default.existsSync(settingsPath)) {
494
+ await import_promises3.default.writeFile(settingsPath, `{${vscodeSettingsString}}
495
+ `, "utf-8");
496
+ p3.log.success(import_picocolors4.default.green(`Created .vscode/settings.json`));
497
+ } else {
498
+ let settingsContent = await import_promises3.default.readFile(settingsPath, "utf8");
499
+ settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
500
+ settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
501
+ settingsContent += `${vscodeSettingsString}}
502
+ `;
503
+ await import_promises3.default.writeFile(settingsPath, settingsContent, "utf-8");
504
+ p3.log.success(import_picocolors4.default.green(`Updated .vscode/settings.json`));
505
+ }
506
+ }
507
+
508
+ // src/cli/run.ts
509
+ async function run(options = {}) {
510
+ const argSkipPrompt = !!import_node_process4.default.env.SKIP_PROMPT || options.yes;
511
+ const argTemplate = options.frameworks?.map((m) => m.trim());
512
+ const argExtra = options.extra?.map((m) => m.trim());
513
+ if (import_node_fs3.default.existsSync(import_node_path4.default.join(import_node_process4.default.cwd(), "eslint.config.js"))) {
514
+ p4.log.warn(import_picocolors5.default.yellow(`eslint.config.js already exists, migration wizard exited.`));
515
+ return import_node_process4.default.exit(1);
516
+ }
517
+ let result = {
518
+ extra: argExtra ?? [],
519
+ frameworks: argTemplate ?? [],
520
+ uncommittedConfirmed: false,
521
+ updateVscodeSettings: true
522
+ };
523
+ if (!argSkipPrompt) {
524
+ result = await p4.group({
525
+ uncommittedConfirmed: () => {
526
+ if (argSkipPrompt || isGitClean())
527
+ return Promise.resolve(true);
528
+ return p4.confirm({
529
+ initialValue: false,
530
+ message: "There are uncommitted changes in the current repository, are you sure to continue?"
531
+ });
532
+ },
533
+ frameworks: ({ results }) => {
534
+ const isArgTemplateValid = typeof argTemplate === "string" && !!frameworks.includes(argTemplate);
535
+ if (!results.uncommittedConfirmed || isArgTemplateValid)
536
+ return;
537
+ const message = !isArgTemplateValid && argTemplate ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:";
538
+ return p4.multiselect({
539
+ message: import_picocolors5.default.reset(message),
540
+ options: frameworkOptions,
541
+ required: false
542
+ });
543
+ },
544
+ extra: ({ results }) => {
545
+ const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
546
+ if (!results.uncommittedConfirmed || isArgExtraValid)
547
+ return;
548
+ const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
549
+ return p4.multiselect({
550
+ message: import_picocolors5.default.reset(message),
551
+ options: extraOptions,
552
+ required: false
553
+ });
554
+ },
555
+ updateVscodeSettings: ({ results }) => {
556
+ if (!results.uncommittedConfirmed)
557
+ return;
558
+ return p4.confirm({
559
+ initialValue: true,
560
+ message: "Update .vscode/settings.json for better VS Code experience?"
561
+ });
562
+ }
563
+ }, {
564
+ onCancel: () => {
565
+ p4.cancel("Operation cancelled.");
566
+ import_node_process4.default.exit(0);
567
+ }
568
+ });
569
+ if (!result.uncommittedConfirmed)
570
+ return import_node_process4.default.exit(1);
571
+ }
572
+ await updatePackageJson(result);
573
+ await updateEslintFiles(result);
574
+ await updateVscodeSettings(result);
575
+ p4.log.success(import_picocolors5.default.green(`Setup completed`));
576
+ p4.outro(`Now you can update the dependencies and run ${import_picocolors5.default.blue("eslint . --fix")}
577
+ `);
578
+ }
579
+
580
+ // src/cli/index.ts
581
+ function header() {
582
+ console.log("\n");
583
+ p5.intro(`${import_picocolors6.default.green(`@2030/eslint-config `)}${import_picocolors6.default.dim(`v${package_default.version}`)}`);
584
+ }
585
+ var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process5.default.argv)).scriptName("@2030/eslint-config").usage("").command(
586
+ "*",
587
+ "Run the initialization or migration",
588
+ (args) => args.option("yes", {
589
+ alias: "y",
590
+ description: "Skip prompts and use default values",
591
+ type: "boolean"
592
+ }).option("template", {
593
+ alias: "t",
594
+ description: "Use the framework template for optimal customization: vue / react / svelte / astro",
595
+ type: "string"
596
+ }).option("extra", {
597
+ alias: "e",
598
+ array: true,
599
+ description: "Use the extra utils: formatter / perfectionist / unocss",
600
+ type: "string"
601
+ }).help(),
602
+ async (args) => {
603
+ header();
604
+ try {
605
+ await run(args);
606
+ } catch (error) {
607
+ p5.log.error(import_picocolors6.default.inverse(import_picocolors6.default.red(" Failed to migrate ")));
608
+ p5.log.error(import_picocolors6.default.red(`\u2718 ${String(error)}`));
609
+ import_node_process5.default.exit(1);
610
+ }
611
+ }
612
+ ).showHelpOnFail(false).alias("h", "help").version("version", package_default.version).alias("v", "version");
613
+ instance.help().argv;
package/dist/cli.d.cts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }