@antfu/eslint-config 9.0.0 → 9.1.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 +4 -0
- package/dist/cli.mjs +26 -26
- package/dist/index.d.mts +1352 -279
- package/dist/index.mjs +10 -7
- package/dist/{lib-C1Uxp5ZW.mjs → lib-NWAatdeh.mjs} +249 -245
- package/package.json +59 -57
package/README.md
CHANGED
|
@@ -547,6 +547,10 @@ export default antfu({
|
|
|
547
547
|
overrides: {
|
|
548
548
|
'ts/consistent-type-definitions': ['error', 'interface'],
|
|
549
549
|
},
|
|
550
|
+
// type aware rules overrides should write here
|
|
551
|
+
overridesTypeAware: {
|
|
552
|
+
'ts/no-unsafe-assignment': ['warn'],
|
|
553
|
+
}
|
|
550
554
|
},
|
|
551
555
|
yaml: {
|
|
552
556
|
overrides: {
|
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";
|
|
@@ -8,7 +8,7 @@ import { cac } from "cac";
|
|
|
8
8
|
import parse from "parse-gitignore";
|
|
9
9
|
import { execSync } from "node:child_process";
|
|
10
10
|
//#region package.json
|
|
11
|
-
var version = "9.
|
|
11
|
+
var version = "9.1.0";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/cli/constants.ts
|
|
14
14
|
const vscodeSettingsString = `
|
|
@@ -137,13 +137,13 @@ async function updateEslintFiles(result) {
|
|
|
137
137
|
const cwd = process.cwd();
|
|
138
138
|
const pathESLintIgnore = path.join(cwd, ".eslintignore");
|
|
139
139
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
140
|
-
const pkgContent = await
|
|
140
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf-8");
|
|
141
141
|
const configFileName = JSON.parse(pkgContent).type === "module" ? "eslint.config.js" : "eslint.config.mjs";
|
|
142
142
|
const pathFlatConfig = path.join(cwd, configFileName);
|
|
143
143
|
const eslintIgnores = [];
|
|
144
|
-
if (fs
|
|
144
|
+
if (fs.existsSync(pathESLintIgnore)) {
|
|
145
145
|
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
146
|
-
const globs = parse(await
|
|
146
|
+
const globs = parse(await fsPromises.readFile(pathESLintIgnore, "utf-8")).globs();
|
|
147
147
|
for (const glob of globs) if (glob.type === "ignore") eslintIgnores.push(...glob.patterns);
|
|
148
148
|
else if (glob.type === "unignore") eslintIgnores.push(...glob.patterns.map((pattern) => `!${pattern}`));
|
|
149
149
|
}
|
|
@@ -153,9 +153,9 @@ async function updateEslintFiles(result) {
|
|
|
153
153
|
if (result.extra.includes("unocss")) configLines.push(`unocss: true,`);
|
|
154
154
|
for (const framework of result.frameworks) configLines.push(`${framework}: true,`);
|
|
155
155
|
const eslintConfigContent = getEslintConfigContent(configLines.map((i) => ` ${i}`).join("\n"), []);
|
|
156
|
-
await
|
|
156
|
+
await fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
|
|
157
157
|
p.log.success(c.green`Created ${configFileName}`);
|
|
158
|
-
const files = fs
|
|
158
|
+
const files = fs.readdirSync(cwd);
|
|
159
159
|
const legacyConfig = [];
|
|
160
160
|
files.forEach((file) => {
|
|
161
161
|
if (ESLINT_OR_PRETTIER.test(file) && !ESLINT_CONFIG.test(file)) legacyConfig.push(file);
|
|
@@ -165,19 +165,19 @@ async function updateEslintFiles(result) {
|
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/cli/constants-generated.ts
|
|
167
167
|
const versionsMap = {
|
|
168
|
-
"@eslint-react/eslint-plugin": "^5.
|
|
169
|
-
"@next/eslint-plugin-next": "^16.2.
|
|
170
|
-
"@unocss/eslint-plugin": "^66.
|
|
171
|
-
"astro-eslint-parser": "^
|
|
172
|
-
"eslint": "^10.
|
|
173
|
-
"eslint-plugin-astro": "^
|
|
168
|
+
"@eslint-react/eslint-plugin": "^5.9.2",
|
|
169
|
+
"@next/eslint-plugin-next": "^16.2.9",
|
|
170
|
+
"@unocss/eslint-plugin": "^66.7.2",
|
|
171
|
+
"astro-eslint-parser": "^2.0.0",
|
|
172
|
+
"eslint": "^10.5.0",
|
|
173
|
+
"eslint-plugin-astro": "^2.0.0",
|
|
174
174
|
"eslint-plugin-format": "^2.0.1",
|
|
175
|
-
"eslint-plugin-react-refresh": "^0.5.
|
|
175
|
+
"eslint-plugin-react-refresh": "^0.5.3",
|
|
176
176
|
"eslint-plugin-solid": "^0.14.5",
|
|
177
|
-
"eslint-plugin-svelte": "^3.
|
|
177
|
+
"eslint-plugin-svelte": "^3.19.0",
|
|
178
178
|
"prettier-plugin-astro": "^0.14.1",
|
|
179
179
|
"prettier-plugin-slidev": "^1.0.5",
|
|
180
|
-
"svelte-eslint-parser": "^1.
|
|
180
|
+
"svelte-eslint-parser": "^1.8.0"
|
|
181
181
|
};
|
|
182
182
|
//#endregion
|
|
183
183
|
//#region src/cli/stages/update-package-json.ts
|
|
@@ -185,7 +185,7 @@ async function updatePackageJson(result) {
|
|
|
185
185
|
const cwd = process.cwd();
|
|
186
186
|
const pathPackageJSON = path.join(cwd, "package.json");
|
|
187
187
|
p.log.step(c.cyan`Bumping @antfu/eslint-config to v${version}`);
|
|
188
|
-
const pkgContent = await
|
|
188
|
+
const pkgContent = await fsPromises.readFile(pathPackageJSON, "utf-8");
|
|
189
189
|
const pkg = JSON.parse(pkgContent);
|
|
190
190
|
pkg.devDependencies ??= {};
|
|
191
191
|
pkg.devDependencies["@antfu/eslint-config"] = `^${version}`;
|
|
@@ -216,7 +216,7 @@ async function updatePackageJson(result) {
|
|
|
216
216
|
});
|
|
217
217
|
}
|
|
218
218
|
if (addedPackages.length) p.note(c.dim(addedPackages.join(", ")), "Added packages");
|
|
219
|
-
await
|
|
219
|
+
await fsPromises.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
|
|
220
220
|
p.log.success(c.green`Changes wrote to package.json`);
|
|
221
221
|
}
|
|
222
222
|
//#endregion
|
|
@@ -227,16 +227,16 @@ async function updateVscodeSettings(result) {
|
|
|
227
227
|
if (!result.updateVscodeSettings) return;
|
|
228
228
|
const dotVscodePath = path.join(cwd, ".vscode");
|
|
229
229
|
const settingsPath = path.join(dotVscodePath, "settings.json");
|
|
230
|
-
if (!fs
|
|
231
|
-
if (!fs
|
|
232
|
-
await
|
|
230
|
+
if (!fs.existsSync(dotVscodePath)) await fsPromises.mkdir(dotVscodePath, { recursive: true });
|
|
231
|
+
if (!fs.existsSync(settingsPath)) {
|
|
232
|
+
await fsPromises.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
|
|
233
233
|
p.log.success(green`Created .vscode/settings.json`);
|
|
234
234
|
} else {
|
|
235
|
-
let settingsContent = await
|
|
235
|
+
let settingsContent = await fsPromises.readFile(settingsPath, "utf8");
|
|
236
236
|
settingsContent = settingsContent.trim().replace(LAST_LINE_PATTERN, "");
|
|
237
237
|
settingsContent += settingsContent.endsWith(",") || settingsContent.endsWith("{") ? "" : ",";
|
|
238
238
|
settingsContent += `${vscodeSettingsString}}\n`;
|
|
239
|
-
await
|
|
239
|
+
await fsPromises.writeFile(settingsPath, settingsContent, "utf-8");
|
|
240
240
|
p.log.success(green`Updated .vscode/settings.json`);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
@@ -246,7 +246,7 @@ async function run(options = {}) {
|
|
|
246
246
|
const argSkipPrompt = !!process.env.SKIP_PROMPT || options.yes;
|
|
247
247
|
const argTemplate = options.frameworks?.map((m) => m?.trim()).filter(Boolean);
|
|
248
248
|
const argExtra = options.extra?.map((m) => m?.trim()).filter(Boolean);
|
|
249
|
-
if (fs
|
|
249
|
+
if (fs.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
250
250
|
p.log.warn(c.yellow`eslint.config.js already exists, migration wizard exited.`);
|
|
251
251
|
return process.exit(1);
|
|
252
252
|
}
|
|
@@ -276,7 +276,7 @@ async function run(options = {}) {
|
|
|
276
276
|
});
|
|
277
277
|
},
|
|
278
278
|
extra: ({ results }) => {
|
|
279
|
-
const isArgExtraValid = argExtra?.length &&
|
|
279
|
+
const isArgExtraValid = argExtra?.length && argExtra.every((element) => extra.includes(element));
|
|
280
280
|
if (!results.uncommittedConfirmed || isArgExtraValid) return;
|
|
281
281
|
const message = !isArgExtraValid && argExtra ? `"${argExtra}" isn't a valid extra util. Please choose from below: ` : "Select a extra utils:";
|
|
282
282
|
return p.multiselect({
|