-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathmarkdownlint-cli2-formatter-default.js
More file actions
25 lines (21 loc) · 1.03 KB
/
Copy pathmarkdownlint-cli2-formatter-default.js
File metadata and controls
25 lines (21 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// @ts-check
"use strict";
/** @typedef {import("../markdownlint-cli2.mjs").OutputFormatterOptions} OutputFormatterOptions */
// Formats markdownlint-cli2 results in the style of `markdownlint-cli`
const outputFormatter = (/** @type {OutputFormatterOptions} */ options) => {
const { results, logError } = options;
for (const errorInfo of results) {
const { fileName, lineNumber, ruleNames, ruleDescription, errorDetail, errorContext, errorRange, severity } = errorInfo;
const rule = ruleNames.join("/");
const line = `:${lineNumber}`;
const rangeStart = (errorRange && errorRange[0]) || 0;
const column = rangeStart ? `:${rangeStart}` : "";
const description = ruleDescription;
const detail = (errorDetail ? ` [${errorDetail}]` : "");
const context = (errorContext ? ` [Context: "${errorContext}"]` : "");
const sev = (severity ? ` ${severity}` : "");
logError(`${fileName}${line}${column}${sev} ${rule} ${description}${detail}${context}`);
}
return Promise.resolve();
};
module.exports = outputFormatter;