This commit is contained in:
David Anson 2025-09-06 17:59:11 -07:00
parent 0117a71138
commit 29fd76ff8e
12 changed files with 48 additions and 174 deletions

View file

@ -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;
};