@antfu/eslint-config 6.7.0 → 6.7.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import process from "node:process";
2
- import fsPromises from "node:fs/promises";
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 = "6.7.0";
12
+ var version = "6.7.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 fsPromises.readFile(pathPackageJSON, "utf-8");
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 fsPromises.readFile(pathESLintIgnore, "utf-8")).globs();
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 fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
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);
@@ -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 fsPromises.readFile(pathPackageJSON, "utf-8");
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 fsPromises.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
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 fsPromises.mkdir(dotVscodePath, { recursive: true });
240
- if (!fs.existsSync(settingsPath)) {
241
- await fsPromises.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
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 fsPromises.readFile(settingsPath, "utf8");
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 fsPromises.writeFile(settingsPath, settingsContent, "utf-8");
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.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
2
  import process from "node:process";
3
- import fsPromises from "node:fs/promises";
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 fsPromises.stat(filePath);
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;
@@ -1143,7 +1143,7 @@ async function perfectionist() {
1143
1143
  async function detectCatalogUsage() {
1144
1144
  const workspaceFile = await findUp("pnpm-workspace.yaml");
1145
1145
  if (!workspaceFile) return false;
1146
- const yaml$1 = await fsPromises.readFile(workspaceFile, "utf-8");
1146
+ const yaml$1 = await fs.readFile(workspaceFile, "utf-8");
1147
1147
  return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
1148
1148
  }
1149
1149
  async function pnpm(options) {
@@ -1174,9 +1174,9 @@ async function pnpm(options) {
1174
1174
  plugins: { pnpm: pluginPnpm },
1175
1175
  rules: {
1176
1176
  "pnpm/yaml-enforce-settings": ["error", { settings: {
1177
- catalogMode: "prefer",
1178
1177
  shellEmulator: true,
1179
- trustPolicy: "no-downgrade"
1178
+ trustPolicy: "no-downgrade",
1179
+ ...catalogs ? { catalogMode: "prefer" } : {}
1180
1180
  } }],
1181
1181
  "pnpm/yaml-no-duplicate-catalog-item": "error",
1182
1182
  "pnpm/yaml-no-unused-catalog-item": "error"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "6.7.0",
4
+ "version": "6.7.1",
5
5
  "description": "Anthony's ESLint config",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
7
7
  "license": "MIT",
@@ -175,7 +175,7 @@
175
175
  "typescript": "^5.9.3",
176
176
  "vitest": "^4.0.15",
177
177
  "vue": "^3.5.25",
178
- "@antfu/eslint-config": "6.7.0"
178
+ "@antfu/eslint-config": "6.7.1"
179
179
  },
180
180
  "resolutions": {
181
181
  "@eslint-community/eslint-utils": "catalog:peer",