From c3b2de4a57a0a74af1b3c6d10d1657ce143fc320 Mon Sep 17 00:00:00 2001 From: David Anson Date: Sat, 5 Feb 2022 12:57:47 -0800 Subject: [PATCH] Include annotation information when reporting errors (fixes #5). --- .eslintrc.json | 4 ++++ dist/index.js | 23 ++++++++++++++++++++++- markdownlint-cli2-action.js | 23 ++++++++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index de7e09d..240b76d 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -18,7 +18,10 @@ "reportUnusedDisableDirectives": true, "rules": { "indent": ["error", 2], + "function-call-argument-newline": "off", "one-var": "off", + "padded-blocks": "off", + "prefer-named-capture-group": "off", "sort-keys": "off", "node/handle-callback-err": "error", @@ -59,6 +62,7 @@ "node/prefer-promises/dns": "error", "node/prefer-promises/fs": "error", + "unicorn/no-unsafe-regex": "off", "unicorn/prefer-module": "off", "unicorn/prefer-top-level-await": "off" } diff --git a/dist/index.js b/dist/index.js index 52c9cfe..52812cd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31663,7 +31663,28 @@ const core = __nccwpck_require__(2186); const {"main": markdownlintCli2} = __nccwpck_require__(9247); const logMessage = core.info; -const logError = core.error; +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, + startLine, + startColumn, + , + title + ] = match; + annotation = { + title, + file, + startLine, + startColumn + }; + } + core.error(error, annotation); +}; const argv = core.getInput("globs"). split("\n"). diff --git a/markdownlint-cli2-action.js b/markdownlint-cli2-action.js index bed962c..d1ed98e 100644 --- a/markdownlint-cli2-action.js +++ b/markdownlint-cli2-action.js @@ -6,7 +6,28 @@ const core = require("@actions/core"); const {"main": markdownlintCli2} = require("markdownlint-cli2"); const logMessage = core.info; -const logError = core.error; +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, + startLine, + startColumn, + , + title + ] = match; + annotation = { + title, + file, + startLine, + startColumn + }; + } + core.error(error, annotation); +}; const argv = core.getInput("globs"). split("\n").