@kirklin/eslint-config 8.0.0 → 8.0.1
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.zh-cn.md +7 -7
- package/dist/cli.mjs +20 -20
- package/dist/index.d.mts +1006 -1964
- package/dist/index.mjs +97 -97
- package/dist/{lib-DRA-mDV0.mjs → lib-4A9shWox.mjs} +496 -496
- package/package.json +94 -99
package/README.zh-cn.md
CHANGED
|
@@ -396,14 +396,14 @@ export default combine(
|
|
|
396
396
|
|
|
397
397
|
由于Flat配置要求我们明确提供插件名称(而不是从npm包名称强制性约定),我们已经重命名了一些插件,以使整体范围更一致且更容易编写。
|
|
398
398
|
|
|
399
|
-
| New Prefix | Original Prefix | Source Plugin
|
|
400
|
-
| ---------- | ---------------------- |
|
|
399
|
+
| New Prefix | Original Prefix | Source Plugin |
|
|
400
|
+
| ---------- | ---------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
401
401
|
| `import/*` | `import-lite/*` | [eslint-plugin-import-lite](https://github.com/9romise/eslint-plugin-import-lite) |
|
|
402
|
-
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n)
|
|
403
|
-
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml)
|
|
404
|
-
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint)
|
|
405
|
-
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
406
|
-
| `test/*` | `vitest/*` | [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest)
|
|
402
|
+
| `node/*` | `n/*` | [eslint-plugin-n](https://github.com/eslint-community/eslint-plugin-n) |
|
|
403
|
+
| `yaml/*` | `yml/*` | [eslint-plugin-yml](https://github.com/ota-meshi/eslint-plugin-yml) |
|
|
404
|
+
| `ts/*` | `@typescript-eslint/*` | [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) |
|
|
405
|
+
| `style/*` | `@stylistic/*` | [@stylistic/eslint-plugin](https://github.com/eslint-stylistic/eslint-stylistic) |
|
|
406
|
+
| `test/*` | `vitest/*` | [@vitest/eslint-plugin](https://github.com/vitest-dev/eslint-plugin-vitest) |
|
|
407
407
|
| `test/*` | `no-only-tests/*` | [eslint-plugin-no-only-tests](https://github.com/levibuzolic/eslint-plugin-no-only-tests) |
|
|
408
408
|
| `next/*` | `@next/next` | [@next/eslint-plugin-next](https://github.com/vercel/next.js/tree/canary/packages/eslint-plugin-next) |
|
|
409
409
|
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import
|
|
3
|
-
import fs
|
|
2
|
+
import fsPromises from "node:fs/promises";
|
|
3
|
+
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import * as p from "@clack/prompts";
|
|
6
6
|
import c, { green } from "ansis";
|
|
@@ -9,7 +9,7 @@ import parse from "parse-gitignore";
|
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
|
-
var version = "8.0.
|
|
12
|
+
var version = "8.0.1";
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/cli/constants.ts
|
|
@@ -143,13 +143,13 @@ async function updateEslintFiles(result) {
|
|
|
143
143
|
const cwd = process.cwd();
|
|
144
144
|
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
145
145
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
146
|
-
const pkgContent = await
|
|
146
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf-8");
|
|
147
147
|
const configFileName = JSON.parse(pkgContent).type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
148
148
|
const pathFlatConfig = path.join(cwd, configFileName);
|
|
149
149
|
const eslintIgnores = [];
|
|
150
|
-
if (fs
|
|
150
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
|
151
151
|
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
152
|
-
const globs = parse(await
|
|
152
|
+
const globs = parse(await fsPromises.readFile(pathESLintIgnore, "utf-8")).globs();
|
|
153
153
|
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
154
154
|
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
155
155
|
}
|
|
@@ -159,9 +159,9 @@ async function updateEslintFiles(result) {
|
|
|
159
159
|
if (result.extra.includes("unocss")) configLines.push(`unocss: true,`);
|
|
160
160
|
for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
|
|
161
161
|
const eslintConfigContent = getEslintConfigContent(configLines.map((i) => ` ${i}`).join("\n"), []);
|
|
162
|
-
await
|
|
162
|
+
await fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
|
|
163
163
|
p.log.success(c.green`Created ${configFileName}`);
|
|
164
|
-
const files = fs
|
|
164
|
+
const files = fs.readdirSync(cwd);
|
|
165
165
|
const legacyConfig = [];
|
|
166
166
|
files.forEach((file) => {
|
|
167
167
|
if (/eslint|prettier/.test(file) && !/eslint\.config\./.test(file)) legacyConfig.push(file);
|
|
@@ -172,12 +172,12 @@ async function updateEslintFiles(result) {
|
|
|
172
172
|
//#endregion
|
|
173
173
|
//#region src/cli/constants-generated.ts
|
|
174
174
|
const versionsMap = {
|
|
175
|
-
"@eslint-react/eslint-plugin": "^2.
|
|
175
|
+
"@eslint-react/eslint-plugin": "^2.13.0",
|
|
176
176
|
"@next/eslint-plugin-next": "^16.1.6",
|
|
177
177
|
"@unocss/eslint-plugin": "^66.6.0",
|
|
178
|
-
"astro-eslint-parser": "^1.
|
|
179
|
-
"eslint": "^
|
|
180
|
-
"eslint-plugin-astro": "^1.
|
|
178
|
+
"astro-eslint-parser": "^1.3.0",
|
|
179
|
+
"eslint": "^10.0.0",
|
|
180
|
+
"eslint-plugin-astro": "^1.6.0",
|
|
181
181
|
"eslint-plugin-format": "^1.4.0",
|
|
182
182
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
183
183
|
"eslint-plugin-react-refresh": "^0.5.0",
|
|
@@ -194,7 +194,7 @@ async function updatePackageJson(result) {
|
|
|
194
194
|
const cwd = process.cwd();
|
|
195
195
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
196
196
|
p.log.step(c.cyan`Bumping @kirklin/eslint-config to v${version}`);
|
|
197
|
-
const pkgContent = await
|
|
197
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf-8");
|
|
198
198
|
const pkg = JSON.parse(pkgContent);
|
|
199
199
|
pkg.devDependencies ??= {};
|
|
200
200
|
pkg.devDependencies["@kirklin/eslint-config"] = `^${version}`;
|
|
@@ -225,7 +225,7 @@ async function updatePackageJson(result) {
|
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
if (addedPackages.length) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
228
|
-
await
|
|
228
|
+
await fsPromises.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
229
229
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
230
230
|
}
|
|
231
231
|
|
|
@@ -236,16 +236,16 @@ async function updateVscodeSettings(result) {
|
|
|
236
236
|
if (!result.updateVscodeSettings) return;
|
|
237
237
|
const dotVscodePath = path.join(cwd, ".vscode");
|
|
238
238
|
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
239
|
-
if (!fs
|
|
240
|
-
if (!fs
|
|
241
|
-
await
|
|
239
|
+
if (!fs.existsSync(dotVscodePath)) await fsPromises.mkdir(dotVscodePath, { recursive: true });
|
|
240
|
+
if (!fs.existsSync(settingsPath)) {
|
|
241
|
+
await fsPromises.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
242
242
|
p.log.success(green`Created .vscode/settings.json`);
|
|
243
243
|
} else {
|
|
244
|
-
let settingsContent = await
|
|
244
|
+
let settingsContent = await fsPromises.readFile(settingsPath, "utf8");
|
|
245
245
|
settingsContent = settingsContent.trim().replace(/\s*\}$/, "");
|
|
246
246
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
247
247
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
248
|
-
await
|
|
248
|
+
await fsPromises.writeFile(settingsPath, settingsContent, "utf-8");
|
|
249
249
|
p.log.success(green`Updated .vscode/settings.json`);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
@@ -256,7 +256,7 @@ async function run(options = {}) {
|
|
|
256
256
|
const argSkipPrompt = !!process.env.SKIP_PROMPT || options.yes;
|
|
257
257
|
const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
|
|
258
258
|
const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
|
|
259
|
-
if (fs
|
|
259
|
+
if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
260
260
|
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
|
|
261
261
|
return process.exit(1);
|
|
262
262
|
}
|