@oliver139/eslint-config 4.1.0 → 4.2.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.md CHANGED
@@ -20,11 +20,6 @@
20
20
  - Respects `.gitignore` by default
21
21
  - Requires ESLint v9.5.0+
22
22
 
23
- > [!NOTE]
24
- > Since v1.0.0, this config is rewritten to the new [ESLint Flat config](https://eslint.org/docs/latest/use/configure/configuration-files-new), check the [release note](https://github.com/antfu/eslint-config/releases/tag/v1.0.0) for more details.
25
- >
26
- > Since v3.0.0, ESLint v9.5.0+ is now required.
27
-
28
23
  > [!WARNING]
29
24
  > I am super appreciative and even a bit flattered that so many of you are fond of using this config. For that reason, I tried to make it as flexible and customizable as possible to fit more use cases.
30
25
  >
@@ -808,8 +803,11 @@ Auto-fixing for the following rules are disabled when ESLint is running in a cod
808
803
  - [`prefer-const`](https://eslint.org/docs/rules/prefer-const)
809
804
  - [`test/no-only-tests`](https://github.com/levibuzolic/eslint-plugin-no-only-tests)
810
805
  - [`unused-imports/no-unused-imports`](https://www.npmjs.com/package/eslint-plugin-unused-imports)
806
+ - [`pnpm/json-enforce-catalog`](https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm#rules)
807
+ - [`pnpm/json-prefer-workspace-settings`](https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm#rules)
808
+ - [`pnpm/json-valid-catalog`](https://github.com/antfu/pnpm-workspace-utils/tree/main/packages/eslint-plugin-pnpm#rules)
811
809
 
812
- Since v3.16.0, they are no longer disabled, but made non-fixable using [this helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix).
810
+ > Since v3.16.0, they are no longer disabled, but made non-fixable using [this helper](https://github.com/antfu/eslint-flat-config-utils#composerdisablerulesfix).
813
811
 
814
812
  This is to prevent unused imports from getting removed by the editor during refactoring to get a better developer experience. Those rules will be applied when you run ESLint in the terminal or [Lint Staged](#lint-staged). If you don't want this behavior, you can disable them:
815
813
 
@@ -891,6 +889,10 @@ If you enjoy this code style, and would like to mention it in your project, here
891
889
 
892
890
  Well, you can still use Prettier to format files that are not supported well by ESLint yet, such as `.css`, `.html`, etc. See [formatters](#formatters) for more details.
893
891
 
892
+ ### oxlint?
893
+
894
+ We do have a plan to integrate [oxlint](https://github.com/oxc-project/oxc) in someway to speed up the linting process. However there are still some blocks we are waiting for. Track the progress [in this issue: **Oxlint Integration Plan**](https://github.com/antfu/eslint-config/issues/767).
895
+
894
896
  ### dprint?
895
897
 
896
898
  [dprint](https://dprint.dev/) is also a great formatter that with more abilities to customize. However, it's in the same model as Prettier which reads the AST and reprints the code from scratch. This means it's similar to Prettier, which ignores the original line breaks and might also cause the inconsistent diff. So in general, we prefer to use ESLint to format and lint JavaScript/TypeScript code.
package/bin/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.mjs'
@@ -1,15 +1,15 @@
1
1
  import process from "node:process";
2
+ import fsPromises from "node:fs/promises";
3
+ import fs from "node:fs";
4
+ import path from "node:path";
2
5
  import * as p from "@clack/prompts";
3
6
  import c, { green } from "ansis";
4
7
  import { cac } from "cac";
5
- import fs from "node:fs";
6
- import path from "node:path";
7
- import fsp from "node:fs/promises";
8
8
  import parse from "parse-gitignore";
9
9
  import { execSync } from "node:child_process";
10
10
 
11
11
  //#region package.json
12
- var version = "4.1.0";
12
+ var version = "4.2.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 fsp.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
150
  if (fs.existsSync(pathESLintIgnore)) {
151
151
  p.log.step(c.cyan`Migrating existing .eslintignore`);
152
- const globs = parse(await fsp.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,7 +159,7 @@ 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 fsp.writeFile(pathFlatConfig, eslintConfigContent);
162
+ await fsPromises.writeFile(pathFlatConfig, eslintConfigContent);
163
163
  p.log.success(c.green`Created ${configFileName}`);
164
164
  const files = fs.readdirSync(cwd);
165
165
  const legacyConfig = [];
@@ -172,20 +172,20 @@ 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.2.4",
176
- "@next/eslint-plugin-next": "^16.0.1",
177
- "@unocss/eslint-plugin": "^66.5.4",
175
+ "@eslint-react/eslint-plugin": "^2.3.13",
176
+ "@next/eslint-plugin-next": "^16.1.0",
177
+ "@unocss/eslint-plugin": "^66.5.10",
178
178
  "astro-eslint-parser": "^1.2.2",
179
- "eslint": "^9.38.0",
180
- "eslint-plugin-astro": "^1.4.0",
181
- "eslint-plugin-format": "^1.0.2",
179
+ "eslint": "^9.39.2",
180
+ "eslint-plugin-astro": "^1.5.0",
181
+ "eslint-plugin-format": "^1.1.0",
182
182
  "eslint-plugin-react-hooks": "^7.0.1",
183
- "eslint-plugin-react-refresh": "^0.4.24",
183
+ "eslint-plugin-react-refresh": "^0.4.26",
184
184
  "eslint-plugin-solid": "^0.14.5",
185
- "eslint-plugin-svelte": "^3.13.0",
185
+ "eslint-plugin-svelte": "^3.13.1",
186
186
  "prettier-plugin-astro": "^0.14.1",
187
187
  "prettier-plugin-slidev": "^1.0.5",
188
- "svelte-eslint-parser": "^1.4.0"
188
+ "svelte-eslint-parser": "^1.4.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 @oliver139/eslint-config to v${version}`);
197
- const pkgContent = await fsp.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["@oliver139/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 fsp.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.existsSync(dotVscodePath)) await fsp.mkdir(dotVscodePath, { recursive: true });
239
+ if (!fs.existsSync(dotVscodePath)) await fsPromises.mkdir(dotVscodePath, { recursive: true });
240
240
  if (!fs.existsSync(settingsPath)) {
241
- await fsp.writeFile(settingsPath, `{${vscodeSettingsString}}\n`, "utf-8");
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 fsp.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 fsp.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
  }