@antfu/eslint-config 7.0.0 → 7.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 +1 -1
- package/dist/cli.mjs +20 -20
- package/dist/index.d.mts +22 -2
- package/dist/index.mjs +14 -13
- package/dist/{lib-DkTwxxWo.mjs → lib-DDDPlqMl.mjs} +222 -221
- package/package.json +24 -22
package/README.md
CHANGED
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.
|
|
12
|
+
var version = "7.1.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
|
|
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);
|
|
@@ -172,13 +172,13 @@ 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.
|
|
176
|
-
"@next/eslint-plugin-next": "^16.1.
|
|
177
|
-
"@unocss/eslint-plugin": "^66.
|
|
175
|
+
"@eslint-react/eslint-plugin": "^2.7.2",
|
|
176
|
+
"@next/eslint-plugin-next": "^16.1.4",
|
|
177
|
+
"@unocss/eslint-plugin": "^66.6.0",
|
|
178
178
|
"astro-eslint-parser": "^1.2.2",
|
|
179
179
|
"eslint": "^9.39.2",
|
|
180
180
|
"eslint-plugin-astro": "^1.5.0",
|
|
181
|
-
"eslint-plugin-format": "^1.3.
|
|
181
|
+
"eslint-plugin-format": "^1.3.1",
|
|
182
182
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
183
183
|
"eslint-plugin-react-refresh": "^0.4.26",
|
|
184
184
|
"eslint-plugin-solid": "^0.14.5",
|
|
@@ -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
|
@@ -3591,7 +3591,7 @@ interface RuleOptions {
|
|
|
3591
3591
|
*/
|
|
3592
3592
|
'react/no-direct-mutation-state'?: Linter.RuleEntry<[]>;
|
|
3593
3593
|
/**
|
|
3594
|
-
*
|
|
3594
|
+
* Prevents duplicate 'key' props on sibling elements when rendering lists.
|
|
3595
3595
|
* @see https://eslint-react.xyz/docs/rules/no-duplicate-key
|
|
3596
3596
|
*/
|
|
3597
3597
|
'react/no-duplicate-key'?: Linter.RuleEntry<[]>;
|
|
@@ -3677,7 +3677,7 @@ interface RuleOptions {
|
|
|
3677
3677
|
*/
|
|
3678
3678
|
'react/no-string-refs'?: Linter.RuleEntry<[]>;
|
|
3679
3679
|
/**
|
|
3680
|
-
* Disallows unnecessary
|
|
3680
|
+
* Disallows unnecessary 'key' props on elements.
|
|
3681
3681
|
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-key
|
|
3682
3682
|
*/
|
|
3683
3683
|
'react/no-unnecessary-key'?: Linter.RuleEntry<[]>;
|
|
@@ -3696,6 +3696,11 @@ interface RuleOptions {
|
|
|
3696
3696
|
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-prefix
|
|
3697
3697
|
*/
|
|
3698
3698
|
'react/no-unnecessary-use-prefix'?: Linter.RuleEntry<[]>;
|
|
3699
|
+
/**
|
|
3700
|
+
* Disallows unnecessary usage of 'useRef'.
|
|
3701
|
+
* @see https://eslint-react.xyz/docs/rules/no-unnecessary-use-ref
|
|
3702
|
+
*/
|
|
3703
|
+
'react/no-unnecessary-use-ref'?: Linter.RuleEntry<[]>;
|
|
3699
3704
|
/**
|
|
3700
3705
|
* Warns about the use of 'UNSAFE_componentWillMount' in class components.
|
|
3701
3706
|
* @see https://eslint-react.xyz/docs/rules/no-unsafe-component-will-mount
|
|
@@ -7857,6 +7862,11 @@ interface RuleOptions {
|
|
|
7857
7862
|
* @see https://eslint.vuejs.org/rules/no-lifecycle-after-await.html
|
|
7858
7863
|
*/
|
|
7859
7864
|
'vue/no-lifecycle-after-await'?: Linter.RuleEntry<[]>;
|
|
7865
|
+
/**
|
|
7866
|
+
* disallow object, array, and function literals in template
|
|
7867
|
+
* @see https://eslint.vuejs.org/rules/no-literals-in-template.html
|
|
7868
|
+
*/
|
|
7869
|
+
'vue/no-literals-in-template'?: Linter.RuleEntry<[]>;
|
|
7860
7870
|
/**
|
|
7861
7871
|
* disallow unnecessary `<template>`
|
|
7862
7872
|
* @see https://eslint.vuejs.org/rules/no-lone-template.html
|
|
@@ -8067,6 +8077,11 @@ interface RuleOptions {
|
|
|
8067
8077
|
* @see https://eslint.vuejs.org/rules/no-undef-components.html
|
|
8068
8078
|
*/
|
|
8069
8079
|
'vue/no-undef-components'?: Linter.RuleEntry<VueNoUndefComponents>;
|
|
8080
|
+
/**
|
|
8081
|
+
* disallow use of undefined custom directives
|
|
8082
|
+
* @see https://eslint.vuejs.org/rules/no-undef-directives.html
|
|
8083
|
+
*/
|
|
8084
|
+
'vue/no-undef-directives'?: Linter.RuleEntry<VueNoUndefDirectives>;
|
|
8070
8085
|
/**
|
|
8071
8086
|
* disallow undefined properties
|
|
8072
8087
|
* @see https://eslint.vuejs.org/rules/no-undef-properties.html
|
|
@@ -18385,6 +18400,7 @@ type VueNoLoneTemplate = [] | [{
|
|
|
18385
18400
|
// ----- vue/no-multi-spaces -----
|
|
18386
18401
|
type VueNoMultiSpaces = [] | [{
|
|
18387
18402
|
ignoreProperties?: boolean;
|
|
18403
|
+
ignoreEOLComments?: boolean;
|
|
18388
18404
|
}];
|
|
18389
18405
|
// ----- vue/no-multiple-template-root -----
|
|
18390
18406
|
type VueNoMultipleTemplateRoot = [] | [{
|
|
@@ -18542,6 +18558,10 @@ type VueNoTemplateTargetBlank = [] | [{
|
|
|
18542
18558
|
type VueNoUndefComponents = [] | [{
|
|
18543
18559
|
ignorePatterns?: unknown[];
|
|
18544
18560
|
}];
|
|
18561
|
+
// ----- vue/no-undef-directives -----
|
|
18562
|
+
type VueNoUndefDirectives = [] | [{
|
|
18563
|
+
ignore?: string[];
|
|
18564
|
+
}];
|
|
18545
18565
|
// ----- vue/no-undef-properties -----
|
|
18546
18566
|
type VueNoUndefProperties = [] | [{
|
|
18547
18567
|
ignores?: string[];
|
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;
|
|
@@ -918,7 +918,7 @@ async function jsonc(options = {}) {
|
|
|
918
918
|
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
919
919
|
"jsonc/comma-dangle": ["error", "never"],
|
|
920
920
|
"jsonc/comma-style": ["error", "last"],
|
|
921
|
-
"jsonc/indent": ["error", indent],
|
|
921
|
+
"jsonc/indent": ["error", typeof indent === "number" ? indent : indent === "tab" ? "tab" : 2],
|
|
922
922
|
"jsonc/key-spacing": ["error", {
|
|
923
923
|
afterColon: true,
|
|
924
924
|
beforeColon: false
|
|
@@ -1144,7 +1144,7 @@ async function perfectionist() {
|
|
|
1144
1144
|
async function detectCatalogUsage() {
|
|
1145
1145
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1146
1146
|
if (!workspaceFile) return false;
|
|
1147
|
-
const yaml$1 = await
|
|
1147
|
+
const yaml$1 = await fs.readFile(workspaceFile, "utf-8");
|
|
1148
1148
|
return yaml$1.includes("catalog:") || yaml$1.includes("catalogs:");
|
|
1149
1149
|
}
|
|
1150
1150
|
async function pnpm(options) {
|
|
@@ -1400,7 +1400,7 @@ async function react(options = {}) {
|
|
|
1400
1400
|
"react-web-api/no-leaked-interval": "warn",
|
|
1401
1401
|
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1402
1402
|
"react-web-api/no-leaked-timeout": "warn",
|
|
1403
|
-
"react-refresh/only-export-components": ["
|
|
1403
|
+
"react-refresh/only-export-components": ["error", {
|
|
1404
1404
|
allowConstantExport: isAllowConstantExport,
|
|
1405
1405
|
allowExportNames: [...isUsingNext ? [
|
|
1406
1406
|
"dynamic",
|
|
@@ -1410,12 +1410,13 @@ async function react(options = {}) {
|
|
|
1410
1410
|
"runtime",
|
|
1411
1411
|
"preferredRegion",
|
|
1412
1412
|
"maxDuration",
|
|
1413
|
-
"config",
|
|
1414
1413
|
"generateStaticParams",
|
|
1415
1414
|
"metadata",
|
|
1416
1415
|
"generateMetadata",
|
|
1417
1416
|
"viewport",
|
|
1418
|
-
"generateViewport"
|
|
1417
|
+
"generateViewport",
|
|
1418
|
+
"generateImageMetadata",
|
|
1419
|
+
"generateSitemaps"
|
|
1419
1420
|
] : [], ...isUsingRemix || isUsingReactRouter ? [
|
|
1420
1421
|
"meta",
|
|
1421
1422
|
"links",
|
|
@@ -1806,7 +1807,7 @@ async function svelte(options = {}) {
|
|
|
1806
1807
|
"svelte/html-quotes": ["error", { prefer: quotes === "backtick" ? "double" : quotes }],
|
|
1807
1808
|
"svelte/indent": ["error", {
|
|
1808
1809
|
alignAttributesVertically: true,
|
|
1809
|
-
indent
|
|
1810
|
+
indent: typeof indent === "number" ? indent : indent === "tab" ? "tab" : 2
|
|
1810
1811
|
}],
|
|
1811
1812
|
"svelte/mustache-spacing": "error",
|
|
1812
1813
|
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
@@ -1883,7 +1884,7 @@ async function toml(options = {}) {
|
|
|
1883
1884
|
"toml/array-bracket-newline": "error",
|
|
1884
1885
|
"toml/array-bracket-spacing": "error",
|
|
1885
1886
|
"toml/array-element-newline": "error",
|
|
1886
|
-
"toml/indent": ["error", indent === "tab" ?
|
|
1887
|
+
"toml/indent": ["error", typeof indent === "number" ? indent : indent === "tab" ? "tab" : 2],
|
|
1887
1888
|
"toml/inline-table-curly-spacing": "error",
|
|
1888
1889
|
"toml/key-spacing": "error",
|
|
1889
1890
|
"toml/padding-line-between-pairs": "error",
|
|
@@ -2030,7 +2031,7 @@ async function typescript(options = {}) {
|
|
|
2030
2031
|
}] : [],
|
|
2031
2032
|
...erasableOnly ? [{
|
|
2032
2033
|
name: "antfu/typescript/erasable-syntax-only",
|
|
2033
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
2034
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-DDDPlqMl.mjs")) },
|
|
2034
2035
|
rules: {
|
|
2035
2036
|
"erasable-syntax-only/enums": "error",
|
|
2036
2037
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -2323,7 +2324,7 @@ async function yaml(options = {}) {
|
|
|
2323
2324
|
"yaml/flow-mapping-curly-spacing": "error",
|
|
2324
2325
|
"yaml/flow-sequence-bracket-newline": "error",
|
|
2325
2326
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2326
|
-
"yaml/indent": ["error", indent === "
|
|
2327
|
+
"yaml/indent": ["error", typeof indent === "number" ? indent : 2],
|
|
2327
2328
|
"yaml/key-spacing": "error",
|
|
2328
2329
|
"yaml/no-tab-indent": "error",
|
|
2329
2330
|
"yaml/quotes": ["error", {
|