@antfu/eslint-config 8.3.0 → 9.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 +4 -0
- package/dist/cli.mjs +26 -26
- package/dist/index.d.mts +1864 -555
- package/dist/index.mjs +14 -21
- package/dist/{lib-C1Uxp5ZW.mjs → lib-NWAatdeh.mjs} +249 -245
- package/package.json +60 -58
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 fsPromises from "node:fs/promises";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import 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
|
|
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
|
|
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;
|
|
@@ -1219,7 +1219,7 @@ async function perfectionist(options) {
|
|
|
1219
1219
|
async function detectCatalogUsage() {
|
|
1220
1220
|
const workspaceFile = await findUp("pnpm-workspace.yaml");
|
|
1221
1221
|
if (!workspaceFile) return false;
|
|
1222
|
-
const yaml = await
|
|
1222
|
+
const yaml = await fsPromises.readFile(workspaceFile, "utf-8");
|
|
1223
1223
|
return yaml.includes("catalog:") || yaml.includes("catalogs:");
|
|
1224
1224
|
}
|
|
1225
1225
|
async function pnpm(options) {
|
|
@@ -1366,17 +1366,12 @@ async function react(options = {}) {
|
|
|
1366
1366
|
const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
|
|
1367
1367
|
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
|
|
1368
1368
|
const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
|
|
1369
|
-
const plugins = pluginReact.configs.all.plugins;
|
|
1370
1369
|
return [
|
|
1371
1370
|
{
|
|
1372
1371
|
name: "antfu/react/setup",
|
|
1373
1372
|
plugins: {
|
|
1374
|
-
"react": plugins["@eslint-react"],
|
|
1375
|
-
"react-
|
|
1376
|
-
"react-naming-convention": plugins["@eslint-react/naming-convention"],
|
|
1377
|
-
"react-refresh": pluginReactRefresh,
|
|
1378
|
-
"react-rsc": plugins["@eslint-react/rsc"],
|
|
1379
|
-
"react-web-api": plugins["@eslint-react/web-api"]
|
|
1373
|
+
"react": pluginReact.configs.all.plugins["@eslint-react"],
|
|
1374
|
+
"react-refresh": pluginReactRefresh
|
|
1380
1375
|
}
|
|
1381
1376
|
},
|
|
1382
1377
|
{
|
|
@@ -1388,7 +1383,6 @@ async function react(options = {}) {
|
|
|
1388
1383
|
name: "antfu/react/rules",
|
|
1389
1384
|
rules: {
|
|
1390
1385
|
...pluginReact.configs.recommended.rules,
|
|
1391
|
-
"react/prefer-namespace-import": "error",
|
|
1392
1386
|
"react-refresh/only-export-components": ["error", {
|
|
1393
1387
|
allowConstantExport: isAllowConstantExport,
|
|
1394
1388
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1425,8 +1419,8 @@ async function react(options = {}) {
|
|
|
1425
1419
|
files: filesTypeAware,
|
|
1426
1420
|
name: "antfu/react/typescript",
|
|
1427
1421
|
rules: {
|
|
1428
|
-
"react-
|
|
1429
|
-
"react-
|
|
1422
|
+
"react/dom-no-string-style-prop": "off",
|
|
1423
|
+
"react/dom-no-unknown-property": "off"
|
|
1430
1424
|
}
|
|
1431
1425
|
},
|
|
1432
1426
|
...isTypeAware ? [{
|
|
@@ -2007,7 +2001,7 @@ async function typescript(options = {}) {
|
|
|
2007
2001
|
}] : [],
|
|
2008
2002
|
...erasableOnly ? [{
|
|
2009
2003
|
name: "antfu/typescript/erasable-syntax-only",
|
|
2010
|
-
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-
|
|
2004
|
+
plugins: { "erasable-syntax-only": await interopDefault(import("./lib-NWAatdeh.mjs")) },
|
|
2011
2005
|
rules: {
|
|
2012
2006
|
"erasable-syntax-only/enums": "error",
|
|
2013
2007
|
"erasable-syntax-only/import-aliases": "error",
|
|
@@ -2022,8 +2016,11 @@ async function typescript(options = {}) {
|
|
|
2022
2016
|
async function unicorn(options = {}) {
|
|
2023
2017
|
const { allRecommended = false, overrides = {} } = options;
|
|
2024
2018
|
return [{
|
|
2019
|
+
name: "antfu/unicorn/setup",
|
|
2020
|
+
plugins: { unicorn: pluginUnicorn }
|
|
2021
|
+
}, {
|
|
2022
|
+
files: [GLOB_SRC],
|
|
2025
2023
|
name: "antfu/unicorn/rules",
|
|
2026
|
-
plugins: { unicorn: pluginUnicorn },
|
|
2027
2024
|
rules: {
|
|
2028
2025
|
...allRecommended ? pluginUnicorn.configs.recommended.rules : {
|
|
2029
2026
|
"unicorn/consistent-empty-array-spread": "error",
|
|
@@ -2351,10 +2348,6 @@ const VuePackages = [
|
|
|
2351
2348
|
];
|
|
2352
2349
|
const defaultPluginRenaming = {
|
|
2353
2350
|
"@eslint-react": "react",
|
|
2354
|
-
"@eslint-react/dom": "react-dom",
|
|
2355
|
-
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2356
|
-
"@eslint-react/rsc": "react-rsc",
|
|
2357
|
-
"@eslint-react/web-api": "react-web-api",
|
|
2358
2351
|
"@next/next": "next",
|
|
2359
2352
|
"@stylistic": "style",
|
|
2360
2353
|
"@typescript-eslint": "ts",
|