Remove abbreviations from rule metadata to clarify API.

This commit is contained in:
David Anson 2018-01-18 21:34:30 -08:00
parent 513a1351a5
commit 49e36f817c
4 changed files with 92 additions and 90 deletions

View file

@ -7,9 +7,9 @@ var shared = require("./shared");
module.exports = [
{
"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" ],
"func": function MD001(params, onError) {
"function": function MD001(params, onError) {
var prevLevel = 0;
shared.filterTokens(params, "heading_open", function forToken(token) {
var level = parseInt(token.tag.slice(1), 10);
@ -24,9 +24,9 @@ module.exports = [
{
"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" ],
"func": function MD002(params, onError) {
"function": function MD002(params, onError) {
var level = params.config.level || 1;
var tag = "h" + level;
params.tokens.every(function forToken(token) {
@ -41,9 +41,9 @@ module.exports = [
{
"names": [ "MD003", "header-style" ],
"desc": "Header style",
"description": "Header style",
"tags": [ "headers" ],
"func": function MD003(params, onError) {
"function": function MD003(params, onError) {
var style = params.config.style || "consistent";
shared.filterTokens(params, "heading_open", function forToken(token) {
var styleForToken = shared.headingStyleFor(token);
@ -77,9 +77,9 @@ module.exports = [
{
"names": [ "MD004", "ul-style" ],
"desc": "Unordered list style",
"description": "Unordered list style",
"tags": [ "bullet", "ul" ],
"func": function MD004(params, onError) {
"function": function MD004(params, onError) {
var style = params.config.style || "consistent";
var expectedStyle = style;
var nestingStyles = [];
@ -113,9 +113,9 @@ module.exports = [
{
"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" ],
"func": function MD005(params, onError) {
"function": function MD005(params, onError) {
shared.flattenLists(params).forEach(function forList(list) {
var indent = shared.indentFor(list.items[0]);
list.items.forEach(function forItem(item) {
@ -129,9 +129,10 @@ module.exports = [
{
"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" ],
"func": function MD006(params, onError) {
"function": function MD006(params, onError) {
shared.flattenLists(params).forEach(function forList(list) {
if (list.unordered && !list.nesting) {
shared.addErrorDetailIf(onError, list.open.lineNumber,
@ -144,9 +145,9 @@ module.exports = [
{
"names": [ "MD007", "ul-indent" ],
"desc": "Unordered list indentation",
"description": "Unordered list indentation",
"tags": [ "bullet", "ul", "indentation" ],
"func": function MD007(params, onError) {
"function": function MD007(params, onError) {
var optionsIndent = params.config.indent || 2;
var prevIndent = 0;
shared.flattenLists(params).forEach(function forList(list) {
@ -165,9 +166,9 @@ module.exports = [
{
"names": [ "MD009", "no-trailing-spaces" ],
"desc": "Trailing spaces",
"description": "Trailing spaces",
"tags": [ "whitespace" ],
"func": function MD009(params, onError) {
"function": function MD009(params, onError) {
var brSpaces = params.config.br_spaces || 0;
var listItemEmptyLines = params.config.list_item_empty_lines;
var trailingSpaceRe = /\s+$/;
@ -196,9 +197,9 @@ module.exports = [
{
"names": [ "MD010", "no-hard-tabs" ],
"desc": "Hard tabs",
"description": "Hard tabs",
"tags": [ "whitespace", "hard_tab" ],
"func": function MD010(params, onError) {
"function": function MD010(params, onError) {
var codeBlocks = params.config.code_blocks;
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
var tabRe = /\t+/;
@ -214,9 +215,9 @@ module.exports = [
{
"names": [ "MD011", "no-reversed-links" ],
"desc": "Reversed link syntax",
"description": "Reversed link syntax",
"tags": [ "links" ],
"func": function MD011(params, onError) {
"function": function MD011(params, onError) {
var reversedLinkRe = /\([^)]+\)\[[^\]^][^\]]*]/;
shared.forEachInlineChild(params, "text", function forToken(token) {
var match = reversedLinkRe.exec(token.content);
@ -230,9 +231,9 @@ module.exports = [
{
"names": [ "MD012", "no-multiple-blanks" ],
"desc": "Multiple consecutive blank lines",
"description": "Multiple consecutive blank lines",
"tags": [ "whitespace", "blank_lines" ],
"func": function MD012(params, onError) {
"function": function MD012(params, onError) {
var maximum = params.config.maximum || 1;
var count = 0;
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
@ -246,9 +247,9 @@ module.exports = [
{
"names": [ "MD013", "line-length" ],
"desc": "Line length",
"description": "Line length",
"tags": [ "line_length" ],
"func": function MD013(params, onError) {
"function": function MD013(params, onError) {
var lineLength = params.config.line_length || 80;
var codeBlocks = params.config.code_blocks;
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
@ -303,9 +304,9 @@ module.exports = [
{
"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" ],
"func": function MD014(params, onError) {
"function": function MD014(params, onError) {
var dollarCommandRe = /^(\s*)(\$\s)/;
[ "code_block", "fence" ].forEach(function forType(type) {
shared.filterTokens(params, type, function forToken(token) {
@ -325,9 +326,9 @@ module.exports = [
{
"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" ],
"func": function MD018(params, onError) {
"function": function MD018(params, onError) {
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
if (!inCode && /^#+[^#\s]/.test(line) && !/#$/.test(line)) {
shared.addErrorContext(onError, lineIndex + 1, line.trim(), null,
@ -339,9 +340,9 @@ module.exports = [
{
"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" ],
"func": function MD019(params, onError) {
"function": function MD019(params, onError) {
shared.filterTokens(params, "heading_open", function forToken(token) {
if ((shared.headingStyleFor(token) === "atx") &&
/^#+\s\s/.test(token.line)) {
@ -355,9 +356,9 @@ module.exports = [
{
"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" ],
"func": function MD020(params, onError) {
"function": function MD020(params, onError) {
var atxClosedHeaderNoSpaceRe = /(?:^#+[^#\s])|(?:[^#\s]#+\s*$)/;
shared.forEachLine(params, function forLine(line, lineIndex, inCode) {
if (!inCode && /^#+[^#]*[^\\]#+$/.test(line)) {
@ -374,9 +375,9 @@ module.exports = [
{
"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" ],
"func": function MD021(params, onError) {
"function": function MD021(params, onError) {
var atxClosedHeaderSpaceRe = /(?:^#+\s\s+?\S)|(?:\S\s\s+?#+\s*$)/;
shared.filterTokens(params, "heading_open", function forToken(token) {
if (shared.headingStyleFor(token) === "atx_closed") {
@ -394,9 +395,9 @@ module.exports = [
{
"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" ],
"func": function MD022(params, onError) {
"function": function MD022(params, onError) {
var prevHeadingLineNumber = 0;
var prevMaxLineIndex = -1;
var needBlankLine = false;
@ -428,9 +429,9 @@ module.exports = [
{
"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" ],
"func": function MD023(params, onError) {
"function": function MD023(params, onError) {
var spaceBeforeHeaderRe = /^\s+\S/;
shared.filterTokens(params, "heading_open", function forToken(token) {
if (spaceBeforeHeaderRe.test(token.line)) {
@ -443,9 +444,9 @@ module.exports = [
{
"names": [ "MD024", "no-duplicate-header" ],
"desc": "Multiple headers with the same content",
"description": "Multiple headers with the same content",
"tags": [ "headers" ],
"func": function MD024(params, onError) {
"function": function MD024(params, onError) {
var knownContent = [];
shared.forEachHeading(params, function forHeading(heading, content) {
if (knownContent.indexOf(content) === -1) {
@ -460,9 +461,9 @@ module.exports = [
{
"names": [ "MD025", "single-h1" ],
"desc": "Multiple top level headers in the same document",
"description": "Multiple top level headers in the same document",
"tags": [ "headers" ],
"func": function MD025(params, onError) {
"function": function MD025(params, onError) {
var level = params.config.level || 1;
var tag = "h" + level;
var hasTopLevelHeading = false;
@ -481,9 +482,9 @@ module.exports = [
{
"names": [ "MD026", "no-trailing-punctuation" ],
"desc": "Trailing punctuation in header",
"description": "Trailing punctuation in header",
"tags": [ "headers" ],
"func": function MD026(params, onError) {
"function": function MD026(params, onError) {
var punctuation = params.config.punctuation || ".,;:!?";
var trailingPunctuationRe = new RegExp("[" + punctuation + "]$");
shared.forEachHeading(params, function forHeading(heading, content) {
@ -499,9 +500,9 @@ module.exports = [
{
"names": [ "MD027", "no-multiple-space-blockquote" ],
"desc": "Multiple spaces after blockquote symbol",
"description": "Multiple spaces after blockquote symbol",
"tags": [ "blockquote", "whitespace", "indentation" ],
"func": function MD027(params, onError) {
"function": function MD027(params, onError) {
var spaceAfterBlockQuote = /^\s*(?:>\s+)+\S/;
var blockquoteNesting = 0;
var listItemNesting = 0;
@ -537,9 +538,9 @@ module.exports = [
{
"names": [ "MD028", "no-blanks-blockquote" ],
"desc": "Blank line inside blockquote",
"description": "Blank line inside blockquote",
"tags": [ "blockquote", "whitespace" ],
"func": function MD028(params, onError) {
"function": function MD028(params, onError) {
var prevToken = {};
params.tokens.forEach(function forToken(token) {
if ((token.type === "blockquote_open") &&
@ -553,9 +554,9 @@ module.exports = [
{
"names": [ "MD029", "ol-prefix" ],
"desc": "Ordered list item prefix",
"description": "Ordered list item prefix",
"tags": [ "ol" ],
"func": function MD029(params, onError) {
"function": function MD029(params, onError) {
var style = params.config.style || "one_or_ordered";
var numberRe = /^[\s>]*([^.)]*)[.)]/;
shared.flattenLists(params).forEach(function forList(list) {
@ -584,9 +585,9 @@ module.exports = [
{
"names": [ "MD030", "list-marker-space" ],
"desc": "Spaces after list markers",
"description": "Spaces after list markers",
"tags": [ "ol", "ul", "whitespace" ],
"func": function MD030(params, onError) {
"function": function MD030(params, onError) {
var ulSingle = params.config.ul_single || 1;
var olSingle = params.config.ol_single || 1;
var ulMulti = params.config.ul_multi || 1;
@ -609,9 +610,9 @@ module.exports = [
{
"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" ],
"func": function MD031(params, onError) {
"function": function MD031(params, onError) {
var lines = params.lines;
shared.forEachLine(params, function forLine(line, i, inCode, onFence) {
if (((onFence > 0) && (i - 1 >= 0) && lines[i - 1].length) ||
@ -624,9 +625,9 @@ module.exports = [
{
"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" ],
"func": function MD032(params, onError) {
"function": function MD032(params, onError) {
var listItemMarkerInterruptsRe = /^[\s>]*(?:[*+-]|1\.)\s+/;
var blankOrListRe = /^[\s>]*($|\s)/;
var inList = false;
@ -656,9 +657,9 @@ module.exports = [
{
"names": [ "MD033", "no-inline-html" ],
"desc": "Inline HTML",
"description": "Inline HTML",
"tags": [ "html" ],
"func": function MD033(params, onError) {
"function": function MD033(params, onError) {
var allowedElements = (params.config.allowed_elements || [])
.map(function forElement(element) {
return element.toLowerCase();
@ -691,9 +692,9 @@ module.exports = [
{
"names": [ "MD034", "no-bare-urls" ],
"desc": "Bare URL used",
"description": "Bare URL used",
"tags": [ "links", "url" ],
"func": function MD034(params, onError) {
"function": function MD034(params, onError) {
shared.filterTokens(params, "inline", function forToken(token) {
var inLink = false;
token.children.forEach(function forChild(child) {
@ -715,9 +716,9 @@ module.exports = [
{
"names": [ "MD035", "hr-style" ],
"desc": "Horizontal rule style",
"description": "Horizontal rule style",
"tags": [ "hr" ],
"func": function MD035(params, onError) {
"function": function MD035(params, onError) {
var style = params.config.style || "consistent";
shared.filterTokens(params, "hr", function forToken(token) {
var lineTrim = token.line.trim();
@ -731,9 +732,9 @@ module.exports = [
{
"names": [ "MD036", "no-emphasis-as-header" ],
"desc": "Emphasis used instead of a header",
"description": "Emphasis used instead of a header",
"tags": [ "headers", "emphasis" ],
"func": function MD036(params, onError) {
"function": function MD036(params, onError) {
var punctuation = params.config.punctuation || ".,;:!?";
var re = new RegExp("[" + punctuation + "]$");
function base(token) {
@ -780,9 +781,9 @@ module.exports = [
{
"names": [ "MD037", "no-space-in-emphasis" ],
"desc": "Spaces inside emphasis markers",
"description": "Spaces inside emphasis markers",
"tags": [ "whitespace", "emphasis" ],
"func": function MD037(params, onError) {
"function": function MD037(params, onError) {
shared.forEachInlineChild(params, "text", function forToken(token) {
var left = true;
var match = /\s(\*\*?|__?)\s.+\1/.exec(token.content);
@ -804,9 +805,9 @@ module.exports = [
{
"names": [ "MD038", "no-space-in-code" ],
"desc": "Spaces inside code span elements",
"description": "Spaces inside code span elements",
"tags": [ "whitespace", "code" ],
"func": function MD038(params, onError) {
"function": function MD038(params, onError) {
var inlineCodeSpansRe = /(?:^|[^\\])((`+)((?:.*?[^`])|)\2(?!`))/g;
shared.forEachInlineChild(params, "code_inline",
function forToken(token) {
@ -832,9 +833,9 @@ module.exports = [
{
"names": [ "MD039", "no-space-in-links" ],
"desc": "Spaces inside link text",
"description": "Spaces inside link text",
"tags": [ "whitespace", "links" ],
"func": function MD039(params, onError) {
"function": function MD039(params, onError) {
var spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
shared.filterTokens(params, "inline", function forToken(token) {
var inLink = false;
@ -862,9 +863,9 @@ module.exports = [
{
"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" ],
"func": function MD040(params, onError) {
"function": function MD040(params, onError) {
shared.filterTokens(params, "fence", function forToken(token) {
if (!token.info.trim()) {
shared.addErrorContext(onError, token.lineNumber, token.line);
@ -875,9 +876,9 @@ module.exports = [
{
"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" ],
"func": function MD041(params, onError) {
"function": function MD041(params, onError) {
var level = params.config.level || 1;
var frontMatterTitle = params.config.front_matter_title;
var tag = "h" + level;
@ -906,9 +907,9 @@ module.exports = [
{
"names": [ "MD042", "no-empty-links" ],
"desc": "No empty links",
"description": "No empty links",
"tags": [ "links" ],
"func": function MD042(params, onError) {
"function": function MD042(params, onError) {
var emptyLinkRe = /\[[^\]]*](?:\((?:#?|(?:<>))\))/;
shared.filterTokens(params, "inline", function forToken(token) {
var inLink = false;
@ -940,9 +941,9 @@ module.exports = [
{
"names": [ "MD043", "required-headers" ],
"desc": "Required header structure",
"description": "Required header structure",
"tags": [ "headers" ],
"func": function MD043(params, onError) {
"function": function MD043(params, onError) {
var requiredHeaders = params.config.headers;
if (requiredHeaders) {
var levels = {};
@ -979,9 +980,9 @@ module.exports = [
{
"names": [ "MD044", "proper-names" ],
"desc": "Proper names should have the correct capitalization",
"description": "Proper names should have the correct capitalization",
"tags": [ "spelling" ],
"func": function MD044(params, onError) {
"function": function MD044(params, onError) {
var names = params.config.names || [];
var codeBlocks = params.config.code_blocks;
var includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
@ -1020,9 +1021,9 @@ module.exports = [
},
{
"names": [ "MD045", "no-alt-text" ],
"desc": "Images should have alternate text (alt text)",
"description": "Images should have alternate text (alt text)",
"tags": [ "accessibility", "images" ],
"func": function MD045(params, onError) {
"function": function MD045(params, onError) {
shared.forEachInlineChild(params, "image", function forToken(token) {
if (token.content === "") {
shared.addError(onError, token.lineNumber);