mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Deprecate LintResults.toString() (at edit time; continue to support at run time), provide helper function formatLintResults, remove outdated grunt/gulp samples, improve typing.
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled
This commit is contained in:
parent
2a06f0a871
commit
616c3f2c22
18 changed files with 161 additions and 207 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,31 @@ 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 = [];
|
||||
const entries = Object.entries(lintResults || {});
|
||||
entries.sort((a, b) => a[0].localeCompare(b[0]));
|
||||
for (const [ source, lintErrors ] of entries) {
|
||||
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