@solvro/config 1.0.2 → 1.0.3
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/bin/index.js +2 -0
- package/dist/chunk-4C4AR77R.js +65 -0
- package/dist/chunk-SND5ODI2.js +20878 -0
- package/dist/dist-2ZVVVZXY.js +35994 -0
- package/dist/eslint-config/cli.cjs +532 -0
- package/dist/eslint-config/cli.d.cts +2 -0
- package/dist/eslint-config/cli.d.ts +2 -0
- package/dist/eslint-config/cli.js +498 -0
- package/dist/eslint-config/index.cjs +73016 -0
- package/dist/eslint-config/index.d.cts +9489 -0
- package/dist/eslint-config/index.d.ts +9489 -0
- package/dist/eslint-config/index.js +15604 -0
- package/dist/eslint-plugin-react-refresh-MJ7ZDK5R.js +258 -0
- package/dist/prettier-config/index.cjs +47 -0
- package/dist/prettier-config/index.d.cts +17 -0
- package/dist/prettier-config/index.d.ts +17 -0
- package/{prettier → dist/prettier-config}/index.js +21 -19
- package/package.json +69 -33
- package/eslint/_base.js +0 -39
- package/eslint/browser.js +0 -6
- package/eslint/comments.js +0 -6
- package/eslint/constants.js +0 -4
- package/eslint/jest-react.js +0 -9
- package/eslint/jest.js +0 -16
- package/eslint/next.js +0 -18
- package/eslint/node.js +0 -6
- package/eslint/playwright-test.js +0 -7
- package/eslint/react.js +0 -16
- package/eslint/rules/best-practice.js +0 -227
- package/eslint/rules/es6.js +0 -65
- package/eslint/rules/import.js +0 -58
- package/eslint/rules/jest.js +0 -16
- package/eslint/rules/jsx-a11y.js +0 -14
- package/eslint/rules/playwright-test.js +0 -46
- package/eslint/rules/possible-errors.js +0 -35
- package/eslint/rules/react.js +0 -97
- package/eslint/rules/stylistic.js +0 -74
- package/eslint/rules/tsdoc.js +0 -11
- package/eslint/rules/typescript/extension.js +0 -38
- package/eslint/rules/typescript/import.js +0 -16
- package/eslint/rules/typescript/index.js +0 -93
- package/eslint/rules/unicorn.js +0 -22
- package/eslint/rules/variables.js +0 -30
- package/eslint/rules/vitest.js +0 -16
- package/eslint/typescript.js +0 -23
- package/eslint/utils/require-package.js +0 -36
- package/eslint/vitest.js +0 -3
- package/typescript/tsconfig.base.json +0 -13
- package/typescript/tsconfig.node16.json +0 -12
- package/typescript/tsconfig.node18.json +0 -12
- package/typescript/tsconfig.node20.json +0 -12
@@ -0,0 +1,498 @@
|
|
1
|
+
import {
|
2
|
+
__commonJS,
|
3
|
+
__toESM,
|
4
|
+
init_esm_shims
|
5
|
+
} from "../chunk-4C4AR77R.js";
|
6
|
+
|
7
|
+
// node_modules/picocolors/picocolors.js
|
8
|
+
var require_picocolors = __commonJS({
|
9
|
+
"node_modules/picocolors/picocolors.js"(exports, module) {
|
10
|
+
"use strict";
|
11
|
+
init_esm_shims();
|
12
|
+
var p6 = process || {};
|
13
|
+
var argv = p6.argv || [];
|
14
|
+
var env = p6.env || {};
|
15
|
+
var isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p6.platform === "win32" || (p6.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI);
|
16
|
+
var formatter = (open, close, replace = open) => (input) => {
|
17
|
+
let string = "" + input, index = string.indexOf(close, open.length);
|
18
|
+
return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
|
19
|
+
};
|
20
|
+
var replaceClose = (string, close, replace, index) => {
|
21
|
+
let result = "", cursor = 0;
|
22
|
+
do {
|
23
|
+
result += string.substring(cursor, index) + replace;
|
24
|
+
cursor = index + close.length;
|
25
|
+
index = string.indexOf(close, cursor);
|
26
|
+
} while (~index);
|
27
|
+
return result + string.substring(cursor);
|
28
|
+
};
|
29
|
+
var createColors = (enabled = isColorSupported) => {
|
30
|
+
let f = enabled ? formatter : () => String;
|
31
|
+
return {
|
32
|
+
isColorSupported: enabled,
|
33
|
+
reset: f("\x1B[0m", "\x1B[0m"),
|
34
|
+
bold: f("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
|
35
|
+
dim: f("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
|
36
|
+
italic: f("\x1B[3m", "\x1B[23m"),
|
37
|
+
underline: f("\x1B[4m", "\x1B[24m"),
|
38
|
+
inverse: f("\x1B[7m", "\x1B[27m"),
|
39
|
+
hidden: f("\x1B[8m", "\x1B[28m"),
|
40
|
+
strikethrough: f("\x1B[9m", "\x1B[29m"),
|
41
|
+
black: f("\x1B[30m", "\x1B[39m"),
|
42
|
+
red: f("\x1B[31m", "\x1B[39m"),
|
43
|
+
green: f("\x1B[32m", "\x1B[39m"),
|
44
|
+
yellow: f("\x1B[33m", "\x1B[39m"),
|
45
|
+
blue: f("\x1B[34m", "\x1B[39m"),
|
46
|
+
magenta: f("\x1B[35m", "\x1B[39m"),
|
47
|
+
cyan: f("\x1B[36m", "\x1B[39m"),
|
48
|
+
white: f("\x1B[37m", "\x1B[39m"),
|
49
|
+
gray: f("\x1B[90m", "\x1B[39m"),
|
50
|
+
bgBlack: f("\x1B[40m", "\x1B[49m"),
|
51
|
+
bgRed: f("\x1B[41m", "\x1B[49m"),
|
52
|
+
bgGreen: f("\x1B[42m", "\x1B[49m"),
|
53
|
+
bgYellow: f("\x1B[43m", "\x1B[49m"),
|
54
|
+
bgBlue: f("\x1B[44m", "\x1B[49m"),
|
55
|
+
bgMagenta: f("\x1B[45m", "\x1B[49m"),
|
56
|
+
bgCyan: f("\x1B[46m", "\x1B[49m"),
|
57
|
+
bgWhite: f("\x1B[47m", "\x1B[49m"),
|
58
|
+
blackBright: f("\x1B[90m", "\x1B[39m"),
|
59
|
+
redBright: f("\x1B[91m", "\x1B[39m"),
|
60
|
+
greenBright: f("\x1B[92m", "\x1B[39m"),
|
61
|
+
yellowBright: f("\x1B[93m", "\x1B[39m"),
|
62
|
+
blueBright: f("\x1B[94m", "\x1B[39m"),
|
63
|
+
magentaBright: f("\x1B[95m", "\x1B[39m"),
|
64
|
+
cyanBright: f("\x1B[96m", "\x1B[39m"),
|
65
|
+
whiteBright: f("\x1B[97m", "\x1B[39m"),
|
66
|
+
bgBlackBright: f("\x1B[100m", "\x1B[49m"),
|
67
|
+
bgRedBright: f("\x1B[101m", "\x1B[49m"),
|
68
|
+
bgGreenBright: f("\x1B[102m", "\x1B[49m"),
|
69
|
+
bgYellowBright: f("\x1B[103m", "\x1B[49m"),
|
70
|
+
bgBlueBright: f("\x1B[104m", "\x1B[49m"),
|
71
|
+
bgMagentaBright: f("\x1B[105m", "\x1B[49m"),
|
72
|
+
bgCyanBright: f("\x1B[106m", "\x1B[49m"),
|
73
|
+
bgWhiteBright: f("\x1B[107m", "\x1B[49m")
|
74
|
+
};
|
75
|
+
};
|
76
|
+
module.exports = createColors();
|
77
|
+
module.exports.createColors = createColors;
|
78
|
+
}
|
79
|
+
});
|
80
|
+
|
81
|
+
// eslint-config/cli.ts
|
82
|
+
init_esm_shims();
|
83
|
+
|
84
|
+
// eslint-config/cli/index.ts
|
85
|
+
init_esm_shims();
|
86
|
+
var import_picocolors6 = __toESM(require_picocolors(), 1);
|
87
|
+
import * as p5 from "@clack/prompts";
|
88
|
+
import process6 from "node:process";
|
89
|
+
import yargs from "yargs";
|
90
|
+
import { hideBin } from "yargs/helpers";
|
91
|
+
|
92
|
+
// eslint-config/cli/constants.ts
|
93
|
+
init_esm_shims();
|
94
|
+
var import_picocolors = __toESM(require_picocolors(), 1);
|
95
|
+
|
96
|
+
// package.json
|
97
|
+
var package_default = {
|
98
|
+
name: "@solvro/config",
|
99
|
+
version: "1.0.2",
|
100
|
+
description: "Solvro's engineering style guide",
|
101
|
+
keywords: [
|
102
|
+
"eslint-config"
|
103
|
+
],
|
104
|
+
homepage: "https://github.com/Solvro/lib-web-solvro-config#readme",
|
105
|
+
bugs: {
|
106
|
+
url: "https://github.com/Solvro/lib-web-solvro-config/issues"
|
107
|
+
},
|
108
|
+
repository: {
|
109
|
+
type: "git",
|
110
|
+
url: "https://github.com/Solvro/lib-web-solvro-config.git"
|
111
|
+
},
|
112
|
+
license: "MPL-2.0",
|
113
|
+
type: "module",
|
114
|
+
exports: {
|
115
|
+
".": {
|
116
|
+
import: "./dist/index.js",
|
117
|
+
require: "./dist/index.cjs"
|
118
|
+
}
|
119
|
+
},
|
120
|
+
main: "./dist/index.js",
|
121
|
+
types: "./dist/index.d.ts",
|
122
|
+
bin: "./bin/index.js",
|
123
|
+
files: [
|
124
|
+
"bin",
|
125
|
+
"dist"
|
126
|
+
],
|
127
|
+
scripts: {
|
128
|
+
build: "npm run typegen && tsup --format esm,cjs --clean --dts",
|
129
|
+
dev: "npx @eslint/config-inspector --config eslint.config.ts",
|
130
|
+
format: "prettier --check .",
|
131
|
+
lint: "eslint --flag unstable_ts_config .",
|
132
|
+
prepare: "husky",
|
133
|
+
prepublish: "npm run build",
|
134
|
+
release: "semantic-release",
|
135
|
+
test: 'echo "Error: no test specified" && exit 1',
|
136
|
+
typecheck: "tsc --noEmit",
|
137
|
+
typegen: "tsx ./scripts/typegen.ts"
|
138
|
+
},
|
139
|
+
"lint-staged": {
|
140
|
+
"*": "prettier -w --ignore-unknown"
|
141
|
+
},
|
142
|
+
prettier: "./dist/prettier-config/index.js",
|
143
|
+
dependencies: {
|
144
|
+
"@antfu/install-pkg": "^0.5.0",
|
145
|
+
"@clack/prompts": "^0.8.2",
|
146
|
+
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.1",
|
147
|
+
"@eslint/markdown": "^6.2.1",
|
148
|
+
"@rushstack/eslint-patch": "^1.10.4",
|
149
|
+
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
|
150
|
+
"@typescript-eslint/eslint-plugin": "^8.16.0",
|
151
|
+
"@typescript-eslint/parser": "^8.16.0",
|
152
|
+
"@vitest/eslint-plugin": "^1.1.12",
|
153
|
+
"eslint-config-flat-gitignore": "^0.3.0",
|
154
|
+
"eslint-config-prettier": "^9.1.0",
|
155
|
+
"eslint-flat-config-utils": "^0.4.0",
|
156
|
+
"eslint-import-resolver-alias": "^1.1.2",
|
157
|
+
"eslint-import-resolver-typescript": "^3.6.3",
|
158
|
+
"eslint-merge-processors": "^0.1.0",
|
159
|
+
"eslint-plugin-antfu": "^2.7.0",
|
160
|
+
"eslint-plugin-command": "^0.2.6",
|
161
|
+
"eslint-plugin-import": "^2.31.0",
|
162
|
+
"eslint-plugin-jest": "^28.9.0",
|
163
|
+
"eslint-plugin-jsdoc": "^50.6.0",
|
164
|
+
"eslint-plugin-jsx-a11y": "^6.10.2",
|
165
|
+
"eslint-plugin-n": "^17.14.0",
|
166
|
+
"eslint-plugin-no-only-tests": "^3.3.0",
|
167
|
+
"eslint-plugin-perfectionist": "^4.1.2",
|
168
|
+
"eslint-plugin-playwright": "^2.1.0",
|
169
|
+
"eslint-plugin-react": "^7.37.2",
|
170
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
171
|
+
"eslint-plugin-regexp": "^2.7.0",
|
172
|
+
"eslint-plugin-testing-library": "^7.0.0",
|
173
|
+
"eslint-plugin-tsdoc": "^0.4.0",
|
174
|
+
"eslint-plugin-unicorn": "^56.0.1",
|
175
|
+
"eslint-plugin-unused-imports": "^4.1.4",
|
176
|
+
globals: "^15.12.0",
|
177
|
+
"parse-gitignore": "^2.0.0",
|
178
|
+
"prettier-plugin-packagejson": "^2.5.6",
|
179
|
+
"prettier-plugin-tailwindcss": "^0.6.9",
|
180
|
+
yargs: "^17.7.2"
|
181
|
+
},
|
182
|
+
devDependencies: {
|
183
|
+
"@commitlint/cli": "^19.6.0",
|
184
|
+
"@commitlint/config-conventional": "^19.6.0",
|
185
|
+
"@eslint-react/eslint-plugin": "^1.17.1",
|
186
|
+
"@eslint/config-inspector": "^0.5.6",
|
187
|
+
"@semantic-release/git": "^10.0.1",
|
188
|
+
"@types/yargs": "^17.0.33",
|
189
|
+
eslint: "^9.15.0",
|
190
|
+
"eslint-plugin-format": "^0.1.2",
|
191
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
192
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
193
|
+
"eslint-typegen": "^0.3.2",
|
194
|
+
husky: "^9.1.7",
|
195
|
+
jiti: "^2.4.1",
|
196
|
+
"lint-staged": "^15.2.10",
|
197
|
+
prettier: "^3.4.1",
|
198
|
+
"semantic-release": "^24.2.0",
|
199
|
+
tsup: "^8.3.5",
|
200
|
+
tsx: "^4.19.2",
|
201
|
+
typescript: "^5.7.2"
|
202
|
+
},
|
203
|
+
peerDependencies: {
|
204
|
+
"@next/eslint-plugin-next": ">=12.3.0 <16.0.0-0",
|
205
|
+
eslint: ">=9.0.0 <10",
|
206
|
+
prettier: ">=3.0.0 <4",
|
207
|
+
typescript: ">=4.8.0 <6"
|
208
|
+
},
|
209
|
+
peerDependenciesMeta: {
|
210
|
+
"@eslint-react/eslint-plugin": {
|
211
|
+
optional: true
|
212
|
+
},
|
213
|
+
"@unocss/eslint-plugin": {
|
214
|
+
optional: true
|
215
|
+
},
|
216
|
+
"eslint-plugin-react-hooks": {
|
217
|
+
optional: true
|
218
|
+
},
|
219
|
+
"eslint-plugin-react-refresh": {
|
220
|
+
optional: true
|
221
|
+
}
|
222
|
+
},
|
223
|
+
packageManager: "npm@10.9.1",
|
224
|
+
engines: {
|
225
|
+
node: ">=20"
|
226
|
+
},
|
227
|
+
publishConfig: {
|
228
|
+
access: "public"
|
229
|
+
}
|
230
|
+
};
|
231
|
+
|
232
|
+
// eslint-config/cli/constants.ts
|
233
|
+
var vscodeSettingsString = `
|
234
|
+
"prettier.enable": true,
|
235
|
+
"editor.formatOnSave": true,
|
236
|
+
`;
|
237
|
+
var frameworkOptions = [
|
238
|
+
{
|
239
|
+
label: import_picocolors.default.cyan("React"),
|
240
|
+
value: "react"
|
241
|
+
}
|
242
|
+
];
|
243
|
+
var frameworks = frameworkOptions.map(
|
244
|
+
({ value }) => value
|
245
|
+
);
|
246
|
+
var dependenciesMap = {
|
247
|
+
react: [
|
248
|
+
"@eslint-react/eslint-plugin",
|
249
|
+
"eslint-plugin-react-hooks",
|
250
|
+
"eslint-plugin-react-refresh"
|
251
|
+
]
|
252
|
+
};
|
253
|
+
|
254
|
+
// eslint-config/cli/run.ts
|
255
|
+
init_esm_shims();
|
256
|
+
var import_picocolors5 = __toESM(require_picocolors(), 1);
|
257
|
+
import * as p4 from "@clack/prompts";
|
258
|
+
import fs3 from "node:fs";
|
259
|
+
import path4 from "node:path";
|
260
|
+
import process5 from "node:process";
|
261
|
+
|
262
|
+
// eslint-config/cli/stages/update-eslint-files.ts
|
263
|
+
init_esm_shims();
|
264
|
+
var import_picocolors2 = __toESM(require_picocolors(), 1);
|
265
|
+
import * as p from "@clack/prompts";
|
266
|
+
import fs from "node:fs";
|
267
|
+
import fsp from "node:fs/promises";
|
268
|
+
import path from "node:path";
|
269
|
+
import process2 from "node:process";
|
270
|
+
import parse from "parse-gitignore";
|
271
|
+
|
272
|
+
// eslint-config/cli/utils.ts
|
273
|
+
init_esm_shims();
|
274
|
+
import { execSync } from "node:child_process";
|
275
|
+
function isGitClean() {
|
276
|
+
try {
|
277
|
+
execSync("git diff-index --quiet HEAD --");
|
278
|
+
return true;
|
279
|
+
} catch {
|
280
|
+
return false;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
function getEslintConfigContent(mainConfig, additionalConfigs) {
|
284
|
+
return `
|
285
|
+
import solvro from '@solvro/config'
|
286
|
+
|
287
|
+
export default solvro({
|
288
|
+
${mainConfig}
|
289
|
+
}${additionalConfigs?.map((config) => `,{
|
290
|
+
${config}
|
291
|
+
}`)})
|
292
|
+
`.trimStart();
|
293
|
+
}
|
294
|
+
|
295
|
+
// eslint-config/cli/stages/update-eslint-files.ts
|
296
|
+
async function updateEslintFiles(result) {
|
297
|
+
const cwd = process2.cwd();
|
298
|
+
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
299
|
+
const pathPackageJSON = path.join(cwd, "package.json");
|
300
|
+
const pkgContent = await fsp.readFile(pathPackageJSON, "utf-8");
|
301
|
+
const pkg = JSON.parse(pkgContent);
|
302
|
+
const configFileName = pkg.type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
303
|
+
const pathFlatConfig = path.join(cwd, configFileName);
|
304
|
+
const eslintIgnores = [];
|
305
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
306
|
+
p.log.step(import_picocolors2.default.cyan(`Migrating existing .eslintignore`));
|
307
|
+
const content = await fsp.readFile(pathESLintIgnore, "utf-8");
|
308
|
+
const parsed = parse(content);
|
309
|
+
const globs = parsed.globs();
|
310
|
+
for (const glob of globs) {
|
311
|
+
if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
312
|
+
else if (glob.type === "unignore")
|
313
|
+
eslintIgnores.push(
|
314
|
+
...glob.patterns.map((pattern) => `!${pattern}`)
|
315
|
+
);
|
316
|
+
}
|
317
|
+
}
|
318
|
+
const configLines = [];
|
319
|
+
if (eslintIgnores.length)
|
320
|
+
configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
|
321
|
+
for (const framework of result.frameworks)
|
322
|
+
configLines.push(`${framework}: true,`);
|
323
|
+
const mainConfig = configLines.map((i) => ` ${i}`).join("\n");
|
324
|
+
const additionalConfig = [];
|
325
|
+
const eslintConfigContent = getEslintConfigContent(
|
326
|
+
mainConfig,
|
327
|
+
additionalConfig
|
328
|
+
);
|
329
|
+
await fsp.writeFile(pathFlatConfig, eslintConfigContent);
|
330
|
+
p.log.success(import_picocolors2.default.green(`Created ${configFileName}`));
|
331
|
+
const files = fs.readdirSync(cwd);
|
332
|
+
const legacyConfig = [];
|
333
|
+
files.forEach((file) => {
|
334
|
+
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file))
|
335
|
+
legacyConfig.push(file);
|
336
|
+
});
|
337
|
+
if (legacyConfig.length)
|
338
|
+
p.note(
|
339
|
+
`${import_picocolors2.default.dim(legacyConfig.join(", "))}`,
|
340
|
+
"You can now remove those files manually"
|
341
|
+
);
|
342
|
+
}
|
343
|
+
|
344
|
+
// eslint-config/cli/stages/update-package-json.ts
|
345
|
+
init_esm_shims();
|
346
|
+
var import_picocolors3 = __toESM(require_picocolors(), 1);
|
347
|
+
import * as p2 from "@clack/prompts";
|
348
|
+
import fsp2 from "node:fs/promises";
|
349
|
+
import path2 from "node:path";
|
350
|
+
import process3 from "node:process";
|
351
|
+
async function updatePackageJson(result) {
|
352
|
+
const cwd = process3.cwd();
|
353
|
+
const pathPackageJSON = path2.join(cwd, "package.json");
|
354
|
+
p2.log.step(import_picocolors3.default.cyan(`Bumping @solvro/config to v${package_default.version}`));
|
355
|
+
const pkgContent = await fsp2.readFile(pathPackageJSON, "utf-8");
|
356
|
+
const pkg = JSON.parse(pkgContent);
|
357
|
+
pkg.devDependencies ??= {};
|
358
|
+
pkg.devDependencies["@solvro/config"] = `^${package_default.version}`;
|
359
|
+
pkg.devDependencies.eslint ??= package_default.devDependencies.eslint.replace("npm:eslint-ts-patch@", "").replace(/-\d+$/, "");
|
360
|
+
const addedPackages = [];
|
361
|
+
for (const framework of result.frameworks) {
|
362
|
+
const deps = dependenciesMap[framework];
|
363
|
+
if (deps) {
|
364
|
+
deps.forEach((f) => {
|
365
|
+
pkg.devDependencies[f] = package_default.devDependencies[f];
|
366
|
+
addedPackages.push(f);
|
367
|
+
});
|
368
|
+
}
|
369
|
+
}
|
370
|
+
if (addedPackages.length)
|
371
|
+
p2.note(`${import_picocolors3.default.dim(addedPackages.join(", "))}`, "Added packages");
|
372
|
+
await fsp2.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
373
|
+
p2.log.success(import_picocolors3.default.green(`Changes wrote to package.json`));
|
374
|
+
}
|
375
|
+
|
376
|
+
// eslint-config/cli/stages/update-vscode-settings.ts
|
377
|
+
init_esm_shims();
|
378
|
+
var import_picocolors4 = __toESM(require_picocolors(), 1);
|
379
|
+
import * as p3 from "@clack/prompts";
|
380
|
+
import fs2 from "node:fs";
|
381
|
+
import fsp3 from "node:fs/promises";
|
382
|
+
import path3 from "node:path";
|
383
|
+
import process4 from "node:process";
|
384
|
+
async function updateVscodeSettings(result) {
|
385
|
+
const cwd = process4.cwd();
|
386
|
+
if (!result.updateVscodeSettings) return;
|
387
|
+
const dotVscodePath = path3.join(cwd, ".vscode");
|
388
|
+
const settingsPath = path3.join(dotVscodePath, "settings.json");
|
389
|
+
if (!fs2.existsSync(dotVscodePath))
|
390
|
+
await fsp3.mkdir(dotVscodePath, { recursive: true });
|
391
|
+
if (!fs2.existsSync(settingsPath)) {
|
392
|
+
await fsp3.writeFile(settingsPath, `{${vscodeSettingsString}}
|
393
|
+
`, "utf-8");
|
394
|
+
p3.log.success(import_picocolors4.default.green(`Created .vscode/settings.json`));
|
395
|
+
} else {
|
396
|
+
let settingsContent = await fsp3.readFile(settingsPath, "utf8");
|
397
|
+
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
398
|
+
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
399
|
+
settingsContent += `${vscodeSettingsString}}
|
400
|
+
`;
|
401
|
+
await fsp3.writeFile(settingsPath, settingsContent, "utf-8");
|
402
|
+
p3.log.success(import_picocolors4.default.green(`Updated .vscode/settings.json`));
|
403
|
+
}
|
404
|
+
}
|
405
|
+
|
406
|
+
// eslint-config/cli/run.ts
|
407
|
+
async function run(options = {}) {
|
408
|
+
const argSkipPrompt = !!process5.env.SKIP_PROMPT || options.yes;
|
409
|
+
const argTemplate = options.frameworks?.map(
|
410
|
+
(m) => m.trim()
|
411
|
+
);
|
412
|
+
if (fs3.existsSync(path4.join(process5.cwd(), "eslint.config.js"))) {
|
413
|
+
p4.log.warn(
|
414
|
+
import_picocolors5.default.yellow(`eslint.config.js already exists, migration wizard exited.`)
|
415
|
+
);
|
416
|
+
return process5.exit(1);
|
417
|
+
}
|
418
|
+
let result = {
|
419
|
+
frameworks: argTemplate ?? [],
|
420
|
+
uncommittedConfirmed: false,
|
421
|
+
updateVscodeSettings: true
|
422
|
+
};
|
423
|
+
if (!argSkipPrompt) {
|
424
|
+
result = await p4.group(
|
425
|
+
{
|
426
|
+
uncommittedConfirmed: () => {
|
427
|
+
if (argSkipPrompt || isGitClean()) return Promise.resolve(true);
|
428
|
+
return p4.confirm({
|
429
|
+
initialValue: false,
|
430
|
+
message: "There are uncommitted changes in the current repository, are you sure to continue?"
|
431
|
+
});
|
432
|
+
},
|
433
|
+
frameworks: ({ results }) => {
|
434
|
+
const isArgTemplateValid = typeof argTemplate === "string" && !!frameworks.includes(argTemplate);
|
435
|
+
if (!results.uncommittedConfirmed || isArgTemplateValid) return;
|
436
|
+
const message = !isArgTemplateValid && argTemplate ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:";
|
437
|
+
return p4.multiselect({
|
438
|
+
message: import_picocolors5.default.reset(message),
|
439
|
+
options: frameworkOptions,
|
440
|
+
required: false
|
441
|
+
});
|
442
|
+
},
|
443
|
+
updateVscodeSettings: ({ results }) => {
|
444
|
+
if (!results.uncommittedConfirmed) return;
|
445
|
+
return p4.confirm({
|
446
|
+
initialValue: true,
|
447
|
+
message: "Update .vscode/settings.json for better VS Code experience?"
|
448
|
+
});
|
449
|
+
}
|
450
|
+
},
|
451
|
+
{
|
452
|
+
onCancel: () => {
|
453
|
+
p4.cancel("Operation cancelled.");
|
454
|
+
process5.exit(0);
|
455
|
+
}
|
456
|
+
}
|
457
|
+
);
|
458
|
+
if (!result.uncommittedConfirmed) return process5.exit(1);
|
459
|
+
}
|
460
|
+
await updatePackageJson(result);
|
461
|
+
await updateEslintFiles(result);
|
462
|
+
await updateVscodeSettings(result);
|
463
|
+
p4.log.success(import_picocolors5.default.green(`Setup completed`));
|
464
|
+
p4.outro(
|
465
|
+
`Now you can update the dependencies by run ${import_picocolors5.default.blue("pnpm install")} and run ${import_picocolors5.default.blue("eslint . --fix")}
|
466
|
+
`
|
467
|
+
);
|
468
|
+
}
|
469
|
+
|
470
|
+
// eslint-config/cli/index.ts
|
471
|
+
function header() {
|
472
|
+
console.log("\n");
|
473
|
+
p5.intro(`${import_picocolors6.default.green(`@solvro/config `)}${import_picocolors6.default.dim(`v${package_default.version}`)}`);
|
474
|
+
}
|
475
|
+
var instance = yargs(hideBin(process6.argv)).scriptName("@solvro/config").usage("").command(
|
476
|
+
"*",
|
477
|
+
"Run the initialization or migration",
|
478
|
+
(args) => args.option("yes", {
|
479
|
+
alias: "y",
|
480
|
+
description: "Skip prompts and use default values",
|
481
|
+
type: "boolean"
|
482
|
+
}).option("template", {
|
483
|
+
alias: "t",
|
484
|
+
description: "Use the framework template for optimal customization: react",
|
485
|
+
type: "string"
|
486
|
+
}).help(),
|
487
|
+
async (args) => {
|
488
|
+
header();
|
489
|
+
try {
|
490
|
+
await run(args);
|
491
|
+
} catch (error) {
|
492
|
+
p5.log.error(import_picocolors6.default.inverse(import_picocolors6.default.red(" Failed to migrate ")));
|
493
|
+
p5.log.error(import_picocolors6.default.red(`\u2718 ${String(error)}`));
|
494
|
+
process6.exit(1);
|
495
|
+
}
|
496
|
+
}
|
497
|
+
).showHelpOnFail(false).alias("h", "help").version("version", package_default.version).alias("v", "version");
|
498
|
+
instance.help().argv;
|