Hide the content of inline configuration HTML comments from the linting process to avoid false positives.

This commit is contained in:
David Anson 2022-06-04 22:59:19 -07:00
parent 535aa1a2ee
commit bbec8c5c1e
7 changed files with 80 additions and 40 deletions

View file

@ -474,23 +474,24 @@ function lintContent(
content = content.replace(/^\uFEFF/, "");
// Remove front matter
const removeFrontMatterResult = removeFrontMatter(content, frontMatter);
const frontMatterLines = removeFrontMatterResult.frontMatterLines;
// Ignore the content of HTML comments
content = helpers.clearHtmlCommentText(removeFrontMatterResult.content);
const { frontMatterLines } = removeFrontMatterResult;
content = removeFrontMatterResult.content;
// Get enabled rules per line (with HTML comments present)
const { effectiveConfig, enabledRulesPerLineNumber } =
getEnabledRulesPerLineNumber(
ruleList,
content.split(helpers.newLineRe),
frontMatterLines,
noInlineConfig,
config,
mapAliasToRuleNames(ruleList)
);
// Hide the content of HTML comments from rules, etc.
content = helpers.clearHtmlCommentText(content);
// Parse content into tokens and lines
const tokens = md.parse(content, {});
const lines = content.split(helpers.newLineRe);
annotateTokens(tokens, lines);
const aliasToRuleNames = mapAliasToRuleNames(ruleList);
const { effectiveConfig, enabledRulesPerLineNumber } =
getEnabledRulesPerLineNumber(
ruleList,
lines,
frontMatterLines,
noInlineConfig,
config,
aliasToRuleNames
);
// Create parameters for rules
const paramsBase = helpers.deepFreeze({
name,