0
0
Fork 0
mirror of https://github.com/DavidAnson/markdownlint-cli2-action.git synced 2024-10-16 12:07:01 +02:00

Include link to rule information with title of annotations (clickable in GitHub), add

endLine/endColumn data to annotations, use output formatter instead of parsing logError
(fixes #79).
This commit is contained in:
David Anson 2023-04-07 20:20:52 -07:00
parent 4d12ee9c45
commit 62350ad050
3 changed files with 80 additions and 46 deletions

View file

@ -19,6 +19,10 @@
"rules": {
"indent": ["error", 2],
"function-call-argument-newline": "off",
"max-statements": "off",
"multiline-ternary": "off",
"no-magic-numbers": "off",
"no-ternary": "off",
"one-var": "off",
"padded-blocks": "off",
"prefer-named-capture-group": "off",

61
dist/index.js vendored
View file

@ -34808,31 +34808,44 @@ const core = __nccwpck_require__(2186);
const {"main": markdownlintCli2} = __nccwpck_require__(9247);
const logMessage = core.info;
const logError = (error) => {
// eslint-disable-next-line init-declarations
let annotation;
const match = error.match(/^([^:]+):(\d+)(?::(\d+))?\s(\S+)\s(.+)$/u);
if (match) {
const [
,
file,
startLineString,
startColumnString,
,
title
] = match;
const startLine = Number(startLineString);
annotation = {
title,
file,
startLine
const outputFormatter = (options) => {
const {results} = options;
for (const lintError of results) {
const {
errorContext,
errorDetail,
errorRange,
fileName,
lineNumber,
ruleDescription,
ruleInformation,
ruleNames
} = lintError;
const line = `:${lineNumber}`;
const column = errorRange ? `:${errorRange[0]}` : "";
const name = ruleNames.join("/");
const detail = errorDetail ? ` [${errorDetail}]` : "";
const context = errorContext ? ` [Context: "${errorContext}"]` : "";
const information = ruleInformation ? ` ${ruleInformation}` : "";
const message =
// eslint-disable-next-line max-len
`${fileName}${line}${column} ${name} ${ruleDescription}${detail}${context}${information}`;
const annotation = {
"title": ruleDescription,
"file": fileName,
"startLine": lineNumber,
"endLine": lineNumber
};
if (startColumnString) {
// @ts-ignore
annotation.startColumn = Number(startColumnString);
if (errorRange) {
const [
errorColumn,
errorLength
] = errorRange;
annotation.startColumn = errorColumn;
annotation.endColumn = errorColumn + errorLength - 1;
}
core.error(message, annotation);
}
core.error(error, annotation);
};
const separator = core.getInput("separator") || "\n";
@ -34844,7 +34857,9 @@ const argv =
const parameters = {
argv,
logMessage,
logError
"optionsOverride": {
"outputFormatters": [[outputFormatter]]
}
};
let invoke = true;
const command = core.getInput("command");

View file

@ -6,31 +6,44 @@ const core = require("@actions/core");
const {"main": markdownlintCli2} = require("markdownlint-cli2");
const logMessage = core.info;
const logError = (error) => {
// eslint-disable-next-line init-declarations
let annotation;
const match = error.match(/^([^:]+):(\d+)(?::(\d+))?\s(\S+)\s(.+)$/u);
if (match) {
const [
,
file,
startLineString,
startColumnString,
,
title
] = match;
const startLine = Number(startLineString);
annotation = {
title,
file,
startLine
const outputFormatter = (options) => {
const {results} = options;
for (const lintError of results) {
const {
errorContext,
errorDetail,
errorRange,
fileName,
lineNumber,
ruleDescription,
ruleInformation,
ruleNames
} = lintError;
const line = `:${lineNumber}`;
const column = errorRange ? `:${errorRange[0]}` : "";
const name = ruleNames.join("/");
const detail = errorDetail ? ` [${errorDetail}]` : "";
const context = errorContext ? ` [Context: "${errorContext}"]` : "";
const information = ruleInformation ? ` ${ruleInformation}` : "";
const message =
// eslint-disable-next-line max-len
`${fileName}${line}${column} ${name} ${ruleDescription}${detail}${context}${information}`;
const annotation = {
"title": ruleDescription,
"file": fileName,
"startLine": lineNumber,
"endLine": lineNumber
};
if (startColumnString) {
// @ts-ignore
annotation.startColumn = Number(startColumnString);
if (errorRange) {
const [
errorColumn,
errorLength
] = errorRange;
annotation.startColumn = errorColumn;
annotation.endColumn = errorColumn + errorLength - 1;
}
core.error(message, annotation);
}
core.error(error, annotation);
};
const separator = core.getInput("separator") || "\n";
@ -42,7 +55,9 @@ const argv =
const parameters = {
argv,
logMessage,
logError
"optionsOverride": {
"outputFormatters": [[outputFormatter]]
}
};
let invoke = true;
const command = core.getInput("command");