@code-pushup/eslint-plugin 0.8.23 → 0.8.24
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/bin.js +4 -4
- package/index.js +8 -5
- package/package.json +1 -1
package/bin.js
CHANGED
|
@@ -698,7 +698,7 @@ function ruleIdToSlug(ruleId, options) {
|
|
|
698
698
|
return `${slug}-${jsonHash(options)}`;
|
|
699
699
|
}
|
|
700
700
|
function jsonHash(data, bytes = 8) {
|
|
701
|
-
return createHash("shake256", { outputLength: bytes }).update(JSON.stringify(data)
|
|
701
|
+
return createHash("shake256", { outputLength: bytes }).update(JSON.stringify(data) || "null").digest("hex");
|
|
702
702
|
}
|
|
703
703
|
|
|
704
704
|
// packages/plugin-eslint/src/lib/runner/transform.ts
|
|
@@ -726,7 +726,7 @@ function toAudit(slug, issues) {
|
|
|
726
726
|
auditIssues.map(({ severity }) => severity)
|
|
727
727
|
);
|
|
728
728
|
const severities = objectToEntries(severityCounts);
|
|
729
|
-
const summaryText = severities.sort((a, b) => -compareIssueSeverity(a[0], b[0])).map(([severity, count = 0]) => pluralizeToken(severity, count)).join(", ");
|
|
729
|
+
const summaryText = [...severities].sort((a, b) => -compareIssueSeverity(a[0], b[0])).map(([severity, count = 0]) => pluralizeToken(severity, count)).join(", ");
|
|
730
730
|
return {
|
|
731
731
|
slug,
|
|
732
732
|
score: Number(auditIssues.length === 0),
|
|
@@ -776,7 +776,7 @@ async function executeRunner(argv = process.argv) {
|
|
|
776
776
|
if (!eslintrc) {
|
|
777
777
|
throw new Error("Invalid runner args - missing eslintrc argument");
|
|
778
778
|
}
|
|
779
|
-
if (
|
|
779
|
+
if (patterns.length === 0) {
|
|
780
780
|
throw new Error("Invalid runner args - missing patterns argument");
|
|
781
781
|
}
|
|
782
782
|
const lintResults = await lint({
|
|
@@ -799,4 +799,4 @@ async function executeRunner(argv = process.argv) {
|
|
|
799
799
|
}
|
|
800
800
|
|
|
801
801
|
// packages/plugin-eslint/src/bin.ts
|
|
802
|
-
executeRunner().catch(console.error);
|
|
802
|
+
await executeRunner().catch(console.error);
|
package/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
|
|
6
6
|
// packages/plugin-eslint/package.json
|
|
7
7
|
var name = "@code-pushup/eslint-plugin";
|
|
8
|
-
var version = "0.8.
|
|
8
|
+
var version = "0.8.24";
|
|
9
9
|
|
|
10
10
|
// packages/plugin-eslint/src/lib/config.ts
|
|
11
11
|
import { z } from "zod";
|
|
@@ -637,7 +637,7 @@ function ruleIdToSlug(ruleId, options) {
|
|
|
637
637
|
return `${slug}-${jsonHash(options)}`;
|
|
638
638
|
}
|
|
639
639
|
function jsonHash(data, bytes = 8) {
|
|
640
|
-
return createHash("shake256", { outputLength: bytes }).update(JSON.stringify(data)
|
|
640
|
+
return createHash("shake256", { outputLength: bytes }).update(JSON.stringify(data) || "null").digest("hex");
|
|
641
641
|
}
|
|
642
642
|
|
|
643
643
|
// packages/plugin-eslint/src/lib/meta/rules.ts
|
|
@@ -653,6 +653,7 @@ async function listRules(eslint, patterns) {
|
|
|
653
653
|
configs.flatMap((config) => Object.keys(config.rules ?? {}))
|
|
654
654
|
);
|
|
655
655
|
const rulesMeta = eslint.getRulesMetaForResults([
|
|
656
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
656
657
|
{
|
|
657
658
|
messages: rulesIds.map((ruleId) => ({ ruleId })),
|
|
658
659
|
suppressedMessages: []
|
|
@@ -761,7 +762,7 @@ function groupsFromRuleCategories(rules) {
|
|
|
761
762
|
},
|
|
762
763
|
{}
|
|
763
764
|
);
|
|
764
|
-
|
|
765
|
+
const groups = Object.entries(categoriesMap).flatMap(
|
|
765
766
|
([plugin, categories]) => Object.entries(categories).map(
|
|
766
767
|
([category, slugs]) => ({
|
|
767
768
|
slug: `${slugify(plugin)}-${slugify(category)}`,
|
|
@@ -769,15 +770,17 @@ function groupsFromRuleCategories(rules) {
|
|
|
769
770
|
refs: slugs.map((slug) => ({ slug, weight: 1 }))
|
|
770
771
|
})
|
|
771
772
|
)
|
|
772
|
-
)
|
|
773
|
+
);
|
|
774
|
+
return [...groups].sort((a, b) => a.slug.localeCompare(b.slug));
|
|
773
775
|
}
|
|
774
776
|
|
|
775
777
|
// packages/plugin-eslint/src/lib/meta/transform.ts
|
|
776
778
|
function ruleToAudit({ ruleId, meta, options }) {
|
|
777
779
|
const name2 = ruleId.split("/").at(-1) ?? ruleId;
|
|
778
780
|
const plugin = name2 === ruleId ? null : ruleId.slice(0, ruleId.lastIndexOf("/"));
|
|
781
|
+
const pluginContext = plugin ? `, from _${plugin}_ plugin` : "";
|
|
779
782
|
const lines = [
|
|
780
|
-
`ESLint rule **${name2}**${
|
|
783
|
+
`ESLint rule **${name2}**${pluginContext}.`,
|
|
781
784
|
...options?.length ? ["Custom options:"] : [],
|
|
782
785
|
...options?.map(
|
|
783
786
|
(option) => ["```json", JSON.stringify(option, null, 2), "```"].join("\n")
|