@oliver139/eslint-config 6.0.5 → 7.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/package.json CHANGED
@@ -1,233 +1,54 @@
1
1
  {
2
2
  "name": "@oliver139/eslint-config",
3
3
  "type": "module",
4
- "version": "6.0.5",
5
- "description": " Oliver's ESLint config preset powered by @antfu/eslint-config v8.2.0",
4
+ "version": "7.0.0",
5
+ "description": " Oliver's ESLint config preset powered by @antfu/eslint-config",
6
6
  "author": "Oliver Mak <oliver139.working@gmail.com> (https://github.com/oliver139)",
7
7
  "license": "MIT",
8
- "homepage": "https://oliver139.github.io/eslint-config-2/",
8
+ "homepage": "https://oliver139.github.io/eslint-config-3/",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/oliver139/eslint-config-2.git"
11
+ "url": "git+https://github.com/oliver139/eslint-config-3.git"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/oliver139/eslint-config-2/issues"
14
+ "url": "https://github.com/oliver139/eslint-config-3/issues"
15
15
  },
16
16
  "keywords": [
17
17
  "eslint-config"
18
18
  ],
19
19
  "exports": {
20
20
  ".": "./dist/index.mjs",
21
- "./cli": "./dist/cli.mjs",
22
21
  "./package.json": "./package.json"
23
22
  },
24
23
  "types": "./dist/index.d.mts",
25
- "bin": "./bin/index.mjs",
26
24
  "files": [
27
- "bin",
28
25
  "dist"
29
26
  ],
30
27
  "peerDependencies": {
31
- "@angular-eslint/eslint-plugin": "^21.1.0",
32
- "@angular-eslint/eslint-plugin-template": "^21.1.0",
33
- "@angular-eslint/template-parser": "^21.1.0",
34
- "@eslint-react/eslint-plugin": "^3.0.0",
35
- "@next/eslint-plugin-next": ">=15.0.0",
36
- "@prettier/plugin-xml": "^3.4.1",
37
- "@unocss/eslint-plugin": ">=0.50.0",
38
- "astro-eslint-parser": "^1.0.2",
39
- "eslint": "^9.10.0 || ^10.0.0",
40
- "eslint-plugin-astro": "^1.2.0",
41
- "eslint-plugin-format": ">=0.1.0",
42
- "eslint-plugin-jsx-a11y": ">=6.10.2",
43
- "eslint-plugin-react-refresh": "^0.5.0",
44
- "eslint-plugin-solid": "^0.14.3",
45
- "eslint-plugin-svelte": ">=2.35.1",
46
- "eslint-plugin-vuejs-accessibility": "^2.4.1",
47
- "prettier-plugin-astro": "^0.14.0",
48
- "prettier-plugin-slidev": "^1.0.5",
49
- "svelte-eslint-parser": ">=0.37.0"
50
- },
51
- "peerDependenciesMeta": {
52
- "@angular-eslint/eslint-plugin": {
53
- "optional": true
54
- },
55
- "@angular-eslint/eslint-plugin-template": {
56
- "optional": true
57
- },
58
- "@angular-eslint/template-parser": {
59
- "optional": true
60
- },
61
- "@eslint-react/eslint-plugin": {
62
- "optional": true
63
- },
64
- "@next/eslint-plugin-next": {
65
- "optional": true
66
- },
67
- "@prettier/plugin-xml": {
68
- "optional": true
69
- },
70
- "@unocss/eslint-plugin": {
71
- "optional": true
72
- },
73
- "astro-eslint-parser": {
74
- "optional": true
75
- },
76
- "eslint-plugin-astro": {
77
- "optional": true
78
- },
79
- "eslint-plugin-format": {
80
- "optional": true
81
- },
82
- "eslint-plugin-jsx-a11y": {
83
- "optional": true
84
- },
85
- "eslint-plugin-react-refresh": {
86
- "optional": true
87
- },
88
- "eslint-plugin-solid": {
89
- "optional": true
90
- },
91
- "eslint-plugin-svelte": {
92
- "optional": true
93
- },
94
- "eslint-plugin-vuejs-accessibility": {
95
- "optional": true
96
- },
97
- "prettier-plugin-astro": {
98
- "optional": true
99
- },
100
- "prettier-plugin-slidev": {
101
- "optional": true
102
- },
103
- "svelte-eslint-parser": {
104
- "optional": true
105
- }
28
+ "@antfu/eslint-config": ">=8.1.0"
106
29
  },
107
30
  "dependencies": {
108
- "@antfu/install-pkg": "^1.1.0",
109
- "@clack/prompts": "^1.2.0",
110
- "@e18e/eslint-plugin": "^0.3.0",
111
- "@eslint-community/eslint-plugin-eslint-comments": "^4.7.1",
112
- "@eslint/markdown": "^8.0.1",
113
- "@stylistic/eslint-plugin": "^5.10.0",
114
- "@typescript-eslint/eslint-plugin": "^8.58.1",
115
- "@typescript-eslint/parser": "^8.58.1",
116
- "@vitest/eslint-plugin": "^1.6.15",
117
- "ansis": "^4.2.0",
118
- "cac": "^7.0.0",
119
- "eslint-config-flat-gitignore": "^2.3.0",
120
- "eslint-flat-config-utils": "^3.1.0",
121
- "eslint-merge-processors": "^2.0.0",
122
- "eslint-plugin-antfu": "^3.2.2",
123
- "eslint-plugin-command": "^3.5.2",
124
- "eslint-plugin-import-lite": "^0.6.0",
125
- "eslint-plugin-jsdoc": "^62.9.0",
126
- "eslint-plugin-jsonc": "^3.1.2",
127
- "eslint-plugin-n": "^17.24.0",
128
- "eslint-plugin-no-only-tests": "^3.3.0",
129
- "eslint-plugin-perfectionist": "^5.8.0",
130
- "eslint-plugin-pnpm": "^1.6.0",
131
- "eslint-plugin-regexp": "^3.1.0",
132
- "eslint-plugin-toml": "^1.3.1",
133
- "eslint-plugin-unicorn": "^64.0.0",
134
- "eslint-plugin-unused-imports": "^4.4.1",
135
- "eslint-plugin-vue": "^10.8.0",
136
- "eslint-plugin-yml": "^3.3.1",
137
- "eslint-processor-vue-blocks": "^2.0.0",
138
- "globals": "^17.5.0",
139
- "local-pkg": "^1.1.2",
140
- "parse-gitignore": "^2.0.0",
141
- "toml-eslint-parser": "^1.0.3",
142
- "vue-eslint-parser": "^10.4.0",
143
- "yaml-eslint-parser": "^2.0.0"
31
+ "@antfu/eslint-config": "^8.3.0",
32
+ "eslint": "^10.3.0"
144
33
  },
145
34
  "devDependencies": {
146
- "@angular-eslint/eslint-plugin": "^21.3.1",
147
- "@angular-eslint/eslint-plugin-template": "^21.3.1",
148
- "@angular-eslint/template-parser": "^21.3.1",
149
- "@angular/core": "^21.2.8",
150
- "@antfu/ni": "^30.0.0",
151
- "@eslint-react/eslint-plugin": "^3.0.0",
152
- "@eslint/config-inspector": "^1.5.0",
153
- "@next/eslint-plugin-next": "^16.2.3",
154
- "@prettier/plugin-xml": "^3.4.2",
155
- "@types/eslint-plugin-jsx-a11y": "^6.10.1",
156
- "@types/node": "^25.6.0",
157
- "@unocss/eslint-plugin": "^66.6.8",
158
- "astro-eslint-parser": "^1.4.0",
159
- "baseline-browser-mapping": "^2.10.18",
160
- "bumpp": "^11.0.1",
161
- "eslint": "^10.2.0",
162
- "eslint-plugin-astro": "^1.7.0",
163
- "eslint-plugin-erasable-syntax-only": "^0.4.0",
164
- "eslint-plugin-format": "^2.0.1",
165
- "eslint-plugin-jsx-a11y": "^6.10.2",
166
- "eslint-plugin-react-refresh": "^0.5.2",
167
- "eslint-plugin-solid": "^0.14.5",
168
- "eslint-plugin-svelte": "^3.17.0",
169
- "eslint-plugin-vuejs-accessibility": "^2.5.0",
170
- "eslint-typegen": "^2.3.1",
171
- "execa": "^9.6.1",
172
- "find-up-simple": "^1.0.1",
173
- "jiti": "^2.6.1",
174
- "lint-staged": "^16.4.0",
175
- "pnpm-workspace-yaml": "^1.6.0",
176
- "prettier-plugin-astro": "^0.14.1",
177
- "prettier-plugin-slidev": "^1.0.5",
35
+ "@antfu/ni": "latest",
178
36
  "simple-git-hooks": "^2.13.1",
179
- "svelte": "^5.55.3",
180
- "svelte-eslint-parser": "^1.6.0",
181
- "tinyglobby": "^0.2.16",
182
- "tsdown": "^0.21.7",
183
- "tsnapi": "^0.1.1",
184
- "tsx": "^4.21.0",
185
- "typescript": "^6.0.2",
186
- "vitest": "^4.1.4",
187
- "vue": "^3.5.32",
188
- "@oliver139/eslint-config": "6.0.5"
189
- },
190
- "resolutions": {
191
- "@eslint-community/eslint-utils": "catalog:peer",
192
- "@typescript-eslint/types": "catalog:peer",
193
- "@typescript-eslint/utils": "catalog:peer",
194
- "chokidar": "catalog:dev",
195
- "eslint": "catalog:peer",
196
- "semver": "catalog:dev",
197
- "synckit": "catalog:dev",
198
- "tsx": "catalog:dev"
37
+ "tsdown": "^0.21.10",
38
+ "typescript": "^6.0.2"
199
39
  },
200
40
  "simple-git-hooks": {
201
41
  "pre-commit": "npx lint-staged"
202
42
  },
203
43
  "lint-staged": {
204
- "*": "eslint --fix"
205
- },
206
- "inlinedDependencies": {
207
- "@eslint-community/eslint-utils": "4.9.1",
208
- "@typescript-eslint/scope-manager": "8.59.1",
209
- "@typescript-eslint/types": "8.59.1",
210
- "@typescript-eslint/utils": "8.59.1",
211
- "@typescript-eslint/visitor-keys": "8.59.1",
212
- "cached-factory": "0.1.0",
213
- "eslint-plugin-erasable-syntax-only": "0.4.0",
214
- "eslint-visitor-keys": [
215
- "3.4.3",
216
- "5.0.1"
217
- ],
218
- "find-up-simple": "1.0.1"
44
+ "*": "eslint --cache --fix"
219
45
  },
220
46
  "scripts": {
221
- "build": "nr gen && tsdown --clean --dts",
222
- "stub": "tsdown",
223
- "dev": "npx @eslint/config-inspector --config eslint.config.ts",
224
- "build:inspector": "pnpm build && npx @eslint/config-inspector build",
225
- "watch": "tsdown --watch",
226
- "lint": "eslint",
227
- "lint:fix": "eslint --fix",
228
- "gen": "tsx scripts/typegen.ts && tsx scripts/versiongen.ts",
229
- "release": "bumpp && pnpm publish",
230
- "test": "vitest",
231
- "typecheck": "tsc --noEmit"
47
+ "dev": "nlx @eslint/config-inspector --config eslint.config.ts",
48
+ "build": "tsdown --clean --dts",
49
+ "lint": "eslint --cache",
50
+ "lint:fix": "eslint --cache --fix",
51
+ "release": "nlx bumpp && pnpm publish",
52
+ "ncu": "nlx npm-check-updates"
232
53
  }
233
54
  }
package/bin/index.mjs DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import '../dist/cli.mjs'
package/dist/cli.d.mts DELETED
@@ -1 +0,0 @@
1
- export { };
package/dist/cli.mjs DELETED
@@ -1,328 +0,0 @@
1
- import process from "node:process";
2
- import fs from "node:fs/promises";
3
- import fs$1 from "node:fs";
4
- import path from "node:path";
5
- import * as p from "@clack/prompts";
6
- import c, { green } from "ansis";
7
- import { cac } from "cac";
8
- import parse from "parse-gitignore";
9
- import { execSync } from "node:child_process";
10
- //#region package.json
11
- var version = "6.0.5";
12
- //#endregion
13
- //#region src/cli/constants.ts
14
- const vscodeSettingsString = `
15
- // Disable the default formatter, use eslint instead
16
- "prettier.enable": false,
17
- "editor.formatOnSave": false,
18
-
19
- // Auto fix
20
- "editor.codeActionsOnSave": {
21
- "source.fixAll.eslint": "explicit",
22
- "source.organizeImports": "never"
23
- },
24
-
25
- // Silent the stylistic rules in your IDE, but still auto fix them
26
- "eslint.rules.customizations": [
27
- { "rule": "style/*", "severity": "off", "fixable": true },
28
- { "rule": "format/*", "severity": "off", "fixable": true },
29
- { "rule": "*-indent", "severity": "off", "fixable": true },
30
- { "rule": "*-spacing", "severity": "off", "fixable": true },
31
- { "rule": "*-spaces", "severity": "off", "fixable": true },
32
- { "rule": "*-order", "severity": "off", "fixable": true },
33
- { "rule": "*-dangle", "severity": "off", "fixable": true },
34
- { "rule": "*-newline", "severity": "off", "fixable": true },
35
- { "rule": "*quotes", "severity": "off", "fixable": true },
36
- { "rule": "*semi", "severity": "off", "fixable": true }
37
- ],
38
-
39
- // Enable eslint for all supported languages
40
- "eslint.validate": [
41
- "javascript",
42
- "javascriptreact",
43
- "typescript",
44
- "typescriptreact",
45
- "vue",
46
- "html",
47
- "markdown",
48
- "json",
49
- "json5",
50
- "jsonc",
51
- "yaml",
52
- "toml",
53
- "xml",
54
- "gql",
55
- "graphql",
56
- "astro",
57
- "svelte",
58
- "css",
59
- "less",
60
- "scss",
61
- "pcss",
62
- "postcss"
63
- ]
64
- `;
65
- const frameworkOptions = [
66
- {
67
- label: c.green("Vue"),
68
- value: "vue"
69
- },
70
- {
71
- label: c.cyan("React"),
72
- value: "react"
73
- },
74
- {
75
- label: c.red("Svelte"),
76
- value: "svelte"
77
- },
78
- {
79
- label: c.magenta("Astro"),
80
- value: "astro"
81
- },
82
- {
83
- label: c.cyan("Solid"),
84
- value: "solid"
85
- },
86
- {
87
- label: c.blue("Slidev"),
88
- value: "slidev"
89
- }
90
- ];
91
- const frameworks = frameworkOptions.map(({ value }) => value);
92
- const extraOptions = [{
93
- hint: "Use external formatters (Prettier and/or dprint) to format files that ESLint cannot handle yet (.css, .html, etc)",
94
- label: c.red("Formatter"),
95
- value: "formatter"
96
- }, {
97
- label: c.cyan("UnoCSS"),
98
- value: "unocss"
99
- }];
100
- const extra = extraOptions.map(({ value }) => value);
101
- const dependenciesMap = {
102
- astro: ["eslint-plugin-astro", "astro-eslint-parser"],
103
- formatter: ["eslint-plugin-format"],
104
- formatterAstro: ["prettier-plugin-astro"],
105
- nextjs: ["@next/eslint-plugin-next"],
106
- react: ["@eslint-react/eslint-plugin", "eslint-plugin-react-refresh"],
107
- slidev: ["prettier-plugin-slidev"],
108
- solid: ["eslint-plugin-solid"],
109
- svelte: ["eslint-plugin-svelte", "svelte-eslint-parser"],
110
- unocss: ["@unocss/eslint-plugin"],
111
- vue: []
112
- };
113
- //#endregion
114
- //#region src/cli/utils.ts
115
- function isGitClean() {
116
- try {
117
- execSync("git diff-index --quiet HEAD --");
118
- return true;
119
- } catch {
120
- return false;
121
- }
122
- }
123
- function getEslintConfigContent(mainConfig, additionalConfigs) {
124
- return `
125
- import eslintConfig from '@oliver139/eslint-config'
126
-
127
- export default eslintConfig({
128
- ${mainConfig}
129
- }${additionalConfigs?.map((config) => `,{\n${config}\n}`)})
130
- `.trimStart();
131
- }
132
- //#endregion
133
- //#region src/cli/stages/update-eslint-files.ts
134
- const ESLINT_OR_PRETTIER = /eslint|prettier/;
135
- const ESLINT_CONFIG = /eslint\.config\./;
136
- async function updateEslintFiles(result) {
137
- const cwd = process.cwd();
138
- const pathESLintIgnore = path.join(cwd, ".eslintignore");
139
- const pathPackageJSON = path.join(cwd, "package.json");
140
- const pkgContent = await fs.readFile(pathPackageJSON, "utf-8");
141
- const configFileName = JSON.parse(pkgContent).type === "module" ? "eslint.config.js" : "eslint.config.mjs";
142
- const pathFlatConfig = path.join(cwd, configFileName);
143
- const eslintIgnores = [];
144
- if (fs$1.existsSync(pathESLintIgnore)) {
145
- p.log.step(c.cyan`Migrating existing .eslintignore`);
146
- const globs = parse(await fs.readFile(pathESLintIgnore, "utf-8")).globs();
147
- for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
148
- else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
149
- }
150
- const configLines = [];
151
- if (eslintIgnores.length) configLines.push(`ignores: ${JSON.stringify(eslintIgnores)},`);
152
- if (result.extra.includes("formatter")) configLines.push(`formatters: true,`);
153
- if (result.extra.includes("unocss")) configLines.push(`unocss: true,`);
154
- for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
155
- const eslintConfigContent = getEslintConfigContent(configLines.map((i) => ` ${i}`).join("\n"), []);
156
- await fs.writeFile(pathFlatConfig, eslintConfigContent);
157
- p.log.success(c.green`Created ${configFileName}`);
158
- const files = fs$1.readdirSync(cwd);
159
- const legacyConfig = [];
160
- files.forEach((file) => {
161
- if (ESLINT_OR_PRETTIER.test(file) && !ESLINT_CONFIG.test(file)) legacyConfig.push(file);
162
- });
163
- if (legacyConfig.length) p.note(c.dim(legacyConfig.join(", ")), "You can now remove those files manually");
164
- }
165
- //#endregion
166
- //#region src/cli/constants-generated.ts
167
- const versionsMap = {
168
- "@eslint-react/eslint-plugin": "^3.0.0",
169
- "@next/eslint-plugin-next": "^16.2.3",
170
- "@unocss/eslint-plugin": "^66.6.8",
171
- "astro-eslint-parser": "^1.4.0",
172
- "eslint": "^10.2.0",
173
- "eslint-plugin-astro": "^1.7.0",
174
- "eslint-plugin-format": "^2.0.1",
175
- "eslint-plugin-react-refresh": "^0.5.2",
176
- "eslint-plugin-solid": "^0.14.5",
177
- "eslint-plugin-svelte": "^3.17.0",
178
- "prettier-plugin-astro": "^0.14.1",
179
- "prettier-plugin-slidev": "^1.0.5",
180
- "svelte-eslint-parser": "^1.6.0"
181
- };
182
- //#endregion
183
- //#region src/cli/stages/update-package-json.ts
184
- async function updatePackageJson(result) {
185
- const cwd = process.cwd();
186
- const pathPackageJSON = path.join(cwd, "package.json");
187
- p.log.step(c.cyan`Bumping @oliver139/eslint-config to v${version}`);
188
- const pkgContent = await fs.readFile(pathPackageJSON, "utf-8");
189
- const pkg = JSON.parse(pkgContent);
190
- pkg.devDependencies ??= {};
191
- pkg.devDependencies["@oliver139/eslint-config"] = `^${version}`;
192
- pkg.devDependencies.eslint ??= versionsMap.eslint;
193
- const addedPackages = [];
194
- if (result.extra.length) result.extra.forEach((item) => {
195
- switch (item) {
196
- case "formatter":
197
- [...dependenciesMap.formatter, ...result.frameworks.includes("astro") ? dependenciesMap.formatterAstro : []].forEach((f) => {
198
- if (!f) return;
199
- pkg.devDependencies[f] = versionsMap[f];
200
- addedPackages.push(f);
201
- });
202
- break;
203
- case "unocss":
204
- dependenciesMap.unocss.forEach((f) => {
205
- pkg.devDependencies[f] = versionsMap[f];
206
- addedPackages.push(f);
207
- });
208
- break;
209
- }
210
- });
211
- for (const framework of result.frameworks) {
212
- const deps = dependenciesMap[framework];
213
- if (deps) deps.forEach((f) => {
214
- pkg.devDependencies[f] = versionsMap[f];
215
- addedPackages.push(f);
216
- });
217
- }
218
- if (addedPackages.length) p.note(c.dim(addedPackages.join(", ")), "Added packages");
219
- await fs.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
220
- p.log.success(c.green`Changes wrote to package.json`);
221
- }
222
- //#endregion
223
- //#region src/cli/stages/update-vscode-settings.ts
224
- const LAST_LINE_PATTERN = /\s*\}$/;
225
- async function updateVscodeSettings(result) {
226
- const cwd = process.cwd();
227
- if (!result.updateVscodeSettings) return;
228
- const dotVscodePath = path.join(cwd, ".vscode");
229
- const settingsPath = path.join(dotVscodePath, "settings.json");
230
- if (!fs$1.existsSync(dotVscodePath)) await fs.mkdir(dotVscodePath, { recursive: true });
231
- if (!fs$1.existsSync(settingsPath)) {
232
- await fs.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
233
- p.log.success(green`Created .vscode/settings.json`);
234
- } else {
235
- let settingsContent = await fs.readFile(settingsPath, "utf8");
236
- settingsContent = settingsContent.trim().replace(LAST_LINE_PATTERN, "");
237
- settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
238
- settingsContent += `${vscodeSettingsString}}\n`;
239
- await fs.writeFile(settingsPath, settingsContent, "utf-8");
240
- p.log.success(green`Updated .vscode/settings.json`);
241
- }
242
- }
243
- //#endregion
244
- //#region src/cli/run.ts
245
- async function run(options = {}) {
246
- const argSkipPrompt = !!process.env.SKIP_PROMPT || options.yes;
247
- const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
248
- const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
249
- if (fs$1.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
250
- p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
251
- return process.exit(1);
252
- }
253
- let result = {
254
- extra: argExtra ?? [],
255
- frameworks: argTemplate ?? [],
256
- uncommittedConfirmed: false,
257
- updateVscodeSettings: true
258
- };
259
- if (!argSkipPrompt) {
260
- result = await p.group({
261
- uncommittedConfirmed: () => {
262
- if (argSkipPrompt || isGitClean()) return Promise.resolve(true);
263
- return p.confirm({
264
- initialValue: false,
265
- message: "There are uncommitted changes in the current repository, are you sure to continue?"
266
- });
267
- },
268
- frameworks: ({ results }) => {
269
- const isArgTemplateValid = typeof argTemplate === "string" && !!frameworks.includes(argTemplate);
270
- if (!results.uncommittedConfirmed || isArgTemplateValid) return;
271
- const message = !isArgTemplateValid && argTemplate ? `"${argTemplate}" isn't a valid template. Please choose from below: ` : "Select a framework:";
272
- return p.multiselect({
273
- message: c.reset(message),
274
- options: frameworkOptions,
275
- required: false
276
- });
277
- },
278
- extra: ({ results }) => {
279
- const isArgExtraValid = argExtra?.length && !argExtra.filter((element) => !extra.includes(element)).length;
280
- if (!results.uncommittedConfirmed || isArgExtraValid) return;
281
- const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
282
- return p.multiselect({
283
- message: c.reset(message),
284
- options: extraOptions,
285
- required: false
286
- });
287
- },
288
- updateVscodeSettings: ({ results }) => {
289
- if (!results.uncommittedConfirmed) return;
290
- return p.confirm({
291
- initialValue: true,
292
- message: "Update .vscode/settings.json for better VS Code experience?"
293
- });
294
- }
295
- }, { onCancel: () => {
296
- p.cancel("Operation cancelled.");
297
- process.exit(0);
298
- } });
299
- if (!result.uncommittedConfirmed) return process.exit(1);
300
- }
301
- await updatePackageJson(result);
302
- await updateEslintFiles(result);
303
- await updateVscodeSettings(result);
304
- p.log.success(c.green`Setup completed`);
305
- p.outro(`Now you can update the dependencies by run ${c.blue("pnpm install")} and run ${c.blue("eslint --fix")}\n`);
306
- }
307
- //#endregion
308
- //#region src/cli/index.ts
309
- function header() {
310
- console.log("\n");
311
- p.intro(`${c.green`@oliver139/eslint-config `}${c.dim`v${version}`}`);
312
- }
313
- const cli = cac("@oliver139/eslint-config");
314
- cli.command("", "Run the initialization or migration").option("--yes, -y", "Skip prompts and use default values", { default: false }).option("--template, -t <template>", "Use the framework template for optimal customization: vue / react / svelte / astro", { type: [] }).option("--extra, -e <extra>", "Use the extra utils: formatter / perfectionist / unocss", { type: [] }).action(async (args) => {
315
- header();
316
- try {
317
- await run(args);
318
- } catch (error) {
319
- p.log.error(c.inverse.red(" Failed to migrate "));
320
- p.log.error(c.red`✘ ${String(error)}`);
321
- process.exit(1);
322
- }
323
- });
324
- cli.help();
325
- cli.version(version);
326
- cli.parse();
327
- //#endregion
328
- export {};