mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
wip
This commit is contained in:
parent
b25be4bf1b
commit
a56441003e
6 changed files with 84 additions and 58 deletions
|
|
@ -623,7 +623,6 @@ function lintContent(
|
|||
const information = errorInfo.information || rule.information;
|
||||
results.push({
|
||||
lineNumber,
|
||||
"ruleName": rule.names[0],
|
||||
"ruleNames": rule.names,
|
||||
"ruleDescription": rule.description,
|
||||
"ruleInformation": information ? information.href : null,
|
||||
|
|
@ -662,45 +661,16 @@ function lintContent(
|
|||
const formatResults = () => {
|
||||
// Sort results by rule name by line number
|
||||
results.sort((a, b) => (
|
||||
a.ruleName.localeCompare(b.ruleName) ||
|
||||
a.ruleNames[0].localeCompare(b.ruleNames[0]) ||
|
||||
a.lineNumber - b.lineNumber
|
||||
));
|
||||
if (resultVersion < 3) {
|
||||
// Remove fixInfo and multiple errors for the same rule and line number
|
||||
const noPrevious = {
|
||||
"ruleName": null,
|
||||
"lineNumber": -1
|
||||
};
|
||||
results = results.filter((error, index, array) => {
|
||||
delete error.fixInfo;
|
||||
const previous = array[index - 1] || noPrevious;
|
||||
return (
|
||||
(error.ruleName !== previous.ruleName) ||
|
||||
(error.lineNumber !== previous.lineNumber)
|
||||
);
|
||||
});
|
||||
}
|
||||
// Deprecated: Convert results to specified resultVersion
|
||||
if (resultVersion === 0) {
|
||||
// Return a dictionary of rule->[line numbers]
|
||||
const dictionary = {};
|
||||
for (const error of results) {
|
||||
const ruleLines = dictionary[error.ruleName] || [];
|
||||
ruleLines.push(error.lineNumber);
|
||||
dictionary[error.ruleName] = ruleLines;
|
||||
}
|
||||
// @ts-ignore
|
||||
results = dictionary;
|
||||
results = helpers.convertToResultVersion0(results);
|
||||
} else if (resultVersion === 1) {
|
||||
// Use ruleAlias instead of ruleNames
|
||||
for (const error of results) {
|
||||
error.ruleAlias = error.ruleNames[1] || error.ruleName;
|
||||
delete error.ruleNames;
|
||||
}
|
||||
} else {
|
||||
// resultVersion 2 or 3: Remove unwanted ruleName
|
||||
for (const error of results) {
|
||||
delete error.ruleName;
|
||||
}
|
||||
results = helpers.convertToResultVersion1(results);
|
||||
} else if (resultVersion === 2) {
|
||||
results = helpers.convertToResultVersion2(results);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
|
@ -1525,7 +1495,7 @@ export function getVersion() {
|
|||
*/
|
||||
|
||||
/**
|
||||
* Lint results (for resultVersion 3).
|
||||
* Lint results.
|
||||
*
|
||||
* @typedef {Object.<string, LintError[]>} LintResults
|
||||
* @property {ToStringCallback} toString String representation.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue