@antfu/eslint-config 2.27.2 → 3.0.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 +3 -1
- package/dist/cli.cjs +18 -17
- package/dist/cli.js +18 -17
- package/dist/index.cjs +42 -39
- package/dist/index.d.cts +119 -54
- package/dist/index.d.ts +119 -54
- package/dist/index.js +41 -38
- package/package.json +19 -18
package/README.md
CHANGED
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
- Single quotes, no semi
|
|
15
15
|
- Using [ESLint Stylistic](https://github.com/eslint-stylistic/eslint-stylistic)
|
|
16
16
|
- Respects `.gitignore` by default
|
|
17
|
-
-
|
|
17
|
+
- Requires ESLint v9.5.0+
|
|
18
18
|
|
|
19
19
|
> [!IMPORTANT]
|
|
20
20
|
> 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.
|
|
21
|
+
>
|
|
22
|
+
> Since v3.0.0, ESLint v9.5.0+ is now required.
|
|
21
23
|
|
|
22
24
|
## Usage
|
|
23
25
|
|
package/dist/cli.cjs
CHANGED
|
@@ -48,7 +48,7 @@ var import_picocolors = __toESM(require("picocolors"), 1);
|
|
|
48
48
|
var package_default = {
|
|
49
49
|
name: "@antfu/eslint-config",
|
|
50
50
|
type: "module",
|
|
51
|
-
version: "
|
|
51
|
+
version: "3.0.0",
|
|
52
52
|
packageManager: "pnpm@9.9.0",
|
|
53
53
|
description: "Anthony's ESLint config",
|
|
54
54
|
author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
@@ -90,7 +90,7 @@ var package_default = {
|
|
|
90
90
|
"@prettier/plugin-xml": "^3.4.1",
|
|
91
91
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
92
92
|
"astro-eslint-parser": "^1.0.2",
|
|
93
|
-
eslint: "
|
|
93
|
+
eslint: "^9.5.0",
|
|
94
94
|
"eslint-plugin-astro": "^1.2.0",
|
|
95
95
|
"eslint-plugin-format": ">=0.1.0",
|
|
96
96
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
@@ -143,25 +143,25 @@ var package_default = {
|
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
145
|
dependencies: {
|
|
146
|
-
"@antfu/install-pkg": "^0.4.
|
|
146
|
+
"@antfu/install-pkg": "^0.4.1",
|
|
147
147
|
"@clack/prompts": "^0.7.0",
|
|
148
148
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
149
|
-
"@stylistic/eslint-plugin": "^2.6.
|
|
150
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
151
|
-
"@typescript-eslint/parser": "^8.
|
|
152
|
-
"@vitest/eslint-plugin": "^1.0
|
|
153
|
-
"eslint-config-flat-gitignore": "^0.
|
|
149
|
+
"@stylistic/eslint-plugin": "^2.6.5",
|
|
150
|
+
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
151
|
+
"@typescript-eslint/parser": "^8.3.0",
|
|
152
|
+
"@vitest/eslint-plugin": "^1.1.0",
|
|
153
|
+
"eslint-config-flat-gitignore": "^0.3.0",
|
|
154
154
|
"eslint-flat-config-utils": "^0.3.1",
|
|
155
155
|
"eslint-merge-processors": "^0.1.0",
|
|
156
156
|
"eslint-plugin-antfu": "^2.3.6",
|
|
157
157
|
"eslint-plugin-command": "^0.2.3",
|
|
158
|
-
"eslint-plugin-import-x": "
|
|
158
|
+
"eslint-plugin-import-x": "^4.1.0",
|
|
159
159
|
"eslint-plugin-jsdoc": "^50.2.2",
|
|
160
160
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
161
161
|
"eslint-plugin-markdown": "^5.1.0",
|
|
162
162
|
"eslint-plugin-n": "^17.10.2",
|
|
163
163
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
164
|
-
"eslint-plugin-perfectionist": "^3.
|
|
164
|
+
"eslint-plugin-perfectionist": "^3.3.0",
|
|
165
165
|
"eslint-plugin-regexp": "^2.6.0",
|
|
166
166
|
"eslint-plugin-toml": "^0.11.1",
|
|
167
167
|
"eslint-plugin-unicorn": "^55.0.0",
|
|
@@ -181,14 +181,14 @@ var package_default = {
|
|
|
181
181
|
},
|
|
182
182
|
devDependencies: {
|
|
183
183
|
"@antfu/eslint-config": "workspace:*",
|
|
184
|
-
"@antfu/ni": "^0.
|
|
185
|
-
"@eslint-react/eslint-plugin": "^1.12.
|
|
184
|
+
"@antfu/ni": "^0.23.0",
|
|
185
|
+
"@eslint-react/eslint-plugin": "^1.12.3",
|
|
186
186
|
"@eslint/config-inspector": "^0.5.4",
|
|
187
187
|
"@prettier/plugin-xml": "^3.4.1",
|
|
188
|
-
"@stylistic/eslint-plugin-migrate": "^2.6.
|
|
188
|
+
"@stylistic/eslint-plugin-migrate": "^2.6.5",
|
|
189
189
|
"@types/eslint": "^9.6.1",
|
|
190
190
|
"@types/fs-extra": "^11.0.4",
|
|
191
|
-
"@types/node": "^22.5.
|
|
191
|
+
"@types/node": "^22.5.1",
|
|
192
192
|
"@types/prompts": "^2.4.9",
|
|
193
193
|
"@types/yargs": "^17.0.33",
|
|
194
194
|
"@unocss/eslint-plugin": "^0.62.3",
|
|
@@ -215,15 +215,16 @@ var package_default = {
|
|
|
215
215
|
svelte: "^4.2.19",
|
|
216
216
|
"svelte-eslint-parser": "^0.41.0",
|
|
217
217
|
tsup: "^8.2.4",
|
|
218
|
-
tsx: "^4.
|
|
218
|
+
tsx: "^4.19.0",
|
|
219
219
|
typescript: "^5.5.4",
|
|
220
220
|
vitest: "^2.0.5",
|
|
221
221
|
vue: "^3.4.38"
|
|
222
222
|
},
|
|
223
223
|
resolutions: {
|
|
224
224
|
"@eslint-community/eslint-utils": "^4.4.0",
|
|
225
|
-
"@typescript-eslint/utils": "^8.
|
|
226
|
-
|
|
225
|
+
"@typescript-eslint/utils": "^8.3.0",
|
|
226
|
+
eslint: "^9.9.1",
|
|
227
|
+
tsx: "^4.19.0"
|
|
227
228
|
},
|
|
228
229
|
"simple-git-hooks": {
|
|
229
230
|
"pre-commit": "npx lint-staged"
|
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,7 @@ import c from "picocolors";
|
|
|
19
19
|
var package_default = {
|
|
20
20
|
name: "@antfu/eslint-config",
|
|
21
21
|
type: "module",
|
|
22
|
-
version: "
|
|
22
|
+
version: "3.0.0",
|
|
23
23
|
packageManager: "pnpm@9.9.0",
|
|
24
24
|
description: "Anthony's ESLint config",
|
|
25
25
|
author: "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
@@ -61,7 +61,7 @@ var package_default = {
|
|
|
61
61
|
"@prettier/plugin-xml": "^3.4.1",
|
|
62
62
|
"@unocss/eslint-plugin": ">=0.50.0",
|
|
63
63
|
"astro-eslint-parser": "^1.0.2",
|
|
64
|
-
eslint: "
|
|
64
|
+
eslint: "^9.5.0",
|
|
65
65
|
"eslint-plugin-astro": "^1.2.0",
|
|
66
66
|
"eslint-plugin-format": ">=0.1.0",
|
|
67
67
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
@@ -114,25 +114,25 @@ var package_default = {
|
|
|
114
114
|
}
|
|
115
115
|
},
|
|
116
116
|
dependencies: {
|
|
117
|
-
"@antfu/install-pkg": "^0.4.
|
|
117
|
+
"@antfu/install-pkg": "^0.4.1",
|
|
118
118
|
"@clack/prompts": "^0.7.0",
|
|
119
119
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
120
|
-
"@stylistic/eslint-plugin": "^2.6.
|
|
121
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
122
|
-
"@typescript-eslint/parser": "^8.
|
|
123
|
-
"@vitest/eslint-plugin": "^1.0
|
|
124
|
-
"eslint-config-flat-gitignore": "^0.
|
|
120
|
+
"@stylistic/eslint-plugin": "^2.6.5",
|
|
121
|
+
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
|
122
|
+
"@typescript-eslint/parser": "^8.3.0",
|
|
123
|
+
"@vitest/eslint-plugin": "^1.1.0",
|
|
124
|
+
"eslint-config-flat-gitignore": "^0.3.0",
|
|
125
125
|
"eslint-flat-config-utils": "^0.3.1",
|
|
126
126
|
"eslint-merge-processors": "^0.1.0",
|
|
127
127
|
"eslint-plugin-antfu": "^2.3.6",
|
|
128
128
|
"eslint-plugin-command": "^0.2.3",
|
|
129
|
-
"eslint-plugin-import-x": "
|
|
129
|
+
"eslint-plugin-import-x": "^4.1.0",
|
|
130
130
|
"eslint-plugin-jsdoc": "^50.2.2",
|
|
131
131
|
"eslint-plugin-jsonc": "^2.16.0",
|
|
132
132
|
"eslint-plugin-markdown": "^5.1.0",
|
|
133
133
|
"eslint-plugin-n": "^17.10.2",
|
|
134
134
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
135
|
-
"eslint-plugin-perfectionist": "^3.
|
|
135
|
+
"eslint-plugin-perfectionist": "^3.3.0",
|
|
136
136
|
"eslint-plugin-regexp": "^2.6.0",
|
|
137
137
|
"eslint-plugin-toml": "^0.11.1",
|
|
138
138
|
"eslint-plugin-unicorn": "^55.0.0",
|
|
@@ -152,14 +152,14 @@ var package_default = {
|
|
|
152
152
|
},
|
|
153
153
|
devDependencies: {
|
|
154
154
|
"@antfu/eslint-config": "workspace:*",
|
|
155
|
-
"@antfu/ni": "^0.
|
|
156
|
-
"@eslint-react/eslint-plugin": "^1.12.
|
|
155
|
+
"@antfu/ni": "^0.23.0",
|
|
156
|
+
"@eslint-react/eslint-plugin": "^1.12.3",
|
|
157
157
|
"@eslint/config-inspector": "^0.5.4",
|
|
158
158
|
"@prettier/plugin-xml": "^3.4.1",
|
|
159
|
-
"@stylistic/eslint-plugin-migrate": "^2.6.
|
|
159
|
+
"@stylistic/eslint-plugin-migrate": "^2.6.5",
|
|
160
160
|
"@types/eslint": "^9.6.1",
|
|
161
161
|
"@types/fs-extra": "^11.0.4",
|
|
162
|
-
"@types/node": "^22.5.
|
|
162
|
+
"@types/node": "^22.5.1",
|
|
163
163
|
"@types/prompts": "^2.4.9",
|
|
164
164
|
"@types/yargs": "^17.0.33",
|
|
165
165
|
"@unocss/eslint-plugin": "^0.62.3",
|
|
@@ -186,15 +186,16 @@ var package_default = {
|
|
|
186
186
|
svelte: "^4.2.19",
|
|
187
187
|
"svelte-eslint-parser": "^0.41.0",
|
|
188
188
|
tsup: "^8.2.4",
|
|
189
|
-
tsx: "^4.
|
|
189
|
+
tsx: "^4.19.0",
|
|
190
190
|
typescript: "^5.5.4",
|
|
191
191
|
vitest: "^2.0.5",
|
|
192
192
|
vue: "^3.4.38"
|
|
193
193
|
},
|
|
194
194
|
resolutions: {
|
|
195
195
|
"@eslint-community/eslint-utils": "^4.4.0",
|
|
196
|
-
"@typescript-eslint/utils": "^8.
|
|
197
|
-
|
|
196
|
+
"@typescript-eslint/utils": "^8.3.0",
|
|
197
|
+
eslint: "^9.9.1",
|
|
198
|
+
tsx: "^4.19.0"
|
|
198
199
|
},
|
|
199
200
|
"simple-git-hooks": {
|
|
200
201
|
"pre-commit": "npx lint-staged"
|
package/dist/index.cjs
CHANGED
|
@@ -106,7 +106,7 @@ __export(src_exports, {
|
|
|
106
106
|
});
|
|
107
107
|
module.exports = __toCommonJS(src_exports);
|
|
108
108
|
|
|
109
|
-
// node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.
|
|
109
|
+
// node_modules/.pnpm/tsup@8.2.4_jiti@1.21.6_postcss@8.4.40_tsx@4.19.0_typescript@5.5.4_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
110
110
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
111
111
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
112
112
|
|
|
@@ -723,10 +723,14 @@ async function formatters(options = {}, stylistic2 = {}) {
|
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
// src/configs/ignores.ts
|
|
726
|
-
async function ignores() {
|
|
726
|
+
async function ignores(userIgnores = []) {
|
|
727
727
|
return [
|
|
728
728
|
{
|
|
729
|
-
ignores:
|
|
729
|
+
ignores: [
|
|
730
|
+
...GLOB_EXCLUDE,
|
|
731
|
+
...userIgnores
|
|
732
|
+
],
|
|
733
|
+
name: "antfu/ignores"
|
|
730
734
|
}
|
|
731
735
|
];
|
|
732
736
|
}
|
|
@@ -882,9 +886,6 @@ async function javascript(options = {}) {
|
|
|
882
886
|
],
|
|
883
887
|
"no-restricted-syntax": [
|
|
884
888
|
"error",
|
|
885
|
-
"DebuggerStatement",
|
|
886
|
-
"LabeledStatement",
|
|
887
|
-
"WithStatement",
|
|
888
889
|
"TSEnumDeclaration[const=true]",
|
|
889
890
|
"TSExportAssignment"
|
|
890
891
|
],
|
|
@@ -2082,7 +2083,7 @@ async function typescript(options = {}) {
|
|
|
2082
2083
|
}
|
|
2083
2084
|
|
|
2084
2085
|
// src/configs/unicorn.ts
|
|
2085
|
-
async function unicorn() {
|
|
2086
|
+
async function unicorn(options = {}) {
|
|
2086
2087
|
return [
|
|
2087
2088
|
{
|
|
2088
2089
|
name: "antfu/unicorn/rules",
|
|
@@ -2090,32 +2091,24 @@ async function unicorn() {
|
|
|
2090
2091
|
unicorn: import_eslint_plugin_unicorn.default
|
|
2091
2092
|
},
|
|
2092
2093
|
rules: {
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
// Prefer using number properties like `Number.isNaN` rather than `isNaN`
|
|
2112
|
-
"unicorn/prefer-number-properties": "error",
|
|
2113
|
-
// String methods startsWith/endsWith instead of more complicated stuff
|
|
2114
|
-
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2115
|
-
// Enforce throwing type error when throwing error while checking typeof
|
|
2116
|
-
"unicorn/prefer-type-error": "error",
|
|
2117
|
-
// Use new when throwing error
|
|
2118
|
-
"unicorn/throw-new-error": "error"
|
|
2094
|
+
...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
|
|
2095
|
+
"unicorn/consistent-empty-array-spread": "error",
|
|
2096
|
+
"unicorn/consistent-function-scoping": "error",
|
|
2097
|
+
"unicorn/error-message": "error",
|
|
2098
|
+
"unicorn/escape-case": "error",
|
|
2099
|
+
"unicorn/new-for-builtins": "error",
|
|
2100
|
+
"unicorn/no-instanceof-array": "error",
|
|
2101
|
+
"unicorn/no-new-array": "error",
|
|
2102
|
+
"unicorn/no-new-buffer": "error",
|
|
2103
|
+
"unicorn/number-literal-case": "error",
|
|
2104
|
+
"unicorn/prefer-dom-node-text-content": "error",
|
|
2105
|
+
"unicorn/prefer-includes": "error",
|
|
2106
|
+
"unicorn/prefer-node-protocol": "error",
|
|
2107
|
+
"unicorn/prefer-number-properties": "error",
|
|
2108
|
+
"unicorn/prefer-string-starts-ends-with": "error",
|
|
2109
|
+
"unicorn/prefer-type-error": "error",
|
|
2110
|
+
"unicorn/throw-new-error": "error"
|
|
2111
|
+
}
|
|
2119
2112
|
}
|
|
2120
2113
|
}
|
|
2121
2114
|
];
|
|
@@ -2408,8 +2401,6 @@ async function regexp(options = {}) {
|
|
|
2408
2401
|
// src/factory.ts
|
|
2409
2402
|
var flatConfigProps = [
|
|
2410
2403
|
"name",
|
|
2411
|
-
"files",
|
|
2412
|
-
"ignores",
|
|
2413
2404
|
"languageOptions",
|
|
2414
2405
|
"linterOptions",
|
|
2415
2406
|
"processor",
|
|
@@ -2447,6 +2438,7 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2447
2438
|
solid: enableSolid = false,
|
|
2448
2439
|
svelte: enableSvelte = false,
|
|
2449
2440
|
typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
|
|
2441
|
+
unicorn: enableUnicorn = true,
|
|
2450
2442
|
unocss: enableUnoCSS = false,
|
|
2451
2443
|
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
|
|
2452
2444
|
} = options;
|
|
@@ -2462,15 +2454,21 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2462
2454
|
const configs2 = [];
|
|
2463
2455
|
if (enableGitignore) {
|
|
2464
2456
|
if (typeof enableGitignore !== "boolean") {
|
|
2465
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(
|
|
2457
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2458
|
+
name: "antfu/gitignore",
|
|
2459
|
+
...enableGitignore
|
|
2460
|
+
})]));
|
|
2466
2461
|
} else {
|
|
2467
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2462
|
+
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
|
|
2463
|
+
name: "antfu/gitignore",
|
|
2464
|
+
strict: false
|
|
2465
|
+
})]));
|
|
2468
2466
|
}
|
|
2469
2467
|
}
|
|
2470
2468
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
2471
2469
|
const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
|
|
2472
2470
|
configs2.push(
|
|
2473
|
-
ignores(),
|
|
2471
|
+
ignores(options.ignores),
|
|
2474
2472
|
javascript({
|
|
2475
2473
|
isInEditor,
|
|
2476
2474
|
overrides: getOverrides(options, "javascript")
|
|
@@ -2483,11 +2481,13 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2483
2481
|
imports({
|
|
2484
2482
|
stylistic: stylisticOptions
|
|
2485
2483
|
}),
|
|
2486
|
-
unicorn(),
|
|
2487
2484
|
command(),
|
|
2488
2485
|
// Optional plugins (installed but not enabled by default)
|
|
2489
2486
|
perfectionist()
|
|
2490
2487
|
);
|
|
2488
|
+
if (enableUnicorn) {
|
|
2489
|
+
configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
|
|
2490
|
+
}
|
|
2491
2491
|
if (enableVue) {
|
|
2492
2492
|
componentExts.push("vue");
|
|
2493
2493
|
}
|
|
@@ -2596,6 +2596,9 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2596
2596
|
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2597
2597
|
));
|
|
2598
2598
|
}
|
|
2599
|
+
if ("files" in options) {
|
|
2600
|
+
throw new Error('[@antfu/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
|
|
2601
|
+
}
|
|
2599
2602
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2600
2603
|
if (key in options)
|
|
2601
2604
|
acc[key] = options[key];
|