mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Enable ESLint rule unicorn/no-array-for-each, auto-fix all violations, manually address new issues for ~4% time reduction measured via profile-fixture.mjs on Apple Silicon M1.
This commit is contained in:
parent
15efcb4282
commit
b6471fba31
34 changed files with 414 additions and 389 deletions
27
lib/md046.js
27
lib/md046.js
|
|
@ -15,18 +15,19 @@ module.exports = {
|
|||
"tags": [ "code" ],
|
||||
"function": function MD046(params, onError) {
|
||||
let expectedStyle = String(params.config.style || "consistent");
|
||||
params.tokens
|
||||
.filter((token) => token.type === "code_block" || token.type === "fence")
|
||||
.forEach((token) => {
|
||||
const { lineNumber, type } = token;
|
||||
if (expectedStyle === "consistent") {
|
||||
expectedStyle = tokenTypeToStyle[type];
|
||||
}
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
lineNumber,
|
||||
expectedStyle,
|
||||
tokenTypeToStyle[type]);
|
||||
});
|
||||
const codeBlocksAndFences = params.tokens.filter(
|
||||
(token) => (token.type === "code_block") || (token.type === "fence")
|
||||
);
|
||||
for (const token of codeBlocksAndFences) {
|
||||
const { lineNumber, type } = token;
|
||||
if (expectedStyle === "consistent") {
|
||||
expectedStyle = tokenTypeToStyle[type];
|
||||
}
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
lineNumber,
|
||||
expectedStyle,
|
||||
tokenTypeToStyle[type]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue