markdownlint 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/CONTRIBUTING.md +4 -3
- package/README.md +25 -10
- package/demo/markdownlint-browser.js +3286 -2119
- package/doc/CustomRules.md +25 -13
- package/doc/Rules.md +106 -7
- package/doc/md013.md +8 -7
- package/doc/md034.md +5 -0
- package/doc/md044.md +10 -0
- package/doc/md049.md +3 -0
- package/doc/md050.md +3 -0
- package/doc/md051.md +26 -0
- package/doc/md058.md +48 -0
- package/helpers/README.md +3 -27
- package/helpers/helpers.js +60 -292
- package/helpers/micromark.cjs +153 -36
- package/helpers/package.json +2 -2
- package/lib/cache.js +62 -13
- package/lib/configuration-strict.d.ts +1185 -0
- package/lib/configuration.d.ts +3 -1173
- package/lib/constants.js +3 -2
- package/lib/markdownlint.d.ts +143 -61
- package/lib/markdownlint.js +151 -54
- package/lib/md001.js +17 -8
- package/lib/md003.js +16 -8
- package/lib/md004.js +57 -47
- package/lib/md005.js +7 -8
- package/lib/md007.js +13 -12
- package/lib/md009.js +52 -43
- package/lib/md010.js +50 -32
- package/lib/md011.js +18 -7
- package/lib/md012.js +19 -8
- package/lib/md013.js +46 -37
- package/lib/md014.js +37 -36
- package/lib/md018.js +20 -8
- package/lib/md019-md021.js +80 -0
- package/lib/md020.js +15 -6
- package/lib/md022.js +10 -12
- package/lib/md023.js +24 -22
- package/lib/md024.js +14 -8
- package/lib/md025.js +17 -9
- package/lib/md026.js +5 -6
- package/lib/md027.js +24 -43
- package/lib/md028.js +26 -14
- package/lib/md029.js +42 -33
- package/lib/md030.js +7 -8
- package/lib/md031.js +45 -22
- package/lib/md032.js +18 -30
- package/lib/md033.js +6 -4
- package/lib/md034.js +30 -9
- package/lib/md035.js +5 -3
- package/lib/md036.js +34 -39
- package/lib/md037.js +3 -0
- package/lib/md038.js +6 -5
- package/lib/md039.js +68 -52
- package/lib/md040.js +21 -21
- package/lib/md041.js +21 -26
- package/lib/md042.js +50 -36
- package/lib/md043.js +22 -13
- package/lib/md044.js +5 -2
- package/lib/md045.js +6 -4
- package/lib/md046.js +9 -8
- package/lib/md047.js +5 -2
- package/lib/md048.js +22 -13
- package/lib/md049-md050.js +19 -5
- package/lib/md051.js +18 -20
- package/lib/md052.js +5 -2
- package/lib/md053.js +5 -2
- package/lib/md054.js +12 -12
- package/lib/md055.js +10 -3
- package/lib/md056.js +18 -6
- package/lib/md058.js +43 -0
- package/lib/rules.js +11 -4
- package/package.json +22 -25
- package/schema/.markdownlint.jsonc +54 -51
- package/schema/.markdownlint.yaml +53 -50
- package/schema/ValidatingConfiguration.md +6 -8
- package/schema/markdownlint-config-schema-strict.json +1819 -0
- package/schema/markdownlint-config-schema.json +115 -105
- package/style/prettier.json +1 -0
- package/lib/md019.js +0 -39
- package/lib/md021.js +0 -62
package/lib/md049-md050.js
CHANGED
|
@@ -5,10 +5,19 @@
|
|
|
5
5
|
const { addError, emphasisOrStrongStyleFor } = require("../helpers");
|
|
6
6
|
const { filterByPredicate, tokenIfType } = require("../helpers/micromark.cjs");
|
|
7
7
|
|
|
8
|
-
const intrawordRe =
|
|
8
|
+
const intrawordRe = /^\w$/;
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @param {import("./markdownlint").RuleParams} params Rule parameters.
|
|
12
|
+
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
|
13
|
+
* @param {import("markdownlint-micromark").TokenType} type Token type.
|
|
14
|
+
* @param {import("markdownlint-micromark").TokenType} typeSequence Token sequence type.
|
|
15
|
+
* @param {"*" | "**"} asterisk Asterisk kind.
|
|
16
|
+
* @param {"_" | "__"} underline Underline kind.
|
|
17
|
+
* @param {"asterisk" | "consistent" | "underscore"} style Style string.
|
|
18
|
+
*/
|
|
10
19
|
const impl =
|
|
11
|
-
(params, onError, type, asterisk, underline, style = "consistent") => {
|
|
20
|
+
(params, onError, type, typeSequence, asterisk, underline, style = "consistent") => {
|
|
12
21
|
const { lines, parsers } = params;
|
|
13
22
|
const emphasisTokens = filterByPredicate(
|
|
14
23
|
parsers.micromark.tokens,
|
|
@@ -17,9 +26,8 @@ const impl =
|
|
|
17
26
|
);
|
|
18
27
|
for (const token of emphasisTokens) {
|
|
19
28
|
const { children } = token;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const endSequence = tokenIfType(children[children.length - 1], childType);
|
|
29
|
+
const startSequence = tokenIfType(children[0], typeSequence);
|
|
30
|
+
const endSequence = tokenIfType(children[children.length - 1], typeSequence);
|
|
23
31
|
if (startSequence && endSequence) {
|
|
24
32
|
const markupStyle = emphasisOrStrongStyleFor(startSequence.text);
|
|
25
33
|
if (style === "consistent") {
|
|
@@ -55,16 +63,20 @@ const impl =
|
|
|
55
63
|
}
|
|
56
64
|
};
|
|
57
65
|
|
|
66
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
67
|
+
/** @type import("./markdownlint").Rule[] */
|
|
58
68
|
module.exports = [
|
|
59
69
|
{
|
|
60
70
|
"names": [ "MD049", "emphasis-style" ],
|
|
61
71
|
"description": "Emphasis style",
|
|
62
72
|
"tags": [ "emphasis" ],
|
|
73
|
+
"parser": "micromark",
|
|
63
74
|
"function": function MD049(params, onError) {
|
|
64
75
|
return impl(
|
|
65
76
|
params,
|
|
66
77
|
onError,
|
|
67
78
|
"emphasis",
|
|
79
|
+
"emphasisSequence",
|
|
68
80
|
"*",
|
|
69
81
|
"_",
|
|
70
82
|
params.config.style || undefined
|
|
@@ -75,11 +87,13 @@ module.exports = [
|
|
|
75
87
|
"names": [ "MD050", "strong-style" ],
|
|
76
88
|
"description": "Strong style",
|
|
77
89
|
"tags": [ "emphasis" ],
|
|
90
|
+
"parser": "micromark",
|
|
78
91
|
"function": function MD050(params, onError) {
|
|
79
92
|
return impl(
|
|
80
93
|
params,
|
|
81
94
|
onError,
|
|
82
95
|
"strong",
|
|
96
|
+
"strongSequence",
|
|
83
97
|
"**",
|
|
84
98
|
"__",
|
|
85
99
|
params.config.style || undefined
|
package/lib/md051.js
CHANGED
|
@@ -2,31 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
|
-
const { addError, addErrorDetailIf, getHtmlAttributeRe } =
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
require("../helpers/micromark.cjs");
|
|
5
|
+
const { addError, addErrorDetailIf, getHtmlAttributeRe } = require("../helpers");
|
|
6
|
+
const { filterByPredicate, filterByTypes, getHtmlTagInfo } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
9
8
|
|
|
10
9
|
// Regular expression for identifying HTML anchor names
|
|
11
10
|
const idRe = getHtmlAttributeRe("id");
|
|
12
11
|
const nameRe = getHtmlAttributeRe("name");
|
|
13
12
|
const anchorRe = /\{(#[a-z\d]+(?:[-_][a-z\d]+)*)\}/gu;
|
|
13
|
+
const lineFragmentRe = /^#(?:L\d+(?:C\d+)?-L\d+(?:C\d+)?|L\d+)$/;
|
|
14
14
|
|
|
15
15
|
// Sets for filtering heading tokens during conversion
|
|
16
16
|
const childrenExclude = new Set([ "image", "reference", "resource" ]);
|
|
17
17
|
const tokensInclude = new Set(
|
|
18
|
-
[ "characterEscapeValue", "codeTextData", "data" ]
|
|
18
|
+
[ "characterEscapeValue", "codeTextData", "data", "mathTextData" ]
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* @typedef {import("../helpers/micromark.cjs").Token} Token
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
21
|
/**
|
|
26
22
|
* Converts a Markdown heading into an HTML fragment according to the rules
|
|
27
23
|
* used by GitHub.
|
|
28
24
|
*
|
|
29
|
-
* @param {Token} headingText Heading text token.
|
|
25
|
+
* @param {import("../helpers/micromark.cjs").Token} headingText Heading text token.
|
|
30
26
|
* @returns {string} Fragment string for heading.
|
|
31
27
|
*/
|
|
32
28
|
function convertHeadingToHTMLFragment(headingText) {
|
|
@@ -55,7 +51,7 @@ function convertHeadingToHTMLFragment(headingText) {
|
|
|
55
51
|
/**
|
|
56
52
|
* Unescapes the text of a String-type micromark Token.
|
|
57
53
|
*
|
|
58
|
-
* @param {Token} token String-type micromark Token.
|
|
54
|
+
* @param {import("../helpers/micromark.cjs").Token} token String-type micromark Token.
|
|
59
55
|
* @returns {string} Unescaped token text.
|
|
60
56
|
*/
|
|
61
57
|
function unescapeStringTokenText(token) {
|
|
@@ -64,19 +60,18 @@ function unescapeStringTokenText(token) {
|
|
|
64
60
|
.join("");
|
|
65
61
|
}
|
|
66
62
|
|
|
63
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
64
|
+
/** @type import("./markdownlint").Rule */
|
|
67
65
|
module.exports = {
|
|
68
66
|
"names": [ "MD051", "link-fragments" ],
|
|
69
67
|
"description": "Link fragments should be valid",
|
|
70
68
|
"tags": [ "links" ],
|
|
69
|
+
"parser": "micromark",
|
|
71
70
|
"function": function MD051(params, onError) {
|
|
72
|
-
const { tokens } = params.parsers.micromark;
|
|
73
71
|
const fragments = new Map();
|
|
74
72
|
|
|
75
73
|
// Process headings
|
|
76
|
-
const headingTexts =
|
|
77
|
-
tokens,
|
|
78
|
-
[ "atxHeadingText", "setextHeadingText" ]
|
|
79
|
-
);
|
|
74
|
+
const headingTexts = filterByTypesCached([ "atxHeadingText", "setextHeadingText" ]);
|
|
80
75
|
for (const headingText of headingTexts) {
|
|
81
76
|
const fragment = convertHeadingToHTMLFragment(headingText);
|
|
82
77
|
if (fragment !== "#") {
|
|
@@ -96,7 +91,7 @@ module.exports = {
|
|
|
96
91
|
}
|
|
97
92
|
|
|
98
93
|
// Process HTML anchors
|
|
99
|
-
for (const token of
|
|
94
|
+
for (const token of filterByTypesCached([ "htmlText" ], true)) {
|
|
100
95
|
const htmlTagInfo = getHtmlTagInfo(token);
|
|
101
96
|
if (htmlTagInfo && !htmlTagInfo.close) {
|
|
102
97
|
const anchorMatch = idRe.exec(token.text) ||
|
|
@@ -108,22 +103,25 @@ module.exports = {
|
|
|
108
103
|
}
|
|
109
104
|
|
|
110
105
|
// Process link and definition fragments
|
|
106
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
107
|
+
/** @type import("../helpers/micromark.cjs").TokenType[][] */
|
|
111
108
|
const parentChilds = [
|
|
112
109
|
[ "link", "resourceDestinationString" ],
|
|
113
110
|
[ "definition", "definitionDestinationString" ]
|
|
114
111
|
];
|
|
115
112
|
for (const [ parentType, definitionType ] of parentChilds) {
|
|
116
|
-
const links =
|
|
113
|
+
const links = filterByTypesCached([ parentType ]);
|
|
117
114
|
for (const link of links) {
|
|
118
115
|
const definitions = filterByTypes(link.children, [ definitionType ]);
|
|
119
116
|
for (const definition of definitions) {
|
|
120
117
|
const { endColumn, startColumn } = definition;
|
|
121
118
|
const text = unescapeStringTokenText(definition);
|
|
119
|
+
const encodedText = `#${encodeURIComponent(text.slice(1))}`;
|
|
122
120
|
if (
|
|
123
121
|
(text.length > 1) &&
|
|
124
122
|
text.startsWith("#") &&
|
|
125
|
-
!fragments.has(
|
|
126
|
-
!
|
|
123
|
+
!fragments.has(encodedText) &&
|
|
124
|
+
!lineFragmentRe.test(encodedText)
|
|
127
125
|
) {
|
|
128
126
|
// eslint-disable-next-line no-undef-init
|
|
129
127
|
let context = undefined;
|
package/lib/md052.js
CHANGED
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
5
|
const { addError } = require("../helpers");
|
|
6
|
-
const {
|
|
6
|
+
const { getReferenceLinkImageData } = require("./cache");
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
8
10
|
module.exports = {
|
|
9
11
|
"names": [ "MD052", "reference-links-images" ],
|
|
10
12
|
"description":
|
|
11
13
|
"Reference links and images should use a label that is defined",
|
|
12
14
|
"tags": [ "images", "links" ],
|
|
15
|
+
"parser": "none",
|
|
13
16
|
"function": function MD052(params, onError) {
|
|
14
17
|
const { config, lines } = params;
|
|
15
18
|
const shortcutSyntax = config.shortcut_syntax || false;
|
|
16
|
-
const { definitions, references, shortcuts } =
|
|
19
|
+
const { definitions, references, shortcuts } = getReferenceLinkImageData();
|
|
17
20
|
const entries = shortcutSyntax ?
|
|
18
21
|
[ ...references.entries(), ...shortcuts.entries() ] :
|
|
19
22
|
references.entries();
|
package/lib/md053.js
CHANGED
|
@@ -4,17 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
const { addError, ellipsify, linkReferenceDefinitionRe } =
|
|
6
6
|
require("../helpers");
|
|
7
|
-
const {
|
|
7
|
+
const { getReferenceLinkImageData } = require("./cache");
|
|
8
8
|
|
|
9
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
10
|
+
/** @type import("./markdownlint").Rule */
|
|
9
11
|
module.exports = {
|
|
10
12
|
"names": [ "MD053", "link-image-reference-definitions" ],
|
|
11
13
|
"description": "Link and image reference definitions should be needed",
|
|
12
14
|
"tags": [ "images", "links" ],
|
|
15
|
+
"parser": "none",
|
|
13
16
|
"function": function MD053(params, onError) {
|
|
14
17
|
const ignored = new Set(params.config.ignored_definitions || [ "//" ]);
|
|
15
18
|
const lines = params.lines;
|
|
16
19
|
const { references, shortcuts, definitions, duplicateDefinitions } =
|
|
17
|
-
|
|
20
|
+
getReferenceLinkImageData();
|
|
18
21
|
const singleLineDefinition = (line) => (
|
|
19
22
|
line.replace(linkReferenceDefinitionRe, "").trim().length > 0
|
|
20
23
|
);
|
package/lib/md054.js
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
|
|
5
5
|
const { addErrorContext, nextLinesRe } = require("../helpers");
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
const { referenceLinkImageData } = require("./cache");
|
|
6
|
+
const { filterByPredicate, getTokenTextByType } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
|
9
8
|
|
|
10
9
|
const backslashEscapeRe = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;
|
|
11
10
|
const removeBackslashEscapes = (text) => text.replace(backslashEscapeRe, "$1");
|
|
@@ -21,12 +20,15 @@ const autolinkAble = (destination) => {
|
|
|
21
20
|
return !autolinkDisallowedRe.test(destination);
|
|
22
21
|
};
|
|
23
22
|
|
|
23
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
24
|
+
/** @type import("./markdownlint").Rule */
|
|
24
25
|
module.exports = {
|
|
25
26
|
"names": [ "MD054", "link-image-style" ],
|
|
26
27
|
"description": "Link and image style",
|
|
27
28
|
"tags": [ "images", "links" ],
|
|
29
|
+
"parser": "micromark",
|
|
28
30
|
"function": (params, onError) => {
|
|
29
|
-
const
|
|
31
|
+
const config = params.config;
|
|
30
32
|
const autolink = (config.autolink === undefined) || !!config.autolink;
|
|
31
33
|
const inline = (config.inline === undefined) || !!config.inline;
|
|
32
34
|
const full = (config.full === undefined) || !!config.full;
|
|
@@ -37,11 +39,8 @@ module.exports = {
|
|
|
37
39
|
// Everything allowed, nothing to check
|
|
38
40
|
return;
|
|
39
41
|
}
|
|
40
|
-
const { definitions } =
|
|
41
|
-
const links =
|
|
42
|
-
parsers.micromark.tokens,
|
|
43
|
-
[ "autolink", "image", "link" ]
|
|
44
|
-
);
|
|
42
|
+
const { definitions } = getReferenceLinkImageData();
|
|
43
|
+
const links = filterByTypesCached([ "autolink", "image", "link" ]);
|
|
45
44
|
for (const link of links) {
|
|
46
45
|
let label = null;
|
|
47
46
|
let destination = null;
|
|
@@ -84,7 +83,8 @@ module.exports = {
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
if (isError) {
|
|
87
|
-
|
|
86
|
+
// eslint-disable-next-line no-undef-init
|
|
87
|
+
let range = undefined;
|
|
88
88
|
let fixInfo = null;
|
|
89
89
|
if (startLine === endLine) {
|
|
90
90
|
range = [ startColumn, endColumn - startColumn ];
|
|
@@ -114,8 +114,8 @@ module.exports = {
|
|
|
114
114
|
onError,
|
|
115
115
|
startLine,
|
|
116
116
|
text.replace(nextLinesRe, ""),
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
undefined,
|
|
118
|
+
undefined,
|
|
119
119
|
range,
|
|
120
120
|
fixInfo
|
|
121
121
|
);
|
package/lib/md055.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const { addErrorDetailIf } = require("../helpers");
|
|
6
6
|
const { filterByTypes } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
7
8
|
|
|
8
9
|
const whitespaceTypes = new Set([ "linePrefix", "whitespace" ]);
|
|
9
10
|
const ignoreWhitespace = (tokens) => tokens.filter(
|
|
@@ -13,10 +14,13 @@ const firstOrNothing = (items) => items[0];
|
|
|
13
14
|
const lastOrNothing = (items) => items[items.length - 1];
|
|
14
15
|
const makeRange = (start, end) => [ start, end - start + 1 ];
|
|
15
16
|
|
|
17
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
18
|
+
/** @type import("./markdownlint").Rule */
|
|
16
19
|
module.exports = {
|
|
17
20
|
"names": [ "MD055", "table-pipe-style" ],
|
|
18
21
|
"description": "Table pipe style",
|
|
19
22
|
"tags": [ "table" ],
|
|
23
|
+
"parser": "micromark",
|
|
20
24
|
"function": function MD055(params, onError) {
|
|
21
25
|
const style = String(params.config.style || "consistent");
|
|
22
26
|
let expectedStyle = style;
|
|
@@ -24,9 +28,12 @@ module.exports = {
|
|
|
24
28
|
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "trailing_only"));
|
|
25
29
|
let expectedTrailingPipe =
|
|
26
30
|
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "leading_only"));
|
|
27
|
-
const tables =
|
|
31
|
+
const tables = filterByTypesCached([ "table" ]);
|
|
28
32
|
for (const table of tables) {
|
|
29
|
-
const rows = filterByTypes(
|
|
33
|
+
const rows = filterByTypes(
|
|
34
|
+
table.children,
|
|
35
|
+
[ "tableDelimiterRow", "tableRow" ]
|
|
36
|
+
);
|
|
30
37
|
for (const row of rows) {
|
|
31
38
|
// The following uses of first/lastOrNothing lack fallback handling
|
|
32
39
|
// because it seems not to be possible (i.e., 0% coverage)
|
|
@@ -69,4 +76,4 @@ module.exports = {
|
|
|
69
76
|
}
|
|
70
77
|
}
|
|
71
78
|
}
|
|
72
|
-
}
|
|
79
|
+
};
|
package/lib/md056.js
CHANGED
|
@@ -4,24 +4,36 @@
|
|
|
4
4
|
|
|
5
5
|
const { addErrorDetailIf } = require("../helpers");
|
|
6
6
|
const { filterByTypes } = require("../helpers/micromark.cjs");
|
|
7
|
+
const { filterByTypesCached } = require("./cache");
|
|
7
8
|
|
|
8
9
|
const makeRange = (start, end) => [ start, end - start + 1 ];
|
|
9
10
|
|
|
11
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
12
|
+
/** @type import("./markdownlint").Rule */
|
|
10
13
|
module.exports = {
|
|
11
14
|
"names": [ "MD056", "table-column-count" ],
|
|
12
15
|
"description": "Table column count",
|
|
13
16
|
"tags": [ "table" ],
|
|
17
|
+
"parser": "micromark",
|
|
14
18
|
"function": function MD056(params, onError) {
|
|
15
|
-
const tables =
|
|
19
|
+
const tables = filterByTypesCached([ "table" ]);
|
|
16
20
|
for (const table of tables) {
|
|
17
|
-
const rows = filterByTypes(
|
|
21
|
+
const rows = filterByTypes(
|
|
22
|
+
table.children,
|
|
23
|
+
[ "tableDelimiterRow", "tableRow" ]
|
|
24
|
+
);
|
|
18
25
|
let expectedCount = 0;
|
|
19
26
|
for (const row of rows) {
|
|
20
|
-
const cells = filterByTypes(
|
|
27
|
+
const cells = filterByTypes(
|
|
28
|
+
row.children,
|
|
29
|
+
[ "tableData", "tableDelimiter", "tableHeader" ]
|
|
30
|
+
);
|
|
21
31
|
const actualCount = cells.length;
|
|
22
32
|
expectedCount ||= actualCount;
|
|
23
|
-
|
|
24
|
-
let
|
|
33
|
+
// eslint-disable-next-line no-undef-init
|
|
34
|
+
let detail = undefined;
|
|
35
|
+
// eslint-disable-next-line no-undef-init
|
|
36
|
+
let range = undefined;
|
|
25
37
|
if (actualCount < expectedCount) {
|
|
26
38
|
detail = "Too few cells, row will be missing data";
|
|
27
39
|
range = [ row.endColumn - 1, 1 ];
|
|
@@ -35,7 +47,7 @@ module.exports = {
|
|
|
35
47
|
expectedCount,
|
|
36
48
|
actualCount,
|
|
37
49
|
detail,
|
|
38
|
-
|
|
50
|
+
undefined,
|
|
39
51
|
range
|
|
40
52
|
);
|
|
41
53
|
}
|
package/lib/md058.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const { addErrorContextForLine, isBlankLine } = require("../helpers");
|
|
6
|
+
const { filterByTypesCached } = require("./cache");
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line jsdoc/valid-types
|
|
9
|
+
/** @type import("./markdownlint").Rule */
|
|
10
|
+
module.exports = {
|
|
11
|
+
"names": [ "MD058", "blanks-around-tables" ],
|
|
12
|
+
"description": "Tables should be surrounded by blank lines",
|
|
13
|
+
"tags": [ "table" ],
|
|
14
|
+
"parser": "micromark",
|
|
15
|
+
"function": function MD058(params, onError) {
|
|
16
|
+
const { lines } = params;
|
|
17
|
+
// For every table...
|
|
18
|
+
const tables = filterByTypesCached([ "table" ]);
|
|
19
|
+
for (const table of tables) {
|
|
20
|
+
// Look for a blank line above the table
|
|
21
|
+
const firstIndex = table.startLine - 1;
|
|
22
|
+
if (!isBlankLine(lines[firstIndex - 1])) {
|
|
23
|
+
addErrorContextForLine(
|
|
24
|
+
onError,
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
lines,
|
|
27
|
+
firstIndex
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
// Look for a blank line below the table
|
|
31
|
+
const lastIndex = table.endLine - 1;
|
|
32
|
+
if (!isBlankLine(lines[lastIndex + 1])) {
|
|
33
|
+
addErrorContextForLine(
|
|
34
|
+
onError,
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
lines,
|
|
37
|
+
lastIndex,
|
|
38
|
+
lastIndex + 2
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
package/lib/rules.js
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
const { homepage, version } = require("./constants");
|
|
6
6
|
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
const [ md019, md021 ] = require("./md019-md021");
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const [ md049, md050 ] = require("./md049-md050");
|
|
11
|
+
|
|
7
12
|
const rules = [
|
|
8
13
|
require("./md001"),
|
|
9
14
|
// md002: Deprecated and removed
|
|
@@ -19,9 +24,9 @@ const rules = [
|
|
|
19
24
|
require("./md013"),
|
|
20
25
|
require("./md014"),
|
|
21
26
|
require("./md018"),
|
|
22
|
-
|
|
27
|
+
md019,
|
|
23
28
|
require("./md020"),
|
|
24
|
-
|
|
29
|
+
md021,
|
|
25
30
|
require("./md022"),
|
|
26
31
|
require("./md023"),
|
|
27
32
|
require("./md024"),
|
|
@@ -49,14 +54,16 @@ const rules = [
|
|
|
49
54
|
require("./md046"),
|
|
50
55
|
require("./md047"),
|
|
51
56
|
require("./md048"),
|
|
52
|
-
|
|
57
|
+
md049,
|
|
58
|
+
md050,
|
|
53
59
|
require("./md051"),
|
|
54
60
|
require("./md052"),
|
|
55
61
|
require("./md053"),
|
|
56
62
|
require("./md054"),
|
|
57
63
|
require("./md055"),
|
|
58
|
-
require("./md056")
|
|
64
|
+
require("./md056"),
|
|
59
65
|
// md057: See https://github.com/markdownlint/markdownlint
|
|
66
|
+
require("./md058")
|
|
60
67
|
];
|
|
61
68
|
for (const rule of rules) {
|
|
62
69
|
const name = rule.names[0].toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./lib/markdownlint.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"build-config": "npm run build-config-schema && npm run build-config-example",
|
|
27
27
|
"build-config-example": "node schema/build-config-example.js",
|
|
28
28
|
"build-config-schema": "node schema/build-config-schema.js",
|
|
29
|
-
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts
|
|
29
|
+
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --outDir dts --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts copy dts/lib/markdownlint.d.ts lib/markdownlint.d.ts && node scripts remove dts",
|
|
30
30
|
"build-demo": "node scripts copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && node scripts copy node_modules/markdownlint-micromark/micromark-browser.js demo/micromark-browser.js && node scripts copy node_modules/markdownlint-micromark/micromark-html-browser.js demo/micromark-html-browser.js && cd demo && webpack --no-stats",
|
|
31
31
|
"build-docs": "node doc-build/build-rules.mjs",
|
|
32
32
|
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:latest npm install",
|
|
50
50
|
"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:latest npm run upgrade",
|
|
51
51
|
"install-micromark": "cd micromark && npm install",
|
|
52
|
-
"lint": "eslint --
|
|
52
|
+
"lint": "eslint --max-warnings 0",
|
|
53
53
|
"lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos-*.js",
|
|
54
54
|
"serial-config-docs": "npm run build-config && npm run build-docs",
|
|
55
55
|
"serial-declaration-demo": "npm run build-declaration && npm-run-all --continue-on-error --parallel build-demo test-declaration",
|
|
56
56
|
"test": "ava --timeout=30s test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js",
|
|
57
57
|
"test-cover": "c8 --100 npm test",
|
|
58
|
-
"test-declaration": "cd example/typescript && tsc && node type-check.js",
|
|
58
|
+
"test-declaration": "cd example/typescript && tsc --module nodenext && tsc --module commonjs && node type-check.js",
|
|
59
59
|
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.js test/markdownlint-test-extra-type.js",
|
|
60
60
|
"update-snapshots": "ava --update-snapshots test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.js",
|
|
61
61
|
"update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.js",
|
|
@@ -65,38 +65,35 @@
|
|
|
65
65
|
"node": ">=18"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"markdown-it": "14.
|
|
69
|
-
"markdownlint-micromark": "0.1.
|
|
68
|
+
"markdown-it": "14.1.0",
|
|
69
|
+
"markdownlint-micromark": "0.1.10"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"babel-loader": "9.1.3",
|
|
77
|
-
"c8": "9.0.0",
|
|
72
|
+
"@eslint/js": "9.9.1",
|
|
73
|
+
"ajv": "8.17.1",
|
|
74
|
+
"ava": "6.1.3",
|
|
75
|
+
"c8": "10.1.2",
|
|
78
76
|
"character-entities": "2.0.2",
|
|
79
|
-
"eslint": "
|
|
80
|
-
"eslint-plugin-jsdoc": "
|
|
81
|
-
"eslint-plugin-n": "
|
|
82
|
-
"eslint-plugin-regexp": "2.
|
|
83
|
-
"eslint-plugin-unicorn": "
|
|
77
|
+
"eslint": "9.9.1",
|
|
78
|
+
"eslint-plugin-jsdoc": "50.2.2",
|
|
79
|
+
"eslint-plugin-n": "17.10.2",
|
|
80
|
+
"eslint-plugin-regexp": "2.6.0",
|
|
81
|
+
"eslint-plugin-unicorn": "55.0.0",
|
|
84
82
|
"gemoji": "8.1.0",
|
|
85
|
-
"globby": "14.0.
|
|
83
|
+
"globby": "14.0.2",
|
|
86
84
|
"js-yaml": "4.1.0",
|
|
87
|
-
"json-schema-to-typescript": "
|
|
85
|
+
"json-schema-to-typescript": "15.0.1",
|
|
86
|
+
"jsonc-parser": "3.3.1",
|
|
88
87
|
"markdown-it-for-inline": "2.0.1",
|
|
89
88
|
"markdown-it-sub": "2.0.0",
|
|
90
89
|
"markdown-it-sup": "2.0.0",
|
|
91
|
-
"markdownlint-rule-
|
|
90
|
+
"markdownlint-rule-extended-ascii": "0.1.0",
|
|
92
91
|
"npm-run-all": "4.1.5",
|
|
93
|
-
"strip-json-comments": "5.0.1",
|
|
94
92
|
"terser-webpack-plugin": "5.3.10",
|
|
95
93
|
"toml": "3.0.0",
|
|
96
|
-
"typescript": "5.
|
|
97
|
-
"webpack": "5.
|
|
98
|
-
"webpack-cli": "5.1.4"
|
|
99
|
-
"yaml": "2.3.4"
|
|
94
|
+
"typescript": "5.5.4",
|
|
95
|
+
"webpack": "5.94.0",
|
|
96
|
+
"webpack-cli": "5.1.4"
|
|
100
97
|
},
|
|
101
98
|
"keywords": [
|
|
102
99
|
"markdown",
|