@antfu/eslint-config 7.6.0 → 7.6.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/dist/cli.mjs +19 -19
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +8 -6
- package/package.json +8 -8
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import process from "node:process";
|
|
2
|
-
import
|
|
3
|
-
import fs from "node:fs";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import fs$1 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 = "7.6.
|
|
12
|
+
var version = "7.6.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 fs.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.existsSync(pathESLintIgnore)) {
|
|
150
|
+
if (fs$1.existsSync(pathESLintIgnore)) {
|
|
151
151
|
p.log.step(c.cyan`Migrating existing .eslintignore`);
|
|
152
|
-
const globs = parse(await
|
|
152
|
+
const globs = parse(await fs.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 fs.writeFile(pathFlatConfig, eslintConfigContent);
|
|
163
163
|
p.log.success(c.green`Created ${configFileName}`);
|
|
164
|
-
const files = fs.readdirSync(cwd);
|
|
164
|
+
const files = fs$1.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);
|
|
@@ -174,18 +174,18 @@ async function updateEslintFiles(result) {
|
|
|
174
174
|
const versionsMap = {
|
|
175
175
|
"@eslint-react/eslint-plugin": "^2.13.0",
|
|
176
176
|
"@next/eslint-plugin-next": "^16.1.6",
|
|
177
|
-
"@unocss/eslint-plugin": "^66.6.
|
|
177
|
+
"@unocss/eslint-plugin": "^66.6.1",
|
|
178
178
|
"astro-eslint-parser": "^1.3.0",
|
|
179
179
|
"eslint": "^10.0.2",
|
|
180
180
|
"eslint-plugin-astro": "^1.6.0",
|
|
181
|
-
"eslint-plugin-format": "^2.0.
|
|
181
|
+
"eslint-plugin-format": "^2.0.1",
|
|
182
182
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
183
183
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
184
184
|
"eslint-plugin-solid": "^0.14.5",
|
|
185
185
|
"eslint-plugin-svelte": "^3.15.0",
|
|
186
186
|
"prettier-plugin-astro": "^0.14.1",
|
|
187
187
|
"prettier-plugin-slidev": "^1.0.5",
|
|
188
|
-
"svelte-eslint-parser": "^1.5.
|
|
188
|
+
"svelte-eslint-parser": "^1.5.1"
|
|
189
189
|
};
|
|
190
190
|
|
|
191
191
|
//#endregion
|
|
@@ -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 @antfu/eslint-config to v${version}`);
|
|
197
|
-
const pkgContent = await
|
|
197
|
+
const pkgContent = await fs.readFile(pathPackageJSON, "utf-8");
|
|
198
198
|
const pkg = JSON.parse(pkgContent);
|
|
199
199
|
pkg.devDependencies ??= {};
|
|
200
200
|
pkg.devDependencies["@antfu/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 fs.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.existsSync(dotVscodePath)) await
|
|
240
|
-
if (!fs.existsSync(settingsPath)) {
|
|
241
|
-
await
|
|
239
|
+
if (!fs$1.existsSync(dotVscodePath)) await fs.mkdir(dotVscodePath, { recursive: true });
|
|
240
|
+
if (!fs$1.existsSync(settingsPath)) {
|
|
241
|
+
await fs.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 fs.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 fs.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.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
|
|
259
|
+
if (fs$1.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
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -19773,7 +19773,7 @@ type Yoda = [] | [("always" | "never")] | [("always" | "never"), {
|
|
|
19773
19773
|
onlyEquality?: boolean;
|
|
19774
19774
|
}];
|
|
19775
19775
|
// Names of all the configs
|
|
19776
|
-
type ConfigNames = 'antfu/gitignore' | 'antfu/ignores' | 'antfu/javascript/setup' | 'antfu/javascript/rules' | 'antfu/eslint-comments/rules' | 'antfu/command/rules' | 'antfu/perfectionist/setup' | 'antfu/node/rules' | 'antfu/jsdoc/setup' | 'antfu/jsdoc/rules' | 'antfu/imports/rules' | 'antfu/unicorn/rules' | 'antfu/jsx/setup' | 'antfu/typescript/setup' | 'antfu/typescript/parser' | 'antfu/typescript/type-aware-parser' | 'antfu/typescript/rules' | 'antfu/typescript/rules-type-aware' | 'antfu/typescript/erasable-syntax-only' | 'antfu/stylistic/rules' | 'antfu/regexp/rules' | 'antfu/test/setup' | 'antfu/test/rules' | 'antfu/vue/setup' | 'antfu/vue/rules' | 'antfu/react/setup' | 'antfu/react/rules' | 'antfu/react/typescript' | 'antfu/react/type-aware-rules' | 'antfu/nextjs/setup' | 'antfu/nextjs/rules' | 'antfu/solid/setup' | 'antfu/solid/rules' | 'antfu/svelte/setup' | 'antfu/svelte/rules' | 'antfu/unocss' | 'antfu/astro/setup' | 'antfu/astro/rules' | 'antfu/angular/setup' | 'antfu/angular/rules/ts' | 'antfu/angular/rules/template' | 'antfu/jsonc/setup' | 'antfu/jsonc/rules' | 'antfu/sort/package-json' | 'antfu/sort/tsconfig-json' | 'antfu/pnpm/package-json' | 'antfu/pnpm/pnpm-workspace-yaml' | 'antfu/pnpm/pnpm-workspace-yaml-sort' | 'antfu/yaml/setup' | 'antfu/yaml/rules' | 'antfu/toml/setup' | 'antfu/toml/rules' | 'antfu/markdown/setup' | 'antfu/markdown/processor' | 'antfu/markdown/parser' | 'antfu/markdown/rules' | 'antfu/markdown/disables/markdown' | 'antfu/markdown/disables/code' | 'antfu/formatter/setup' | 'antfu/formatter/css' | 'antfu/formatter/scss' | 'antfu/formatter/less' | 'antfu/formatter/html' | 'antfu/formatter/xml' | 'antfu/formatter/svg' | 'antfu/formatter/markdown' | 'antfu/formatter/astro' | 'antfu/formatter/astro/disables' | 'antfu/formatter/graphql' | 'antfu/disables/scripts' | 'antfu/disables/cli' | 'antfu/disables/bin' | 'antfu/disables/dts' | 'antfu/disables/cjs' | 'antfu/disables/config-files';
|
|
19776
|
+
type ConfigNames = 'antfu/gitignore' | 'antfu/ignores' | 'antfu/javascript/setup' | 'antfu/javascript/rules' | 'antfu/eslint-comments/rules' | 'antfu/command/rules' | 'antfu/perfectionist/setup' | 'antfu/node/setup' | 'antfu/node/rules' | 'antfu/jsdoc/setup' | 'antfu/jsdoc/rules' | 'antfu/imports/rules' | 'antfu/unicorn/rules' | 'antfu/jsx/setup' | 'antfu/typescript/setup' | 'antfu/typescript/parser' | 'antfu/typescript/type-aware-parser' | 'antfu/typescript/rules' | 'antfu/typescript/rules-type-aware' | 'antfu/typescript/erasable-syntax-only' | 'antfu/stylistic/rules' | 'antfu/regexp/rules' | 'antfu/test/setup' | 'antfu/test/rules' | 'antfu/vue/setup' | 'antfu/vue/rules' | 'antfu/react/setup' | 'antfu/react/rules' | 'antfu/react/typescript' | 'antfu/react/type-aware-rules' | 'antfu/nextjs/setup' | 'antfu/nextjs/rules' | 'antfu/solid/setup' | 'antfu/solid/rules' | 'antfu/svelte/setup' | 'antfu/svelte/rules' | 'antfu/unocss' | 'antfu/astro/setup' | 'antfu/astro/rules' | 'antfu/angular/setup' | 'antfu/angular/rules/ts' | 'antfu/angular/rules/template' | 'antfu/jsonc/setup' | 'antfu/jsonc/rules' | 'antfu/sort/package-json' | 'antfu/sort/tsconfig-json' | 'antfu/pnpm/package-json' | 'antfu/pnpm/pnpm-workspace-yaml' | 'antfu/pnpm/pnpm-workspace-yaml-sort' | 'antfu/yaml/setup' | 'antfu/yaml/rules' | 'antfu/toml/setup' | 'antfu/toml/rules' | 'antfu/markdown/setup' | 'antfu/markdown/processor' | 'antfu/markdown/parser' | 'antfu/markdown/rules' | 'antfu/markdown/disables/markdown' | 'antfu/markdown/disables/code' | 'antfu/formatter/setup' | 'antfu/formatter/css' | 'antfu/formatter/scss' | 'antfu/formatter/less' | 'antfu/formatter/html' | 'antfu/formatter/xml' | 'antfu/formatter/svg' | 'antfu/formatter/markdown' | 'antfu/formatter/astro' | 'antfu/formatter/astro/disables' | 'antfu/formatter/graphql' | 'antfu/disables/scripts' | 'antfu/disables/cli' | 'antfu/disables/bin' | 'antfu/disables/dts' | 'antfu/disables/cjs' | 'antfu/disables/config-files';
|
|
19777
19777
|
//#endregion
|
|
19778
19778
|
//#region src/vender/prettier-types.d.ts
|
|
19779
19779
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
2
2
|
import process from "node:process";
|
|
3
|
-
import
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import fs from "node:fs";
|
|
5
|
+
import fs$1 from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { isPackageExists } from "local-pkg";
|
|
8
8
|
import createCommand from "eslint-plugin-command/config";
|
|
@@ -27,7 +27,7 @@ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {})
|
|
|
27
27
|
while (directory) {
|
|
28
28
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
29
29
|
try {
|
|
30
|
-
const stats = await
|
|
30
|
+
const stats = await fs.stat(filePath);
|
|
31
31
|
if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
|
|
32
32
|
} catch {}
|
|
33
33
|
if (directory === stopAt || directory === root) break;
|
|
@@ -42,7 +42,7 @@ function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
|
|
|
42
42
|
while (directory) {
|
|
43
43
|
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
|
44
44
|
try {
|
|
45
|
-
const stats = fs.statSync(filePath, { throwIfNoEntry: false });
|
|
45
|
+
const stats = fs$1.statSync(filePath, { throwIfNoEntry: false });
|
|
46
46
|
if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
|
|
47
47
|
} catch {}
|
|
48
48
|
if (directory === stopAt || directory === root) break;
|
|
@@ -1163,9 +1163,11 @@ async function nextjs(options = {}) {
|
|
|
1163
1163
|
//#region src/configs/node.ts
|
|
1164
1164
|
async function node() {
|
|
1165
1165
|
return [{
|
|
1166
|
+
name: "antfu/node/setup",
|
|
1167
|
+
plugins: { node: pluginNode }
|
|
1168
|
+
}, {
|
|
1166
1169
|
files: [GLOB_SRC],
|
|
1167
1170
|
name: "antfu/node/rules",
|
|
1168
|
-
plugins: { node: pluginNode },
|
|
1169
1171
|
rules: {
|
|
1170
1172
|
"node/handle-callback-err": ["error", "^(err|error)$"],
|
|
1171
1173
|
"node/no-deprecated-api": "error",
|
|
@@ -1238,7 +1240,7 @@ async function perfectionist() {
|
|
|
1238
1240
|
async function detectCatalogUsage() {
|
|
1239
1241
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1240
1242
|
if (!workspaceFile) return false;
|
|
1241
|
-
const yaml$1 = await
|
|
1243
|
+
const yaml$1 = await fs.readFile(workspaceFile, "utf-8");
|
|
1242
1244
|
return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
|
|
1243
1245
|
}
|
|
1244
1246
|
async function pnpm(options) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antfu/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.6.
|
|
4
|
+
"version": "7.6.1",
|
|
5
5
|
"description": "Anthony's ESLint config",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -126,14 +126,14 @@
|
|
|
126
126
|
"eslint-flat-config-utils": "^3.0.1",
|
|
127
127
|
"eslint-merge-processors": "^2.0.0",
|
|
128
128
|
"eslint-plugin-antfu": "^3.2.2",
|
|
129
|
-
"eslint-plugin-command": "^3.5.
|
|
129
|
+
"eslint-plugin-command": "^3.5.2",
|
|
130
130
|
"eslint-plugin-import-lite": "^0.5.2",
|
|
131
131
|
"eslint-plugin-jsdoc": "^62.7.1",
|
|
132
132
|
"eslint-plugin-jsonc": "^3.1.0",
|
|
133
133
|
"eslint-plugin-n": "^17.24.0",
|
|
134
134
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
135
135
|
"eslint-plugin-perfectionist": "^5.6.0",
|
|
136
|
-
"eslint-plugin-pnpm": "^1.
|
|
136
|
+
"eslint-plugin-pnpm": "^1.6.0",
|
|
137
137
|
"eslint-plugin-regexp": "^3.0.0",
|
|
138
138
|
"eslint-plugin-toml": "^1.3.0",
|
|
139
139
|
"eslint-plugin-unicorn": "^63.0.0",
|
|
@@ -160,14 +160,14 @@
|
|
|
160
160
|
"@prettier/plugin-xml": "^3.4.2",
|
|
161
161
|
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
162
162
|
"@types/node": "^25.3.0",
|
|
163
|
-
"@unocss/eslint-plugin": "^66.6.
|
|
163
|
+
"@unocss/eslint-plugin": "^66.6.1",
|
|
164
164
|
"astro-eslint-parser": "^1.3.0",
|
|
165
165
|
"baseline-browser-mapping": "^2.10.0",
|
|
166
166
|
"bumpp": "^10.4.1",
|
|
167
167
|
"eslint": "^10.0.2",
|
|
168
168
|
"eslint-plugin-astro": "^1.6.0",
|
|
169
169
|
"eslint-plugin-erasable-syntax-only": "^0.4.0",
|
|
170
|
-
"eslint-plugin-format": "^2.0.
|
|
170
|
+
"eslint-plugin-format": "^2.0.1",
|
|
171
171
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
172
172
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
173
173
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
@@ -179,19 +179,19 @@
|
|
|
179
179
|
"find-up-simple": "^1.0.1",
|
|
180
180
|
"jiti": "^2.6.1",
|
|
181
181
|
"lint-staged": "^16.2.7",
|
|
182
|
-
"pnpm-workspace-yaml": "^1.
|
|
182
|
+
"pnpm-workspace-yaml": "^1.6.0",
|
|
183
183
|
"prettier-plugin-astro": "^0.14.1",
|
|
184
184
|
"prettier-plugin-slidev": "^1.0.5",
|
|
185
185
|
"simple-git-hooks": "^2.13.1",
|
|
186
186
|
"svelte": "^5.53.3",
|
|
187
|
-
"svelte-eslint-parser": "^1.5.
|
|
187
|
+
"svelte-eslint-parser": "^1.5.1",
|
|
188
188
|
"tinyglobby": "^0.2.15",
|
|
189
189
|
"tsdown": "^0.18.4",
|
|
190
190
|
"tsx": "^4.21.0",
|
|
191
191
|
"typescript": "^5.9.3",
|
|
192
192
|
"vitest": "^4.0.18",
|
|
193
193
|
"vue": "^3.5.29",
|
|
194
|
-
"@antfu/eslint-config": "7.6.
|
|
194
|
+
"@antfu/eslint-config": "7.6.1"
|
|
195
195
|
},
|
|
196
196
|
"resolutions": {
|
|
197
197
|
"@eslint-community/eslint-utils": "catalog:peer",
|