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