mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Stop sharing params object across rules because doing so is unstable for asynchronous rules (fixes #510).
This commit is contained in:
parent
4affefc68d
commit
62f5c85238
3 changed files with 87 additions and 20 deletions
|
|
@ -489,16 +489,16 @@ function lintContent(
|
|||
aliasToRuleNames
|
||||
);
|
||||
// Create parameters for rules
|
||||
const params = {
|
||||
"name": helpers.deepFreeze(name),
|
||||
"tokens": helpers.deepFreeze(tokens),
|
||||
"lines": helpers.deepFreeze(lines),
|
||||
"frontMatterLines": helpers.deepFreeze(frontMatterLines)
|
||||
};
|
||||
cache.lineMetadata(helpers.getLineMetadata(params));
|
||||
cache.flattenedLists(helpers.flattenLists(params.tokens));
|
||||
const paramsBase = helpers.deepFreeze({
|
||||
name,
|
||||
tokens,
|
||||
lines,
|
||||
frontMatterLines
|
||||
});
|
||||
cache.lineMetadata(helpers.getLineMetadata(paramsBase));
|
||||
cache.flattenedLists(helpers.flattenLists(paramsBase.tokens));
|
||||
cache.codeBlockAndSpanRanges(
|
||||
helpers.codeBlockAndSpanRanges(params, cache.lineMetadata())
|
||||
helpers.codeBlockAndSpanRanges(paramsBase, cache.lineMetadata())
|
||||
);
|
||||
// Function to run for each rule
|
||||
let results = [];
|
||||
|
|
@ -506,7 +506,10 @@ function lintContent(
|
|||
function forRule(rule) {
|
||||
// Configure rule
|
||||
const ruleName = rule.names[0].toUpperCase();
|
||||
params.config = effectiveConfig[ruleName];
|
||||
const params = {
|
||||
...paramsBase,
|
||||
"config": effectiveConfig[ruleName]
|
||||
};
|
||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||
function throwError(property) {
|
||||
throw new Error(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue