mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00: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
|
|
@ -11,12 +11,12 @@ module.exports = {
|
|||
),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
for (const inline of params.tokens.filter(function filterToken(token) {
|
||||
return token.type === "inline";
|
||||
}).forEach(function forToken(inline) {
|
||||
inline.children.filter(function filterChild(child) {
|
||||
})) {
|
||||
for (const text of inline.children.filter(function filterChild(child) {
|
||||
return child.type === "text";
|
||||
}).forEach(function forChild(text) {
|
||||
})) {
|
||||
const index = text.content.toLowerCase().indexOf("ex");
|
||||
if (index !== -1) {
|
||||
onError({
|
||||
|
|
@ -24,7 +24,7 @@ module.exports = {
|
|||
"context": text.content.substr(index - 1, 4)
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@ module.exports = {
|
|||
.then((config) => {
|
||||
config = cleanJsdocRulesFromEslintConfig(config);
|
||||
const results = linter.verify(fence.content, config);
|
||||
results.forEach((result) => {
|
||||
for (const result of results) {
|
||||
const lineNumber = fence.lineNumber + result.line;
|
||||
onError({
|
||||
"lineNumber": lineNumber,
|
||||
"detail": result.message,
|
||||
"context": params.lines[lineNumber - 1]
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ module.exports = {
|
|||
"description": "Sample rule",
|
||||
"tags": [ "sample" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.forEach((token) => {
|
||||
for (const token of params.tokens) {
|
||||
if (token.type === "hr") {
|
||||
onError({
|
||||
"lineNumber": token.lineNumber,
|
||||
"detail": "Sample error for hr"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue