mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2026-01-04 15:08:49 +01:00
Update resultVersion 3 to report all issues on a line; update MD010/no-hard-tabs to log all issues.
This commit is contained in:
parent
cdd87e647f
commit
679c83e23b
3 changed files with 140 additions and 7 deletions
|
|
@ -296,6 +296,11 @@ function lineNumberComparison(a, b) {
|
|||
return a.lineNumber - b.lineNumber;
|
||||
}
|
||||
|
||||
// Function to return true for all inputs
|
||||
function filterAllValues() {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function to return unique values from a sorted errors array
|
||||
function uniqueFilterForSortedErrors(value, index, array) {
|
||||
return (index === 0) || (value.lineNumber > array[index - 1].lineNumber);
|
||||
|
|
@ -402,7 +407,9 @@ function lintContent(
|
|||
if (errors.length) {
|
||||
errors.sort(lineNumberComparison);
|
||||
const filteredErrors = errors
|
||||
.filter(uniqueFilterForSortedErrors)
|
||||
.filter((resultVersion === 3) ?
|
||||
filterAllValues :
|
||||
uniqueFilterForSortedErrors)
|
||||
.filter(function removeDisabledRules(error) {
|
||||
return enabledRulesPerLineNumber[error.lineNumber][ruleName];
|
||||
})
|
||||
|
|
|
|||
18
lib/md010.js
18
lib/md010.js
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addError, forEachLine, rangeFromRegExp } = require("../helpers");
|
||||
const { addError, forEachLine } = require("../helpers");
|
||||
const { lineMetadata } = require("./cache");
|
||||
|
||||
const tabRe = /\t+/;
|
||||
const tabRe = /\t+/g;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD010", "no-hard-tabs" ],
|
||||
|
|
@ -15,9 +15,17 @@ module.exports = {
|
|||
const codeBlocks = params.config.code_blocks;
|
||||
const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
|
||||
if (tabRe.test(line) && (!inCode || includeCodeBlocks)) {
|
||||
addError(onError, lineIndex + 1, "Column: " + (line.indexOf("\t") + 1),
|
||||
null, rangeFromRegExp(line, tabRe));
|
||||
if (!inCode || includeCodeBlocks) {
|
||||
let match = null;
|
||||
while ((match = tabRe.exec(line)) !== null) {
|
||||
const column = match.index + 1;
|
||||
addError(
|
||||
onError,
|
||||
lineIndex + 1,
|
||||
"Column: " + column,
|
||||
null,
|
||||
[ column, match[0].length ]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue