@antfu/eslint-config 3.2.2 → 3.3.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/dist/cli.cjs +79 -77
- package/dist/cli.js +79 -77
- package/dist/index.cjs +118 -110
- package/dist/index.d.cts +128 -128
- package/dist/index.d.ts +128 -128
- package/dist/index.js +130 -122
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -29,17 +29,10 @@ module.exports = __toCommonJS(cli_exports);
|
|
|
29
29
|
|
|
30
30
|
// src/cli/index.ts
|
|
31
31
|
var import_node_process5 = __toESM(require("process"), 1);
|
|
32
|
+
var p5 = __toESM(require("@clack/prompts"), 1);
|
|
32
33
|
var import_picocolors6 = __toESM(require("picocolors"), 1);
|
|
33
|
-
var import_helpers = require("yargs/helpers");
|
|
34
34
|
var import_yargs = __toESM(require("yargs"), 1);
|
|
35
|
-
var
|
|
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);
|
|
35
|
+
var import_helpers = require("yargs/helpers");
|
|
43
36
|
|
|
44
37
|
// src/cli/constants.ts
|
|
45
38
|
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
@@ -48,7 +41,7 @@ var import_picocolors = __toESM(require("picocolors"), 1);
|
|
|
48
41
|
var package_default = {
|
|
49
42
|
name: "@antfu/eslint-config",
|
|
50
43
|
type: "module",
|
|
51
|
-
version: "3.
|
|
44
|
+
version: "3.3.0",
|
|
52
45
|
packageManager: "pnpm@9.9.0",
|
|
53
46
|
description: "Anthony's ESLint config",
|
|
54
47
|
author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
@@ -346,6 +339,22 @@ var dependenciesMap = {
|
|
|
346
339
|
vue: []
|
|
347
340
|
};
|
|
348
341
|
|
|
342
|
+
// src/cli/run.ts
|
|
343
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
344
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
345
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
346
|
+
var p4 = __toESM(require("@clack/prompts"), 1);
|
|
347
|
+
var import_picocolors5 = __toESM(require("picocolors"), 1);
|
|
348
|
+
|
|
349
|
+
// src/cli/stages/update-eslint-files.ts
|
|
350
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
351
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
352
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
353
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
354
|
+
var p = __toESM(require("@clack/prompts"), 1);
|
|
355
|
+
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
356
|
+
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
357
|
+
|
|
349
358
|
// src/cli/utils.ts
|
|
350
359
|
var import_node_child_process = require("child_process");
|
|
351
360
|
function isGitClean() {
|
|
@@ -368,18 +377,64 @@ ${config}
|
|
|
368
377
|
`.trimStart();
|
|
369
378
|
}
|
|
370
379
|
|
|
371
|
-
// src/cli/stages/update-
|
|
372
|
-
|
|
373
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
374
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
375
|
-
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
376
|
-
var p = __toESM(require("@clack/prompts"), 1);
|
|
377
|
-
async function updatePackageJson(result) {
|
|
380
|
+
// src/cli/stages/update-eslint-files.ts
|
|
381
|
+
async function updateEslintFiles(result) {
|
|
378
382
|
const cwd = import_node_process.default.cwd();
|
|
383
|
+
const pathESLintIgnore = import_node_path.default.join(cwd, ".eslintignore");
|
|
379
384
|
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
380
|
-
p.log.step(import_picocolors2.default.cyan(`Bumping @antfu/eslint-config to v${package_default.version}`));
|
|
381
385
|
const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
|
|
382
386
|
const pkg = JSON.parse(pkgContent);
|
|
387
|
+
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
388
|
+
const pathFlatConfig = import_node_path.default.join(cwd, configFileName);
|
|
389
|
+
const eslintIgnores = [];
|
|
390
|
+
if (import_node_fs.default.existsSync(pathESLintIgnore)) {
|
|
391
|
+
p.log.step(import_picocolors2.default.cyan(`Migrating existing .eslintignore`));
|
|
392
|
+
const content = await import_promises.default.readFile(pathESLintIgnore, "utf-8");
|
|
393
|
+
const parsed = (0, import_parse_gitignore.default)(content);
|
|
394
|
+
const globs = parsed.globs();
|
|
395
|
+
for (const glob of globs) {
|
|
396
|
+
if (glob.type === "ignore")
|
|
397
|
+
eslintIgnores.push(...glob.patterns);
|
|
398
|
+
else if (glob.type === "unignore")
|
|
399
|
+
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
const configLines = [];
|
|
403
|
+
if (eslintIgnores.length)
|
|
404
|
+
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
405
|
+
if (result.extra.includes("formatter"))
|
|
406
|
+
configLines.push(`formatters: true,`);
|
|
407
|
+
if (result.extra.includes("unocss"))
|
|
408
|
+
configLines.push(`unocss: true,`);
|
|
409
|
+
for (const framework of result.frameworks)
|
|
410
|
+
configLines.push(`${framework}: true,`);
|
|
411
|
+
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
412
|
+
const additionalConfig = [];
|
|
413
|
+
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
414
|
+
await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
|
|
415
|
+
p.log.success(import_picocolors2.default.green(`Created ${configFileName}`));
|
|
416
|
+
const files = import_node_fs.default.readdirSync(cwd);
|
|
417
|
+
const legacyConfig = [];
|
|
418
|
+
files.forEach((file) => {
|
|
419
|
+
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
|
420
|
+
legacyConfig.push(file);
|
|
421
|
+
});
|
|
422
|
+
if (legacyConfig.length)
|
|
423
|
+
p.note(`${import_picocolors2.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/cli/stages/update-package-json.ts
|
|
427
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
428
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
429
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
430
|
+
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
431
|
+
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
432
|
+
async function updatePackageJson(result) {
|
|
433
|
+
const cwd = import_node_process2.default.cwd();
|
|
434
|
+
const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
|
|
435
|
+
p2.log.step(import_picocolors3.default.cyan(`Bumping @antfu/eslint-config to v${package_default.version}`));
|
|
436
|
+
const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
|
|
437
|
+
const pkg = JSON.parse(pkgContent);
|
|
383
438
|
pkg.devDependencies ??= {};
|
|
384
439
|
pkg.devDependencies["@antfu/eslint-config"] = `^${package_default.version}`;
|
|
385
440
|
pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
|
|
@@ -419,71 +474,18 @@ async function updatePackageJson(result) {
|
|
|
419
474
|
}
|
|
420
475
|
}
|
|
421
476
|
if (addedPackages.length)
|
|
422
|
-
|
|
423
|
-
await
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// src/cli/stages/update-eslint-files.ts
|
|
428
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
429
|
-
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
430
|
-
var import_node_process2 = __toESM(require("process"), 1);
|
|
431
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
432
|
-
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
433
|
-
var p2 = __toESM(require("@clack/prompts"), 1);
|
|
434
|
-
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
435
|
-
async function updateEslintFiles(result) {
|
|
436
|
-
const cwd = import_node_process2.default.cwd();
|
|
437
|
-
const pathESLintIgnore = import_node_path2.default.join(cwd, ".eslintignore");
|
|
438
|
-
const pathPackageJSON = import_node_path2.default.join(cwd, "package.json");
|
|
439
|
-
const pkgContent = await import_promises2.default.readFile(pathPackageJSON, "utf-8");
|
|
440
|
-
const pkg = JSON.parse(pkgContent);
|
|
441
|
-
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
442
|
-
const pathFlatConfig = import_node_path2.default.join(cwd, configFileName);
|
|
443
|
-
const eslintIgnores = [];
|
|
444
|
-
if (import_node_fs.default.existsSync(pathESLintIgnore)) {
|
|
445
|
-
p2.log.step(import_picocolors3.default.cyan(`Migrating existing .eslintignore`));
|
|
446
|
-
const content = await import_promises2.default.readFile(pathESLintIgnore, "utf-8");
|
|
447
|
-
const parsed = (0, import_parse_gitignore.default)(content);
|
|
448
|
-
const globs = parsed.globs();
|
|
449
|
-
for (const glob of globs) {
|
|
450
|
-
if (glob.type === "ignore")
|
|
451
|
-
eslintIgnores.push(...glob.patterns);
|
|
452
|
-
else if (glob.type === "unignore")
|
|
453
|
-
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
const configLines = [];
|
|
457
|
-
if (eslintIgnores.length)
|
|
458
|
-
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
459
|
-
if (result.extra.includes("formatter"))
|
|
460
|
-
configLines.push(`formatters: true,`);
|
|
461
|
-
if (result.extra.includes("unocss"))
|
|
462
|
-
configLines.push(`unocss: true,`);
|
|
463
|
-
for (const framework of result.frameworks)
|
|
464
|
-
configLines.push(`${framework}: true,`);
|
|
465
|
-
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
466
|
-
const additionalConfig = [];
|
|
467
|
-
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
468
|
-
await import_promises2.default.writeFile(pathFlatConfig, eslintConfigContent);
|
|
469
|
-
p2.log.success(import_picocolors3.default.green(`Created ${configFileName}`));
|
|
470
|
-
const files = import_node_fs.default.readdirSync(cwd);
|
|
471
|
-
const legacyConfig = [];
|
|
472
|
-
files.forEach((file) => {
|
|
473
|
-
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
|
474
|
-
legacyConfig.push(file);
|
|
475
|
-
});
|
|
476
|
-
if (legacyConfig.length)
|
|
477
|
-
p2.note(`${import_picocolors3.default.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
477
|
+
p2.note(`${import_picocolors3.default.dim(addedPackages.join(", "))}`, "Added packages");
|
|
478
|
+
await import_promises2.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
479
|
+
p2.log.success(import_picocolors3.default.green(`Changes wrote to package.json`));
|
|
478
480
|
}
|
|
479
481
|
|
|
480
482
|
// src/cli/stages/update-vscode-settings.ts
|
|
481
|
-
var import_node_path3 = __toESM(require("path"), 1);
|
|
482
|
-
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
483
483
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
484
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
485
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
484
486
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
485
|
-
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
486
487
|
var p3 = __toESM(require("@clack/prompts"), 1);
|
|
488
|
+
var import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
487
489
|
async function updateVscodeSettings(result) {
|
|
488
490
|
const cwd = import_node_process3.default.cwd();
|
|
489
491
|
if (!result.updateVscodeSettings)
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
// src/cli/index.ts
|
|
2
2
|
import process5 from "node:process";
|
|
3
|
+
import * as p5 from "@clack/prompts";
|
|
3
4
|
import c6 from "picocolors";
|
|
4
|
-
import { hideBin } from "yargs/helpers";
|
|
5
5
|
import yargs from "yargs";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
// src/cli/run.ts
|
|
9
|
-
import fs3 from "node:fs";
|
|
10
|
-
import path4 from "node:path";
|
|
11
|
-
import process4 from "node:process";
|
|
12
|
-
import c5 from "picocolors";
|
|
13
|
-
import * as p4 from "@clack/prompts";
|
|
6
|
+
import { hideBin } from "yargs/helpers";
|
|
14
7
|
|
|
15
8
|
// src/cli/constants.ts
|
|
16
9
|
import c from "picocolors";
|
|
@@ -19,7 +12,7 @@ import c from "picocolors";
|
|
|
19
12
|
var package_default = {
|
|
20
13
|
name: "@antfu/eslint-config",
|
|
21
14
|
type: "module",
|
|
22
|
-
version: "3.
|
|
15
|
+
version: "3.3.0",
|
|
23
16
|
packageManager: "pnpm@9.9.0",
|
|
24
17
|
description: "Anthony's ESLint config",
|
|
25
18
|
author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
@@ -317,6 +310,22 @@ var dependenciesMap = {
|
|
|
317
310
|
vue: []
|
|
318
311
|
};
|
|
319
312
|
|
|
313
|
+
// src/cli/run.ts
|
|
314
|
+
import fs3 from "node:fs";
|
|
315
|
+
import path4 from "node:path";
|
|
316
|
+
import process4 from "node:process";
|
|
317
|
+
import * as p4 from "@clack/prompts";
|
|
318
|
+
import c5 from "picocolors";
|
|
319
|
+
|
|
320
|
+
// src/cli/stages/update-eslint-files.ts
|
|
321
|
+
import fs from "node:fs";
|
|
322
|
+
import fsp from "node:fs/promises";
|
|
323
|
+
import path from "node:path";
|
|
324
|
+
import process from "node:process";
|
|
325
|
+
import * as p from "@clack/prompts";
|
|
326
|
+
import parse from "parse-gitignore";
|
|
327
|
+
import c2 from "picocolors";
|
|
328
|
+
|
|
320
329
|
// src/cli/utils.ts
|
|
321
330
|
import { execSync } from "node:child_process";
|
|
322
331
|
function isGitClean() {
|
|
@@ -339,18 +348,64 @@ ${config}
|
|
|
339
348
|
`.trimStart();
|
|
340
349
|
}
|
|
341
350
|
|
|
342
|
-
// src/cli/stages/update-
|
|
343
|
-
|
|
344
|
-
import fsp from "node:fs/promises";
|
|
345
|
-
import process from "node:process";
|
|
346
|
-
import c2 from "picocolors";
|
|
347
|
-
import * as p from "@clack/prompts";
|
|
348
|
-
async function updatePackageJson(result) {
|
|
351
|
+
// src/cli/stages/update-eslint-files.ts
|
|
352
|
+
async function updateEslintFiles(result) {
|
|
349
353
|
const cwd = process.cwd();
|
|
354
|
+
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
350
355
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
351
|
-
p.log.step(c2.cyan(`Bumping @antfu/eslint-config to v${package_default.version}`));
|
|
352
356
|
const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
|
|
353
357
|
const pkg = JSON.parse(pkgContent);
|
|
358
|
+
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
359
|
+
const pathFlatConfig = path.join(cwd, configFileName);
|
|
360
|
+
const eslintIgnores = [];
|
|
361
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
|
362
|
+
p.log.step(c2.cyan(`Migrating existing .eslintignore`));
|
|
363
|
+
const content = await fsp.readFile(pathESLintIgnore, "utf-8");
|
|
364
|
+
const parsed = parse(content);
|
|
365
|
+
const globs = parsed.globs();
|
|
366
|
+
for (const glob of globs) {
|
|
367
|
+
if (glob.type === "ignore")
|
|
368
|
+
eslintIgnores.push(...glob.patterns);
|
|
369
|
+
else if (glob.type === "unignore")
|
|
370
|
+
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
const configLines = [];
|
|
374
|
+
if (eslintIgnores.length)
|
|
375
|
+
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
376
|
+
if (result.extra.includes("formatter"))
|
|
377
|
+
configLines.push(`formatters: true,`);
|
|
378
|
+
if (result.extra.includes("unocss"))
|
|
379
|
+
configLines.push(`unocss: true,`);
|
|
380
|
+
for (const framework of result.frameworks)
|
|
381
|
+
configLines.push(`${framework}: true,`);
|
|
382
|
+
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
383
|
+
const additionalConfig = [];
|
|
384
|
+
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
385
|
+
await fsp.writeFile(pathFlatConfig, eslintConfigContent);
|
|
386
|
+
p.log.success(c2.green(`Created ${configFileName}`));
|
|
387
|
+
const files = fs.readdirSync(cwd);
|
|
388
|
+
const legacyConfig = [];
|
|
389
|
+
files.forEach((file) => {
|
|
390
|
+
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
|
391
|
+
legacyConfig.push(file);
|
|
392
|
+
});
|
|
393
|
+
if (legacyConfig.length)
|
|
394
|
+
p.note(`${c2.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// src/cli/stages/update-package-json.ts
|
|
398
|
+
import fsp2 from "node:fs/promises";
|
|
399
|
+
import path2 from "node:path";
|
|
400
|
+
import process2 from "node:process";
|
|
401
|
+
import * as p2 from "@clack/prompts";
|
|
402
|
+
import c3 from "picocolors";
|
|
403
|
+
async function updatePackageJson(result) {
|
|
404
|
+
const cwd = process2.cwd();
|
|
405
|
+
const pathPackageJSON = path2.join(cwd, "package.json");
|
|
406
|
+
p2.log.step(c3.cyan(`Bumping @antfu/eslint-config to v${package_default.version}`));
|
|
407
|
+
const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
|
|
408
|
+
const pkg = JSON.parse(pkgContent);
|
|
354
409
|
pkg.devDependencies ??= {};
|
|
355
410
|
pkg.devDependencies["@antfu/eslint-config"] = `^${package_default.version}`;
|
|
356
411
|
pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
|
|
@@ -390,71 +445,18 @@ async function updatePackageJson(result) {
|
|
|
390
445
|
}
|
|
391
446
|
}
|
|
392
447
|
if (addedPackages.length)
|
|
393
|
-
|
|
394
|
-
await
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/cli/stages/update-eslint-files.ts
|
|
399
|
-
import fs from "node:fs";
|
|
400
|
-
import fsp2 from "node:fs/promises";
|
|
401
|
-
import process2 from "node:process";
|
|
402
|
-
import path2 from "node:path";
|
|
403
|
-
import c3 from "picocolors";
|
|
404
|
-
import * as p2 from "@clack/prompts";
|
|
405
|
-
import parse from "parse-gitignore";
|
|
406
|
-
async function updateEslintFiles(result) {
|
|
407
|
-
const cwd = process2.cwd();
|
|
408
|
-
const pathESLintIgnore = path2.join(cwd, ".eslintignore");
|
|
409
|
-
const pathPackageJSON = path2.join(cwd, "package.json");
|
|
410
|
-
const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
|
|
411
|
-
const pkg = JSON.parse(pkgContent);
|
|
412
|
-
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
413
|
-
const pathFlatConfig = path2.join(cwd, configFileName);
|
|
414
|
-
const eslintIgnores = [];
|
|
415
|
-
if (fs.existsSync(pathESLintIgnore)) {
|
|
416
|
-
p2.log.step(c3.cyan(`Migrating existing .eslintignore`));
|
|
417
|
-
const content = await fsp2.readFile(pathESLintIgnore, "utf-8");
|
|
418
|
-
const parsed = parse(content);
|
|
419
|
-
const globs = parsed.globs();
|
|
420
|
-
for (const glob of globs) {
|
|
421
|
-
if (glob.type === "ignore")
|
|
422
|
-
eslintIgnores.push(...glob.patterns);
|
|
423
|
-
else if (glob.type === "unignore")
|
|
424
|
-
eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
const configLines = [];
|
|
428
|
-
if (eslintIgnores.length)
|
|
429
|
-
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
|
430
|
-
if (result.extra.includes("formatter"))
|
|
431
|
-
configLines.push(`formatters: true,`);
|
|
432
|
-
if (result.extra.includes("unocss"))
|
|
433
|
-
configLines.push(`unocss: true,`);
|
|
434
|
-
for (const framework of result.frameworks)
|
|
435
|
-
configLines.push(`${framework}: true,`);
|
|
436
|
-
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
|
437
|
-
const additionalConfig = [];
|
|
438
|
-
const eslintConfigContent = getEslintConfigContent(mainConfig, additionalConfig);
|
|
439
|
-
await fsp2.writeFile(pathFlatConfig, eslintConfigContent);
|
|
440
|
-
p2.log.success(c3.green(`Created ${configFileName}`));
|
|
441
|
-
const files = fs.readdirSync(cwd);
|
|
442
|
-
const legacyConfig = [];
|
|
443
|
-
files.forEach((file) => {
|
|
444
|
-
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
|
445
|
-
legacyConfig.push(file);
|
|
446
|
-
});
|
|
447
|
-
if (legacyConfig.length)
|
|
448
|
-
p2.note(`${c3.dim(legacyConfig.join(", "))}`, "You can now remove those files manually");
|
|
448
|
+
p2.note(`${c3.dim(addedPackages.join(", "))}`, "Added packages");
|
|
449
|
+
await fsp2.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
450
|
+
p2.log.success(c3.green(`Changes wrote to package.json`));
|
|
449
451
|
}
|
|
450
452
|
|
|
451
453
|
// src/cli/stages/update-vscode-settings.ts
|
|
452
|
-
import path3 from "node:path";
|
|
453
|
-
import fsp3 from "node:fs/promises";
|
|
454
454
|
import fs2 from "node:fs";
|
|
455
|
+
import fsp3 from "node:fs/promises";
|
|
456
|
+
import path3 from "node:path";
|
|
455
457
|
import process3 from "node:process";
|
|
456
|
-
import c4 from "picocolors";
|
|
457
458
|
import * as p3 from "@clack/prompts";
|
|
459
|
+
import c4 from "picocolors";
|
|
458
460
|
async function updateVscodeSettings(result) {
|
|
459
461
|
const cwd = process3.cwd();
|
|
460
462
|
if (!result.updateVscodeSettings)
|