Skip to content

Commit c3b2de4

Browse files
committed
Include annotation information when reporting errors (fixes #5).
1 parent b3c3b40 commit c3b2de4

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

.eslintrc.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
"reportUnusedDisableDirectives": true,
1919
"rules": {
2020
"indent": ["error", 2],
21+
"function-call-argument-newline": "off",
2122
"one-var": "off",
23+
"padded-blocks": "off",
24+
"prefer-named-capture-group": "off",
2225
"sort-keys": "off",
2326

2427
"node/handle-callback-err": "error",
@@ -59,6 +62,7 @@
5962
"node/prefer-promises/dns": "error",
6063
"node/prefer-promises/fs": "error",
6164

65+
"unicorn/no-unsafe-regex": "off",
6266
"unicorn/prefer-module": "off",
6367
"unicorn/prefer-top-level-await": "off"
6468
}

dist/index.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31663,7 +31663,28 @@ const core = __nccwpck_require__(2186);
3166331663
const {"main": markdownlintCli2} = __nccwpck_require__(9247);
3166431664

3166531665
const logMessage = core.info;
31666-
const logError = core.error;
31666+
const logError = (error) => {
31667+
// eslint-disable-next-line init-declarations
31668+
let annotation;
31669+
const match = error.match(/^([^:]+):(\d+)(?::(\d+))?\s(\S+)\s(.+)$/u);
31670+
if (match) {
31671+
const [
31672+
,
31673+
file,
31674+
startLine,
31675+
startColumn,
31676+
,
31677+
title
31678+
] = match;
31679+
annotation = {
31680+
title,
31681+
file,
31682+
startLine,
31683+
startColumn
31684+
};
31685+
}
31686+
core.error(error, annotation);
31687+
};
3166731688
const argv =
3166831689
core.getInput("globs").
3166931690
split("\n").

markdownlint-cli2-action.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,28 @@ const core = require("@actions/core");
66
const {"main": markdownlintCli2} = require("markdownlint-cli2");
77

88
const logMessage = core.info;
9-
const logError = core.error;
9+
const logError = (error) => {
10+
// eslint-disable-next-line init-declarations
11+
let annotation;
12+
const match = error.match(/^([^:]+):(\d+)(?::(\d+))?\s(\S+)\s(.+)$/u);
13+
if (match) {
14+
const [
15+
,
16+
file,
17+
startLine,
18+
startColumn,
19+
,
20+
title
21+
] = match;
22+
annotation = {
23+
title,
24+
file,
25+
startLine,
26+
startColumn
27+
};
28+
}
29+
core.error(error, annotation);
30+
};
1031
const argv =
1132
core.getInput("globs").
1233
split("\n").

0 commit comments

Comments
 (0)