mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Remove abbreviations from rule metadata to clarify API.
This commit is contained in:
parent
513a1351a5
commit
49e36f817c
4 changed files with 92 additions and 90 deletions
|
@ -21,7 +21,7 @@ rules.forEach(function forRule(rule) {
|
||||||
// The following is useful for updating README.md
|
// The following is useful for updating README.md
|
||||||
// console.log(
|
// console.log(
|
||||||
// "* **[" + ruleName + "](doc/Rules.md#" + ruleName.toLowerCase() +
|
// "* **[" + ruleName + "](doc/Rules.md#" + ruleName.toLowerCase() +
|
||||||
// ")** *" + ruleAliases.join(", ") + "* - " + rule.desc);
|
// ")** *" + ruleAliases.join(", ") + "* - " + rule.description);
|
||||||
rule.tags.forEach(function forTag(tag) {
|
rule.tags.forEach(function forTag(tag) {
|
||||||
var tagUpper = tag.toUpperCase();
|
var tagUpper = tag.toUpperCase();
|
||||||
var ruleNames = idUpperToRuleNames[tagUpper] || [];
|
var ruleNames = idUpperToRuleNames[tagUpper] || [];
|
||||||
|
@ -73,7 +73,7 @@ Results.prototype.toString = function resultsToString(useAlias) {
|
||||||
file + ": " +
|
file + ": " +
|
||||||
lineNumber + ": " +
|
lineNumber + ": " +
|
||||||
rule.names[useAlias ? 1 : 0] + " " +
|
rule.names[useAlias ? 1 : 0] + " " +
|
||||||
rule.desc;
|
rule.description;
|
||||||
results.push(result);
|
results.push(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -241,7 +241,7 @@ function lintContent(
|
||||||
"range": errorInfo.range || null
|
"range": errorInfo.range || null
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
rule.func(params, onError);
|
rule.function(params, onError);
|
||||||
// Record any errors (significant performance benefit from length check)
|
// Record any errors (significant performance benefit from length check)
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
errors.sort(lineNumberComparison);
|
errors.sort(lineNumberComparison);
|
||||||
|
@ -262,7 +262,7 @@ function lintContent(
|
||||||
} else {
|
} else {
|
||||||
errorObject.ruleNames = rule.names;
|
errorObject.ruleNames = rule.names;
|
||||||
}
|
}
|
||||||
errorObject.ruleDescription = rule.desc;
|
errorObject.ruleDescription = rule.description;
|
||||||
errorObject.errorDetail = error.detail;
|
errorObject.errorDetail = error.detail;
|
||||||
errorObject.errorContext = error.context;
|
errorObject.errorContext = error.context;
|
||||||
errorObject.errorRange = error.range;
|
errorObject.errorRange = error.range;
|
||||||
|
|
165
lib/rules.js
165
lib/rules.js
|
@ -7,9 +7,9 @@ var shared = require("./shared");
|
||||||
module.exports = [
|
module.exports = [
|
||||||
{
|
{
|
||||||
"names": [ "MD001", "header-increment" ],
|
"names": [ "MD001", "header-increment" ],
|
||||||
"desc": "Header levels should only increment by one level at a time",
|
"description": "Header levels should only increment by one level at a time",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD001(params, onError) {
|
"function": function MD001(params, onError) {
|
||||||
var prevLevel = 0;
|
var prevLevel = 0;
|
||||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||||
var level = parseInt(token.tag.slice(1), 10);
|
var level = parseInt(token.tag.slice(1), 10);
|
||||||
|
@ -24,9 +24,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD002", "first-header-h1" ],
|
"names": [ "MD002", "first-header-h1" ],
|
||||||
"desc": "First header should be a top level header",
|
"description": "First header should be a top level header",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD002(params, onError) {
|
"function": function MD002(params, onError) {
|
||||||
var level = params.config.level || 1;
|
var level = params.config.level || 1;
|
||||||
var tag = "h" + level;
|
var tag = "h" + level;
|
||||||
params.tokens.every(function forToken(token) {
|
params.tokens.every(function forToken(token) {
|
||||||
|
@ -41,9 +41,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD003", "header-style" ],
|
"names": [ "MD003", "header-style" ],
|
||||||
"desc": "Header style",
|
"description": "Header style",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD003(params, onError) {
|
"function": function MD003(params, onError) {
|
||||||
var style = params.config.style || "consistent";
|
var style = params.config.style || "consistent";
|
||||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||||
var styleForToken = shared.headingStyleFor(token);
|
var styleForToken = shared.headingStyleFor(token);
|
||||||
|
@ -77,9 +77,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD004", "ul-style" ],
|
"names": [ "MD004", "ul-style" ],
|
||||||
"desc": "Unordered list style",
|
"description": "Unordered list style",
|
||||||
"tags": [ "bullet", "ul" ],
|
"tags": [ "bullet", "ul" ],
|
||||||
"func": function MD004(params, onError) {
|
"function": function MD004(params, onError) {
|
||||||
var style = params.config.style || "consistent";
|
var style = params.config.style || "consistent";
|
||||||
var expectedStyle = style;
|
var expectedStyle = style;
|
||||||
var nestingStyles = [];
|
var nestingStyles = [];
|
||||||
|
@ -113,9 +113,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD005", "list-indent" ],
|
"names": [ "MD005", "list-indent" ],
|
||||||
"desc": "Inconsistent indentation for list items at the same level",
|
"description": "Inconsistent indentation for list items at the same level",
|
||||||
"tags": [ "bullet", "ul", "indentation" ],
|
"tags": [ "bullet", "ul", "indentation" ],
|
||||||
"func": function MD005(params, onError) {
|
"function": function MD005(params, onError) {
|
||||||
shared.flattenLists(params).forEach(function forList(list) {
|
shared.flattenLists(params).forEach(function forList(list) {
|
||||||
var indent = shared.indentFor(list.items[0]);
|
var indent = shared.indentFor(list.items[0]);
|
||||||
list.items.forEach(function forItem(item) {
|
list.items.forEach(function forItem(item) {
|
||||||
|
@ -129,9 +129,10 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD006", "ul-start-left" ],
|
"names": [ "MD006", "ul-start-left" ],
|
||||||
"desc": "Consider starting bulleted lists at the beginning of the line",
|
"description":
|
||||||
|
"Consider starting bulleted lists at the beginning of the line",
|
||||||
"tags": [ "bullet", "ul", "indentation" ],
|
"tags": [ "bullet", "ul", "indentation" ],
|
||||||
"func": function MD006(params, onError) {
|
"function": function MD006(params, onError) {
|
||||||
shared.flattenLists(params).forEach(function forList(list) {
|
shared.flattenLists(params).forEach(function forList(list) {
|
||||||
if (list.unordered && !list.nesting) {
|
if (list.unordered && !list.nesting) {
|
||||||
shared.addErrorDetailIf(onError, list.open.lineNumber,
|
shared.addErrorDetailIf(onError, list.open.lineNumber,
|
||||||
|
@ -144,9 +145,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD007", "ul-indent" ],
|
"names": [ "MD007", "ul-indent" ],
|
||||||
"desc": "Unordered list indentation",
|
"description": "Unordered list indentation",
|
||||||
"tags": [ "bullet", "ul", "indentation" ],
|
"tags": [ "bullet", "ul", "indentation" ],
|
||||||
"func": function MD007(params, onError) {
|
"function": function MD007(params, onError) {
|
||||||
var optionsIndent = params.config.indent || 2;
|
var optionsIndent = params.config.indent || 2;
|
||||||
var prevIndent = 0;
|
var prevIndent = 0;
|
||||||
shared.flattenLists(params).forEach(function forList(list) {
|
shared.flattenLists(params).forEach(function forList(list) {
|
||||||
|
@ -165,9 +166,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD009", "no-trailing-spaces" ],
|
"names": [ "MD009", "no-trailing-spaces" ],
|
||||||
"desc": "Trailing spaces",
|
"description": "Trailing spaces",
|
||||||
"tags": [ "whitespace" ],
|
"tags": [ "whitespace" ],
|
||||||
"func": function MD009(params, onError) {
|
"function": function MD009(params, onError) {
|
||||||
var brSpaces = params.config.br_spaces || 0;
|
var brSpaces = params.config.br_spaces || 0;
|
||||||
var listItemEmptyLines = params.config.list_item_empty_lines;
|
var listItemEmptyLines = params.config.list_item_empty_lines;
|
||||||
var trailingSpaceRe = /\s+$/;
|
var trailingSpaceRe = /\s+$/;
|
||||||
|
@ -196,9 +197,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD010", "no-hard-tabs" ],
|
"names": [ "MD010", "no-hard-tabs" ],
|
||||||
"desc": "Hard tabs",
|
"description": "Hard tabs",
|
||||||
"tags": [ "whitespace", "hard_tab" ],
|
"tags": [ "whitespace", "hard_tab" ],
|
||||||
"func": function MD010(params, onError) {
|
"function": function MD010(params, onError) {
|
||||||
var codeBlocks = params.config.code_blocks;
|
var codeBlocks = params.config.code_blocks;
|
||||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||||
var tabRe = /\t+/;
|
var tabRe = /\t+/;
|
||||||
|
@ -214,9 +215,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD011", "no-reversed-links" ],
|
"names": [ "MD011", "no-reversed-links" ],
|
||||||
"desc": "Reversed link syntax",
|
"description": "Reversed link syntax",
|
||||||
"tags": [ "links" ],
|
"tags": [ "links" ],
|
||||||
"func": function MD011(params, onError) {
|
"function": function MD011(params, onError) {
|
||||||
var reversedLinkRe = /\([^)]+\)\[[^\]^][^\]]*]/;
|
var reversedLinkRe = /\([^)]+\)\[[^\]^][^\]]*]/;
|
||||||
shared.forEachInlineChild(params, "text", function forToken(token) {
|
shared.forEachInlineChild(params, "text", function forToken(token) {
|
||||||
var match = reversedLinkRe.exec(token.content);
|
var match = reversedLinkRe.exec(token.content);
|
||||||
|
@ -230,9 +231,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD012", "no-multiple-blanks" ],
|
"names": [ "MD012", "no-multiple-blanks" ],
|
||||||
"desc": "Multiple consecutive blank lines",
|
"description": "Multiple consecutive blank lines",
|
||||||
"tags": [ "whitespace", "blank_lines" ],
|
"tags": [ "whitespace", "blank_lines" ],
|
||||||
"func": function MD012(params, onError) {
|
"function": function MD012(params, onError) {
|
||||||
var maximum = params.config.maximum || 1;
|
var maximum = params.config.maximum || 1;
|
||||||
var count = 0;
|
var count = 0;
|
||||||
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
|
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
|
||||||
|
@ -246,9 +247,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD013", "line-length" ],
|
"names": [ "MD013", "line-length" ],
|
||||||
"desc": "Line length",
|
"description": "Line length",
|
||||||
"tags": [ "line_length" ],
|
"tags": [ "line_length" ],
|
||||||
"func": function MD013(params, onError) {
|
"function": function MD013(params, onError) {
|
||||||
var lineLength = params.config.line_length || 80;
|
var lineLength = params.config.line_length || 80;
|
||||||
var codeBlocks = params.config.code_blocks;
|
var codeBlocks = params.config.code_blocks;
|
||||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||||
|
@ -303,9 +304,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD014", "commands-show-output" ],
|
"names": [ "MD014", "commands-show-output" ],
|
||||||
"desc": "Dollar signs used before commands without showing output",
|
"description": "Dollar signs used before commands without showing output",
|
||||||
"tags": [ "code" ],
|
"tags": [ "code" ],
|
||||||
"func": function MD014(params, onError) {
|
"function": function MD014(params, onError) {
|
||||||
var dollarCommandRe = /^(\s*)(\$\s)/;
|
var dollarCommandRe = /^(\s*)(\$\s)/;
|
||||||
[ "code_block", "fence" ].forEach(function forType(type) {
|
[ "code_block", "fence" ].forEach(function forType(type) {
|
||||||
shared.filterTokens(params, type, function forToken(token) {
|
shared.filterTokens(params, type, function forToken(token) {
|
||||||
|
@ -325,9 +326,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD018", "no-missing-space-atx" ],
|
"names": [ "MD018", "no-missing-space-atx" ],
|
||||||
"desc": "No space after hash on atx style header",
|
"description": "No space after hash on atx style header",
|
||||||
"tags": [ "headers", "atx", "spaces" ],
|
"tags": [ "headers", "atx", "spaces" ],
|
||||||
"func": function MD018(params, onError) {
|
"function": function MD018(params, onError) {
|
||||||
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
|
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
|
||||||
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
|
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
|
||||||
shared.addErrorContext(onError, lineIndex + 1, line.trim(), null,
|
shared.addErrorContext(onError, lineIndex + 1, line.trim(), null,
|
||||||
|
@ -339,9 +340,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD019", "no-multiple-space-atx" ],
|
"names": [ "MD019", "no-multiple-space-atx" ],
|
||||||
"desc": "Multiple spaces after hash on atx style header",
|
"description": "Multiple spaces after hash on atx style header",
|
||||||
"tags": [ "headers", "atx", "spaces" ],
|
"tags": [ "headers", "atx", "spaces" ],
|
||||||
"func": function MD019(params, onError) {
|
"function": function MD019(params, onError) {
|
||||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||||
if ((shared.headingStyleFor(token) === "atx") &&
|
if ((shared.headingStyleFor(token) === "atx") &&
|
||||||
/^#+\s\s/.test(token.line)) {
|
/^#+\s\s/.test(token.line)) {
|
||||||
|
@ -355,9 +356,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
||||||
"desc": "No space inside hashes on closed atx style header",
|
"description": "No space inside hashes on closed atx style header",
|
||||||
"tags": [ "headers", "atx_closed", "spaces" ],
|
"tags": [ "headers", "atx_closed", "spaces" ],
|
||||||
"func": function MD020(params, onError) {
|
"function": function MD020(params, onError) {
|
||||||
var atxClosedHeaderNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
|
var atxClosedHeaderNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
|
||||||
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
|
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
|
||||||
if (!inCode && /^#+[^#]*[^\\]#+$/.test(line)) {
|
if (!inCode && /^#+[^#]*[^\\]#+$/.test(line)) {
|
||||||
|
@ -374,9 +375,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD021", "no-multiple-space-closed-atx" ],
|
"names": [ "MD021", "no-multiple-space-closed-atx" ],
|
||||||
"desc": "Multiple spaces inside hashes on closed atx style header",
|
"description": "Multiple spaces inside hashes on closed atx style header",
|
||||||
"tags": [ "headers", "atx_closed", "spaces" ],
|
"tags": [ "headers", "atx_closed", "spaces" ],
|
||||||
"func": function MD021(params, onError) {
|
"function": function MD021(params, onError) {
|
||||||
var atxClosedHeaderSpaceRe = /(?:^#+\s\s+?\S)|(?:\S\s\s+?#+\s*$)/;
|
var atxClosedHeaderSpaceRe = /(?:^#+\s\s+?\S)|(?:\S\s\s+?#+\s*$)/;
|
||||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||||
if (shared.headingStyleFor(token) === "atx_closed") {
|
if (shared.headingStyleFor(token) === "atx_closed") {
|
||||||
|
@ -394,9 +395,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD022", "blanks-around-headers" ],
|
"names": [ "MD022", "blanks-around-headers" ],
|
||||||
"desc": "Headers should be surrounded by blank lines",
|
"description": "Headers should be surrounded by blank lines",
|
||||||
"tags": [ "headers", "blank_lines" ],
|
"tags": [ "headers", "blank_lines" ],
|
||||||
"func": function MD022(params, onError) {
|
"function": function MD022(params, onError) {
|
||||||
var prevHeadingLineNumber = 0;
|
var prevHeadingLineNumber = 0;
|
||||||
var prevMaxLineIndex = -1;
|
var prevMaxLineIndex = -1;
|
||||||
var needBlankLine = false;
|
var needBlankLine = false;
|
||||||
|
@ -428,9 +429,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD023", "header-start-left" ],
|
"names": [ "MD023", "header-start-left" ],
|
||||||
"desc": "Headers must start at the beginning of the line",
|
"description": "Headers must start at the beginning of the line",
|
||||||
"tags": [ "headers", "spaces" ],
|
"tags": [ "headers", "spaces" ],
|
||||||
"func": function MD023(params, onError) {
|
"function": function MD023(params, onError) {
|
||||||
var spaceBeforeHeaderRe = /^\s+\S/;
|
var spaceBeforeHeaderRe = /^\s+\S/;
|
||||||
shared.filterTokens(params, "heading_open", function forToken(token) {
|
shared.filterTokens(params, "heading_open", function forToken(token) {
|
||||||
if (spaceBeforeHeaderRe.test(token.line)) {
|
if (spaceBeforeHeaderRe.test(token.line)) {
|
||||||
|
@ -443,9 +444,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD024", "no-duplicate-header" ],
|
"names": [ "MD024", "no-duplicate-header" ],
|
||||||
"desc": "Multiple headers with the same content",
|
"description": "Multiple headers with the same content",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD024(params, onError) {
|
"function": function MD024(params, onError) {
|
||||||
var knownContent = [];
|
var knownContent = [];
|
||||||
shared.forEachHeading(params, function forHeading(heading, content) {
|
shared.forEachHeading(params, function forHeading(heading, content) {
|
||||||
if (knownContent.indexOf(content) === -1) {
|
if (knownContent.indexOf(content) === -1) {
|
||||||
|
@ -460,9 +461,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD025", "single-h1" ],
|
"names": [ "MD025", "single-h1" ],
|
||||||
"desc": "Multiple top level headers in the same document",
|
"description": "Multiple top level headers in the same document",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD025(params, onError) {
|
"function": function MD025(params, onError) {
|
||||||
var level = params.config.level || 1;
|
var level = params.config.level || 1;
|
||||||
var tag = "h" + level;
|
var tag = "h" + level;
|
||||||
var hasTopLevelHeading = false;
|
var hasTopLevelHeading = false;
|
||||||
|
@ -481,9 +482,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||||
"desc": "Trailing punctuation in header",
|
"description": "Trailing punctuation in header",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD026(params, onError) {
|
"function": function MD026(params, onError) {
|
||||||
var punctuation = params.config.punctuation || ".,;:!?";
|
var punctuation = params.config.punctuation || ".,;:!?";
|
||||||
var trailingPunctuationRe = new RegExp("[" + punctuation + "]$");
|
var trailingPunctuationRe = new RegExp("[" + punctuation + "]$");
|
||||||
shared.forEachHeading(params, function forHeading(heading, content) {
|
shared.forEachHeading(params, function forHeading(heading, content) {
|
||||||
|
@ -499,9 +500,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||||
"desc": "Multiple spaces after blockquote symbol",
|
"description": "Multiple spaces after blockquote symbol",
|
||||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||||
"func": function MD027(params, onError) {
|
"function": function MD027(params, onError) {
|
||||||
var spaceAfterBlockQuote = /^\s*(?:>\s+)+\S/;
|
var spaceAfterBlockQuote = /^\s*(?:>\s+)+\S/;
|
||||||
var blockquoteNesting = 0;
|
var blockquoteNesting = 0;
|
||||||
var listItemNesting = 0;
|
var listItemNesting = 0;
|
||||||
|
@ -537,9 +538,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD028", "no-blanks-blockquote" ],
|
"names": [ "MD028", "no-blanks-blockquote" ],
|
||||||
"desc": "Blank line inside blockquote",
|
"description": "Blank line inside blockquote",
|
||||||
"tags": [ "blockquote", "whitespace" ],
|
"tags": [ "blockquote", "whitespace" ],
|
||||||
"func": function MD028(params, onError) {
|
"function": function MD028(params, onError) {
|
||||||
var prevToken = {};
|
var prevToken = {};
|
||||||
params.tokens.forEach(function forToken(token) {
|
params.tokens.forEach(function forToken(token) {
|
||||||
if ((token.type === "blockquote_open") &&
|
if ((token.type === "blockquote_open") &&
|
||||||
|
@ -553,9 +554,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD029", "ol-prefix" ],
|
"names": [ "MD029", "ol-prefix" ],
|
||||||
"desc": "Ordered list item prefix",
|
"description": "Ordered list item prefix",
|
||||||
"tags": [ "ol" ],
|
"tags": [ "ol" ],
|
||||||
"func": function MD029(params, onError) {
|
"function": function MD029(params, onError) {
|
||||||
var style = params.config.style || "one_or_ordered";
|
var style = params.config.style || "one_or_ordered";
|
||||||
var numberRe = /^[\s>]*([^.)]*)[.)]/;
|
var numberRe = /^[\s>]*([^.)]*)[.)]/;
|
||||||
shared.flattenLists(params).forEach(function forList(list) {
|
shared.flattenLists(params).forEach(function forList(list) {
|
||||||
|
@ -584,9 +585,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD030", "list-marker-space" ],
|
"names": [ "MD030", "list-marker-space" ],
|
||||||
"desc": "Spaces after list markers",
|
"description": "Spaces after list markers",
|
||||||
"tags": [ "ol", "ul", "whitespace" ],
|
"tags": [ "ol", "ul", "whitespace" ],
|
||||||
"func": function MD030(params, onError) {
|
"function": function MD030(params, onError) {
|
||||||
var ulSingle = params.config.ul_single || 1;
|
var ulSingle = params.config.ul_single || 1;
|
||||||
var olSingle = params.config.ol_single || 1;
|
var olSingle = params.config.ol_single || 1;
|
||||||
var ulMulti = params.config.ul_multi || 1;
|
var ulMulti = params.config.ul_multi || 1;
|
||||||
|
@ -609,9 +610,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD031", "blanks-around-fences" ],
|
"names": [ "MD031", "blanks-around-fences" ],
|
||||||
"desc": "Fenced code blocks should be surrounded by blank lines",
|
"description": "Fenced code blocks should be surrounded by blank lines",
|
||||||
"tags": [ "code", "blank_lines" ],
|
"tags": [ "code", "blank_lines" ],
|
||||||
"func": function MD031(params, onError) {
|
"function": function MD031(params, onError) {
|
||||||
var lines = params.lines;
|
var lines = params.lines;
|
||||||
shared.forEachLine(params, function forLine(line, i, inCode, onFence) {
|
shared.forEachLine(params, function forLine(line, i, inCode, onFence) {
|
||||||
if (((onFence > 0) && (i - 1 >= 0) && lines[i - 1].length) ||
|
if (((onFence > 0) && (i - 1 >= 0) && lines[i - 1].length) ||
|
||||||
|
@ -624,9 +625,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD032", "blanks-around-lists" ],
|
"names": [ "MD032", "blanks-around-lists" ],
|
||||||
"desc": "Lists should be surrounded by blank lines",
|
"description": "Lists should be surrounded by blank lines",
|
||||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||||
"func": function MD032(params, onError) {
|
"function": function MD032(params, onError) {
|
||||||
var listItemMarkerInterruptsRe = /^[\s>]*(?:[*+-]|1\.)\s+/;
|
var listItemMarkerInterruptsRe = /^[\s>]*(?:[*+-]|1\.)\s+/;
|
||||||
var blankOrListRe = /^[\s>]*($|\s)/;
|
var blankOrListRe = /^[\s>]*($|\s)/;
|
||||||
var inList = false;
|
var inList = false;
|
||||||
|
@ -656,9 +657,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD033", "no-inline-html" ],
|
"names": [ "MD033", "no-inline-html" ],
|
||||||
"desc": "Inline HTML",
|
"description": "Inline HTML",
|
||||||
"tags": [ "html" ],
|
"tags": [ "html" ],
|
||||||
"func": function MD033(params, onError) {
|
"function": function MD033(params, onError) {
|
||||||
var allowedElements = (params.config.allowed_elements || [])
|
var allowedElements = (params.config.allowed_elements || [])
|
||||||
.map(function forElement(element) {
|
.map(function forElement(element) {
|
||||||
return element.toLowerCase();
|
return element.toLowerCase();
|
||||||
|
@ -691,9 +692,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD034", "no-bare-urls" ],
|
"names": [ "MD034", "no-bare-urls" ],
|
||||||
"desc": "Bare URL used",
|
"description": "Bare URL used",
|
||||||
"tags": [ "links", "url" ],
|
"tags": [ "links", "url" ],
|
||||||
"func": function MD034(params, onError) {
|
"function": function MD034(params, onError) {
|
||||||
shared.filterTokens(params, "inline", function forToken(token) {
|
shared.filterTokens(params, "inline", function forToken(token) {
|
||||||
var inLink = false;
|
var inLink = false;
|
||||||
token.children.forEach(function forChild(child) {
|
token.children.forEach(function forChild(child) {
|
||||||
|
@ -715,9 +716,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD035", "hr-style" ],
|
"names": [ "MD035", "hr-style" ],
|
||||||
"desc": "Horizontal rule style",
|
"description": "Horizontal rule style",
|
||||||
"tags": [ "hr" ],
|
"tags": [ "hr" ],
|
||||||
"func": function MD035(params, onError) {
|
"function": function MD035(params, onError) {
|
||||||
var style = params.config.style || "consistent";
|
var style = params.config.style || "consistent";
|
||||||
shared.filterTokens(params, "hr", function forToken(token) {
|
shared.filterTokens(params, "hr", function forToken(token) {
|
||||||
var lineTrim = token.line.trim();
|
var lineTrim = token.line.trim();
|
||||||
|
@ -731,9 +732,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD036", "no-emphasis-as-header" ],
|
"names": [ "MD036", "no-emphasis-as-header" ],
|
||||||
"desc": "Emphasis used instead of a header",
|
"description": "Emphasis used instead of a header",
|
||||||
"tags": [ "headers", "emphasis" ],
|
"tags": [ "headers", "emphasis" ],
|
||||||
"func": function MD036(params, onError) {
|
"function": function MD036(params, onError) {
|
||||||
var punctuation = params.config.punctuation || ".,;:!?";
|
var punctuation = params.config.punctuation || ".,;:!?";
|
||||||
var re = new RegExp("[" + punctuation + "]$");
|
var re = new RegExp("[" + punctuation + "]$");
|
||||||
function base(token) {
|
function base(token) {
|
||||||
|
@ -780,9 +781,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD037", "no-space-in-emphasis" ],
|
"names": [ "MD037", "no-space-in-emphasis" ],
|
||||||
"desc": "Spaces inside emphasis markers",
|
"description": "Spaces inside emphasis markers",
|
||||||
"tags": [ "whitespace", "emphasis" ],
|
"tags": [ "whitespace", "emphasis" ],
|
||||||
"func": function MD037(params, onError) {
|
"function": function MD037(params, onError) {
|
||||||
shared.forEachInlineChild(params, "text", function forToken(token) {
|
shared.forEachInlineChild(params, "text", function forToken(token) {
|
||||||
var left = true;
|
var left = true;
|
||||||
var match = /\s(\*\*?|__?)\s.+\1/.exec(token.content);
|
var match = /\s(\*\*?|__?)\s.+\1/.exec(token.content);
|
||||||
|
@ -804,9 +805,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD038", "no-space-in-code" ],
|
"names": [ "MD038", "no-space-in-code" ],
|
||||||
"desc": "Spaces inside code span elements",
|
"description": "Spaces inside code span elements",
|
||||||
"tags": [ "whitespace", "code" ],
|
"tags": [ "whitespace", "code" ],
|
||||||
"func": function MD038(params, onError) {
|
"function": function MD038(params, onError) {
|
||||||
var inlineCodeSpansRe = /(?:^|[^\\])((`+)((?:.*?[^`])|)\2(?!`))/g;
|
var inlineCodeSpansRe = /(?:^|[^\\])((`+)((?:.*?[^`])|)\2(?!`))/g;
|
||||||
shared.forEachInlineChild(params, "code_inline",
|
shared.forEachInlineChild(params, "code_inline",
|
||||||
function forToken(token) {
|
function forToken(token) {
|
||||||
|
@ -832,9 +833,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD039", "no-space-in-links" ],
|
"names": [ "MD039", "no-space-in-links" ],
|
||||||
"desc": "Spaces inside link text",
|
"description": "Spaces inside link text",
|
||||||
"tags": [ "whitespace", "links" ],
|
"tags": [ "whitespace", "links" ],
|
||||||
"func": function MD039(params, onError) {
|
"function": function MD039(params, onError) {
|
||||||
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
|
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
|
||||||
shared.filterTokens(params, "inline", function forToken(token) {
|
shared.filterTokens(params, "inline", function forToken(token) {
|
||||||
var inLink = false;
|
var inLink = false;
|
||||||
|
@ -862,9 +863,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD040", "fenced-code-language" ],
|
"names": [ "MD040", "fenced-code-language" ],
|
||||||
"desc": "Fenced code blocks should have a language specified",
|
"description": "Fenced code blocks should have a language specified",
|
||||||
"tags": [ "code", "language" ],
|
"tags": [ "code", "language" ],
|
||||||
"func": function MD040(params, onError) {
|
"function": function MD040(params, onError) {
|
||||||
shared.filterTokens(params, "fence", function forToken(token) {
|
shared.filterTokens(params, "fence", function forToken(token) {
|
||||||
if (!token.info.trim()) {
|
if (!token.info.trim()) {
|
||||||
shared.addErrorContext(onError, token.lineNumber, token.line);
|
shared.addErrorContext(onError, token.lineNumber, token.line);
|
||||||
|
@ -875,9 +876,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD041", "first-line-h1" ],
|
"names": [ "MD041", "first-line-h1" ],
|
||||||
"desc": "First line in file should be a top level header",
|
"description": "First line in file should be a top level header",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD041(params, onError) {
|
"function": function MD041(params, onError) {
|
||||||
var level = params.config.level || 1;
|
var level = params.config.level || 1;
|
||||||
var frontMatterTitle = params.config.front_matter_title;
|
var frontMatterTitle = params.config.front_matter_title;
|
||||||
var tag = "h" + level;
|
var tag = "h" + level;
|
||||||
|
@ -906,9 +907,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD042", "no-empty-links" ],
|
"names": [ "MD042", "no-empty-links" ],
|
||||||
"desc": "No empty links",
|
"description": "No empty links",
|
||||||
"tags": [ "links" ],
|
"tags": [ "links" ],
|
||||||
"func": function MD042(params, onError) {
|
"function": function MD042(params, onError) {
|
||||||
var emptyLinkRe = /\[[^\]]*](?:\((?:#?|(?:<>))\))/;
|
var emptyLinkRe = /\[[^\]]*](?:\((?:#?|(?:<>))\))/;
|
||||||
shared.filterTokens(params, "inline", function forToken(token) {
|
shared.filterTokens(params, "inline", function forToken(token) {
|
||||||
var inLink = false;
|
var inLink = false;
|
||||||
|
@ -940,9 +941,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD043", "required-headers" ],
|
"names": [ "MD043", "required-headers" ],
|
||||||
"desc": "Required header structure",
|
"description": "Required header structure",
|
||||||
"tags": [ "headers" ],
|
"tags": [ "headers" ],
|
||||||
"func": function MD043(params, onError) {
|
"function": function MD043(params, onError) {
|
||||||
var requiredHeaders = params.config.headers;
|
var requiredHeaders = params.config.headers;
|
||||||
if (requiredHeaders) {
|
if (requiredHeaders) {
|
||||||
var levels = {};
|
var levels = {};
|
||||||
|
@ -979,9 +980,9 @@ module.exports = [
|
||||||
|
|
||||||
{
|
{
|
||||||
"names": [ "MD044", "proper-names" ],
|
"names": [ "MD044", "proper-names" ],
|
||||||
"desc": "Proper names should have the correct capitalization",
|
"description": "Proper names should have the correct capitalization",
|
||||||
"tags": [ "spelling" ],
|
"tags": [ "spelling" ],
|
||||||
"func": function MD044(params, onError) {
|
"function": function MD044(params, onError) {
|
||||||
var names = params.config.names || [];
|
var names = params.config.names || [];
|
||||||
var codeBlocks = params.config.code_blocks;
|
var codeBlocks = params.config.code_blocks;
|
||||||
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
|
||||||
|
@ -1020,9 +1021,9 @@ module.exports = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"names": [ "MD045", "no-alt-text" ],
|
"names": [ "MD045", "no-alt-text" ],
|
||||||
"desc": "Images should have alternate text (alt text)",
|
"description": "Images should have alternate text (alt text)",
|
||||||
"tags": [ "accessibility", "images" ],
|
"tags": [ "accessibility", "images" ],
|
||||||
"func": function MD045(params, onError) {
|
"function": function MD045(params, onError) {
|
||||||
shared.forEachInlineChild(params, "image", function forToken(token) {
|
shared.forEachInlineChild(params, "image", function forToken(token) {
|
||||||
if (token.content === "") {
|
if (token.content === "") {
|
||||||
shared.addError(onError, token.lineNumber);
|
shared.addError(onError, token.lineNumber);
|
||||||
|
|
|
@ -32,7 +32,7 @@ rules.forEach(function forRule(rule) {
|
||||||
tags[tag] = tagRules;
|
tags[tag] = tagRules;
|
||||||
});
|
});
|
||||||
var scheme = {
|
var scheme = {
|
||||||
"description": rule.names.join("/") + " - " + rule.desc,
|
"description": rule.names.join("/") + " - " + rule.description,
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true
|
"default": true
|
||||||
};
|
};
|
||||||
|
|
|
@ -1090,7 +1090,7 @@ module.exports.readme = function readme(test) {
|
||||||
var ruleAliases = rule.names.slice(1);
|
var ruleAliases = rule.names.slice(1);
|
||||||
var expected = "**[" + ruleName + "](doc/Rules.md#" +
|
var expected = "**[" + ruleName + "](doc/Rules.md#" +
|
||||||
ruleName.toLowerCase() + ")** *" +
|
ruleName.toLowerCase() + ")** *" +
|
||||||
ruleAliases.join(", ") + "* - " + rule.desc;
|
ruleAliases.join(", ") + "* - " + rule.description;
|
||||||
test.equal(token.content, expected, "Rule mismatch.");
|
test.equal(token.content, expected, "Rule mismatch.");
|
||||||
}
|
}
|
||||||
} else if (inTags) {
|
} else if (inTags) {
|
||||||
|
@ -1146,9 +1146,10 @@ module.exports.doc = function doc(test) {
|
||||||
test.ok(rule,
|
test.ok(rule,
|
||||||
"Missing rule implementation for " + token.content + ".");
|
"Missing rule implementation for " + token.content + ".");
|
||||||
if (rule) {
|
if (rule) {
|
||||||
test.equal(token.content, rule.names[0] + " - " + rule.desc,
|
test.equal(token.content,
|
||||||
|
rule.names[0] + " - " + rule.description,
|
||||||
"Rule mismatch.");
|
"Rule mismatch.");
|
||||||
ruleUsesParams = rule.func.toString()
|
ruleUsesParams = rule.function.toString()
|
||||||
.match(/params\.config\.[_a-z]*/gi);
|
.match(/params\.config\.[_a-z]*/gi);
|
||||||
if (ruleUsesParams) {
|
if (ruleUsesParams) {
|
||||||
ruleUsesParams = ruleUsesParams.map(function forUse(use) {
|
ruleUsesParams = ruleUsesParams.map(function forUse(use) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue