mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
wip
This commit is contained in:
parent
0117a71138
commit
29fd76ff8e
12 changed files with 48 additions and 174 deletions
|
|
@ -554,6 +554,7 @@ function convertLintErrorsVersion3To2(errors) {
|
|||
"lineNumber": -1
|
||||
};
|
||||
return errors.filter((error, index, array) => {
|
||||
// @ts-ignore
|
||||
delete error.fixInfo;
|
||||
const previous = array[index - 1] || noPrevious;
|
||||
return (
|
||||
|
|
@ -646,3 +647,29 @@ module.exports.convertToResultVersion1 = function convertToResultVersion1(result
|
|||
module.exports.convertToResultVersion2 = function convertToResultVersion2(results) {
|
||||
return copyAndTransformResults(results, convertLintErrorsVersion3To2);
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats lint results to an array of strings.
|
||||
*
|
||||
* @param {LintResults|undefined} lintResults Lint results.
|
||||
* @returns {string[]} Lint error strings.
|
||||
*/
|
||||
module.exports.formatLintResults = function formatLintResults(lintResults) {
|
||||
const results = [];
|
||||
for (const [ source, lintErrors ] of Object.entries(lintResults || {})) {
|
||||
for (const lintError of lintErrors) {
|
||||
results.push(
|
||||
source + ": " +
|
||||
lintError.lineNumber + ": " +
|
||||
lintError.ruleNames.join("/") + " " +
|
||||
lintError.ruleDescription +
|
||||
(lintError.errorDetail ?
|
||||
" [" + lintError.errorDetail + "]" :
|
||||
"") +
|
||||
(lintError.errorContext ?
|
||||
" [Context: \"" + lintError.errorContext + "\"]" :
|
||||
""));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue