mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add optional "information" property to custom rules to provide a link to more information.
This commit is contained in:
parent
b77dd5ccd3
commit
ff86e1d7f1
14 changed files with 201 additions and 6 deletions
|
@ -538,24 +538,28 @@ Output:
|
|||
{ "lineNumber": 3,
|
||||
"ruleNames": [ "MD010", "no-hard-tabs" ],
|
||||
"ruleDescription": "Hard tabs",
|
||||
"errorDetail": "Column: 17",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"errorDetail": "Column: 19",
|
||||
"errorContext": null,
|
||||
"errorRange": [ 17, 1 ] },
|
||||
"errorRange": [ 19, 1 ] },
|
||||
{ "lineNumber": 1,
|
||||
"ruleNames": [ "MD018", "no-missing-space-atx" ],
|
||||
"ruleDescription": "No space after hash on atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
|
||||
"errorDetail": null,
|
||||
"errorContext": "#bad.md",
|
||||
"errorRange": [ 1, 2 ] },
|
||||
{ "lineNumber": 3,
|
||||
"ruleNames": [ "MD018", "no-missing-space-atx" ],
|
||||
"ruleDescription": "No space after hash on atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
|
||||
"errorDetail": null,
|
||||
"errorContext": "#This file fails\tsome rules.",
|
||||
"errorRange": [ 1, 2 ] },
|
||||
{ "lineNumber": 1,
|
||||
"ruleNames": [ "MD041", "first-line-h1" ],
|
||||
"ruleDescription": "First line in file should be a top level heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md041",
|
||||
"errorDetail": null,
|
||||
"errorContext": "#bad.md",
|
||||
"errorRange": null }
|
||||
|
|
|
@ -6,15 +6,18 @@ Custom rules can be disabled, enabled, and customized using the same syntax as b
|
|||
|
||||
## Authoring
|
||||
|
||||
Rules are defined by a name (or multiple names), a description, one or more tags, and a function that implements the rule's behavior.
|
||||
Rules are defined by a name (or multiple names), a description, an optional link to more information, one or more tags, and a function that implements the rule's behavior.
|
||||
That function is called once for each file/string input and is passed the parsed input and a function to log any violations.
|
||||
|
||||
A simple rule implementation looks like:
|
||||
|
||||
```js
|
||||
const { URL } = require("url");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
"information": new URL("https://example.com/rules/any-blockquote"),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
|
@ -35,6 +38,7 @@ A rule is implemented as an `Object` with four required properties:
|
|||
|
||||
- `names` is an `Array` of `String` values that identify the rule in output messages and config.
|
||||
- `description` is a `String` value that describes the rule in output messages.
|
||||
- `information` is an optional (absolute) `URL` of a link to more information about the rule.
|
||||
- `tags` is an `Array` of `String` values that groups related rules for easier customization.
|
||||
- `function` is a synchronous `Function` that implements the rule and is passed two parameters:
|
||||
- `params` is an `Object` with properties that describe the content being analyzed:
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { URL } = require("url");
|
||||
const md = require("markdown-it")({ "html": true });
|
||||
const rules = require("./rules");
|
||||
const shared = require("./shared");
|
||||
|
@ -41,6 +42,11 @@ function validateRuleList(ruleList) {
|
|||
result = newError(property);
|
||||
}
|
||||
});
|
||||
if (!result && rule.information) {
|
||||
if (Object.getPrototypeOf(rule.information) !== URL.prototype) {
|
||||
result = newError("information");
|
||||
}
|
||||
}
|
||||
if (!result) {
|
||||
rule.names.forEach(function forName(name) {
|
||||
const nameUpper = name.toUpperCase();
|
||||
|
@ -373,6 +379,8 @@ function lintContent(
|
|||
errorObject.ruleNames = rule.names;
|
||||
}
|
||||
errorObject.ruleDescription = rule.description;
|
||||
errorObject.ruleInformation =
|
||||
rule.information ? rule.information.href : null;
|
||||
errorObject.errorDetail = error.detail;
|
||||
errorObject.errorContext = error.context;
|
||||
errorObject.errorRange = error.range;
|
||||
|
|
13
lib/rules.js
13
lib/rules.js
|
@ -2,7 +2,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
module.exports = [
|
||||
const { URL } = require("url");
|
||||
const packageJson = require("../package.json");
|
||||
const homepage = packageJson.homepage;
|
||||
const version = packageJson.version;
|
||||
|
||||
const rules = [
|
||||
require("./md001"),
|
||||
require("./md002"),
|
||||
require("./md003"),
|
||||
|
@ -45,3 +50,9 @@ module.exports = [
|
|||
require("./md044"),
|
||||
require("./md045")
|
||||
];
|
||||
rules.forEach((rule) => {
|
||||
const name = rule.names[0].toLowerCase();
|
||||
rule.information =
|
||||
new URL(`${homepage}/blob/v${version}/doc/Rules.md#${name}`);
|
||||
});
|
||||
module.exports = rules;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 3,
|
||||
"ruleNames": [ "MD001", "heading-increment", "header-increment" ],
|
||||
"ruleDescription": "Heading levels should only increment by one level at a time",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md001",
|
||||
"errorDetail": "Expected: h3; Actual: h4",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 1,
|
||||
"ruleNames": [ "MD002", "first-heading-h1", "first-header-h1" ],
|
||||
"ruleDescription": "First heading should be a top level heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md002",
|
||||
"errorDetail": "Expected: h1; Actual: h2",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -19,6 +21,7 @@
|
|||
"lineNumber": 5,
|
||||
"ruleNames": [ "MD003", "heading-style", "header-style" ],
|
||||
"ruleDescription": "Heading style",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md003",
|
||||
"errorDetail": "Expected: atx; Actual: atx_closed",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -27,6 +30,7 @@
|
|||
"lineNumber": 10,
|
||||
"ruleNames": [ "MD004", "ul-style" ],
|
||||
"ruleDescription": "Unordered list style",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md004",
|
||||
"errorDetail": "Expected: asterisk; Actual: dash",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 2]
|
||||
|
@ -35,6 +39,7 @@
|
|||
"lineNumber": 8,
|
||||
"ruleNames": [ "MD005", "list-indent" ],
|
||||
"ruleDescription": "Inconsistent indentation for list items at the same level",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md005",
|
||||
"errorDetail": "Expected: 0; Actual: 1",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 3]
|
||||
|
@ -43,6 +48,7 @@
|
|||
"lineNumber": 23,
|
||||
"ruleNames": [ "MD005", "list-indent" ],
|
||||
"ruleDescription": "Inconsistent indentation for list items at the same level",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md005",
|
||||
"errorDetail": "Expected: 1; Actual: 0",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 3]
|
||||
|
@ -51,6 +57,7 @@
|
|||
"lineNumber": 29,
|
||||
"ruleNames": [ "MD005", "list-indent" ],
|
||||
"ruleDescription": "Inconsistent indentation for list items at the same level",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md005",
|
||||
"errorDetail": "Expected: (3); Actual: (4)",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 5]
|
||||
|
@ -59,6 +66,7 @@
|
|||
"lineNumber": 12,
|
||||
"ruleNames": [ "MD006", "ul-start-left" ],
|
||||
"ruleDescription": "Consider starting bulleted lists at the beginning of the line",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md006",
|
||||
"errorDetail": "Expected: 0; Actual: 1",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 3]
|
||||
|
@ -67,6 +75,7 @@
|
|||
"lineNumber": 12,
|
||||
"ruleNames": [ "MD007", "ul-indent" ],
|
||||
"ruleDescription": "Unordered list indentation",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md007",
|
||||
"errorDetail": "Expected: 2; Actual: 1",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 3]
|
||||
|
@ -75,6 +84,7 @@
|
|||
"lineNumber": 15,
|
||||
"ruleNames": [ "MD009", "no-trailing-spaces" ],
|
||||
"ruleDescription": "Trailing spaces",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009",
|
||||
"errorDetail": "Expected: 0 or 2; Actual: 1",
|
||||
"errorContext": null,
|
||||
"errorRange": [5, 1]
|
||||
|
@ -83,6 +93,7 @@
|
|||
"lineNumber": 17,
|
||||
"ruleNames": [ "MD010", "no-hard-tabs" ],
|
||||
"ruleDescription": "Hard tabs",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md010",
|
||||
"errorDetail": "Column: 5",
|
||||
"errorContext": null,
|
||||
"errorRange": [5, 1]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 5,
|
||||
"ruleNames": [ "MD011", "no-reversed-links" ],
|
||||
"ruleDescription": "Reversed link syntax",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md011",
|
||||
"errorDetail": "(reversed)[link]",
|
||||
"errorContext": null,
|
||||
"errorRange": [3, 16]
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 7,
|
||||
"ruleNames": [ "MD012", "no-multiple-blanks" ],
|
||||
"ruleDescription": "Multiple consecutive blank lines",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md012",
|
||||
"errorDetail": "Expected: 1; Actual: 2",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -19,6 +21,7 @@
|
|||
"lineNumber": 8,
|
||||
"ruleNames": [ "MD013", "line-length" ],
|
||||
"ruleDescription": "Line length",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md013",
|
||||
"errorDetail": "Expected: 80; Actual: 99",
|
||||
"errorContext": null,
|
||||
"errorRange": [81, 19]
|
||||
|
@ -27,6 +30,7 @@
|
|||
"lineNumber": 10,
|
||||
"ruleNames": [ "MD014", "commands-show-output" ],
|
||||
"ruleDescription": "Dollar signs used before commands without showing output",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md014",
|
||||
"errorDetail": null,
|
||||
"errorContext": "$ command with no output",
|
||||
"errorRange": [5, 2]
|
||||
|
@ -35,6 +39,7 @@
|
|||
"lineNumber": 12,
|
||||
"ruleNames": [ "MD018", "no-missing-space-atx" ],
|
||||
"ruleDescription": "No space after hash on atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md018",
|
||||
"errorDetail": null,
|
||||
"errorContext": "##No space A",
|
||||
"errorRange": [1, 3]
|
||||
|
@ -43,6 +48,7 @@
|
|||
"lineNumber": 14,
|
||||
"ruleNames": [ "MD019", "no-multiple-space-atx" ],
|
||||
"ruleDescription": "Multiple spaces after hash on atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md019",
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Multiple spaces B",
|
||||
"errorRange": [1, 5]
|
||||
|
@ -51,6 +57,7 @@
|
|||
"lineNumber": 16,
|
||||
"ruleNames": [ "MD020", "no-missing-space-closed-atx" ],
|
||||
"ruleDescription": "No space inside hashes on closed atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md020",
|
||||
"errorDetail": null,
|
||||
"errorContext": "##No space C ##",
|
||||
"errorRange": [1, 3]
|
||||
|
@ -59,6 +66,7 @@
|
|||
"lineNumber": 18,
|
||||
"ruleNames": [ "MD020", "no-missing-space-closed-atx" ],
|
||||
"ruleDescription": "No space inside hashes on closed atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md020",
|
||||
"errorDetail": null,
|
||||
"errorContext": "## No space D##",
|
||||
"errorRange": [13, 3]
|
||||
|
@ -67,6 +75,7 @@
|
|||
"lineNumber": 20,
|
||||
"ruleNames": [ "MD021", "no-multiple-space-closed-atx" ],
|
||||
"ruleDescription": "Multiple spaces inside hashes on closed atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md021",
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Multiple spaces E ##",
|
||||
"errorRange": [1, 5]
|
||||
|
@ -75,6 +84,7 @@
|
|||
"lineNumber": 22,
|
||||
"ruleNames": [ "MD021", "no-multiple-space-closed-atx" ],
|
||||
"ruleDescription": "Multiple spaces inside hashes on closed atx style heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md021",
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Multiple spaces F ##",
|
||||
"errorRange": [20, 5]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 1,
|
||||
"ruleNames": [ "MD022", "blanks-around-headings", "blanks-around-headers" ],
|
||||
"ruleDescription": "Headings should be surrounded by blank lines",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md022",
|
||||
"errorDetail": null,
|
||||
"errorContext": "# Heading",
|
||||
"errorRange": null
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 1,
|
||||
"ruleNames": [ "MD023", "heading-start-left", "header-start-left" ],
|
||||
"ruleDescription": "Headings must start at the beginning of the line",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md023",
|
||||
"errorDetail": null,
|
||||
"errorContext": " # Heading",
|
||||
"errorRange": [1, 2]
|
||||
|
@ -19,6 +21,7 @@
|
|||
"lineNumber": 4,
|
||||
"ruleNames": [ "MD024", "no-duplicate-heading", "no-duplicate-header" ],
|
||||
"ruleDescription": "Multiple headings with the same content",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md024",
|
||||
"errorDetail": null,
|
||||
"errorContext": "# Heading",
|
||||
"errorRange": null
|
||||
|
@ -27,6 +30,7 @@
|
|||
"lineNumber": 4,
|
||||
"ruleNames": [ "MD025", "single-h1" ],
|
||||
"ruleDescription": "Multiple top level headings in the same document",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md025",
|
||||
"errorDetail": null,
|
||||
"errorContext": "# Heading",
|
||||
"errorRange": null
|
||||
|
@ -35,6 +39,7 @@
|
|||
"lineNumber": 6,
|
||||
"ruleNames": [ "MD026", "no-trailing-punctuation" ],
|
||||
"ruleDescription": "Trailing punctuation in heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md026",
|
||||
"errorDetail": "Punctuation: '.'",
|
||||
"errorContext": null,
|
||||
"errorRange": [19, 1]
|
||||
|
@ -43,6 +48,7 @@
|
|||
"lineNumber": 8,
|
||||
"ruleNames": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"ruleDescription": "Multiple spaces after blockquote symbol",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md027",
|
||||
"errorDetail": null,
|
||||
"errorContext": "> Multiple spaces",
|
||||
"errorRange": [1, 4]
|
||||
|
@ -51,6 +57,7 @@
|
|||
"lineNumber": 15,
|
||||
"ruleNames": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"ruleDescription": "Multiple spaces after blockquote symbol",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md027",
|
||||
"errorDetail": null,
|
||||
"errorContext": "> > Multiple spaces, multiple...",
|
||||
"errorRange": [ 1, 6 ]
|
||||
|
@ -59,6 +66,7 @@
|
|||
"lineNumber": 17,
|
||||
"ruleNames": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"ruleDescription": "Multiple spaces after blockquote symbol",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md027",
|
||||
"errorDetail": null,
|
||||
"errorContext": "> > > Multiple spaces, multip...",
|
||||
"errorRange": [ 1, 8 ]
|
||||
|
@ -67,6 +75,7 @@
|
|||
"lineNumber": 19,
|
||||
"ruleNames": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"ruleDescription": "Multiple spaces after blockquote symbol",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md027",
|
||||
"errorDetail": null,
|
||||
"errorContext": "> > > Multiple spaces, multip...",
|
||||
"errorRange": [ 1, 8 ]
|
||||
|
@ -75,6 +84,7 @@
|
|||
"lineNumber": 9,
|
||||
"ruleNames": [ "MD028", "no-blanks-blockquote" ],
|
||||
"ruleDescription": "Blank line inside blockquote",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md028",
|
||||
"errorDetail": null,
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -83,6 +93,7 @@
|
|||
"lineNumber": 13,
|
||||
"ruleNames": [ "MD029", "ol-prefix" ],
|
||||
"ruleDescription": "Ordered list item prefix",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md029",
|
||||
"errorDetail": "Expected: 2; Actual: 3; Style: 1/2/3",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 4]
|
||||
|
@ -91,6 +102,7 @@
|
|||
"lineNumber": 13,
|
||||
"ruleNames": [ "MD030", "list-marker-space" ],
|
||||
"ruleDescription": "Spaces after list markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
|
||||
"errorDetail": "Expected: 1; Actual: 2",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 4]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 3,
|
||||
"ruleNames": [ "MD030", "list-marker-space" ],
|
||||
"ruleDescription": "Spaces after list markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
|
||||
"errorDetail": "Expected: 1; Actual: 0",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 5,
|
||||
"ruleNames": [ "MD030", "list-marker-space" ],
|
||||
"ruleDescription": "Spaces after list markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
|
||||
"errorDetail": "Expected: 1; Actual: 0",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -19,6 +21,7 @@
|
|||
"lineNumber": 11,
|
||||
"ruleNames": [ "MD030", "list-marker-space" ],
|
||||
"ruleDescription": "Spaces after list markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
|
||||
"errorDetail": "Expected: 1; Actual: 2",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 3]
|
||||
|
@ -27,6 +30,7 @@
|
|||
"lineNumber": 13,
|
||||
"ruleNames": [ "MD030", "list-marker-space" ],
|
||||
"ruleDescription": "Spaces after list markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md030",
|
||||
"errorDetail": "Expected: 1; Actual: 2",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 4]
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 3,
|
||||
"ruleNames": [ "MD031", "blanks-around-fences" ],
|
||||
"ruleDescription": "Fenced code blocks should be surrounded by blank lines",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md031",
|
||||
"errorDetail": null,
|
||||
"errorContext": "```",
|
||||
"errorRange": null
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 4,
|
||||
"ruleNames": [ "MD032", "blanks-around-lists" ],
|
||||
"ruleDescription": "Lists should be surrounded by blank lines",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md032",
|
||||
"errorDetail": null,
|
||||
"errorContext": "* List",
|
||||
"errorRange": null
|
||||
|
@ -19,6 +21,7 @@
|
|||
"lineNumber": 6,
|
||||
"ruleNames": [ "MD033", "no-inline-html" ],
|
||||
"ruleDescription": "Inline HTML",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md033",
|
||||
"errorDetail": "Element: hr",
|
||||
"errorContext": null,
|
||||
"errorRange": [7, 5]
|
||||
|
@ -27,6 +30,7 @@
|
|||
"lineNumber": 8,
|
||||
"ruleNames": [ "MD034", "no-bare-urls" ],
|
||||
"ruleDescription": "Bare URL used",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md034",
|
||||
"errorDetail": null,
|
||||
"errorContext": "http://example.com",
|
||||
"errorRange": [6, 18]
|
||||
|
@ -35,6 +39,7 @@
|
|||
"lineNumber": 11,
|
||||
"ruleNames": [ "MD035", "hr-style" ],
|
||||
"ruleDescription": "Horizontal rule style",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md035",
|
||||
"errorDetail": "Expected: ---; Actual: ***",
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
@ -43,6 +48,7 @@
|
|||
"lineNumber": 13,
|
||||
"ruleNames": [ "MD036", "no-emphasis-as-heading", "no-emphasis-as-header" ],
|
||||
"ruleDescription": "Emphasis used instead of a heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md036",
|
||||
"errorDetail": null,
|
||||
"errorContext": "Emphasis",
|
||||
"errorRange": null
|
||||
|
@ -51,6 +57,7 @@
|
|||
"lineNumber": 15,
|
||||
"ruleNames": [ "MD037", "no-space-in-emphasis" ],
|
||||
"ruleDescription": "Spaces inside emphasis markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md037",
|
||||
"errorDetail": null,
|
||||
"errorContext": "* inside *",
|
||||
"errorRange": [7, 10]
|
||||
|
@ -59,6 +66,7 @@
|
|||
"lineNumber": 31,
|
||||
"ruleNames": [ "MD037", "no-space-in-emphasis" ],
|
||||
"ruleDescription": "Spaces inside emphasis markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md037",
|
||||
"errorDetail": null,
|
||||
"errorContext": "* some*",
|
||||
"errorRange": [ 17, 7 ]
|
||||
|
@ -67,6 +75,7 @@
|
|||
"lineNumber": 32,
|
||||
"ruleNames": [ "MD037", "no-space-in-emphasis" ],
|
||||
"ruleDescription": "Spaces inside emphasis markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md037",
|
||||
"errorDetail": null,
|
||||
"errorContext": "*some *",
|
||||
"errorRange": [ 17, 7 ]
|
||||
|
@ -75,6 +84,7 @@
|
|||
"lineNumber": 33,
|
||||
"ruleNames": [ "MD037", "no-space-in-emphasis" ],
|
||||
"ruleDescription": "Spaces inside emphasis markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md037",
|
||||
"errorDetail": null,
|
||||
"errorContext": "**some **",
|
||||
"errorRange": [ 17, 9 ]
|
||||
|
@ -83,6 +93,7 @@
|
|||
"lineNumber": 34,
|
||||
"ruleNames": [ "MD037", "no-space-in-emphasis" ],
|
||||
"ruleDescription": "Spaces inside emphasis markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md037",
|
||||
"errorDetail": null,
|
||||
"errorContext": "_ some_",
|
||||
"errorRange": [ 17, 7 ]
|
||||
|
@ -91,6 +102,7 @@
|
|||
"lineNumber": 35,
|
||||
"ruleNames": [ "MD037", "no-space-in-emphasis" ],
|
||||
"ruleDescription": "Spaces inside emphasis markers",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md037",
|
||||
"errorDetail": null,
|
||||
"errorContext": "__ some __",
|
||||
"errorRange": [ 19, 10 ]
|
||||
|
@ -99,6 +111,7 @@
|
|||
"lineNumber": 17,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "` inside `",
|
||||
"errorRange": [7, 10]
|
||||
|
@ -107,6 +120,7 @@
|
|||
"lineNumber": 24,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "`` inside ``",
|
||||
"errorRange": [ 7, 12 ]
|
||||
|
@ -115,6 +129,7 @@
|
|||
"lineNumber": 25,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "` code`",
|
||||
"errorRange": [ 19, 7 ]
|
||||
|
@ -123,6 +138,7 @@
|
|||
"lineNumber": 26,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "` elements`",
|
||||
"errorRange": [ 26, 11 ]
|
||||
|
@ -131,6 +147,7 @@
|
|||
"lineNumber": 27,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "`` code``",
|
||||
"errorRange": [ 21, 9 ]
|
||||
|
@ -139,6 +156,7 @@
|
|||
"lineNumber": 28,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "`` ` embedded backtick``",
|
||||
"errorRange": [ 1, 25 ]
|
||||
|
@ -147,6 +165,7 @@
|
|||
"lineNumber": 29,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "``embedded backtick` ``",
|
||||
"errorRange": [ 1, 24 ]
|
||||
|
@ -155,6 +174,7 @@
|
|||
"lineNumber": 38,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "` code\nspan`",
|
||||
"errorRange": [ 6, 6 ]
|
||||
|
@ -163,6 +183,7 @@
|
|||
"lineNumber": 44,
|
||||
"ruleNames": [ "MD038", "no-space-in-code" ],
|
||||
"ruleDescription": "Spaces inside code span elements",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md038",
|
||||
"errorDetail": null,
|
||||
"errorContext": "`code\nspan `",
|
||||
"errorRange": [ 1, 7 ]
|
||||
|
@ -171,6 +192,7 @@
|
|||
"lineNumber": 19,
|
||||
"ruleNames": [ "MD039", "no-space-in-links" ],
|
||||
"ruleDescription": "Spaces inside link text",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md039",
|
||||
"errorDetail": null,
|
||||
"errorContext": "[ inside ]",
|
||||
"errorRange": [7, 10]
|
||||
|
@ -179,6 +201,7 @@
|
|||
"lineNumber": 21,
|
||||
"ruleNames": [ "MD040", "fenced-code-language" ],
|
||||
"ruleDescription": "Fenced code blocks should have a language specified",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md040",
|
||||
"errorDetail": null,
|
||||
"errorContext": "```",
|
||||
"errorRange": null
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 1,
|
||||
"ruleNames": [ "MD041", "first-line-h1" ],
|
||||
"ruleDescription": "First line in file should be a top level heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md041",
|
||||
"errorDetail": null,
|
||||
"errorContext": "Not a heading",
|
||||
"errorRange": null
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 3,
|
||||
"ruleNames": [ "MD042", "no-empty-links" ],
|
||||
"ruleDescription": "No empty links",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md042",
|
||||
"errorDetail": null,
|
||||
"errorContext": "[empty]()",
|
||||
"errorRange": [4, 9]
|
||||
|
@ -19,6 +21,7 @@
|
|||
"lineNumber": 5,
|
||||
"ruleNames": [ "MD042", "no-empty-links" ],
|
||||
"ruleDescription": "No empty links",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md042",
|
||||
"errorDetail": null,
|
||||
"errorContext": "[empty]()",
|
||||
"errorRange": [4, 10]
|
||||
|
@ -27,6 +30,7 @@
|
|||
"lineNumber": 7,
|
||||
"ruleNames": [ "MD042", "no-empty-links" ],
|
||||
"ruleDescription": "No empty links",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md042",
|
||||
"errorDetail": null,
|
||||
"errorContext": "[empty]()",
|
||||
"errorRange": [4, 11]
|
||||
|
@ -35,6 +39,7 @@
|
|||
"lineNumber": 17,
|
||||
"ruleNames": [ "MD042", "no-empty-links" ],
|
||||
"ruleDescription": "No empty links",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md042",
|
||||
"errorDetail": null,
|
||||
"errorContext": "[empty one]()",
|
||||
"errorRange": [25, 13]
|
||||
|
@ -43,6 +48,7 @@
|
|||
"lineNumber": 20,
|
||||
"ruleNames": [ "MD043", "required-headings", "required-headers" ],
|
||||
"ruleDescription": "Required heading structure",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md043",
|
||||
"errorDetail": null,
|
||||
"errorContext": "# Heading",
|
||||
"errorRange": null
|
||||
|
@ -51,6 +57,7 @@
|
|||
"lineNumber": 9,
|
||||
"ruleNames": [ "MD044", "proper-names" ],
|
||||
"ruleDescription": "Proper names should have the correct capitalization",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md044",
|
||||
"errorDetail": "Expected: markdownlint; Actual: MARKDOWNLINT",
|
||||
"errorContext": null,
|
||||
"errorRange": [29, 12]
|
||||
|
@ -59,6 +66,7 @@
|
|||
"lineNumber": 12,
|
||||
"ruleNames": [ "MD044", "proper-names" ],
|
||||
"ruleDescription": "Proper names should have the correct capitalization",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md044",
|
||||
"errorDetail": "Expected: markdownlint; Actual: Markdownlint",
|
||||
"errorContext": null,
|
||||
"errorRange": [7, 12]
|
||||
|
@ -67,6 +75,7 @@
|
|||
"lineNumber": 15,
|
||||
"ruleNames": [ "MD044", "proper-names" ],
|
||||
"ruleDescription": "Proper names should have the correct capitalization",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md044",
|
||||
"errorDetail": "Expected: markdownlint; Actual: MarkDownLint",
|
||||
"errorContext": null,
|
||||
"errorRange": [1, 12]
|
||||
|
@ -75,6 +84,7 @@
|
|||
"lineNumber": 19,
|
||||
"ruleNames": [ "MD045", "no-alt-text" ],
|
||||
"ruleDescription": "Images should have alternate text (alt text)",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md045",
|
||||
"errorDetail": null,
|
||||
"errorContext": null,
|
||||
"errorRange": null
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"lineNumber": 6,
|
||||
"ruleNames": [ "MD009", "no-trailing-spaces" ],
|
||||
"ruleDescription": "Trailing spaces",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md009",
|
||||
"errorDetail": "Expected: 0; Actual: 1",
|
||||
"errorContext": null,
|
||||
"errorRange": [5, 1]
|
||||
|
@ -11,6 +12,7 @@
|
|||
"lineNumber": 4,
|
||||
"ruleNames": [ "MD041", "first-line-h1" ],
|
||||
"ruleDescription": "First line in file should be a top level heading",
|
||||
"ruleInformation": "https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md041",
|
||||
"errorDetail": null,
|
||||
"errorContext": "Text",
|
||||
"errorRange": null
|
||||
|
|
|
@ -2,14 +2,18 @@
|
|||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { URL } = require("url");
|
||||
const md = require("markdown-it")();
|
||||
const tv4 = require("tv4");
|
||||
const packageJson = require("../package.json");
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
const shared = require("../lib/shared");
|
||||
const rules = require("../lib/rules");
|
||||
const customRules = require("./rules/rules.js");
|
||||
const defaultConfig = require("./markdownlint-test-default-config.json");
|
||||
const configSchema = require("../schema/markdownlint-config-schema.json");
|
||||
const homepage = packageJson.homepage;
|
||||
const version = packageJson.version;
|
||||
|
||||
function promisify(func, ...args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
@ -49,7 +53,17 @@ function createTestForFile(file) {
|
|||
});
|
||||
const expectedPromise = detailedResults ?
|
||||
promisify(fs.readFile, resultsFile, shared.utf8Encoding)
|
||||
.then(JSON.parse) :
|
||||
.then(
|
||||
function fileContents(contents) {
|
||||
const errorObjects = JSON.parse(contents);
|
||||
errorObjects.forEach(function forObject(errorObject) {
|
||||
if (errorObject.ruleInformation) {
|
||||
errorObject.ruleInformation =
|
||||
errorObject.ruleInformation.replace("v0.0.0", `v${version}`);
|
||||
}
|
||||
});
|
||||
return errorObjects;
|
||||
}) :
|
||||
promisify(fs.readFile, file, shared.utf8Encoding)
|
||||
.then(
|
||||
function fileContents(contents) {
|
||||
|
@ -242,6 +256,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
"ruleAlias": "no-multiple-space-closed-atx",
|
||||
"ruleDescription":
|
||||
"Multiple spaces inside hashes on closed atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md021`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "# Multiple spa...tyle heading #",
|
||||
"errorRange": [ 1, 4 ] }
|
||||
|
@ -251,6 +266,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
"ruleName": "MD002",
|
||||
"ruleAlias": "first-heading-h1",
|
||||
"ruleDescription": "First heading should be a top level heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md002`,
|
||||
"errorDetail": "Expected: h1; Actual: h2",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -258,6 +274,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
"ruleName": "MD018",
|
||||
"ruleAlias": "no-missing-space-atx",
|
||||
"ruleDescription": "No space after hash on atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md018`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "#Heading 1 {MD018}",
|
||||
"errorRange": [ 1, 2 ] },
|
||||
|
@ -265,6 +282,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
"ruleName": "MD019",
|
||||
"ruleAlias": "no-multiple-space-atx",
|
||||
"ruleDescription": "Multiple spaces after hash on atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md019`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Heading 2 {MD019}",
|
||||
"errorRange": [ 1, 5 ] },
|
||||
|
@ -272,6 +290,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
"ruleName": "MD019",
|
||||
"ruleAlias": "no-multiple-space-atx",
|
||||
"ruleDescription": "Multiple spaces after hash on atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md019`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Heading 3 {MD019}",
|
||||
"errorRange": [ 1, 6 ] }
|
||||
|
@ -281,6 +300,7 @@ module.exports.resultFormattingV1 = function resultFormattingV1(test) {
|
|||
"ruleName": "MD002",
|
||||
"ruleAlias": "first-heading-h1",
|
||||
"ruleDescription": "First heading should be a top level heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md002`,
|
||||
"errorDetail": "Expected: h1; Actual: h2",
|
||||
"errorContext": null,
|
||||
"errorRange": null }
|
||||
|
@ -333,6 +353,7 @@ module.exports.resultFormattingV2 = function resultFormattingV2(test) {
|
|||
"ruleNames": [ "MD021", "no-multiple-space-closed-atx" ],
|
||||
"ruleDescription":
|
||||
"Multiple spaces inside hashes on closed atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md021`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "# Multiple spa...tyle heading #",
|
||||
"errorRange": [ 1, 4 ] }
|
||||
|
@ -341,24 +362,28 @@ module.exports.resultFormattingV2 = function resultFormattingV2(test) {
|
|||
{ "lineNumber": 3,
|
||||
"ruleNames": [ "MD002", "first-heading-h1", "first-header-h1" ],
|
||||
"ruleDescription": "First heading should be a top level heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md002`,
|
||||
"errorDetail": "Expected: h1; Actual: h2",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 1,
|
||||
"ruleNames": [ "MD018", "no-missing-space-atx" ],
|
||||
"ruleDescription": "No space after hash on atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md018`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "#Heading 1 {MD018}",
|
||||
"errorRange": [ 1, 2 ] },
|
||||
{ "lineNumber": 3,
|
||||
"ruleNames": [ "MD019", "no-multiple-space-atx" ],
|
||||
"ruleDescription": "Multiple spaces after hash on atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md019`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Heading 2 {MD019}",
|
||||
"errorRange": [ 1, 5 ] },
|
||||
{ "lineNumber": 5,
|
||||
"ruleNames": [ "MD019", "no-multiple-space-atx" ],
|
||||
"ruleDescription": "Multiple spaces after hash on atx style heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md019`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "## Heading 3 {MD019}",
|
||||
"errorRange": [ 1, 6 ] }
|
||||
|
@ -367,6 +392,7 @@ module.exports.resultFormattingV2 = function resultFormattingV2(test) {
|
|||
{ "lineNumber": 1,
|
||||
"ruleNames": [ "MD002", "first-heading-h1", "first-header-h1" ],
|
||||
"ruleDescription": "First heading should be a top level heading",
|
||||
"ruleInformation": `${homepage}/blob/v${version}/doc/Rules.md#md002`,
|
||||
"errorDetail": "Expected: h1; Actual: h2",
|
||||
"errorContext": null,
|
||||
"errorRange": null }
|
||||
|
@ -1686,6 +1712,42 @@ module.exports.configBadHybridSync = function configBadHybridSync(test) {
|
|||
test.done();
|
||||
};
|
||||
|
||||
module.exports.allBuiltInRulesHaveValidUrl =
|
||||
function allBuiltInRulesHaveValidUrl(test) {
|
||||
test.expect(123);
|
||||
rules.forEach(function forRule(rule) {
|
||||
test.ok(rule.information);
|
||||
test.ok(Object.getPrototypeOf(rule.information) === URL.prototype);
|
||||
const name = rule.names[0].toLowerCase();
|
||||
test.equal(
|
||||
rule.information.href,
|
||||
`${homepage}/blob/v${version}/doc/Rules.md#${name}`
|
||||
);
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
module.exports.someCustomRulesHaveValidUrl =
|
||||
function someCustomRulesHaveValidUrl(test) {
|
||||
test.expect(6);
|
||||
customRules.all.forEach(function forRule(rule) {
|
||||
test.ok(!rule.information ||
|
||||
(Object.getPrototypeOf(rule.information) === URL.prototype));
|
||||
if (rule === customRules.anyBlockquote) {
|
||||
test.equal(
|
||||
rule.information,
|
||||
`${homepage}/blob/master/test/rules/any-blockquote.js`
|
||||
);
|
||||
} else if (rule === customRules.lettersEX) {
|
||||
test.equal(
|
||||
rule.information,
|
||||
`${homepage}/blob/master/test/rules/letters-E-X.js`
|
||||
);
|
||||
}
|
||||
});
|
||||
test.done();
|
||||
};
|
||||
|
||||
module.exports.customRulesV0 = function customRulesV0(test) {
|
||||
test.expect(4);
|
||||
const customRulesMd = "./test/custom-rules.md";
|
||||
|
@ -1766,6 +1828,8 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "any-blockquote",
|
||||
"ruleAlias": "any-blockquote",
|
||||
"ruleDescription": "Rule that reports an error for any blockquote",
|
||||
"ruleInformation":
|
||||
`${homepage}/blob/master/test/rules/any-blockquote.js`,
|
||||
"errorDetail": "Blockquote spans 1 line(s).",
|
||||
"errorContext": "> Block",
|
||||
"errorRange": null },
|
||||
|
@ -1773,6 +1837,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "every-n-lines",
|
||||
"ruleAlias": "every-n-lines",
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 2",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1780,6 +1845,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "every-n-lines",
|
||||
"ruleAlias": "every-n-lines",
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 4",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1787,6 +1853,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "every-n-lines",
|
||||
"ruleAlias": "every-n-lines",
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 6",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1794,6 +1861,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "every-n-lines",
|
||||
"ruleAlias": "every-n-lines",
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 10",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1801,6 +1869,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "every-n-lines",
|
||||
"ruleAlias": "every-n-lines",
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 12",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1808,6 +1877,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleName": "first-line",
|
||||
"ruleAlias": "first-line",
|
||||
"ruleDescription": "Rule that reports an error for the first line",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": null,
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1816,6 +1886,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleAlias": "letter-E-letter-X",
|
||||
"ruleDescription":
|
||||
"Rule that reports an error for lines with the letters 'EX'",
|
||||
"ruleInformation": `${homepage}/blob/master/test/rules/letters-E-X.js`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "text",
|
||||
"errorRange": null },
|
||||
|
@ -1824,6 +1895,7 @@ module.exports.customRulesV1 = function customRulesV1(test) {
|
|||
"ruleAlias": "letter-E-letter-X",
|
||||
"ruleDescription":
|
||||
"Rule that reports an error for lines with the letters 'EX'",
|
||||
"ruleInformation": `${homepage}/blob/master/test/rules/letters-E-X.js`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "text",
|
||||
"errorRange": null }
|
||||
|
@ -1872,42 +1944,50 @@ module.exports.customRulesV2 = function customRulesV2(test) {
|
|||
{ "lineNumber": 12,
|
||||
"ruleNames": [ "any-blockquote" ],
|
||||
"ruleDescription": "Rule that reports an error for any blockquote",
|
||||
"ruleInformation":
|
||||
`${homepage}/blob/master/test/rules/any-blockquote.js`,
|
||||
"errorDetail": "Blockquote spans 1 line(s).",
|
||||
"errorContext": "> Block",
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 2,
|
||||
"ruleNames": [ "every-n-lines" ],
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 2",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 4,
|
||||
"ruleNames": [ "every-n-lines" ],
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 4",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 6,
|
||||
"ruleNames": [ "every-n-lines" ],
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 6",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 10,
|
||||
"ruleNames": [ "every-n-lines" ],
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 10",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 12,
|
||||
"ruleNames": [ "every-n-lines" ],
|
||||
"ruleDescription": "Rule that reports an error every N lines",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": "Line number 12",
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
{ "lineNumber": 1,
|
||||
"ruleNames": [ "first-line" ],
|
||||
"ruleDescription": "Rule that reports an error for the first line",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": null,
|
||||
"errorContext": null,
|
||||
"errorRange": null },
|
||||
|
@ -1915,6 +1995,7 @@ module.exports.customRulesV2 = function customRulesV2(test) {
|
|||
"ruleNames": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"ruleDescription":
|
||||
"Rule that reports an error for lines with the letters 'EX'",
|
||||
"ruleInformation": `${homepage}/blob/master/test/rules/letters-E-X.js`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "text",
|
||||
"errorRange": null },
|
||||
|
@ -1922,6 +2003,7 @@ module.exports.customRulesV2 = function customRulesV2(test) {
|
|||
"ruleNames": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"ruleDescription":
|
||||
"Rule that reports an error for lines with the letters 'EX'",
|
||||
"ruleInformation": `${homepage}/blob/master/test/rules/letters-E-X.js`,
|
||||
"errorDetail": null,
|
||||
"errorContext": "text",
|
||||
"errorRange": null }
|
||||
|
@ -2005,10 +2087,11 @@ module.exports.customRulesNpmPackage = function customRulesNpmPackage(test) {
|
|||
};
|
||||
|
||||
module.exports.customRulesBadProperty = function customRulesBadProperty(test) {
|
||||
test.expect(76);
|
||||
test.expect(92);
|
||||
[
|
||||
[ "names", [ null, "string", [], [ null ], [ "" ], [ "string", 10 ] ] ],
|
||||
[ "description", [ null, 10, "", [] ] ],
|
||||
[ "information", [ 10, [], "string", "https://example.com" ] ],
|
||||
[ "tags", [ null, "string", [], [ null ], [ "" ], [ "string", 10 ] ] ],
|
||||
[ "function", [ null, "string", [] ] ]
|
||||
].forEach(function forProperty(property) {
|
||||
|
@ -2298,6 +2381,7 @@ module.exports.customRulesOnErrorLazy = function customRulesOnErrorLazy(test) {
|
|||
"lineNumber": 1,
|
||||
"ruleNames": [ "name" ],
|
||||
"ruleDescription": "description",
|
||||
"ruleInformation": null,
|
||||
"errorDetail": null,
|
||||
"errorContext": null,
|
||||
"errorRange": [ 0, 0 ]
|
||||
|
|
|
@ -2,9 +2,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { URL } = require("url");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "any-blockquote" ],
|
||||
"description": "Rule that reports an error for any blockquote",
|
||||
"information": new URL(
|
||||
"https://github.com/DavidAnson/markdownlint" +
|
||||
"/blob/master/test/rules/any-blockquote.js"
|
||||
),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
|
|
|
@ -2,9 +2,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { URL } = require("url");
|
||||
|
||||
module.exports = {
|
||||
"names": [ "letters-E-X", "letter-E-letter-X", "contains-ex" ],
|
||||
"description": "Rule that reports an error for lines with the letters 'EX'",
|
||||
"information": new URL(
|
||||
"https://github.com/DavidAnson/markdownlint" +
|
||||
"/blob/master/test/rules/letters-E-X.js"
|
||||
),
|
||||
"tags": [ "test" ],
|
||||
"function": function rule(params, onError) {
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue