@antfu/eslint-config 9.4.0 → 9.5.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 +44 -0
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +1841 -189
- package/dist/index.mjs +76 -7
- package/package.json +13 -3
package/dist/index.mjs
CHANGED
|
@@ -305,6 +305,55 @@ async function angular(options = {}) {
|
|
|
305
305
|
];
|
|
306
306
|
}
|
|
307
307
|
//#endregion
|
|
308
|
+
//#region src/configs/antislop.ts
|
|
309
|
+
async function antislop(options = {}) {
|
|
310
|
+
const { overrides = {}, slop = true, sonarjs = true, typescript = false } = options;
|
|
311
|
+
await ensurePackages([...slop ? ["eslint-plugin-slop"] : [], ...sonarjs ? ["eslint-plugin-sonarjs"] : []]);
|
|
312
|
+
const [pluginSlop, pluginSonarjs] = await Promise.all([slop ? interopDefault(import("eslint-plugin-slop")) : void 0, sonarjs ? interopDefault(import("eslint-plugin-sonarjs")) : void 0]);
|
|
313
|
+
return [{
|
|
314
|
+
name: "antfu/antislop/rules",
|
|
315
|
+
plugins: {
|
|
316
|
+
...slop ? { slop: pluginSlop } : {},
|
|
317
|
+
...sonarjs ? { sonarjs: pluginSonarjs } : {}
|
|
318
|
+
},
|
|
319
|
+
...typeof slop === "object" ? { settings: { slop } } : {},
|
|
320
|
+
rules: {
|
|
321
|
+
...slop ? {
|
|
322
|
+
"slop/max-comment-length": "error",
|
|
323
|
+
"slop/no-chained-type-assertions": "error",
|
|
324
|
+
"slop/no-em-dash": "error",
|
|
325
|
+
"slop/no-jargon": "error",
|
|
326
|
+
"slop/no-trivial-functions": "error",
|
|
327
|
+
"slop/no-trivial-type-aliases": "error",
|
|
328
|
+
"slop/prefer-jsdoc": "error"
|
|
329
|
+
} : {},
|
|
330
|
+
...sonarjs ? {
|
|
331
|
+
"sonarjs/cognitive-complexity": "error",
|
|
332
|
+
"sonarjs/no-all-duplicated-branches": "error",
|
|
333
|
+
"sonarjs/no-collapsible-if": "error",
|
|
334
|
+
"sonarjs/no-commented-code": "error",
|
|
335
|
+
"sonarjs/no-dead-store": "error",
|
|
336
|
+
"sonarjs/no-duplicated-branches": "error",
|
|
337
|
+
"sonarjs/no-element-overwrite": "error",
|
|
338
|
+
"sonarjs/no-empty-collection": "error",
|
|
339
|
+
"sonarjs/no-gratuitous-expressions": "error",
|
|
340
|
+
"sonarjs/no-identical-conditions": "error",
|
|
341
|
+
"sonarjs/no-identical-expressions": "error",
|
|
342
|
+
"sonarjs/no-identical-functions": "error",
|
|
343
|
+
"sonarjs/no-invariant-returns": "error",
|
|
344
|
+
"sonarjs/no-inverted-boolean-check": "error",
|
|
345
|
+
"sonarjs/no-redundant-boolean": "error",
|
|
346
|
+
"sonarjs/no-redundant-jump": "error",
|
|
347
|
+
"sonarjs/no-unused-collection": "error",
|
|
348
|
+
"sonarjs/no-use-of-empty-return-value": "error",
|
|
349
|
+
"sonarjs/prefer-single-boolean-return": "error"
|
|
350
|
+
} : {},
|
|
351
|
+
...typescript ? { "ts/no-explicit-any": "error" } : {},
|
|
352
|
+
...overrides
|
|
353
|
+
}
|
|
354
|
+
}];
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
308
357
|
//#region src/configs/astro.ts
|
|
309
358
|
async function astro(options = {}) {
|
|
310
359
|
const { files = [GLOB_ASTRO], overrides = {}, stylistic = true } = options;
|
|
@@ -1228,7 +1277,7 @@ async function pnpm(options) {
|
|
|
1228
1277
|
interopDefault(import("eslint-plugin-yml")),
|
|
1229
1278
|
interopDefault(import("yaml-eslint-parser"))
|
|
1230
1279
|
]);
|
|
1231
|
-
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
|
|
1280
|
+
const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, stylistic = true, yaml = true } = options;
|
|
1232
1281
|
const configs = [];
|
|
1233
1282
|
if (json) configs.push({
|
|
1234
1283
|
files: ["package.json", "**/package.json"],
|
|
@@ -1260,7 +1309,14 @@ async function pnpm(options) {
|
|
|
1260
1309
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1261
1310
|
}
|
|
1262
1311
|
});
|
|
1263
|
-
if (
|
|
1312
|
+
if (yaml && stylistic) configs.push({
|
|
1313
|
+
files: ["pnpm-workspace.yaml"],
|
|
1314
|
+
languageOptions: { parser: yamlParser },
|
|
1315
|
+
name: "antfu/pnpm/pnpm-workspace-yaml-stylistic",
|
|
1316
|
+
plugins: { pnpm: pluginPnpm },
|
|
1317
|
+
rules: { "pnpm/yaml-blank-lines": "error" }
|
|
1318
|
+
});
|
|
1319
|
+
if (yaml && sort) configs.push({
|
|
1264
1320
|
files: ["pnpm-workspace.yaml"],
|
|
1265
1321
|
languageOptions: { parser: yamlParser },
|
|
1266
1322
|
name: "antfu/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1294,17 +1350,17 @@ async function pnpm(options) {
|
|
|
1294
1350
|
"blockExoticSubdeps",
|
|
1295
1351
|
"ignoredOptionalDependencies",
|
|
1296
1352
|
"minimumReleaseAge",
|
|
1297
|
-
"minimumReleaseAgeExclude",
|
|
1298
|
-
"minimumReleaseAgeExcludePrune",
|
|
1299
1353
|
"minimumReleaseAgeIgnoreMissingTime",
|
|
1300
1354
|
"minimumReleaseAgeStrict",
|
|
1355
|
+
"minimumReleaseAgeExcludePrune",
|
|
1356
|
+
"minimumReleaseAgeExclude",
|
|
1301
1357
|
"registrySupportsTimeField",
|
|
1302
1358
|
"resolutionMode",
|
|
1303
1359
|
"supportedArchitectures",
|
|
1304
1360
|
"trustLockfile",
|
|
1305
1361
|
"trustPolicy",
|
|
1306
|
-
"trustPolicyExclude",
|
|
1307
1362
|
"trustPolicyIgnoreAfter",
|
|
1363
|
+
"trustPolicyExclude",
|
|
1308
1364
|
"update"
|
|
1309
1365
|
],
|
|
1310
1366
|
...[
|
|
@@ -2423,6 +2479,11 @@ async function yaml(options = {}) {
|
|
|
2423
2479
|
"yaml/flow-sequence-bracket-spacing": "error",
|
|
2424
2480
|
"yaml/indent": ["error", typeof indent === "number" ? indent : 2],
|
|
2425
2481
|
"yaml/key-spacing": "error",
|
|
2482
|
+
"yaml/no-multiple-empty-lines": ["error", {
|
|
2483
|
+
max: 1,
|
|
2484
|
+
maxBOF: 0,
|
|
2485
|
+
maxEOF: 0
|
|
2486
|
+
}],
|
|
2426
2487
|
"yaml/no-tab-indent": "error",
|
|
2427
2488
|
"yaml/quotes": ["error", {
|
|
2428
2489
|
avoidEscape: true,
|
|
@@ -2495,7 +2556,7 @@ const defaultPluginRenaming = {
|
|
|
2495
2556
|
* The merged ESLint configurations.
|
|
2496
2557
|
*/
|
|
2497
2558
|
function antfu(options = {}, ...userConfigs) {
|
|
2498
|
-
const { angular: enableAngular = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, perfectionist: enablePerfectionist = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2559
|
+
const { angular: enableAngular = false, antislop: enableAntislop = false, astro: enableAstro = false, autoRenamePlugins = true, componentExts = [], e18e: enableE18e = true, gitignore: enableGitignore = true, ignores: userIgnores = [], imports: enableImports = true, jsdoc: enableJsdoc = true, jsx: enableJsx = true, nextjs: enableNextjs = false, node: enableNode = true, perfectionist: enablePerfectionist = true, pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"), react: enableReact = false, regexp: enableRegexp = true, solid: enableSolid = false, svelte: enableSvelte = false, type: appType = "app", typescript: enableTypeScript = isPackageExists("typescript") || isPackageExists("@typescript/native-preview"), unicorn: enableUnicorn = true, unocss: enableUnoCSS = false, vue: enableVue = VuePackages.some((i) => isPackageExists(i)) } = options;
|
|
2499
2560
|
let isInEditor = options.isInEditor;
|
|
2500
2561
|
if (isInEditor == null) {
|
|
2501
2562
|
isInEditor = isInEditorEnv();
|
|
@@ -2538,6 +2599,11 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2538
2599
|
overrides: getOverrides(options, "typescript"),
|
|
2539
2600
|
type: appType
|
|
2540
2601
|
}));
|
|
2602
|
+
if (enableAntislop) configs.push(antislop({
|
|
2603
|
+
...resolveSubOptions(options, "antislop"),
|
|
2604
|
+
overrides: getOverrides(options, "antislop"),
|
|
2605
|
+
typescript: !!enableTypeScript
|
|
2606
|
+
}));
|
|
2541
2607
|
if (stylisticOptions) configs.push(stylistic({
|
|
2542
2608
|
...stylisticOptions,
|
|
2543
2609
|
lessOpinionated: options.lessOpinionated,
|
|
@@ -2589,6 +2655,7 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2589
2655
|
configs.push(pnpm({
|
|
2590
2656
|
isInEditor,
|
|
2591
2657
|
json: options.jsonc !== false,
|
|
2658
|
+
stylistic: stylisticOptions,
|
|
2592
2659
|
yaml: options.yaml !== false,
|
|
2593
2660
|
...optionsPnpm
|
|
2594
2661
|
}));
|
|
@@ -2638,6 +2705,7 @@ function getOverrides(options, key) {
|
|
|
2638
2705
|
//#region src/config-presets.ts
|
|
2639
2706
|
const CONFIG_PRESET_FULL_ON = {
|
|
2640
2707
|
angular: true,
|
|
2708
|
+
antislop: true,
|
|
2641
2709
|
astro: true,
|
|
2642
2710
|
formatters: true,
|
|
2643
2711
|
gitignore: true,
|
|
@@ -2668,6 +2736,7 @@ const CONFIG_PRESET_FULL_ON = {
|
|
|
2668
2736
|
};
|
|
2669
2737
|
const CONFIG_PRESET_FULL_OFF = {
|
|
2670
2738
|
angular: false,
|
|
2739
|
+
antislop: false,
|
|
2671
2740
|
astro: false,
|
|
2672
2741
|
formatters: false,
|
|
2673
2742
|
gitignore: false,
|
|
@@ -2697,4 +2766,4 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2697
2766
|
//#region src/index.ts
|
|
2698
2767
|
var src_default = antfu;
|
|
2699
2768
|
//#endregion
|
|
2700
|
-
export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, angular, antfu, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
|
2769
|
+
export { CONFIG_PRESET_FULL_OFF, CONFIG_PRESET_FULL_ON, GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLE, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, StylisticConfigDefaults, angular, antfu, antislop, astro, combine, command, comments, src_default as default, defaultPluginRenaming, disables, ensurePackages, formatters, getOverrides, ignores, imports, interopDefault, isInEditorEnv, isInGitHooksOrLintStaged, isPackageInScope, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, parserPlain, perfectionist, pnpm, react, regexp, renamePluginInConfigs, renameRules, resolveSubOptions, solid, sortPackageJson, sortTsconfig, stylistic, svelte, test, toArray, toml, typescript, unicorn, unocss, vue, yaml };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antfu/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "9.
|
|
4
|
+
"version": "9.5.0",
|
|
5
5
|
"description": "Anthony's ESLint config",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com> (https://github.com/antfu/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"eslint-plugin-format": ">=0.1.0",
|
|
43
43
|
"eslint-plugin-jsx-a11y": ">=6.10.2",
|
|
44
44
|
"eslint-plugin-react-refresh": "^0.5.0",
|
|
45
|
+
"eslint-plugin-slop": ">=0.1.1",
|
|
45
46
|
"eslint-plugin-solid": "^0.17.0",
|
|
47
|
+
"eslint-plugin-sonarjs": ">=4.0.0",
|
|
46
48
|
"eslint-plugin-svelte": ">=2.35.1",
|
|
47
49
|
"eslint-plugin-vuejs-accessibility": "^2.4.1",
|
|
48
50
|
"prettier-plugin-astro": "^0.14.0",
|
|
@@ -89,9 +91,15 @@
|
|
|
89
91
|
"eslint-plugin-react-refresh": {
|
|
90
92
|
"optional": true
|
|
91
93
|
},
|
|
94
|
+
"eslint-plugin-slop": {
|
|
95
|
+
"optional": true
|
|
96
|
+
},
|
|
92
97
|
"eslint-plugin-solid": {
|
|
93
98
|
"optional": true
|
|
94
99
|
},
|
|
100
|
+
"eslint-plugin-sonarjs": {
|
|
101
|
+
"optional": true
|
|
102
|
+
},
|
|
95
103
|
"eslint-plugin-svelte": {
|
|
96
104
|
"optional": true
|
|
97
105
|
},
|
|
@@ -131,7 +139,7 @@
|
|
|
131
139
|
"eslint-plugin-n": "^18.3.0",
|
|
132
140
|
"eslint-plugin-no-only-tests": "^3.4.0",
|
|
133
141
|
"eslint-plugin-perfectionist": "^5.10.1",
|
|
134
|
-
"eslint-plugin-pnpm": "^1.
|
|
142
|
+
"eslint-plugin-pnpm": "^1.9.1",
|
|
135
143
|
"eslint-plugin-regexp": "^3.2.0",
|
|
136
144
|
"eslint-plugin-toml": "^1.5.0",
|
|
137
145
|
"eslint-plugin-unicorn": "^74.0.0",
|
|
@@ -151,7 +159,7 @@
|
|
|
151
159
|
"@angular-eslint/eslint-plugin-template": "^22.2.0",
|
|
152
160
|
"@angular-eslint/template-parser": "^22.2.0",
|
|
153
161
|
"@angular/core": "^22.1.4",
|
|
154
|
-
"@antfu/eslint-config": "9.
|
|
162
|
+
"@antfu/eslint-config": "9.5.0",
|
|
155
163
|
"@antfu/ni": "^30.5.0",
|
|
156
164
|
"@eslint-react/eslint-plugin": "^5.18.6",
|
|
157
165
|
"@eslint/config-inspector": "^3.3.0",
|
|
@@ -169,7 +177,9 @@
|
|
|
169
177
|
"eslint-plugin-format": "^2.0.1",
|
|
170
178
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
171
179
|
"eslint-plugin-react-refresh": "^0.5.5",
|
|
180
|
+
"eslint-plugin-slop": "^0.1.1",
|
|
172
181
|
"eslint-plugin-solid": "^0.17.0",
|
|
182
|
+
"eslint-plugin-sonarjs": "^4.2.0",
|
|
173
183
|
"eslint-plugin-svelte": "^3.23.0",
|
|
174
184
|
"eslint-plugin-vuejs-accessibility": "^2.6.0",
|
|
175
185
|
"eslint-typegen": "^2.3.1",
|