0
0
Fork 0
mirror of https://github.com/DavidAnson/markdownlint-cli2-action.git synced 2024-11-23 06:36:25 +01: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": { "rules": {
"indent": ["error", 2], "indent": ["error", 2],
"function-call-argument-newline": "off", "function-call-argument-newline": "off",
"max-statements": "off",
"multiline-ternary": "off",
"no-magic-numbers": "off",
"no-ternary": "off",
"one-var": "off", "one-var": "off",
"padded-blocks": "off", "padded-blocks": "off",
"prefer-named-capture-group": "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 {"main": markdownlintCli2} = __nccwpck_require__(9247);
const logMessage = core.info; const logMessage = core.info;
const logError = (error) => { const outputFormatter = (options) => {
// eslint-disable-next-line init-declarations const {results} = options;
let annotation; for (const lintError of results) {
const match = error.match(/^([^:]+):(\d+)(?::(\d+))?\s(\S+)\s(.+)$/u); const {
if (match) { errorContext,
const [ errorDetail,
, errorRange,
file, fileName,
startLineString, lineNumber,
startColumnString, ruleDescription,
, ruleInformation,
title ruleNames
] = match; } = lintError;
const startLine = Number(startLineString); const line = `:${lineNumber}`;
annotation = { const column = errorRange ? `:${errorRange[0]}` : "";
title, const name = ruleNames.join("/");
file, const detail = errorDetail ? ` [${errorDetail}]` : "";
startLine 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) { if (errorRange) {
// @ts-ignore const [
annotation.startColumn = Number(startColumnString); 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"; const separator = core.getInput("separator") || "\n";
@ -34844,7 +34857,9 @@ const argv =
const parameters = { const parameters = {
argv, argv,
logMessage, logMessage,
logError "optionsOverride": {
"outputFormatters": [[outputFormatter]]
}
}; };
let invoke = true; let invoke = true;
const command = core.getInput("command"); const command = core.getInput("command");

View file

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