Skip to content

Commit

Permalink
style: 优化代码结构
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnAngela committed Sep 13, 2024
1 parent 15f5da3 commit ede4f23
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/eslint-formatter-gha/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const formatter: ESLint.Formatter["format"] = (results, data) => {
const url = data?.rulesMeta[ruleId].docs?.url;
return url ? md ? actionsSummary.wrapLink({ text: ruleId, href: url }) : url : ruleId;
};
actionsSummary.addEOL();
actionsSummary.addHeading({ text: "ESLint Annotation", level: 1 });
actionsSummary.addRaw(`ESLint Annotation from ${actionsSummary.wrapLink({ text: "@annangela/eslint-formatter-gha", href: "https://www.npmjs.com/package/@annangela/eslint-formatter-gha" })}`);
actionsSummary
.addEOL()
.addHeading({ text: "ESLint Annotation", level: 1 })
.addRaw(`ESLint Annotation from ${actionsSummary.wrapLink({ text: "@annangela/eslint-formatter-gha", href: "https://www.npmjs.com/package/@annangela/eslint-formatter-gha" })}`);
const deprecatedRulesSeverityFromEnv = process.env.ESLINT_FORMATTER_GHA_DEPRECATED_RULES_SEVERITY?.toLowerCase();
const deprecatedRulesSeverities = ["debug", "notice", "warning", "error"];
// @TODO: Switch to `warning` when eslint 9 is released
Expand Down Expand Up @@ -128,12 +129,14 @@ const formatter: ESLint.Formatter["format"] = (results, data) => {
actionsSummary.addRaw("Nothing is broken, everything is fine.");
}
if (deprecatedRulesSummary.length > 0) {
actionsSummary.addHeading({ text: `${ActionsSummary.EMOJI[deprecatedRulesSeverity]} Deprecated Rules`, level: 2 });
actionsSummary.addList({ items: deprecatedRulesSummary });
actionsSummary
.addHeading({ text: `${ActionsSummary.EMOJI[deprecatedRulesSeverity]} Deprecated Rules`, level: 2 })
.addList({ items: deprecatedRulesSummary });
}
if (annotationSummary.length > 0) {
actionsSummary.addHeading({ text: "Annotations", level: 2 });
actionsSummary.addList({ items: annotationSummary });
actionsSummary
.addHeading({ text: "Annotations", level: 2 })
.addList({ items: annotationSummary });
}
actionsSummary.write();
return "";
Expand Down

0 comments on commit ede4f23

Please sign in to comment.