@antfu/eslint-config 7.5.0 → 7.6.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/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import process from "node:process";
2
- import fs from "node:fs/promises";
3
- import fs$1 from "node: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 = "7.5.0";
12
+ var version = "7.6.0";
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 fs.readFile(pathPackageJSON, "utf-8");
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$1.existsSync(pathESLintIgnore)) {
150
+ if (fs.existsSync(pathESLintIgnore)) {
151
151
  p.log.step(c.cyan`Migrating existing .eslintignore`);
152
- const globs = parse(await fs.readFile(pathESLintIgnore, "utf-8")).globs();
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 fs.writeFile(pathFlatConfig, eslintConfigContent);
162
+ await fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
163
163
  p.log.success(c.green`Created ${configFileName}`);
164
- const files = fs$1.readdirSync(cwd);
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);
@@ -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 fs.readFile(pathPackageJSON, "utf-8");
197
+ const pkgContent = await fsPromises.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 fs.writeFile(pathPackageJSON, JSON.stringify(pkg, null, 2));
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$1.existsSync(dotVscodePath)) await fs.mkdir(dotVscodePath, { recursive: true });
240
- if (!fs$1.existsSync(settingsPath)) {
241
- await fs.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
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 fs.readFile(settingsPath, "utf8");
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 fs.writeFile(settingsPath, settingsContent, "utf-8");
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$1.existsSync(path.join(process.cwd(), "eslint.config.js"))) {
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
  }
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/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/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 fs from "node:fs/promises";
3
+ import fsPromises from "node:fs/promises";
4
4
  import { fileURLToPath } from "node:url";
5
- import fs$1 from "node:fs";
5
+ import fs 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 fs.stat(filePath);
30
+ const stats = await fsPromises.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$1.statSync(filePath, { throwIfNoEntry: false });
45
+ const stats = fs.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;
@@ -911,9 +911,11 @@ async function javascript(options = {}) {
911
911
  async function jsdoc(options = {}) {
912
912
  const { stylistic: stylistic$1 = true } = options;
913
913
  return [{
914
+ name: "antfu/jsdoc/setup",
915
+ plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) }
916
+ }, {
914
917
  files: [GLOB_SRC],
915
918
  name: "antfu/jsdoc/rules",
916
- plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
917
919
  rules: {
918
920
  "jsdoc/check-access": "warn",
919
921
  "jsdoc/check-param-names": "warn",
@@ -947,13 +949,12 @@ async function jsonc(options = {}) {
947
949
  GLOB_JSONC
948
950
  ], overrides = {}, stylistic: stylistic$1 = true } = options;
949
951
  const { indent = 2 } = typeof stylistic$1 === "boolean" ? {} : stylistic$1;
950
- const [pluginJsonc, parserJsonc] = await Promise.all([interopDefault(import("eslint-plugin-jsonc")), interopDefault(import("jsonc-eslint-parser"))]);
951
952
  return [{
952
953
  name: "antfu/jsonc/setup",
953
- plugins: { jsonc: pluginJsonc }
954
+ plugins: { jsonc: await interopDefault(import("eslint-plugin-jsonc")) }
954
955
  }, {
955
956
  files,
956
- languageOptions: { parser: parserJsonc },
957
+ language: "jsonc/x",
957
958
  name: "antfu/jsonc/rules",
958
959
  rules: {
959
960
  "jsonc/no-bigint-literals": "error",
@@ -1237,21 +1238,20 @@ async function perfectionist() {
1237
1238
  async function detectCatalogUsage() {
1238
1239
  const workspaceFile = await findUp("pnpm-workspace.yaml");
1239
1240
  if (!workspaceFile) return false;
1240
- const yaml$1 = await fs.readFile(workspaceFile, "utf-8");
1241
+ const yaml$1 = await fsPromises.readFile(workspaceFile, "utf-8");
1241
1242
  return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
1242
1243
  }
1243
1244
  async function pnpm(options) {
1244
- const [pluginPnpm, pluginYaml, yamlParser, jsoncParser] = await Promise.all([
1245
+ const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
1245
1246
  interopDefault(import("eslint-plugin-pnpm")),
1246
1247
  interopDefault(import("eslint-plugin-yml")),
1247
- interopDefault(import("yaml-eslint-parser")),
1248
- interopDefault(import("jsonc-eslint-parser"))
1248
+ interopDefault(import("yaml-eslint-parser"))
1249
1249
  ]);
1250
1250
  const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml: yaml$1 = true } = options;
1251
1251
  const configs$1 = [];
1252
1252
  if (json) configs$1.push({
1253
1253
  files: ["package.json", "**/package.json"],
1254
- languageOptions: { parser: jsoncParser },
1254
+ language: "jsonc/x",
1255
1255
  name: "antfu/pnpm/package-json",
1256
1256
  plugins: { pnpm: pluginPnpm },
1257
1257
  rules: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@antfu/eslint-config",
3
3
  "type": "module",
4
- "version": "7.5.0",
4
+ "version": "7.6.0",
5
5
  "description": "Anthony's ESLint config",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
7
7
  "license": "MIT",
@@ -142,7 +142,6 @@
142
142
  "eslint-plugin-yml": "^3.3.0",
143
143
  "eslint-processor-vue-blocks": "^2.0.0",
144
144
  "globals": "^17.3.0",
145
- "jsonc-eslint-parser": "^3.1.0",
146
145
  "local-pkg": "^1.1.2",
147
146
  "parse-gitignore": "^2.0.0",
148
147
  "toml-eslint-parser": "^1.0.3",
@@ -192,7 +191,7 @@
192
191
  "typescript": "^5.9.3",
193
192
  "vitest": "^4.0.18",
194
193
  "vue": "^3.5.29",
195
- "@antfu/eslint-config": "7.5.0"
194
+ "@antfu/eslint-config": "7.6.0"
196
195
  },
197
196
  "resolutions": {
198
197
  "@eslint-community/eslint-utils": "catalog:peer",