mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add noInlineConfig option to disable inline config comments.
This commit is contained in:
parent
ac6b80b42a
commit
614ac8fa23
4 changed files with 110 additions and 45 deletions
|
@ -84,7 +84,8 @@ function uniqueFilterForSortedErrors(value, index, array) {
|
|||
}
|
||||
|
||||
// Lints a single string
|
||||
function lintContent(content, config, frontMatter, resultVersion) {
|
||||
function lintContent(
|
||||
content, config, frontMatter, noInlineConfig, resultVersion) {
|
||||
// Remove UTF-8 byte order marker (if present)
|
||||
if (content.charCodeAt(0) === 0xfeff) {
|
||||
content = content.slice(1);
|
||||
|
@ -192,12 +193,14 @@ function lintContent(content, config, frontMatter, resultVersion) {
|
|||
}
|
||||
var enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length);
|
||||
lines.forEach(function forLine(line) {
|
||||
var match = shared.inlineCommentRe.exec(line);
|
||||
if (match) {
|
||||
enabledRules = shared.clone(enabledRules);
|
||||
while (match) {
|
||||
forMatch(match);
|
||||
match = shared.inlineCommentRe.exec(line);
|
||||
if (!noInlineConfig) {
|
||||
var match = shared.inlineCommentRe.exec(line);
|
||||
if (match) {
|
||||
enabledRules = shared.clone(enabledRules);
|
||||
while (match) {
|
||||
forMatch(match);
|
||||
match = shared.inlineCommentRe.exec(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
enabledRulesPerLineNumber.push(enabledRules);
|
||||
|
@ -303,6 +306,7 @@ function lintFile(
|
|||
file,
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion,
|
||||
synchronous,
|
||||
callback) {
|
||||
|
@ -310,7 +314,8 @@ function lintFile(
|
|||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
var result = lintContent(content, config, frontMatter, resultVersion);
|
||||
var result = lintContent(
|
||||
content, config, frontMatter, noInlineConfig, resultVersion);
|
||||
callback(null, result);
|
||||
}
|
||||
// Make a/synchronous call to read file
|
||||
|
@ -347,9 +352,10 @@ function markdownlint(options, callback) {
|
|||
files = [ String(options.files) ];
|
||||
}
|
||||
var strings = options.strings || {};
|
||||
var config = options.config || { "default": true };
|
||||
var frontMatter = (options.frontMatter === undefined) ?
|
||||
shared.frontMatterRe : options.frontMatter;
|
||||
var config = options.config || { "default": true };
|
||||
var noInlineConfig = !!options.noInlineConfig;
|
||||
var resultVersion = options.resultVersion || 0;
|
||||
var synchronous = (callback === markdownlintSynchronousCallback);
|
||||
var results = new Results();
|
||||
|
@ -357,7 +363,13 @@ function markdownlint(options, callback) {
|
|||
function lintFilesArray() {
|
||||
var file = files.shift();
|
||||
if (file) {
|
||||
lintFile(file, config, frontMatter, resultVersion, synchronous,
|
||||
lintFile(
|
||||
file,
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion,
|
||||
synchronous,
|
||||
function lintedFile(err, result) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
@ -376,6 +388,7 @@ function markdownlint(options, callback) {
|
|||
strings[key] || "",
|
||||
config,
|
||||
frontMatter,
|
||||
noInlineConfig,
|
||||
resultVersion);
|
||||
results[key] = result;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue