mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Rename rule params.options to .config for API consistency.
This commit is contained in:
parent
a0e3b4db90
commit
f79cdcb0d4
3 changed files with 29 additions and 29 deletions
|
@ -231,7 +231,7 @@ function lintContent(
|
|||
rules.forEach(function forRule(rule) {
|
||||
// Configure rule
|
||||
var ruleName = rule.names[0];
|
||||
params.options = mergedRules[ruleName];
|
||||
params.config = mergedRules[ruleName];
|
||||
var errors = [];
|
||||
function onError(errorInfo) {
|
||||
errors.push({
|
||||
|
|
54
lib/rules.js
54
lib/rules.js
|
@ -254,7 +254,7 @@ module.exports = [
|
|||
"desc": "First header should be a top level header",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD002(params, onError) {
|
||||
var level = params.options.level || 1;
|
||||
var level = params.config.level || 1;
|
||||
var tag = "h" + level;
|
||||
params.tokens.every(function forToken(token) {
|
||||
if (token.type === "heading_open") {
|
||||
|
@ -271,7 +271,7 @@ module.exports = [
|
|||
"desc": "Header style",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD003(params, onError) {
|
||||
var style = params.options.style || "consistent";
|
||||
var style = params.config.style || "consistent";
|
||||
filterTokens(params, "heading_open", function forToken(token) {
|
||||
var styleForToken = headingStyleFor(token);
|
||||
if (style === "consistent") {
|
||||
|
@ -307,7 +307,7 @@ module.exports = [
|
|||
"desc": "Unordered list style",
|
||||
"tags": [ "bullet", "ul" ],
|
||||
"func": function MD004(params, onError) {
|
||||
var style = params.options.style || "consistent";
|
||||
var style = params.config.style || "consistent";
|
||||
var expectedStyle = style;
|
||||
var nestingStyles = [];
|
||||
flattenLists(params).forEach(function forList(list) {
|
||||
|
@ -373,7 +373,7 @@ module.exports = [
|
|||
"desc": "Unordered list indentation",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
||||
"func": function MD007(params, onError) {
|
||||
var optionsIndent = params.options.indent || 2;
|
||||
var optionsIndent = params.config.indent || 2;
|
||||
var prevIndent = 0;
|
||||
flattenLists(params).forEach(function forList(list) {
|
||||
if (list.unordered && list.parentsUnordered) {
|
||||
|
@ -394,8 +394,8 @@ module.exports = [
|
|||
"desc": "Trailing spaces",
|
||||
"tags": [ "whitespace" ],
|
||||
"func": function MD009(params, onError) {
|
||||
var brSpaces = params.options.br_spaces || 0;
|
||||
var listItemEmptyLines = params.options.list_item_empty_lines;
|
||||
var brSpaces = params.config.br_spaces || 0;
|
||||
var listItemEmptyLines = params.config.list_item_empty_lines;
|
||||
var allowListItemEmptyLines =
|
||||
(listItemEmptyLines === undefined) ? false : !!listItemEmptyLines;
|
||||
var listItemLineNumbers = [];
|
||||
|
@ -424,7 +424,7 @@ module.exports = [
|
|||
"desc": "Hard tabs",
|
||||
"tags": [ "whitespace", "hard_tab" ],
|
||||
"func": function MD010(params, onError) {
|
||||
var codeBlocks = params.options.code_blocks;
|
||||
var codeBlocks = params.config.code_blocks;
|
||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
forEachLine(params, function forLine(line, lineIndex, inCode) {
|
||||
if (tabRe.test(line) && (!inCode || includeCodeBlocks)) {
|
||||
|
@ -456,7 +456,7 @@ module.exports = [
|
|||
"desc": "Multiple consecutive blank lines",
|
||||
"tags": [ "whitespace", "blank_lines" ],
|
||||
"func": function MD012(params, onError) {
|
||||
var maximum = params.options.maximum || 1;
|
||||
var maximum = params.config.maximum || 1;
|
||||
var count = 0;
|
||||
forEachLine(params, function forLine(line, lineIndex, inCode) {
|
||||
count = (inCode || line.trim().length) ? 0 : count + 1;
|
||||
|
@ -472,12 +472,12 @@ module.exports = [
|
|||
"desc": "Line length",
|
||||
"tags": [ "line_length" ],
|
||||
"func": function MD013(params, onError) {
|
||||
var lineLength = params.options.line_length || defaultLineLength;
|
||||
var codeBlocks = params.options.code_blocks;
|
||||
var lineLength = params.config.line_length || defaultLineLength;
|
||||
var codeBlocks = params.config.code_blocks;
|
||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
var tables = params.options.tables;
|
||||
var tables = params.config.tables;
|
||||
var includeTables = (tables === undefined) ? true : !!tables;
|
||||
var headers = params.options.headers;
|
||||
var headers = params.config.headers;
|
||||
var includeHeaders = (headers === undefined) ? true : !!headers;
|
||||
var headerLineNumbers = [];
|
||||
if (!includeHeaders) {
|
||||
|
@ -678,7 +678,7 @@ module.exports = [
|
|||
"desc": "Multiple top level headers in the same document",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD025(params, onError) {
|
||||
var level = params.options.level || 1;
|
||||
var level = params.config.level || 1;
|
||||
var tag = "h" + level;
|
||||
var hasTopLevelHeading = false;
|
||||
filterTokens(params, "heading_open", function forToken(token) {
|
||||
|
@ -698,7 +698,7 @@ module.exports = [
|
|||
"desc": "Trailing punctuation in header",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD026(params, onError) {
|
||||
var punctuation = params.options.punctuation || ".,;:!?";
|
||||
var punctuation = params.config.punctuation || ".,;:!?";
|
||||
var re = new RegExp("[" + punctuation + "]$");
|
||||
forEachHeading(params, function forHeading(heading, content) {
|
||||
var match = re.exec(content);
|
||||
|
@ -769,7 +769,7 @@ module.exports = [
|
|||
"desc": "Ordered list item prefix",
|
||||
"tags": [ "ol" ],
|
||||
"func": function MD029(params, onError) {
|
||||
var style = params.options.style || "one_or_ordered";
|
||||
var style = params.config.style || "one_or_ordered";
|
||||
var numberRe = /^[\s>]*([^.)]*)[.)]/;
|
||||
flattenLists(params).forEach(function forList(list) {
|
||||
if (!list.unordered) {
|
||||
|
@ -800,10 +800,10 @@ module.exports = [
|
|||
"desc": "Spaces after list markers",
|
||||
"tags": [ "ol", "ul", "whitespace" ],
|
||||
"func": function MD030(params, onError) {
|
||||
var ulSingle = params.options.ul_single || 1;
|
||||
var olSingle = params.options.ol_single || 1;
|
||||
var ulMulti = params.options.ul_multi || 1;
|
||||
var olMulti = params.options.ol_multi || 1;
|
||||
var ulSingle = params.config.ul_single || 1;
|
||||
var olSingle = params.config.ol_single || 1;
|
||||
var ulMulti = params.config.ul_multi || 1;
|
||||
var olMulti = params.config.ol_multi || 1;
|
||||
flattenLists(params).forEach(function forList(list) {
|
||||
var lineCount = list.lastLineIndex - list.open.map[0];
|
||||
var allSingle = lineCount === list.items.length;
|
||||
|
@ -869,7 +869,7 @@ module.exports = [
|
|||
"desc": "Inline HTML",
|
||||
"tags": [ "html" ],
|
||||
"func": function MD033(params, onError) {
|
||||
var allowedElements = (params.options.allowed_elements || [])
|
||||
var allowedElements = (params.config.allowed_elements || [])
|
||||
.map(function forElement(element) {
|
||||
return element.toLowerCase();
|
||||
});
|
||||
|
@ -927,7 +927,7 @@ module.exports = [
|
|||
"desc": "Horizontal rule style",
|
||||
"tags": [ "hr" ],
|
||||
"func": function MD035(params, onError) {
|
||||
var style = params.options.style || "consistent";
|
||||
var style = params.config.style || "consistent";
|
||||
filterTokens(params, "hr", function forToken(token) {
|
||||
var lineTrim = token.line.trim();
|
||||
if (style === "consistent") {
|
||||
|
@ -943,7 +943,7 @@ module.exports = [
|
|||
"desc": "Emphasis used instead of a header",
|
||||
"tags": [ "headers", "emphasis" ],
|
||||
"func": function MD036(params, onError) {
|
||||
var punctuation = params.options.punctuation || ".,;:!?";
|
||||
var punctuation = params.config.punctuation || ".,;:!?";
|
||||
var re = new RegExp("[" + punctuation + "]$");
|
||||
function base(token) {
|
||||
if (token.type === "paragraph_open") {
|
||||
|
@ -1085,8 +1085,8 @@ module.exports = [
|
|||
"desc": "First line in file should be a top level header",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD041(params, onError) {
|
||||
var level = params.options.level || 1;
|
||||
var frontMatterTitle = params.options.front_matter_title;
|
||||
var level = params.config.level || 1;
|
||||
var frontMatterTitle = params.config.front_matter_title;
|
||||
var tag = "h" + level;
|
||||
var frontMatterTitleRe =
|
||||
new RegExp(frontMatterTitle || "^\\s*title\\s*[:=]", "i");
|
||||
|
@ -1149,7 +1149,7 @@ module.exports = [
|
|||
"desc": "Required header structure",
|
||||
"tags": [ "headers" ],
|
||||
"func": function MD043(params, onError) {
|
||||
var requiredHeaders = params.options.headers;
|
||||
var requiredHeaders = params.config.headers;
|
||||
if (requiredHeaders) {
|
||||
var levels = {};
|
||||
[ 1, 2, 3, 4, 5, 6 ].forEach(function forLevel(level) {
|
||||
|
@ -1186,8 +1186,8 @@ module.exports = [
|
|||
"desc": "Proper names should have the correct capitalization",
|
||||
"tags": [ "spelling" ],
|
||||
"func": function MD044(params, onError) {
|
||||
var names = params.options.names || [];
|
||||
var codeBlocks = params.options.code_blocks;
|
||||
var names = params.config.names || [];
|
||||
var codeBlocks = params.config.code_blocks;
|
||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||
names.forEach(function forName(name) {
|
||||
var escapedName = escapeForRegExp(name);
|
||||
|
|
|
@ -1149,7 +1149,7 @@ module.exports.doc = function doc(test) {
|
|||
test.equal(token.content, rule.names[0] + " - " + rule.desc,
|
||||
"Rule mismatch.");
|
||||
ruleUsesParams = rule.func.toString()
|
||||
.match(/params\.options\.[_a-z]*/gi);
|
||||
.match(/params\.config\.[_a-z]*/gi);
|
||||
if (ruleUsesParams) {
|
||||
ruleUsesParams = ruleUsesParams.map(function forUse(use) {
|
||||
return use.split(".").pop();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue