@antfu/eslint-config 9.4.1 → 9.5.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 +60 -12
- package/dist/cli.mjs +8 -7
- package/dist/index.d.mts +1751 -95
- package/dist/index.mjs +240 -123
- package/package.json +14 -4
package/dist/index.mjs
CHANGED
|
@@ -305,6 +305,75 @@ async function angular(options = {}) {
|
|
|
305
305
|
];
|
|
306
306
|
}
|
|
307
307
|
//#endregion
|
|
308
|
+
//#region src/configs/antislop.ts
|
|
309
|
+
async function antislop(options = {}) {
|
|
310
|
+
const { cognitiveComplexity = 15, overrides = {}, slop = true, sonarjs = true } = 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
|
+
{
|
|
315
|
+
name: "antfu/antislop/setup",
|
|
316
|
+
plugins: {
|
|
317
|
+
...slop ? { slop: pluginSlop } : {},
|
|
318
|
+
...sonarjs ? { sonarjs: pluginSonarjs } : {}
|
|
319
|
+
},
|
|
320
|
+
...typeof slop === "object" ? { settings: { slop } } : {}
|
|
321
|
+
},
|
|
322
|
+
...slop ? [{
|
|
323
|
+
files: [
|
|
324
|
+
...GLOB_ALL_SRC,
|
|
325
|
+
GLOB_JSONC,
|
|
326
|
+
GLOB_TOML,
|
|
327
|
+
GLOB_GRAPHQL
|
|
328
|
+
],
|
|
329
|
+
/**
|
|
330
|
+
* Markdown code fences are already scanned as part of the raw
|
|
331
|
+
* Markdown text, so exclude the virtual embedded-code files to
|
|
332
|
+
* avoid reporting the same em dash twice
|
|
333
|
+
*/
|
|
334
|
+
ignores: [GLOB_MARKDOWN_CODE],
|
|
335
|
+
name: "antfu/antislop/rules/universal",
|
|
336
|
+
rules: { "slop/no-em-dash": "error" }
|
|
337
|
+
}] : [],
|
|
338
|
+
{
|
|
339
|
+
files: [GLOB_SRC],
|
|
340
|
+
name: "antfu/antislop/rules/javascript",
|
|
341
|
+
rules: {
|
|
342
|
+
...slop ? {
|
|
343
|
+
"slop/max-comment-length": "error",
|
|
344
|
+
"slop/no-chained-type-assertions": "error",
|
|
345
|
+
"slop/no-jargon": "error",
|
|
346
|
+
"slop/no-trivial-functions": "error",
|
|
347
|
+
"slop/no-trivial-type-aliases": "error",
|
|
348
|
+
"slop/prefer-jsdoc": "error"
|
|
349
|
+
} : {},
|
|
350
|
+
...sonarjs ? {
|
|
351
|
+
...cognitiveComplexity === false ? {} : { "sonarjs/cognitive-complexity": ["error", cognitiveComplexity] },
|
|
352
|
+
"sonarjs/no-all-duplicated-branches": "error",
|
|
353
|
+
"sonarjs/no-collapsible-if": "error",
|
|
354
|
+
"sonarjs/no-commented-code": "error",
|
|
355
|
+
"sonarjs/no-dead-store": "error",
|
|
356
|
+
"sonarjs/no-duplicated-branches": "error",
|
|
357
|
+
"sonarjs/no-element-overwrite": "error",
|
|
358
|
+
"sonarjs/no-empty-collection": "error",
|
|
359
|
+
"sonarjs/no-gratuitous-expressions": "error",
|
|
360
|
+
"sonarjs/no-identical-conditions": "error",
|
|
361
|
+
"sonarjs/no-identical-expressions": "error",
|
|
362
|
+
"sonarjs/no-identical-functions": "error",
|
|
363
|
+
"sonarjs/no-invariant-returns": "error",
|
|
364
|
+
"sonarjs/no-inverted-boolean-check": "error",
|
|
365
|
+
"sonarjs/no-redundant-boolean": "error",
|
|
366
|
+
"sonarjs/no-redundant-jump": "error",
|
|
367
|
+
"sonarjs/no-unused-collection": "error",
|
|
368
|
+
"sonarjs/no-use-of-empty-return-value": "error",
|
|
369
|
+
"sonarjs/prefer-single-boolean-return": "error"
|
|
370
|
+
} : {},
|
|
371
|
+
...overrides
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
];
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
308
377
|
//#region src/configs/astro.ts
|
|
309
378
|
async function astro(options = {}) {
|
|
310
379
|
const { files = [GLOB_ASTRO], overrides = {}, stylistic = true } = options;
|
|
@@ -330,7 +399,12 @@ async function astro(options = {}) {
|
|
|
330
399
|
name: "antfu/astro/rules",
|
|
331
400
|
processor: "astro/client-side-ts",
|
|
332
401
|
rules: {
|
|
402
|
+
/**
|
|
403
|
+
* Astro uses top level await for e.g. data fetching
|
|
404
|
+
* https://docs.astro.build/en/guides/data-fetching/#fetch-in-astro
|
|
405
|
+
*/
|
|
333
406
|
"antfu/no-top-level-await": "off",
|
|
407
|
+
/** use recommended rules */
|
|
334
408
|
"astro/missing-client-only-directive-value": "error",
|
|
335
409
|
"astro/no-conflict-set-directives": "error",
|
|
336
410
|
"astro/no-deprecated-astro-canonicalurl": "error",
|
|
@@ -488,26 +562,136 @@ function mergePrettierOptions(options, overrides) {
|
|
|
488
562
|
plugins: [...overrides.plugins || [], ...options.plugins || []]
|
|
489
563
|
};
|
|
490
564
|
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
css
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
565
|
+
function buildCssConfigs(prettierOptions) {
|
|
566
|
+
return [
|
|
567
|
+
[
|
|
568
|
+
[GLOB_CSS, GLOB_POSTCSS],
|
|
569
|
+
"css",
|
|
570
|
+
"antfu/formatter/css"
|
|
571
|
+
],
|
|
572
|
+
[
|
|
573
|
+
[GLOB_SCSS],
|
|
574
|
+
"scss",
|
|
575
|
+
"antfu/formatter/scss"
|
|
576
|
+
],
|
|
577
|
+
[
|
|
578
|
+
[GLOB_LESS],
|
|
579
|
+
"less",
|
|
580
|
+
"antfu/formatter/less"
|
|
581
|
+
]
|
|
582
|
+
].map(([files, parser, name]) => ({
|
|
583
|
+
files: [...files],
|
|
584
|
+
languageOptions: { parser: parserPlain },
|
|
585
|
+
name,
|
|
586
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser })] }
|
|
587
|
+
}));
|
|
588
|
+
}
|
|
589
|
+
function buildXmlLikeConfig(prettierOptions, prettierXmlOptions, files, name) {
|
|
590
|
+
return {
|
|
591
|
+
files,
|
|
592
|
+
languageOptions: { parser: parserPlain },
|
|
593
|
+
name,
|
|
594
|
+
rules: { "format/prettier": ["error", mergePrettierOptions({
|
|
595
|
+
...prettierXmlOptions,
|
|
596
|
+
...prettierOptions
|
|
597
|
+
}, {
|
|
598
|
+
parser: "xml",
|
|
599
|
+
plugins: ["@prettier/plugin-xml"]
|
|
600
|
+
})] }
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function buildMarkdownConfigs(options, prettierOptions, dprintOptions) {
|
|
604
|
+
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
605
|
+
const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
|
|
606
|
+
const configs = [{
|
|
607
|
+
files: [GLOB_MARKDOWN],
|
|
608
|
+
ignores: GLOB_SLIDEV,
|
|
609
|
+
languageOptions: { parser: parserPlain },
|
|
610
|
+
name: "antfu/formatter/markdown",
|
|
611
|
+
rules: { [`format/${formater}`]: ["error", formater === "prettier" ? mergePrettierOptions(prettierOptions, {
|
|
612
|
+
embeddedLanguageFormatting: "off",
|
|
613
|
+
parser: "markdown"
|
|
614
|
+
}) : {
|
|
615
|
+
...dprintOptions,
|
|
616
|
+
language: "markdown"
|
|
617
|
+
}] }
|
|
618
|
+
}];
|
|
619
|
+
if (options.slidev) configs.push({
|
|
620
|
+
files: GLOB_SLIDEV,
|
|
621
|
+
languageOptions: { parser: parserPlain },
|
|
622
|
+
name: "antfu/formatter/slidev",
|
|
623
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
|
|
624
|
+
embeddedLanguageFormatting: "off",
|
|
625
|
+
parser: "slidev",
|
|
626
|
+
plugins: ["prettier-plugin-slidev"]
|
|
627
|
+
})] }
|
|
628
|
+
});
|
|
629
|
+
return configs;
|
|
630
|
+
}
|
|
631
|
+
function buildAstroConfigs(prettierOptions) {
|
|
632
|
+
return [{
|
|
633
|
+
files: [GLOB_ASTRO],
|
|
634
|
+
languageOptions: { parser: parserPlain },
|
|
635
|
+
name: "antfu/formatter/astro",
|
|
636
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
|
|
637
|
+
parser: "astro",
|
|
638
|
+
plugins: ["prettier-plugin-astro"]
|
|
639
|
+
})] }
|
|
640
|
+
}, {
|
|
641
|
+
files: [GLOB_ASTRO, GLOB_ASTRO_TS],
|
|
642
|
+
name: "antfu/formatter/astro/disables",
|
|
643
|
+
rules: {
|
|
644
|
+
"style/arrow-parens": "off",
|
|
645
|
+
"style/block-spacing": "off",
|
|
646
|
+
"style/comma-dangle": "off",
|
|
647
|
+
"style/indent": "off",
|
|
648
|
+
"style/no-multi-spaces": "off",
|
|
649
|
+
"style/quotes": "off",
|
|
650
|
+
"style/semi": "off"
|
|
651
|
+
}
|
|
652
|
+
}];
|
|
653
|
+
}
|
|
654
|
+
function resolveFormattersOptions(options) {
|
|
655
|
+
if (options !== true) return options;
|
|
656
|
+
const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
|
|
657
|
+
return {
|
|
658
|
+
astro: isPackageInScope("prettier-plugin-astro"),
|
|
659
|
+
css: true,
|
|
660
|
+
graphql: true,
|
|
661
|
+
html: true,
|
|
662
|
+
markdown: true,
|
|
663
|
+
slidev: isPackageExists("@slidev/cli"),
|
|
664
|
+
svg: isPrettierPluginXmlInScope,
|
|
665
|
+
xml: isPrettierPluginXmlInScope
|
|
666
|
+
};
|
|
667
|
+
}
|
|
668
|
+
function buildHtmlConfig(prettierOptions) {
|
|
669
|
+
return {
|
|
670
|
+
files: [GLOB_HTML],
|
|
671
|
+
languageOptions: { parser: parserPlain },
|
|
672
|
+
name: "antfu/formatter/html",
|
|
673
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function buildGraphqlConfig(prettierOptions) {
|
|
677
|
+
return {
|
|
678
|
+
files: [GLOB_GRAPHQL],
|
|
679
|
+
languageOptions: { parser: parserPlain },
|
|
680
|
+
name: "antfu/formatter/graphql",
|
|
681
|
+
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
function getFormattersPackagesToEnsure(options) {
|
|
685
|
+
return [
|
|
506
686
|
"eslint-plugin-format",
|
|
507
687
|
options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
|
|
508
688
|
options.astro ? "prettier-plugin-astro" : void 0,
|
|
509
689
|
options.xml || options.svg ? "@prettier/plugin-xml" : void 0
|
|
510
|
-
]
|
|
690
|
+
];
|
|
691
|
+
}
|
|
692
|
+
async function formatters(rawOptions = {}, stylistic = {}) {
|
|
693
|
+
const options = resolveFormattersOptions(rawOptions);
|
|
694
|
+
await ensurePackages(getFormattersPackagesToEnsure(options));
|
|
511
695
|
if (options.slidev && options.markdown !== true && options.markdown !== "prettier") throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
|
|
512
696
|
const { indent, quotes, semi } = {
|
|
513
697
|
...StylisticConfigDefaults,
|
|
@@ -538,109 +722,13 @@ async function formatters(options = {}, stylistic = {}) {
|
|
|
538
722
|
name: "antfu/formatter/setup",
|
|
539
723
|
plugins: { format: await interopDefault(import("eslint-plugin-format")) }
|
|
540
724
|
}];
|
|
541
|
-
if (options.css) configs.push(
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
languageOptions: { parser: parserPlain },
|
|
549
|
-
name: "antfu/formatter/scss",
|
|
550
|
-
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "scss" })] }
|
|
551
|
-
}, {
|
|
552
|
-
files: [GLOB_LESS],
|
|
553
|
-
languageOptions: { parser: parserPlain },
|
|
554
|
-
name: "antfu/formatter/less",
|
|
555
|
-
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "less" })] }
|
|
556
|
-
});
|
|
557
|
-
if (options.html) configs.push({
|
|
558
|
-
files: [GLOB_HTML],
|
|
559
|
-
languageOptions: { parser: parserPlain },
|
|
560
|
-
name: "antfu/formatter/html",
|
|
561
|
-
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "html" })] }
|
|
562
|
-
});
|
|
563
|
-
if (options.xml) configs.push({
|
|
564
|
-
files: [GLOB_XML],
|
|
565
|
-
languageOptions: { parser: parserPlain },
|
|
566
|
-
name: "antfu/formatter/xml",
|
|
567
|
-
rules: { "format/prettier": ["error", mergePrettierOptions({
|
|
568
|
-
...prettierXmlOptions,
|
|
569
|
-
...prettierOptions
|
|
570
|
-
}, {
|
|
571
|
-
parser: "xml",
|
|
572
|
-
plugins: ["@prettier/plugin-xml"]
|
|
573
|
-
})] }
|
|
574
|
-
});
|
|
575
|
-
if (options.svg) configs.push({
|
|
576
|
-
files: [GLOB_SVG],
|
|
577
|
-
languageOptions: { parser: parserPlain },
|
|
578
|
-
name: "antfu/formatter/svg",
|
|
579
|
-
rules: { "format/prettier": ["error", mergePrettierOptions({
|
|
580
|
-
...prettierXmlOptions,
|
|
581
|
-
...prettierOptions
|
|
582
|
-
}, {
|
|
583
|
-
parser: "xml",
|
|
584
|
-
plugins: ["@prettier/plugin-xml"]
|
|
585
|
-
})] }
|
|
586
|
-
});
|
|
587
|
-
if (options.markdown) {
|
|
588
|
-
const formater = options.markdown === true ? "prettier" : options.markdown;
|
|
589
|
-
const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
|
|
590
|
-
configs.push({
|
|
591
|
-
files: [GLOB_MARKDOWN],
|
|
592
|
-
ignores: GLOB_SLIDEV,
|
|
593
|
-
languageOptions: { parser: parserPlain },
|
|
594
|
-
name: "antfu/formatter/markdown",
|
|
595
|
-
rules: { [`format/${formater}`]: ["error", formater === "prettier" ? mergePrettierOptions(prettierOptions, {
|
|
596
|
-
embeddedLanguageFormatting: "off",
|
|
597
|
-
parser: "markdown"
|
|
598
|
-
}) : {
|
|
599
|
-
...dprintOptions,
|
|
600
|
-
language: "markdown"
|
|
601
|
-
}] }
|
|
602
|
-
});
|
|
603
|
-
if (options.slidev) configs.push({
|
|
604
|
-
files: GLOB_SLIDEV,
|
|
605
|
-
languageOptions: { parser: parserPlain },
|
|
606
|
-
name: "antfu/formatter/slidev",
|
|
607
|
-
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
|
|
608
|
-
embeddedLanguageFormatting: "off",
|
|
609
|
-
parser: "slidev",
|
|
610
|
-
plugins: ["prettier-plugin-slidev"]
|
|
611
|
-
})] }
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
if (options.astro) {
|
|
615
|
-
configs.push({
|
|
616
|
-
files: [GLOB_ASTRO],
|
|
617
|
-
languageOptions: { parser: parserPlain },
|
|
618
|
-
name: "antfu/formatter/astro",
|
|
619
|
-
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, {
|
|
620
|
-
parser: "astro",
|
|
621
|
-
plugins: ["prettier-plugin-astro"]
|
|
622
|
-
})] }
|
|
623
|
-
});
|
|
624
|
-
configs.push({
|
|
625
|
-
files: [GLOB_ASTRO, GLOB_ASTRO_TS],
|
|
626
|
-
name: "antfu/formatter/astro/disables",
|
|
627
|
-
rules: {
|
|
628
|
-
"style/arrow-parens": "off",
|
|
629
|
-
"style/block-spacing": "off",
|
|
630
|
-
"style/comma-dangle": "off",
|
|
631
|
-
"style/indent": "off",
|
|
632
|
-
"style/no-multi-spaces": "off",
|
|
633
|
-
"style/quotes": "off",
|
|
634
|
-
"style/semi": "off"
|
|
635
|
-
}
|
|
636
|
-
});
|
|
637
|
-
}
|
|
638
|
-
if (options.graphql) configs.push({
|
|
639
|
-
files: [GLOB_GRAPHQL],
|
|
640
|
-
languageOptions: { parser: parserPlain },
|
|
641
|
-
name: "antfu/formatter/graphql",
|
|
642
|
-
rules: { "format/prettier": ["error", mergePrettierOptions(prettierOptions, { parser: "graphql" })] }
|
|
643
|
-
});
|
|
725
|
+
if (options.css) configs.push(...buildCssConfigs(prettierOptions));
|
|
726
|
+
if (options.html) configs.push(buildHtmlConfig(prettierOptions));
|
|
727
|
+
if (options.xml) configs.push(buildXmlLikeConfig(prettierOptions, prettierXmlOptions, [GLOB_XML], "antfu/formatter/xml"));
|
|
728
|
+
if (options.svg) configs.push(buildXmlLikeConfig(prettierOptions, prettierXmlOptions, [GLOB_SVG], "antfu/formatter/svg"));
|
|
729
|
+
if (options.markdown) configs.push(...buildMarkdownConfigs(options, prettierOptions, dprintOptions));
|
|
730
|
+
if (options.astro) configs.push(...buildAstroConfigs(prettierOptions));
|
|
731
|
+
if (options.graphql) configs.push(buildGraphqlConfig(prettierOptions));
|
|
644
732
|
return configs;
|
|
645
733
|
}
|
|
646
734
|
//#endregion
|
|
@@ -1053,6 +1141,11 @@ async function markdown(options = {}) {
|
|
|
1053
1141
|
files,
|
|
1054
1142
|
ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
|
|
1055
1143
|
name: "antfu/markdown/processor",
|
|
1144
|
+
/**
|
|
1145
|
+
* `eslint-plugin-markdown` only creates virtual files for code blocks,
|
|
1146
|
+
* but not the markdown file itself. We use `eslint-merge-processors` to
|
|
1147
|
+
* add a pass-through processor for the markdown file itself.
|
|
1148
|
+
*/
|
|
1056
1149
|
processor: mergeProcessors([markdown.processors.markdown, processorPassThrough])
|
|
1057
1150
|
},
|
|
1058
1151
|
{
|
|
@@ -1066,6 +1159,7 @@ async function markdown(options = {}) {
|
|
|
1066
1159
|
rules: {
|
|
1067
1160
|
...markdown.configs.recommended.at(0)?.rules,
|
|
1068
1161
|
"markdown/fenced-code-language": "off",
|
|
1162
|
+
/** https://github.com/eslint/markdown/issues/294 */
|
|
1069
1163
|
"markdown/no-missing-label-refs": "off",
|
|
1070
1164
|
...overridesMarkdown
|
|
1071
1165
|
}
|
|
@@ -1260,14 +1354,14 @@ async function pnpm(options) {
|
|
|
1260
1354
|
"pnpm/yaml-no-unused-catalog-item": "error"
|
|
1261
1355
|
}
|
|
1262
1356
|
});
|
|
1263
|
-
if (
|
|
1357
|
+
if (stylistic) configs.push({
|
|
1264
1358
|
files: ["pnpm-workspace.yaml"],
|
|
1265
1359
|
languageOptions: { parser: yamlParser },
|
|
1266
1360
|
name: "antfu/pnpm/pnpm-workspace-yaml-stylistic",
|
|
1267
1361
|
plugins: { pnpm: pluginPnpm },
|
|
1268
1362
|
rules: { "pnpm/yaml-blank-lines": "error" }
|
|
1269
1363
|
});
|
|
1270
|
-
if (
|
|
1364
|
+
if (sort) configs.push({
|
|
1271
1365
|
files: ["pnpm-workspace.yaml"],
|
|
1272
1366
|
languageOptions: { parser: yamlParser },
|
|
1273
1367
|
name: "antfu/pnpm/pnpm-workspace-yaml-sort",
|
|
@@ -1516,6 +1610,7 @@ async function react(options = {}) {
|
|
|
1516
1610
|
name: "antfu/react/rules",
|
|
1517
1611
|
rules: {
|
|
1518
1612
|
...pluginReact.configs.recommended.rules,
|
|
1613
|
+
/** preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src */
|
|
1519
1614
|
"react-refresh/only-export-components": ["error", {
|
|
1520
1615
|
allowConstantExport: isAllowConstantExport,
|
|
1521
1616
|
allowExportNames: [...isUsingNext ? [
|
|
@@ -1552,6 +1647,7 @@ async function react(options = {}) {
|
|
|
1552
1647
|
files: filesTypeAware,
|
|
1553
1648
|
name: "antfu/react/typescript",
|
|
1554
1649
|
rules: {
|
|
1650
|
+
/** Disables rules that are already handled by TypeScript */
|
|
1555
1651
|
"react/dom-no-string-style-prop": "off",
|
|
1556
1652
|
"react/dom-no-unknown-property": "off"
|
|
1557
1653
|
}
|
|
@@ -1604,17 +1700,23 @@ async function solid(options = {}) {
|
|
|
1604
1700
|
},
|
|
1605
1701
|
name: "antfu/solid/rules",
|
|
1606
1702
|
rules: {
|
|
1703
|
+
/** reactivity */
|
|
1607
1704
|
"solid/components-return-once": "warn",
|
|
1608
1705
|
"solid/event-handlers": ["error", {
|
|
1706
|
+
/** if true, don't warn on ambiguously named event handlers like `onclick` or `onchange` */
|
|
1609
1707
|
ignoreCase: false,
|
|
1708
|
+
/** if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6. */
|
|
1610
1709
|
warnOnSpread: false
|
|
1611
1710
|
}],
|
|
1711
|
+
/** these rules are mostly style suggestions */
|
|
1612
1712
|
"solid/imports": "error",
|
|
1713
|
+
/** identifier usage is important */
|
|
1613
1714
|
"solid/jsx-no-duplicate-props": "error",
|
|
1614
1715
|
"solid/jsx-no-script-url": "error",
|
|
1615
1716
|
"solid/jsx-no-undef": "error",
|
|
1616
1717
|
"solid/jsx-uses-vars": "error",
|
|
1617
1718
|
"solid/no-destructure": "error",
|
|
1719
|
+
/** security problems */
|
|
1618
1720
|
"solid/no-innerhtml": ["error", { allowStatic: true }],
|
|
1619
1721
|
"solid/no-react-deps": "error",
|
|
1620
1722
|
"solid/no-react-specific-props": "error",
|
|
@@ -2066,6 +2168,7 @@ async function typescript(options = {}) {
|
|
|
2066
2168
|
}
|
|
2067
2169
|
return [
|
|
2068
2170
|
{
|
|
2171
|
+
/** Install the plugins without globs, so they can be configured separately. */
|
|
2069
2172
|
name: "antfu/typescript/setup",
|
|
2070
2173
|
plugins: {
|
|
2071
2174
|
antfu: pluginAntfu,
|
|
@@ -2208,6 +2311,10 @@ async function vue(options = {}) {
|
|
|
2208
2311
|
...a11y ? [interopDefault(import("eslint-plugin-vuejs-accessibility"))] : []
|
|
2209
2312
|
]);
|
|
2210
2313
|
return [{
|
|
2314
|
+
/**
|
|
2315
|
+
* This allows Vue plugin to work with auto imports
|
|
2316
|
+
* https://github.com/vuejs/eslint-plugin-vue/pull/2422
|
|
2317
|
+
*/
|
|
2211
2318
|
languageOptions: { globals: {
|
|
2212
2319
|
computed: "readonly",
|
|
2213
2320
|
defineEmits: "readonly",
|
|
@@ -2278,6 +2385,7 @@ async function vue(options = {}) {
|
|
|
2278
2385
|
] }],
|
|
2279
2386
|
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
2280
2387
|
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
2388
|
+
/** this is deprecated */
|
|
2281
2389
|
"vue/component-tags-order": "off",
|
|
2282
2390
|
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
2283
2391
|
"vue/define-macros-order": ["error", { order: [
|
|
@@ -2459,6 +2567,7 @@ async function e18e(options = {}) {
|
|
|
2459
2567
|
...moduleReplacements ? { ...configs.moduleReplacements.rules } : {},
|
|
2460
2568
|
...performanceImprovements ? { ...configs.performanceImprovements.rules } : {},
|
|
2461
2569
|
...type === "lib" ? {} : { "e18e/prefer-static-regex": "off" },
|
|
2570
|
+
/** these are a bit opinionated and dangerous (introducing behavioral changes), so we'll disable them by default for now */
|
|
2462
2571
|
"e18e/prefer-array-at": "off",
|
|
2463
2572
|
"e18e/prefer-array-from-map": "off",
|
|
2464
2573
|
"e18e/prefer-array-to-reversed": "off",
|
|
@@ -2507,7 +2616,7 @@ const defaultPluginRenaming = {
|
|
|
2507
2616
|
* The merged ESLint configurations.
|
|
2508
2617
|
*/
|
|
2509
2618
|
function antfu(options = {}, ...userConfigs) {
|
|
2510
|
-
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;
|
|
2619
|
+
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;
|
|
2511
2620
|
let isInEditor = options.isInEditor;
|
|
2512
2621
|
if (isInEditor == null) {
|
|
2513
2622
|
isInEditor = isInEditorEnv();
|
|
@@ -2550,6 +2659,11 @@ function antfu(options = {}, ...userConfigs) {
|
|
|
2550
2659
|
overrides: getOverrides(options, "typescript"),
|
|
2551
2660
|
type: appType
|
|
2552
2661
|
}));
|
|
2662
|
+
if (enableAntislop) configs.push(antislop({
|
|
2663
|
+
...resolveSubOptions(options, "antislop"),
|
|
2664
|
+
overrides: getOverrides(options, "antislop"),
|
|
2665
|
+
typescript: !!enableTypeScript
|
|
2666
|
+
}));
|
|
2553
2667
|
if (stylisticOptions) configs.push(stylistic({
|
|
2554
2668
|
...stylisticOptions,
|
|
2555
2669
|
lessOpinionated: options.lessOpinionated,
|
|
@@ -2649,8 +2763,10 @@ function getOverrides(options, key) {
|
|
|
2649
2763
|
}
|
|
2650
2764
|
//#endregion
|
|
2651
2765
|
//#region src/config-presets.ts
|
|
2766
|
+
/** @keep-sorted */
|
|
2652
2767
|
const CONFIG_PRESET_FULL_ON = {
|
|
2653
2768
|
angular: true,
|
|
2769
|
+
antislop: true,
|
|
2654
2770
|
astro: true,
|
|
2655
2771
|
formatters: true,
|
|
2656
2772
|
gitignore: true,
|
|
@@ -2681,6 +2797,7 @@ const CONFIG_PRESET_FULL_ON = {
|
|
|
2681
2797
|
};
|
|
2682
2798
|
const CONFIG_PRESET_FULL_OFF = {
|
|
2683
2799
|
angular: false,
|
|
2800
|
+
antislop: false,
|
|
2684
2801
|
astro: false,
|
|
2685
2802
|
formatters: false,
|
|
2686
2803
|
gitignore: false,
|
|
@@ -2710,4 +2827,4 @@ const CONFIG_PRESET_FULL_OFF = {
|
|
|
2710
2827
|
//#region src/index.ts
|
|
2711
2828
|
var src_default = antfu;
|
|
2712
2829
|
//#endregion
|
|
2713
|
-
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 };
|
|
2830
|
+
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.1",
|
|
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
|
},
|
|
@@ -151,10 +159,10 @@
|
|
|
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.1",
|
|
155
163
|
"@antfu/ni": "^30.5.0",
|
|
156
164
|
"@eslint-react/eslint-plugin": "^5.18.6",
|
|
157
|
-
"@eslint/config-inspector": "^3.
|
|
165
|
+
"@eslint/config-inspector": "^3.4.0",
|
|
158
166
|
"@next/eslint-plugin-next": "^16.3.3",
|
|
159
167
|
"@prettier/plugin-xml": "^3.4.2",
|
|
160
168
|
"@types/eslint-plugin-jsx-a11y": "^6.10.1",
|
|
@@ -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.2",
|
|
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",
|
|
@@ -216,7 +226,7 @@
|
|
|
216
226
|
"build": "nr gen && tsdown --clean --dts",
|
|
217
227
|
"stub": "tsdown",
|
|
218
228
|
"dev": "npx @eslint/config-inspector --config eslint.config.ts",
|
|
219
|
-
"build:inspector": "pnpm build && npx @eslint/config-inspector build --config eslint.config.ts --out-dir ./.eslint-config-inspector",
|
|
229
|
+
"build:inspector": "pnpm build && npx @eslint/config-inspector build --stats --config eslint.config.ts --out-dir ./.eslint-config-inspector",
|
|
220
230
|
"watch": "tsdown --watch",
|
|
221
231
|
"lint": "eslint",
|
|
222
232
|
"gen": "tsx scripts/typegen.ts && tsx scripts/versiongen.ts",
|