@coderwyd/eslint-config 3.6.0 → 4.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 +0 -11
- package/dist/cli.js +10 -10
- package/dist/index.d.ts +368 -1719
- package/dist/index.js +10 -26
- package/package.json +19 -24
- package/dist/cli.cjs +0 -256
- package/dist/cli.d.cts +0 -2
- package/dist/index.cjs +0 -1936
- package/dist/index.d.cts +0 -15266
package/dist/index.js
CHANGED
|
@@ -114,6 +114,7 @@ function imports() {
|
|
|
114
114
|
"antfu/import-dedupe": "error",
|
|
115
115
|
"antfu/no-import-dist": "error",
|
|
116
116
|
"antfu/no-import-node-modules-by-path": "error",
|
|
117
|
+
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
117
118
|
"import/first": "error",
|
|
118
119
|
"import/no-duplicates": "error",
|
|
119
120
|
"import/no-mutable-exports": "error",
|
|
@@ -366,26 +367,6 @@ import { fileURLToPath } from "node:url";
|
|
|
366
367
|
import { getPackageInfoSync, isPackageExists } from "local-pkg";
|
|
367
368
|
var scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
368
369
|
var isCwdInScope = isPackageExists("@coderwyd/eslint-config");
|
|
369
|
-
var parserPlain = {
|
|
370
|
-
meta: {
|
|
371
|
-
name: "parser-plain"
|
|
372
|
-
},
|
|
373
|
-
parseForESLint: (code) => ({
|
|
374
|
-
ast: {
|
|
375
|
-
body: [],
|
|
376
|
-
comments: [],
|
|
377
|
-
loc: { end: code.length, start: 0 },
|
|
378
|
-
range: [0, code.length],
|
|
379
|
-
tokens: [],
|
|
380
|
-
type: "Program"
|
|
381
|
-
},
|
|
382
|
-
scopeManager: null,
|
|
383
|
-
services: { isPlain: true },
|
|
384
|
-
visitorKeys: {
|
|
385
|
-
Program: []
|
|
386
|
-
}
|
|
387
|
-
})
|
|
388
|
-
};
|
|
389
370
|
async function combine(...configs2) {
|
|
390
371
|
const resolved = await Promise.all(configs2);
|
|
391
372
|
return resolved.flat();
|
|
@@ -644,9 +625,7 @@ function prettier() {
|
|
|
644
625
|
import process2 from "node:process";
|
|
645
626
|
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
646
627
|
var isInEditor = !!((process2.env.VSCODE_PID || process2.env.VSCODE_CWD || process2.env.JETBRAINS_IDE || process2.env.VIM || process2.env.NVIM) && !process2.env.CI);
|
|
647
|
-
var hasTypeScript = isPackageExists2("typescript");
|
|
648
628
|
var VueJsPackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
|
|
649
|
-
var hasVue = hasPackages(VueJsPackages);
|
|
650
629
|
var RemixPackages = [
|
|
651
630
|
"@remix-run/node",
|
|
652
631
|
"@remix-run/react",
|
|
@@ -661,6 +640,8 @@ var ReactRouterPackages = [
|
|
|
661
640
|
];
|
|
662
641
|
var NextJsPackages = ["next"];
|
|
663
642
|
var ReactRefreshAllowConstantExportPackages = ["vite"];
|
|
643
|
+
var isUsingTypeScript = isPackageExists2("typescript");
|
|
644
|
+
var isUsingVue = hasPackages(VueJsPackages);
|
|
664
645
|
var isUsingRemix = hasPackages(RemixPackages);
|
|
665
646
|
var isUsingReactRouter = hasPackages(ReactRouterPackages);
|
|
666
647
|
var isUsingNext = hasPackages(NextJsPackages);
|
|
@@ -1391,7 +1372,11 @@ async function typescript(options = {}) {
|
|
|
1391
1372
|
"ts/consistent-type-definitions": ["error", "interface"],
|
|
1392
1373
|
"ts/consistent-type-imports": [
|
|
1393
1374
|
"error",
|
|
1394
|
-
{
|
|
1375
|
+
{
|
|
1376
|
+
disallowTypeAnnotations: false,
|
|
1377
|
+
fixStyle: "separate-type-imports",
|
|
1378
|
+
prefer: "type-imports"
|
|
1379
|
+
}
|
|
1395
1380
|
],
|
|
1396
1381
|
"ts/method-signature-style": ["error", "property"],
|
|
1397
1382
|
// https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
|
|
@@ -1728,9 +1713,9 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
1728
1713
|
regexp: enableRegexp = true,
|
|
1729
1714
|
svelte: enableSvelte = false,
|
|
1730
1715
|
tailwindcss: enableTailwindCSS = false,
|
|
1731
|
-
typescript: enableTypeScript =
|
|
1716
|
+
typescript: enableTypeScript = isUsingTypeScript,
|
|
1732
1717
|
unocss: enableUnoCSS = false,
|
|
1733
|
-
vue: enableVue =
|
|
1718
|
+
vue: enableVue = isUsingVue
|
|
1734
1719
|
} = options;
|
|
1735
1720
|
let isInEditor2 = options.isInEditor;
|
|
1736
1721
|
if (isInEditor2 == null) {
|
|
@@ -1873,7 +1858,6 @@ export {
|
|
|
1873
1858
|
isInEditorEnv,
|
|
1874
1859
|
isInGitHooksOrLintStaged,
|
|
1875
1860
|
isPackageInScope,
|
|
1876
|
-
parserPlain,
|
|
1877
1861
|
renamePluginInConfigs,
|
|
1878
1862
|
renameRules,
|
|
1879
1863
|
resolveSubOptions,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderwyd/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"description": "Donny's ESLint config",
|
|
6
6
|
"author": "Donny Wang <donny526@outlook.com> (https://github.com/coderwyd/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -17,14 +17,9 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"exports": {
|
|
20
|
-
".":
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"import": "./dist/index.js",
|
|
23
|
-
"require": "./dist/index.cjs"
|
|
24
|
-
}
|
|
20
|
+
".": "./dist/index.js"
|
|
25
21
|
},
|
|
26
22
|
"main": "./dist/index.js",
|
|
27
|
-
"module": "./dist/index.js",
|
|
28
23
|
"types": "./dist/index.d.ts",
|
|
29
24
|
"bin": "./bin/index.js",
|
|
30
25
|
"files": [
|
|
@@ -74,20 +69,20 @@
|
|
|
74
69
|
"dependencies": {
|
|
75
70
|
"@antfu/install-pkg": "^1.0.0",
|
|
76
71
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
78
|
-
"@typescript-eslint/parser": "^8.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.23.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.23.0",
|
|
79
74
|
"@vitest/eslint-plugin": "^1.1.25",
|
|
80
|
-
"eslint-config-flat-gitignore": "^
|
|
75
|
+
"eslint-config-flat-gitignore": "^2.0.0",
|
|
81
76
|
"eslint-config-prettier": "^10.0.1",
|
|
82
|
-
"eslint-plugin-antfu": "^
|
|
83
|
-
"eslint-plugin-command": "^
|
|
77
|
+
"eslint-plugin-antfu": "^3.0.0",
|
|
78
|
+
"eslint-plugin-command": "^3.0.0",
|
|
84
79
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
85
80
|
"eslint-plugin-import-x": "^4.6.1",
|
|
86
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
87
|
-
"eslint-plugin-jsonc": "^2.
|
|
81
|
+
"eslint-plugin-jsdoc": "^50.6.3",
|
|
82
|
+
"eslint-plugin-jsonc": "^2.19.1",
|
|
88
83
|
"eslint-plugin-n": "^17.15.1",
|
|
89
84
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
90
|
-
"eslint-plugin-perfectionist": "^4.
|
|
85
|
+
"eslint-plugin-perfectionist": "^4.8.0",
|
|
91
86
|
"eslint-plugin-regexp": "^2.7.0",
|
|
92
87
|
"eslint-plugin-unicorn": "^56.0.1",
|
|
93
88
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
@@ -104,17 +99,17 @@
|
|
|
104
99
|
"yargs": "^17.7.2"
|
|
105
100
|
},
|
|
106
101
|
"devDependencies": {
|
|
107
|
-
"@antfu/ni": "^23.
|
|
108
|
-
"@eslint-react/eslint-plugin": "^1.
|
|
102
|
+
"@antfu/ni": "^23.3.1",
|
|
103
|
+
"@eslint-react/eslint-plugin": "^1.26.2",
|
|
109
104
|
"@eslint/config-inspector": "^1.0.0",
|
|
110
105
|
"@types/eslint-config-prettier": "^6.11.3",
|
|
111
|
-
"@types/node": "^22.
|
|
106
|
+
"@types/node": "^22.13.1",
|
|
112
107
|
"@types/prompts": "^2.4.9",
|
|
113
108
|
"@types/yargs": "^17.0.33",
|
|
114
|
-
"@unocss/eslint-plugin": "^65.4.
|
|
115
|
-
"bumpp": "^
|
|
116
|
-
"eslint": "^9.
|
|
117
|
-
"eslint-plugin-react-compiler": "19.0.0-beta-
|
|
109
|
+
"@unocss/eslint-plugin": "^65.4.3",
|
|
110
|
+
"bumpp": "^10.0.2",
|
|
111
|
+
"eslint": "^9.19.0",
|
|
112
|
+
"eslint-plugin-react-compiler": "19.0.0-beta-e552027-20250112",
|
|
118
113
|
"eslint-plugin-react-hooks": "^5.1.0",
|
|
119
114
|
"eslint-plugin-react-refresh": "^0.4.18",
|
|
120
115
|
"eslint-plugin-svelte": "^2.46.1",
|
|
@@ -122,9 +117,9 @@
|
|
|
122
117
|
"jiti": "^2.4.2",
|
|
123
118
|
"nano-staged": "^0.8.0",
|
|
124
119
|
"simple-git-hooks": "^2.11.1",
|
|
125
|
-
"svelte": "^5.19.
|
|
120
|
+
"svelte": "^5.19.9",
|
|
126
121
|
"svelte-eslint-parser": "^0.43.0",
|
|
127
|
-
"tsup": "^8.3.
|
|
122
|
+
"tsup": "^8.3.6",
|
|
128
123
|
"typescript": "^5.7.3"
|
|
129
124
|
},
|
|
130
125
|
"simple-git-hooks": {
|
package/dist/cli.cjs
DELETED
|
@@ -1,256 +0,0 @@
|
|
|
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_process2 = __toESM(require("process"), 1);
|
|
32
|
-
var import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
33
|
-
var import_yargs = __toESM(require("yargs"), 1);
|
|
34
|
-
var import_helpers = require("yargs/helpers");
|
|
35
|
-
|
|
36
|
-
// src/cli/constants.ts
|
|
37
|
-
var import_picocolors = __toESM(require("picocolors"), 1);
|
|
38
|
-
|
|
39
|
-
// package.json
|
|
40
|
-
var version = "3.6.0";
|
|
41
|
-
var devDependencies = {
|
|
42
|
-
"@antfu/ni": "^23.2.0",
|
|
43
|
-
"@eslint-react/eslint-plugin": "^1.23.2",
|
|
44
|
-
"@eslint/config-inspector": "^1.0.0",
|
|
45
|
-
"@types/eslint-config-prettier": "^6.11.3",
|
|
46
|
-
"@types/node": "^22.10.7",
|
|
47
|
-
"@types/prompts": "^2.4.9",
|
|
48
|
-
"@types/yargs": "^17.0.33",
|
|
49
|
-
"@unocss/eslint-plugin": "^65.4.2",
|
|
50
|
-
bumpp: "^9.10.1",
|
|
51
|
-
eslint: "^9.18.0",
|
|
52
|
-
"eslint-plugin-react-compiler": "19.0.0-beta-decd7b8-20250118",
|
|
53
|
-
"eslint-plugin-react-hooks": "^5.1.0",
|
|
54
|
-
"eslint-plugin-react-refresh": "^0.4.18",
|
|
55
|
-
"eslint-plugin-svelte": "^2.46.1",
|
|
56
|
-
"eslint-plugin-tailwindcss": "^3.18.0",
|
|
57
|
-
jiti: "^2.4.2",
|
|
58
|
-
"nano-staged": "^0.8.0",
|
|
59
|
-
"simple-git-hooks": "^2.11.1",
|
|
60
|
-
svelte: "^5.19.0",
|
|
61
|
-
"svelte-eslint-parser": "^0.43.0",
|
|
62
|
-
tsup: "^8.3.5",
|
|
63
|
-
typescript: "^5.7.3"
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// src/cli/constants.ts
|
|
67
|
-
var ARROW = import_picocolors.default.cyan("\u2192");
|
|
68
|
-
var CHECK = import_picocolors.default.green("\u2714");
|
|
69
|
-
var CROSS = import_picocolors.default.red("\u2718");
|
|
70
|
-
var WARN = import_picocolors.default.yellow("\u2139");
|
|
71
|
-
var eslintVersion = devDependencies.eslint;
|
|
72
|
-
var vscodeSettingsString = `
|
|
73
|
-
"editor.formatOnSave": true,
|
|
74
|
-
|
|
75
|
-
// Auto fix
|
|
76
|
-
"editor.codeActionsOnSave": {
|
|
77
|
-
"source.fixAll.eslint": "explicit",
|
|
78
|
-
"source.organizeImports": "never"
|
|
79
|
-
},
|
|
80
|
-
`;
|
|
81
|
-
|
|
82
|
-
// src/cli/run.ts
|
|
83
|
-
var import_node_fs = __toESM(require("fs"), 1);
|
|
84
|
-
var import_promises = __toESM(require("fs/promises"), 1);
|
|
85
|
-
var import_node_path = __toESM(require("path"), 1);
|
|
86
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
87
|
-
var import_parse_gitignore = __toESM(require("parse-gitignore"), 1);
|
|
88
|
-
var import_picocolors2 = __toESM(require("picocolors"), 1);
|
|
89
|
-
var import_prompts = __toESM(require("prompts"), 1);
|
|
90
|
-
|
|
91
|
-
// src/cli/utils.ts
|
|
92
|
-
var import_node_child_process = require("child_process");
|
|
93
|
-
function isGitClean() {
|
|
94
|
-
try {
|
|
95
|
-
(0, import_node_child_process.execSync)("git diff-index --quiet HEAD --");
|
|
96
|
-
return true;
|
|
97
|
-
} catch {
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// src/cli/run.ts
|
|
103
|
-
async function run(options = {}) {
|
|
104
|
-
const SKIP_PROMPT = !!import_node_process.default.env.SKIP_PROMPT || options.yes;
|
|
105
|
-
const SKIP_GIT_CHECK = !!import_node_process.default.env.SKIP_GIT_CHECK;
|
|
106
|
-
const cwd = import_node_process.default.cwd();
|
|
107
|
-
const pathFlatConfig = import_node_path.default.join(cwd, "eslint.config.js");
|
|
108
|
-
const pathPackageJSON = import_node_path.default.join(cwd, "package.json");
|
|
109
|
-
const pathESLintIngore = import_node_path.default.join(cwd, ".eslintignore");
|
|
110
|
-
if (import_node_fs.default.existsSync(pathFlatConfig)) {
|
|
111
|
-
console.log(
|
|
112
|
-
import_picocolors2.default.yellow(
|
|
113
|
-
`${WARN} eslint.config.js already exists, migration wizard exited.`
|
|
114
|
-
)
|
|
115
|
-
);
|
|
116
|
-
return import_node_process.default.exit(1);
|
|
117
|
-
}
|
|
118
|
-
if (!SKIP_GIT_CHECK && !isGitClean()) {
|
|
119
|
-
const { confirmed } = await (0, import_prompts.default)({
|
|
120
|
-
initial: false,
|
|
121
|
-
message: "There are uncommitted changes in the current repository, are you sure to continue?",
|
|
122
|
-
name: "confirmed",
|
|
123
|
-
type: "confirm"
|
|
124
|
-
});
|
|
125
|
-
if (!confirmed) return import_node_process.default.exit(1);
|
|
126
|
-
}
|
|
127
|
-
console.log(import_picocolors2.default.cyan(`${ARROW} bumping @coderwyd/eslint-config to v${version}`));
|
|
128
|
-
const pkgContent = await import_promises.default.readFile(pathPackageJSON, "utf-8");
|
|
129
|
-
const pkg = JSON.parse(pkgContent);
|
|
130
|
-
pkg.devDependencies ??= {};
|
|
131
|
-
pkg.devDependencies["@coderwyd/eslint-config"] = `^${version}`;
|
|
132
|
-
if (!pkg.devDependencies.eslint) pkg.devDependencies.eslint = eslintVersion;
|
|
133
|
-
await import_promises.default.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
134
|
-
console.log(import_picocolors2.default.green(`${CHECK} changes wrote to package.json`));
|
|
135
|
-
const eslintIgnores = [];
|
|
136
|
-
if (import_node_fs.default.existsSync(pathESLintIngore)) {
|
|
137
|
-
console.log(import_picocolors2.default.cyan(`${ARROW} migrating existing .eslintignore`));
|
|
138
|
-
const content = await import_promises.default.readFile(pathESLintIngore, "utf-8");
|
|
139
|
-
const parsed = (0, import_parse_gitignore.default)(content);
|
|
140
|
-
const globs = parsed.globs();
|
|
141
|
-
for (const glob of globs) {
|
|
142
|
-
if (glob.type === "ignore") {
|
|
143
|
-
eslintIgnores.push(...glob.patterns);
|
|
144
|
-
} else if (glob.type === "unignore") {
|
|
145
|
-
eslintIgnores.push(
|
|
146
|
-
...glob.patterns.map((pattern) => `!${pattern}`)
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
let eslintConfigContent = "";
|
|
152
|
-
const coderwydConfig = `${eslintIgnores.length > 0 ? `ignores: ${JSON.stringify(eslintIgnores)}` : ""}`;
|
|
153
|
-
if (pkg.type === "module") {
|
|
154
|
-
eslintConfigContent = `
|
|
155
|
-
import { defineConfig } from '@coderwyd/eslint-config'
|
|
156
|
-
|
|
157
|
-
export default defineConfig({
|
|
158
|
-
${coderwydConfig}
|
|
159
|
-
})
|
|
160
|
-
`.trimStart();
|
|
161
|
-
} else {
|
|
162
|
-
eslintConfigContent = `
|
|
163
|
-
const { defineConfig } = require('@coderwyd/eslint-config')
|
|
164
|
-
|
|
165
|
-
module.exports = defineConfig({
|
|
166
|
-
${coderwydConfig}
|
|
167
|
-
})
|
|
168
|
-
`.trimStart();
|
|
169
|
-
}
|
|
170
|
-
await import_promises.default.writeFile(pathFlatConfig, eslintConfigContent);
|
|
171
|
-
console.log(import_picocolors2.default.green(`${CHECK} created eslint.config.js`));
|
|
172
|
-
const files = import_node_fs.default.readdirSync(cwd);
|
|
173
|
-
const legacyConfig = [];
|
|
174
|
-
files.forEach((file) => {
|
|
175
|
-
if (/eslint|prettier/.test(file) && !/eslint.config./.test(file))
|
|
176
|
-
legacyConfig.push(file);
|
|
177
|
-
});
|
|
178
|
-
if (legacyConfig.length > 0) {
|
|
179
|
-
console.log(`${WARN} you can now remove those files manually:`);
|
|
180
|
-
console.log(` ${import_picocolors2.default.dim(legacyConfig.join(", "))}`);
|
|
181
|
-
}
|
|
182
|
-
let promptResult = {
|
|
183
|
-
updateVscodeSettings: true
|
|
184
|
-
};
|
|
185
|
-
if (!SKIP_PROMPT) {
|
|
186
|
-
try {
|
|
187
|
-
promptResult = await (0, import_prompts.default)(
|
|
188
|
-
{
|
|
189
|
-
initial: true,
|
|
190
|
-
message: "Update .vscode/settings.json for better VS Code experience?",
|
|
191
|
-
name: "updateVscodeSettings",
|
|
192
|
-
type: "confirm"
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
onCancel: () => {
|
|
196
|
-
throw new Error(`Cancelled`);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
);
|
|
200
|
-
} catch (error) {
|
|
201
|
-
console.log(error.message);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (promptResult?.updateVscodeSettings ?? true) {
|
|
206
|
-
const dotVscodePath = import_node_path.default.join(cwd, ".vscode");
|
|
207
|
-
const settingsPath = import_node_path.default.join(dotVscodePath, "settings.json");
|
|
208
|
-
if (!import_node_fs.default.existsSync(dotVscodePath))
|
|
209
|
-
await import_promises.default.mkdir(dotVscodePath, { recursive: true });
|
|
210
|
-
if (!import_node_fs.default.existsSync(settingsPath)) {
|
|
211
|
-
await import_promises.default.writeFile(settingsPath, `{${vscodeSettingsString}}
|
|
212
|
-
`, "utf-8");
|
|
213
|
-
console.log(import_picocolors2.default.green(`${CHECK} created .vscode/settings.json`));
|
|
214
|
-
} else {
|
|
215
|
-
let settingsContent = await import_promises.default.readFile(settingsPath, "utf8");
|
|
216
|
-
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
217
|
-
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
218
|
-
settingsContent += `${vscodeSettingsString}}
|
|
219
|
-
`;
|
|
220
|
-
await import_promises.default.writeFile(settingsPath, settingsContent, "utf-8");
|
|
221
|
-
console.log(import_picocolors2.default.green(`${CHECK} updated .vscode/settings.json`));
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
console.log(import_picocolors2.default.green(`${CHECK} migration completed`));
|
|
225
|
-
console.log(
|
|
226
|
-
`Now you can update the dependencies and run ${import_picocolors2.default.blue("eslint . --fix")}
|
|
227
|
-
`
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// src/cli/index.ts
|
|
232
|
-
function header() {
|
|
233
|
-
console.log(`
|
|
234
|
-
${import_picocolors3.default.green(`@coderwyd/eslint-config `)}${import_picocolors3.default.dim(`v${version}`)}`);
|
|
235
|
-
}
|
|
236
|
-
var instance = (0, import_yargs.default)((0, import_helpers.hideBin)(import_node_process2.default.argv)).scriptName("@coderwyd/eslint-config").usage("").command(
|
|
237
|
-
"*",
|
|
238
|
-
"Run the initialization or migration",
|
|
239
|
-
(args) => args.option("yes", {
|
|
240
|
-
alias: "y",
|
|
241
|
-
description: "Skip prompts and use default values",
|
|
242
|
-
type: "boolean"
|
|
243
|
-
}).help(),
|
|
244
|
-
async (args) => {
|
|
245
|
-
header();
|
|
246
|
-
console.log();
|
|
247
|
-
try {
|
|
248
|
-
await run(args);
|
|
249
|
-
} catch (error) {
|
|
250
|
-
console.error(import_picocolors3.default.inverse(import_picocolors3.default.red(" Failed to migrate ")));
|
|
251
|
-
console.error(import_picocolors3.default.red(`${CROSS} ${String(error)}`));
|
|
252
|
-
import_node_process2.default.exit(1);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
).showHelpOnFail(false).alias("h", "help").version("version", version).alias("v", "version");
|
|
256
|
-
instance.help().argv;
|
package/dist/cli.d.cts
DELETED