mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Include file/string name in params object for custom rules (fixes #119).
This commit is contained in:
parent
8c87a20677
commit
1c816897c1
3 changed files with 53 additions and 5 deletions
|
@ -283,7 +283,7 @@ function uniqueFilterForSortedErrors(value, index, array) {
|
|||
|
||||
// Lints a single string
|
||||
function lintContent(
|
||||
ruleList, content, config, frontMatter, noInlineConfig, resultVersion,
|
||||
ruleList, name, content, config, frontMatter, noInlineConfig, resultVersion,
|
||||
callback) {
|
||||
// Remove UTF-8 byte order marker (if present)
|
||||
content = content.replace(/^\ufeff/, "");
|
||||
|
@ -304,9 +304,10 @@ function lintContent(
|
|||
effectiveConfig, aliasToRuleNames);
|
||||
// Create parameters for rules
|
||||
const params = {
|
||||
"tokens": tokens,
|
||||
"lines": lines,
|
||||
"frontMatterLines": frontMatterLines
|
||||
name,
|
||||
tokens,
|
||||
lines,
|
||||
frontMatterLines
|
||||
};
|
||||
shared.makeTokenCache(params);
|
||||
// Function to run for each rule
|
||||
|
@ -411,7 +412,7 @@ function lintFile(
|
|||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
lintContent(ruleList, content, config, frontMatter, noInlineConfig,
|
||||
lintContent(ruleList, file, content, config, frontMatter, noInlineConfig,
|
||||
resultVersion, callback);
|
||||
}
|
||||
// Make a/synchronous call to read file
|
||||
|
@ -465,6 +466,7 @@ function lintInput(options, synchronous, callback) {
|
|||
if ((item = stringsKeys.shift())) {
|
||||
lintContent(
|
||||
ruleList,
|
||||
item,
|
||||
strings[item] || "",
|
||||
config,
|
||||
frontMatter,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue