mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Remove outdated type annotations and lint suppressions.
This commit is contained in:
parent
d9c5d24e20
commit
1513e3803b
25 changed files with 208 additions and 322 deletions
|
|
@ -3549,13 +3549,8 @@ module.exports = {
|
||||||
"tags": [ "bullet", "ul", "indentation" ],
|
"tags": [ "bullet", "ul", "indentation" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD005(params, onError) {
|
"function": function MD005(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const lists = filterByTypes(
|
const lists = filterByTypes(
|
||||||
micromarkTokens,
|
params.parsers.micromark.tokens,
|
||||||
[ "listOrdered", "listUnordered" ]
|
[ "listOrdered", "listUnordered" ]
|
||||||
);
|
);
|
||||||
for (const list of lists) {
|
for (const list of lists) {
|
||||||
|
|
@ -3653,14 +3648,12 @@ module.exports = {
|
||||||
const indent = Number(params.config.indent || 2);
|
const indent = Number(params.config.indent || 2);
|
||||||
const startIndented = !!params.config.start_indented;
|
const startIndented = !!params.config.start_indented;
|
||||||
const startIndent = Number(params.config.start_indent || indent);
|
const startIndent = Number(params.config.start_indent || indent);
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const unorderedListNesting = new Map();
|
const unorderedListNesting = new Map();
|
||||||
let lastBlockQuotePrefix = null;
|
let lastBlockQuotePrefix = null;
|
||||||
const tokens = filterByTypes(micromarkTokens, unorderedListTypes);
|
const tokens = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
unorderedListTypes
|
||||||
|
);
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const { endColumn, parent, startColumn, startLine, type } = token;
|
const { endColumn, parent, startColumn, startLine, type } = token;
|
||||||
if (type === "blockQuotePrefix") {
|
if (type === "blockQuotePrefix") {
|
||||||
|
|
@ -4448,14 +4441,10 @@ module.exports = {
|
||||||
"function": function MD022(params, onError) {
|
"function": function MD022(params, onError) {
|
||||||
const getLinesAbove = getLinesFunction(params.config.lines_above);
|
const getLinesAbove = getLinesFunction(params.config.lines_above);
|
||||||
const getLinesBelow = getLinesFunction(params.config.lines_below);
|
const getLinesBelow = getLinesFunction(params.config.lines_below);
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
const { lines } = params;
|
||||||
const headings = filterByTypes(
|
const headings = filterByTypes(
|
||||||
micromarkTokens,
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
[ "atxHeading", "setextHeading" ]
|
[ "atxHeading", "setextHeading" ]
|
||||||
);
|
);
|
||||||
for (const heading of headings) {
|
for (const heading of headings) {
|
||||||
|
|
@ -4724,12 +4713,10 @@ module.exports = {
|
||||||
);
|
);
|
||||||
const trailingPunctuationRe =
|
const trailingPunctuationRe =
|
||||||
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
|
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const headings = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "atxHeadingText", "setextHeadingText" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const headings = filterByTypes(micromarkTokens, [ "atxHeadingText", "setextHeadingText" ]);
|
|
||||||
for (const heading of headings) {
|
for (const heading of headings) {
|
||||||
const { endColumn, endLine, text } = heading;
|
const { endColumn, endLine, text } = heading;
|
||||||
const match = trailingPunctuationRe.exec(text);
|
const match = trailingPunctuationRe.exec(text);
|
||||||
|
|
@ -4782,11 +4769,7 @@ module.exports = {
|
||||||
"tags": ["blockquote", "whitespace", "indentation"],
|
"tags": ["blockquote", "whitespace", "indentation"],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD027(params, onError) {
|
"function": function MD027(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
for (const token of filterByTypes(micromarkTokens, [ "linePrefix" ])) {
|
for (const token of filterByTypes(micromarkTokens, [ "linePrefix" ])) {
|
||||||
const siblings = token.parent?.children || micromarkTokens;
|
const siblings = token.parent?.children || micromarkTokens;
|
||||||
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
||||||
|
|
@ -4797,8 +4780,8 @@ module.exports = {
|
||||||
onError,
|
onError,
|
||||||
startLine,
|
startLine,
|
||||||
line,
|
line,
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
[ startColumn, length ],
|
[ startColumn, length ],
|
||||||
{
|
{
|
||||||
"editColumn": startColumn,
|
"editColumn": startColumn,
|
||||||
|
|
@ -4837,11 +4820,7 @@ module.exports = {
|
||||||
"tags": [ "blockquote", "whitespace" ],
|
"tags": [ "blockquote", "whitespace" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD028(params, onError) {
|
"function": function MD028(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
for (const token of filterByTypes(micromarkTokens, [ "blockQuote" ])) {
|
for (const token of filterByTypes(micromarkTokens, [ "blockQuote" ])) {
|
||||||
const errorLineNumbers = [];
|
const errorLineNumbers = [];
|
||||||
const siblings = token.parent?.children || micromarkTokens;
|
const siblings = token.parent?.children || micromarkTokens;
|
||||||
|
|
@ -4978,12 +4957,10 @@ module.exports = {
|
||||||
const olSingle = Number(params.config.ol_single || 1);
|
const olSingle = Number(params.config.ol_single || 1);
|
||||||
const ulMulti = Number(params.config.ul_multi || 1);
|
const ulMulti = Number(params.config.ul_multi || 1);
|
||||||
const olMulti = Number(params.config.ol_multi || 1);
|
const olMulti = Number(params.config.ol_multi || 1);
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const lists = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "listOrdered", "listUnordered" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const lists = filterByTypes(micromarkTokens, [ "listOrdered", "listUnordered" ]);
|
|
||||||
for (const list of lists) {
|
for (const list of lists) {
|
||||||
const ordered = (list.type === "listOrdered");
|
const ordered = (list.type === "listOrdered");
|
||||||
const listItemPrefixes =
|
const listItemPrefixes =
|
||||||
|
|
@ -5015,8 +4992,8 @@ module.exports = {
|
||||||
startLine,
|
startLine,
|
||||||
expectedSpaces,
|
expectedSpaces,
|
||||||
actualSpaces,
|
actualSpaces,
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
range,
|
range,
|
||||||
fixInfo
|
fixInfo
|
||||||
);
|
);
|
||||||
|
|
@ -5109,16 +5086,11 @@ module.exports = {
|
||||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD032(params, onError) {
|
"function": function MD032(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
|
|
||||||
// For every top-level list...
|
// For every top-level list...
|
||||||
const topLevelLists = filterByPredicate(
|
const topLevelLists = filterByPredicate(
|
||||||
micromarkTokens,
|
parsers.micromark.tokens,
|
||||||
isList,
|
isList,
|
||||||
(token) => (
|
(token) => (
|
||||||
(isList(token) || (token.type === "htmlFlow")) ? [] : token.children
|
(isList(token) || (token.type === "htmlFlow")) ? [] : token.children
|
||||||
|
|
@ -5191,12 +5163,7 @@ module.exports = {
|
||||||
let allowedElements = params.config.allowed_elements;
|
let allowedElements = params.config.allowed_elements;
|
||||||
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
||||||
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
for (const token of filterByTypes(params.parsers.micromark.tokens, [ "htmlText" ], true)) {
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
for (const token of filterByTypes(micromarkTokens, [ "htmlText" ], true)) {
|
|
||||||
const htmlTagInfo = getHtmlTagInfo(token);
|
const htmlTagInfo = getHtmlTagInfo(token);
|
||||||
if (
|
if (
|
||||||
htmlTagInfo &&
|
htmlTagInfo &&
|
||||||
|
|
@ -5245,11 +5212,6 @@ module.exports = {
|
||||||
"tags": [ "links", "url" ],
|
"tags": [ "links", "url" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD034(params, onError) {
|
"function": function MD034(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const literalAutolinks = (tokens) => (
|
const literalAutolinks = (tokens) => (
|
||||||
filterByPredicate(
|
filterByPredicate(
|
||||||
tokens,
|
tokens,
|
||||||
|
|
@ -5306,7 +5268,10 @@ module.exports = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
const autoLinks = filterByTypes(micromarkTokens, [ "literalAutolink" ]);
|
const autoLinks = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
[ "literalAutolink" ]
|
||||||
|
);
|
||||||
if (autoLinks.length > 0) {
|
if (autoLinks.length > 0) {
|
||||||
// Re-parse with correct link/image reference definition handling
|
// Re-parse with correct link/image reference definition handling
|
||||||
const document = params.lines.join("\n");
|
const document = params.lines.join("\n");
|
||||||
|
|
@ -5361,12 +5326,10 @@ module.exports = {
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD035(params, onError) {
|
"function": function MD035(params, onError) {
|
||||||
let style = String(params.config.style || "consistent").trim();
|
let style = String(params.config.style || "consistent").trim();
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const thematicBreaks = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "thematicBreak" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const thematicBreaks = filterByTypes(micromarkTokens, [ "thematicBreak" ]);
|
|
||||||
for (const token of thematicBreaks) {
|
for (const token of thematicBreaks) {
|
||||||
const { startLine, text } = token;
|
const { startLine, text } = token;
|
||||||
if (style === "consistent") {
|
if (style === "consistent") {
|
||||||
|
|
@ -5465,18 +5428,13 @@ module.exports = {
|
||||||
"function": function MD037(params, onError) {
|
"function": function MD037(params, onError) {
|
||||||
|
|
||||||
// Initialize variables
|
// Initialize variables
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
const emphasisTokensByMarker = new Map();
|
const emphasisTokensByMarker = new Map();
|
||||||
for (const marker of [ "_", "__", "___", "*", "**", "***" ]) {
|
for (const marker of [ "_", "__", "___", "*", "**", "***" ]) {
|
||||||
emphasisTokensByMarker.set(marker, []);
|
emphasisTokensByMarker.set(marker, []);
|
||||||
}
|
}
|
||||||
const tokens = filterByPredicate(
|
const tokens = filterByPredicate(
|
||||||
micromarkTokens,
|
parsers.micromark.tokens,
|
||||||
(token) => token.children.some((child) => child.type === "data")
|
(token) => token.children.some((child) => child.type === "data")
|
||||||
);
|
);
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
|
|
@ -5586,12 +5544,10 @@ module.exports = {
|
||||||
"tags": [ "whitespace", "code" ],
|
"tags": [ "whitespace", "code" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD038(params, onError) {
|
"function": function MD038(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const codeTexts = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "codeText" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const codeTexts = filterByTypes(micromarkTokens, [ "codeText" ]);
|
|
||||||
for (const codeText of codeTexts) {
|
for (const codeText of codeTexts) {
|
||||||
const { children } = codeText;
|
const { children } = codeText;
|
||||||
const first = 0;
|
const first = 0;
|
||||||
|
|
@ -5774,12 +5730,10 @@ module.exports = {
|
||||||
let allowed = params.config.allowed_languages;
|
let allowed = params.config.allowed_languages;
|
||||||
allowed = Array.isArray(allowed) ? allowed : [];
|
allowed = Array.isArray(allowed) ? allowed : [];
|
||||||
const languageOnly = !!params.config.language_only;
|
const languageOnly = !!params.config.language_only;
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const fencedCodes = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "codeFenced" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const fencedCodes = filterByTypes(micromarkTokens, [ "codeFenced" ]);
|
|
||||||
for (const fencedCode of fencedCodes) {
|
for (const fencedCode of fencedCodes) {
|
||||||
const openingFence = tokenIfType(fencedCode.children[0], "codeFencedFence");
|
const openingFence = tokenIfType(fencedCode.children[0], "codeFencedFence");
|
||||||
if (openingFence) {
|
if (openingFence) {
|
||||||
|
|
@ -6032,11 +5986,6 @@ module.exports = {
|
||||||
const htmlElements = params.config.html_elements;
|
const htmlElements = params.config.html_elements;
|
||||||
const includeHtmlElements =
|
const includeHtmlElements =
|
||||||
(htmlElements === undefined) ? true : !!htmlElements;
|
(htmlElements === undefined) ? true : !!htmlElements;
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const scannedTypes = new Set([ "data" ]);
|
const scannedTypes = new Set([ "data" ]);
|
||||||
if (includeCodeBlocks) {
|
if (includeCodeBlocks) {
|
||||||
scannedTypes.add("codeFlowValue");
|
scannedTypes.add("codeFlowValue");
|
||||||
|
|
@ -6048,7 +5997,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
const contentTokens =
|
const contentTokens =
|
||||||
filterByPredicate(
|
filterByPredicate(
|
||||||
micromarkTokens,
|
params.parsers.micromark.tokens,
|
||||||
(token) => scannedTypes.has(token.type),
|
(token) => scannedTypes.has(token.type),
|
||||||
(token) => (
|
(token) => (
|
||||||
token.children.filter((t) => !ignoredChildTypes.has(t.type))
|
token.children.filter((t) => !ignoredChildTypes.has(t.type))
|
||||||
|
|
@ -6096,8 +6045,8 @@ module.exports = {
|
||||||
token.startLine,
|
token.startLine,
|
||||||
name,
|
name,
|
||||||
nameMatch,
|
nameMatch,
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
[ column, length ],
|
[ column, length ],
|
||||||
{
|
{
|
||||||
"editColumn": column,
|
"editColumn": column,
|
||||||
|
|
@ -6141,14 +6090,13 @@ module.exports = {
|
||||||
"tags": [ "accessibility", "images" ],
|
"tags": [ "accessibility", "images" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD045(params, onError) {
|
"function": function MD045(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
|
|
||||||
// Process Markdown images
|
// Process Markdown images
|
||||||
const images = filterByTypes(micromarkTokens, [ "image" ]);
|
const images = filterByTypes(
|
||||||
|
micromarkTokens,
|
||||||
|
[ "image" ]
|
||||||
|
);
|
||||||
for (const image of images) {
|
for (const image of images) {
|
||||||
const labelTexts = filterByTypes(image.children, [ "labelText" ]);
|
const labelTexts = filterByTypes(image.children, [ "labelText" ]);
|
||||||
if (labelTexts.some((labelText) => labelText.text.length === 0)) {
|
if (labelTexts.some((labelText) => labelText.text.length === 0)) {
|
||||||
|
|
@ -6166,7 +6114,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process HTML images
|
// Process HTML images
|
||||||
const htmlTexts = filterByTypes(micromarkTokens, [ "htmlText" ], true);
|
const htmlTexts = filterByTypes(
|
||||||
|
micromarkTokens,
|
||||||
|
[ "htmlText" ],
|
||||||
|
true
|
||||||
|
);
|
||||||
for (const htmlText of htmlTexts) {
|
for (const htmlText of htmlTexts) {
|
||||||
const { startColumn, startLine, text } = htmlText;
|
const { startColumn, startLine, text } = htmlText;
|
||||||
const htmlTagInfo = getHtmlTagInfo(htmlText);
|
const htmlTagInfo = getHtmlTagInfo(htmlText);
|
||||||
|
|
@ -6223,12 +6175,10 @@ module.exports = {
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD046(params, onError) {
|
"function": function MD046(params, onError) {
|
||||||
let expectedStyle = String(params.config.style || "consistent");
|
let expectedStyle = String(params.config.style || "consistent");
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const codeBlocksAndFences = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "codeFenced", "codeIndented" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const codeBlocksAndFences = filterByTypes(micromarkTokens, [ "codeFenced", "codeIndented" ]);
|
|
||||||
for (const token of codeBlocksAndFences) {
|
for (const token of codeBlocksAndFences) {
|
||||||
const { startLine, type } = token;
|
const { startLine, type } = token;
|
||||||
if (expectedStyle === "consistent") {
|
if (expectedStyle === "consistent") {
|
||||||
|
|
@ -6311,13 +6261,11 @@ module.exports = {
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD048(params, onError) {
|
"function": function MD048(params, onError) {
|
||||||
const style = String(params.config.style || "consistent");
|
const style = String(params.config.style || "consistent");
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
let expectedStyle = style;
|
let expectedStyle = style;
|
||||||
const codeFenceds = filterByTypes(micromarkTokens, [ "codeFenced" ]);
|
const codeFenceds = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
[ "codeFenced" ]
|
||||||
|
);
|
||||||
for (const codeFenced of codeFenceds) {
|
for (const codeFenced of codeFenceds) {
|
||||||
const codeFencedFence = tokenIfType(codeFenced.children[0], "codeFencedFence");
|
const codeFencedFence = tokenIfType(codeFenced.children[0], "codeFencedFence");
|
||||||
if (codeFencedFence) {
|
if (codeFencedFence) {
|
||||||
|
|
@ -6369,14 +6317,9 @@ const intrawordRe = /^\w$/;
|
||||||
*/
|
*/
|
||||||
const impl =
|
const impl =
|
||||||
(params, onError, type, typeSequence, asterisk, underline, style = "consistent") => {
|
(params, onError, type, typeSequence, asterisk, underline, style = "consistent") => {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
const emphasisTokens = filterByPredicate(
|
const emphasisTokens = filterByPredicate(
|
||||||
micromarkTokens,
|
parsers.micromark.tokens,
|
||||||
(token) => token.type === type,
|
(token) => token.type === type,
|
||||||
(token) => ((token.type === "htmlFlow") ? [] : token.children)
|
(token) => ((token.type === "htmlFlow") ? [] : token.children)
|
||||||
);
|
);
|
||||||
|
|
@ -6539,11 +6482,7 @@ module.exports = {
|
||||||
"tags": [ "links" ],
|
"tags": [ "links" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD051(params, onError) {
|
"function": function MD051(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const fragments = new Map();
|
const fragments = new Map();
|
||||||
|
|
||||||
// Process headings
|
// Process headings
|
||||||
|
|
@ -6823,13 +6762,11 @@ module.exports = {
|
||||||
// Everything allowed, nothing to check
|
// Everything allowed, nothing to check
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { definitions } = referenceLinkImageData();
|
const { definitions } = referenceLinkImageData();
|
||||||
const links = filterByTypes(micromarkTokens, [ "autolink", "image", "link" ]);
|
const links = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
[ "autolink", "image", "link" ]
|
||||||
|
);
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
let label = null;
|
let label = null;
|
||||||
let destination = null;
|
let destination = null;
|
||||||
|
|
@ -6872,7 +6809,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isError) {
|
if (isError) {
|
||||||
let range = null;
|
// eslint-disable-next-line no-undef-init
|
||||||
|
let range = undefined;
|
||||||
let fixInfo = null;
|
let fixInfo = null;
|
||||||
if (startLine === endLine) {
|
if (startLine === endLine) {
|
||||||
range = [ startColumn, endColumn - startColumn ];
|
range = [ startColumn, endColumn - startColumn ];
|
||||||
|
|
@ -6902,8 +6840,8 @@ module.exports = {
|
||||||
onError,
|
onError,
|
||||||
startLine,
|
startLine,
|
||||||
text.replace(nextLinesRe, ""),
|
text.replace(nextLinesRe, ""),
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
range,
|
range,
|
||||||
fixInfo
|
fixInfo
|
||||||
);
|
);
|
||||||
|
|
@ -6951,14 +6889,15 @@ module.exports = {
|
||||||
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "trailing_only"));
|
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "trailing_only"));
|
||||||
let expectedTrailingPipe =
|
let expectedTrailingPipe =
|
||||||
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "leading_only"));
|
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "leading_only"));
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const tables = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "table" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const tables = filterByTypes(micromarkTokens, [ "table" ]);
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
const rows = filterByTypes(table.children, [ "tableDelimiterRow", "tableRow" ]);
|
const rows = filterByTypes(
|
||||||
|
table.children,
|
||||||
|
[ "tableDelimiterRow", "tableRow" ]
|
||||||
|
);
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
// The following uses of first/lastOrNothing lack fallback handling
|
// The following uses of first/lastOrNothing lack fallback handling
|
||||||
// because it seems not to be possible (i.e., 0% coverage)
|
// because it seems not to be possible (i.e., 0% coverage)
|
||||||
|
|
@ -7030,21 +6969,27 @@ module.exports = {
|
||||||
"tags": [ "table" ],
|
"tags": [ "table" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD056(params, onError) {
|
"function": function MD056(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const tables = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "table" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const tables = filterByTypes(micromarkTokens, [ "table" ]);
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
const rows = filterByTypes(table.children, [ "tableDelimiterRow", "tableRow" ]);
|
const rows = filterByTypes(
|
||||||
|
table.children,
|
||||||
|
[ "tableDelimiterRow", "tableRow" ]
|
||||||
|
);
|
||||||
let expectedCount = 0;
|
let expectedCount = 0;
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const cells = filterByTypes(row.children, [ "tableData", "tableDelimiter", "tableHeader" ]);
|
const cells = filterByTypes(
|
||||||
|
row.children,
|
||||||
|
[ "tableData", "tableDelimiter", "tableHeader" ]
|
||||||
|
);
|
||||||
const actualCount = cells.length;
|
const actualCount = cells.length;
|
||||||
expectedCount ||= actualCount;
|
expectedCount ||= actualCount;
|
||||||
let detail = null;
|
// eslint-disable-next-line no-undef-init
|
||||||
let range = null;
|
let detail = undefined;
|
||||||
|
// eslint-disable-next-line no-undef-init
|
||||||
|
let range = undefined;
|
||||||
if (actualCount < expectedCount) {
|
if (actualCount < expectedCount) {
|
||||||
detail = "Too few cells, row will be missing data";
|
detail = "Too few cells, row will be missing data";
|
||||||
range = [ row.endColumn - 1, 1 ];
|
range = [ row.endColumn - 1, 1 ];
|
||||||
|
|
@ -7058,7 +7003,7 @@ module.exports = {
|
||||||
expectedCount,
|
expectedCount,
|
||||||
actualCount,
|
actualCount,
|
||||||
detail,
|
detail,
|
||||||
null,
|
undefined,
|
||||||
range
|
range
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -7091,14 +7036,12 @@ module.exports = {
|
||||||
"tags": [ "table" ],
|
"tags": [ "table" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD058(params, onError) {
|
"function": function MD058(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
// For every table...
|
// For every table...
|
||||||
const tables = filterByTypes(micromarkTokens, [ "table" ]);
|
const tables = filterByTypes(
|
||||||
|
parsers.micromark.tokens,
|
||||||
|
[ "table" ]
|
||||||
|
);
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
// Look for a blank line above the table
|
// Look for a blank line above the table
|
||||||
const firstIndex = table.startLine - 1;
|
const firstIndex = table.startLine - 1;
|
||||||
|
|
|
||||||
|
|
@ -13,13 +13,8 @@ module.exports = {
|
||||||
"tags": [ "bullet", "ul", "indentation" ],
|
"tags": [ "bullet", "ul", "indentation" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD005(params, onError) {
|
"function": function MD005(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const lists = filterByTypes(
|
const lists = filterByTypes(
|
||||||
micromarkTokens,
|
params.parsers.micromark.tokens,
|
||||||
[ "listOrdered", "listUnordered" ]
|
[ "listOrdered", "listUnordered" ]
|
||||||
);
|
);
|
||||||
for (const list of lists) {
|
for (const list of lists) {
|
||||||
|
|
|
||||||
10
lib/md007.js
10
lib/md007.js
|
|
@ -25,14 +25,12 @@ module.exports = {
|
||||||
const indent = Number(params.config.indent || 2);
|
const indent = Number(params.config.indent || 2);
|
||||||
const startIndented = !!params.config.start_indented;
|
const startIndented = !!params.config.start_indented;
|
||||||
const startIndent = Number(params.config.start_indent || indent);
|
const startIndent = Number(params.config.start_indent || indent);
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const unorderedListNesting = new Map();
|
const unorderedListNesting = new Map();
|
||||||
let lastBlockQuotePrefix = null;
|
let lastBlockQuotePrefix = null;
|
||||||
const tokens = filterByTypes(micromarkTokens, unorderedListTypes);
|
const tokens = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
unorderedListTypes
|
||||||
|
);
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const { endColumn, parent, startColumn, startLine, type } = token;
|
const { endColumn, parent, startColumn, startLine, type } = token;
|
||||||
if (type === "blockQuotePrefix") {
|
if (type === "blockQuotePrefix") {
|
||||||
|
|
|
||||||
|
|
@ -40,14 +40,10 @@ module.exports = {
|
||||||
"function": function MD022(params, onError) {
|
"function": function MD022(params, onError) {
|
||||||
const getLinesAbove = getLinesFunction(params.config.lines_above);
|
const getLinesAbove = getLinesFunction(params.config.lines_above);
|
||||||
const getLinesBelow = getLinesFunction(params.config.lines_below);
|
const getLinesBelow = getLinesFunction(params.config.lines_below);
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
const { lines } = params;
|
||||||
const headings = filterByTypes(
|
const headings = filterByTypes(
|
||||||
micromarkTokens,
|
// eslint-disable-next-line unicorn/consistent-destructuring
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
[ "atxHeading", "setextHeading" ]
|
[ "atxHeading", "setextHeading" ]
|
||||||
);
|
);
|
||||||
for (const heading of headings) {
|
for (const heading of headings) {
|
||||||
|
|
|
||||||
10
lib/md026.js
10
lib/md026.js
|
|
@ -20,12 +20,10 @@ module.exports = {
|
||||||
);
|
);
|
||||||
const trailingPunctuationRe =
|
const trailingPunctuationRe =
|
||||||
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
|
new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const headings = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "atxHeadingText", "setextHeadingText" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const headings = filterByTypes(micromarkTokens, [ "atxHeadingText", "setextHeadingText" ]);
|
|
||||||
for (const heading of headings) {
|
for (const heading of headings) {
|
||||||
const { endColumn, endLine, text } = heading;
|
const { endColumn, endLine, text } = heading;
|
||||||
const match = trailingPunctuationRe.exec(text);
|
const match = trailingPunctuationRe.exec(text);
|
||||||
|
|
|
||||||
10
lib/md027.js
10
lib/md027.js
|
|
@ -13,11 +13,7 @@ module.exports = {
|
||||||
"tags": ["blockquote", "whitespace", "indentation"],
|
"tags": ["blockquote", "whitespace", "indentation"],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD027(params, onError) {
|
"function": function MD027(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
for (const token of filterByTypes(micromarkTokens, [ "linePrefix" ])) {
|
for (const token of filterByTypes(micromarkTokens, [ "linePrefix" ])) {
|
||||||
const siblings = token.parent?.children || micromarkTokens;
|
const siblings = token.parent?.children || micromarkTokens;
|
||||||
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
if (siblings[siblings.indexOf(token) - 1]?.type === "blockQuotePrefix") {
|
||||||
|
|
@ -28,8 +24,8 @@ module.exports = {
|
||||||
onError,
|
onError,
|
||||||
startLine,
|
startLine,
|
||||||
line,
|
line,
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
[ startColumn, length ],
|
[ startColumn, length ],
|
||||||
{
|
{
|
||||||
"editColumn": startColumn,
|
"editColumn": startColumn,
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,7 @@ module.exports = {
|
||||||
"tags": [ "blockquote", "whitespace" ],
|
"tags": [ "blockquote", "whitespace" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD028(params, onError) {
|
"function": function MD028(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
for (const token of filterByTypes(micromarkTokens, [ "blockQuote" ])) {
|
for (const token of filterByTypes(micromarkTokens, [ "blockQuote" ])) {
|
||||||
const errorLineNumbers = [];
|
const errorLineNumbers = [];
|
||||||
const siblings = token.parent?.children || micromarkTokens;
|
const siblings = token.parent?.children || micromarkTokens;
|
||||||
|
|
|
||||||
14
lib/md030.js
14
lib/md030.js
|
|
@ -17,12 +17,10 @@ module.exports = {
|
||||||
const olSingle = Number(params.config.ol_single || 1);
|
const olSingle = Number(params.config.ol_single || 1);
|
||||||
const ulMulti = Number(params.config.ul_multi || 1);
|
const ulMulti = Number(params.config.ul_multi || 1);
|
||||||
const olMulti = Number(params.config.ol_multi || 1);
|
const olMulti = Number(params.config.ol_multi || 1);
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const lists = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "listOrdered", "listUnordered" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const lists = filterByTypes(micromarkTokens, [ "listOrdered", "listUnordered" ]);
|
|
||||||
for (const list of lists) {
|
for (const list of lists) {
|
||||||
const ordered = (list.type === "listOrdered");
|
const ordered = (list.type === "listOrdered");
|
||||||
const listItemPrefixes =
|
const listItemPrefixes =
|
||||||
|
|
@ -54,8 +52,8 @@ module.exports = {
|
||||||
startLine,
|
startLine,
|
||||||
expectedSpaces,
|
expectedSpaces,
|
||||||
actualSpaces,
|
actualSpaces,
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
range,
|
range,
|
||||||
fixInfo
|
fixInfo
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,11 @@ module.exports = {
|
||||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD032(params, onError) {
|
"function": function MD032(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
|
|
||||||
// For every top-level list...
|
// For every top-level list...
|
||||||
const topLevelLists = filterByPredicate(
|
const topLevelLists = filterByPredicate(
|
||||||
micromarkTokens,
|
parsers.micromark.tokens,
|
||||||
isList,
|
isList,
|
||||||
(token) => (
|
(token) => (
|
||||||
(isList(token) || (token.type === "htmlFlow")) ? [] : token.children
|
(isList(token) || (token.type === "htmlFlow")) ? [] : token.children
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,7 @@ module.exports = {
|
||||||
let allowedElements = params.config.allowed_elements;
|
let allowedElements = params.config.allowed_elements;
|
||||||
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
|
||||||
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
allowedElements = allowedElements.map((element) => element.toLowerCase());
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
for (const token of filterByTypes(params.parsers.micromark.tokens, [ "htmlText" ], true)) {
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
for (const token of filterByTypes(micromarkTokens, [ "htmlText" ], true)) {
|
|
||||||
const htmlTagInfo = getHtmlTagInfo(token);
|
const htmlTagInfo = getHtmlTagInfo(token);
|
||||||
if (
|
if (
|
||||||
htmlTagInfo &&
|
htmlTagInfo &&
|
||||||
|
|
|
||||||
10
lib/md034.js
10
lib/md034.js
|
|
@ -14,11 +14,6 @@ module.exports = {
|
||||||
"tags": [ "links", "url" ],
|
"tags": [ "links", "url" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD034(params, onError) {
|
"function": function MD034(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const literalAutolinks = (tokens) => (
|
const literalAutolinks = (tokens) => (
|
||||||
filterByPredicate(
|
filterByPredicate(
|
||||||
tokens,
|
tokens,
|
||||||
|
|
@ -75,7 +70,10 @@ module.exports = {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
const autoLinks = filterByTypes(micromarkTokens, [ "literalAutolink" ]);
|
const autoLinks = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
[ "literalAutolink" ]
|
||||||
|
);
|
||||||
if (autoLinks.length > 0) {
|
if (autoLinks.length > 0) {
|
||||||
// Re-parse with correct link/image reference definition handling
|
// Re-parse with correct link/image reference definition handling
|
||||||
const document = params.lines.join("\n");
|
const document = params.lines.join("\n");
|
||||||
|
|
|
||||||
10
lib/md035.js
10
lib/md035.js
|
|
@ -14,12 +14,10 @@ module.exports = {
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD035(params, onError) {
|
"function": function MD035(params, onError) {
|
||||||
let style = String(params.config.style || "consistent").trim();
|
let style = String(params.config.style || "consistent").trim();
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const thematicBreaks = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "thematicBreak" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const thematicBreaks = filterByTypes(micromarkTokens, [ "thematicBreak" ]);
|
|
||||||
for (const token of thematicBreaks) {
|
for (const token of thematicBreaks) {
|
||||||
const { startLine, text } = token;
|
const { startLine, text } = token;
|
||||||
if (style === "consistent") {
|
if (style === "consistent") {
|
||||||
|
|
|
||||||
|
|
@ -15,18 +15,13 @@ module.exports = {
|
||||||
"function": function MD037(params, onError) {
|
"function": function MD037(params, onError) {
|
||||||
|
|
||||||
// Initialize variables
|
// Initialize variables
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
const emphasisTokensByMarker = new Map();
|
const emphasisTokensByMarker = new Map();
|
||||||
for (const marker of [ "_", "__", "___", "*", "**", "***" ]) {
|
for (const marker of [ "_", "__", "___", "*", "**", "***" ]) {
|
||||||
emphasisTokensByMarker.set(marker, []);
|
emphasisTokensByMarker.set(marker, []);
|
||||||
}
|
}
|
||||||
const tokens = filterByPredicate(
|
const tokens = filterByPredicate(
|
||||||
micromarkTokens,
|
parsers.micromark.tokens,
|
||||||
(token) => token.children.some((child) => child.type === "data")
|
(token) => token.children.some((child) => child.type === "data")
|
||||||
);
|
);
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
|
|
|
||||||
10
lib/md038.js
10
lib/md038.js
|
|
@ -26,12 +26,10 @@ module.exports = {
|
||||||
"tags": [ "whitespace", "code" ],
|
"tags": [ "whitespace", "code" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD038(params, onError) {
|
"function": function MD038(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const codeTexts = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "codeText" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const codeTexts = filterByTypes(micromarkTokens, [ "codeText" ]);
|
|
||||||
for (const codeText of codeTexts) {
|
for (const codeText of codeTexts) {
|
||||||
const { children } = codeText;
|
const { children } = codeText;
|
||||||
const first = 0;
|
const first = 0;
|
||||||
|
|
|
||||||
10
lib/md040.js
10
lib/md040.js
|
|
@ -17,12 +17,10 @@ module.exports = {
|
||||||
let allowed = params.config.allowed_languages;
|
let allowed = params.config.allowed_languages;
|
||||||
allowed = Array.isArray(allowed) ? allowed : [];
|
allowed = Array.isArray(allowed) ? allowed : [];
|
||||||
const languageOnly = !!params.config.language_only;
|
const languageOnly = !!params.config.language_only;
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const fencedCodes = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "codeFenced" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const fencedCodes = filterByTypes(micromarkTokens, [ "codeFenced" ]);
|
|
||||||
for (const fencedCode of fencedCodes) {
|
for (const fencedCode of fencedCodes) {
|
||||||
const openingFence = tokenIfType(fencedCode.children[0], "codeFencedFence");
|
const openingFence = tokenIfType(fencedCode.children[0], "codeFencedFence");
|
||||||
if (openingFence) {
|
if (openingFence) {
|
||||||
|
|
|
||||||
11
lib/md044.js
11
lib/md044.js
|
|
@ -32,11 +32,6 @@ module.exports = {
|
||||||
const htmlElements = params.config.html_elements;
|
const htmlElements = params.config.html_elements;
|
||||||
const includeHtmlElements =
|
const includeHtmlElements =
|
||||||
(htmlElements === undefined) ? true : !!htmlElements;
|
(htmlElements === undefined) ? true : !!htmlElements;
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const scannedTypes = new Set([ "data" ]);
|
const scannedTypes = new Set([ "data" ]);
|
||||||
if (includeCodeBlocks) {
|
if (includeCodeBlocks) {
|
||||||
scannedTypes.add("codeFlowValue");
|
scannedTypes.add("codeFlowValue");
|
||||||
|
|
@ -48,7 +43,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
const contentTokens =
|
const contentTokens =
|
||||||
filterByPredicate(
|
filterByPredicate(
|
||||||
micromarkTokens,
|
params.parsers.micromark.tokens,
|
||||||
(token) => scannedTypes.has(token.type),
|
(token) => scannedTypes.has(token.type),
|
||||||
(token) => (
|
(token) => (
|
||||||
token.children.filter((t) => !ignoredChildTypes.has(t.type))
|
token.children.filter((t) => !ignoredChildTypes.has(t.type))
|
||||||
|
|
@ -96,8 +91,8 @@ module.exports = {
|
||||||
token.startLine,
|
token.startLine,
|
||||||
name,
|
name,
|
||||||
nameMatch,
|
nameMatch,
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
[ column, length ],
|
[ column, length ],
|
||||||
{
|
{
|
||||||
"editColumn": column,
|
"editColumn": column,
|
||||||
|
|
|
||||||
17
lib/md045.js
17
lib/md045.js
|
|
@ -15,14 +15,13 @@ module.exports = {
|
||||||
"tags": [ "accessibility", "images" ],
|
"tags": [ "accessibility", "images" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD045(params, onError) {
|
"function": function MD045(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
|
|
||||||
// Process Markdown images
|
// Process Markdown images
|
||||||
const images = filterByTypes(micromarkTokens, [ "image" ]);
|
const images = filterByTypes(
|
||||||
|
micromarkTokens,
|
||||||
|
[ "image" ]
|
||||||
|
);
|
||||||
for (const image of images) {
|
for (const image of images) {
|
||||||
const labelTexts = filterByTypes(image.children, [ "labelText" ]);
|
const labelTexts = filterByTypes(image.children, [ "labelText" ]);
|
||||||
if (labelTexts.some((labelText) => labelText.text.length === 0)) {
|
if (labelTexts.some((labelText) => labelText.text.length === 0)) {
|
||||||
|
|
@ -40,7 +39,11 @@ module.exports = {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process HTML images
|
// Process HTML images
|
||||||
const htmlTexts = filterByTypes(micromarkTokens, [ "htmlText" ], true);
|
const htmlTexts = filterByTypes(
|
||||||
|
micromarkTokens,
|
||||||
|
[ "htmlText" ],
|
||||||
|
true
|
||||||
|
);
|
||||||
for (const htmlText of htmlTexts) {
|
for (const htmlText of htmlTexts) {
|
||||||
const { startColumn, startLine, text } = htmlText;
|
const { startColumn, startLine, text } = htmlText;
|
||||||
const htmlTagInfo = getHtmlTagInfo(htmlText);
|
const htmlTagInfo = getHtmlTagInfo(htmlText);
|
||||||
|
|
|
||||||
10
lib/md046.js
10
lib/md046.js
|
|
@ -19,12 +19,10 @@ module.exports = {
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD046(params, onError) {
|
"function": function MD046(params, onError) {
|
||||||
let expectedStyle = String(params.config.style || "consistent");
|
let expectedStyle = String(params.config.style || "consistent");
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const codeBlocksAndFences = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "codeFenced", "codeIndented" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const codeBlocksAndFences = filterByTypes(micromarkTokens, [ "codeFenced", "codeIndented" ]);
|
|
||||||
for (const token of codeBlocksAndFences) {
|
for (const token of codeBlocksAndFences) {
|
||||||
const { startLine, type } = token;
|
const { startLine, type } = token;
|
||||||
if (expectedStyle === "consistent") {
|
if (expectedStyle === "consistent") {
|
||||||
|
|
|
||||||
10
lib/md048.js
10
lib/md048.js
|
|
@ -14,13 +14,11 @@ module.exports = {
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD048(params, onError) {
|
"function": function MD048(params, onError) {
|
||||||
const style = String(params.config.style || "consistent");
|
const style = String(params.config.style || "consistent");
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
let expectedStyle = style;
|
let expectedStyle = style;
|
||||||
const codeFenceds = filterByTypes(micromarkTokens, [ "codeFenced" ]);
|
const codeFenceds = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
[ "codeFenced" ]
|
||||||
|
);
|
||||||
for (const codeFenced of codeFenceds) {
|
for (const codeFenced of codeFenceds) {
|
||||||
const codeFencedFence = tokenIfType(codeFenced.children[0], "codeFencedFence");
|
const codeFencedFence = tokenIfType(codeFenced.children[0], "codeFencedFence");
|
||||||
if (codeFencedFence) {
|
if (codeFencedFence) {
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,9 @@ const intrawordRe = /^\w$/;
|
||||||
*/
|
*/
|
||||||
const impl =
|
const impl =
|
||||||
(params, onError, type, typeSequence, asterisk, underline, style = "consistent") => {
|
(params, onError, type, typeSequence, asterisk, underline, style = "consistent") => {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
const emphasisTokens = filterByPredicate(
|
const emphasisTokens = filterByPredicate(
|
||||||
micromarkTokens,
|
parsers.micromark.tokens,
|
||||||
(token) => token.type === type,
|
(token) => token.type === type,
|
||||||
(token) => ((token.type === "htmlFlow") ? [] : token.children)
|
(token) => ((token.type === "htmlFlow") ? [] : token.children)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -69,11 +69,7 @@ module.exports = {
|
||||||
"tags": [ "links" ],
|
"tags": [ "links" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD051(params, onError) {
|
"function": function MD051(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const micromarkTokens = params.parsers.micromark.tokens;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const fragments = new Map();
|
const fragments = new Map();
|
||||||
|
|
||||||
// Process headings
|
// Process headings
|
||||||
|
|
|
||||||
17
lib/md054.js
17
lib/md054.js
|
|
@ -40,13 +40,11 @@ module.exports = {
|
||||||
// Everything allowed, nothing to check
|
// Everything allowed, nothing to check
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { definitions } = referenceLinkImageData();
|
const { definitions } = referenceLinkImageData();
|
||||||
const links = filterByTypes(micromarkTokens, [ "autolink", "image", "link" ]);
|
const links = filterByTypes(
|
||||||
|
params.parsers.micromark.tokens,
|
||||||
|
[ "autolink", "image", "link" ]
|
||||||
|
);
|
||||||
for (const link of links) {
|
for (const link of links) {
|
||||||
let label = null;
|
let label = null;
|
||||||
let destination = null;
|
let destination = null;
|
||||||
|
|
@ -89,7 +87,8 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isError) {
|
if (isError) {
|
||||||
let range = null;
|
// eslint-disable-next-line no-undef-init
|
||||||
|
let range = undefined;
|
||||||
let fixInfo = null;
|
let fixInfo = null;
|
||||||
if (startLine === endLine) {
|
if (startLine === endLine) {
|
||||||
range = [ startColumn, endColumn - startColumn ];
|
range = [ startColumn, endColumn - startColumn ];
|
||||||
|
|
@ -119,8 +118,8 @@ module.exports = {
|
||||||
onError,
|
onError,
|
||||||
startLine,
|
startLine,
|
||||||
text.replace(nextLinesRe, ""),
|
text.replace(nextLinesRe, ""),
|
||||||
null,
|
undefined,
|
||||||
null,
|
undefined,
|
||||||
range,
|
range,
|
||||||
fixInfo
|
fixInfo
|
||||||
);
|
);
|
||||||
|
|
|
||||||
15
lib/md055.js
15
lib/md055.js
|
|
@ -27,14 +27,15 @@ module.exports = {
|
||||||
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "trailing_only"));
|
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "trailing_only"));
|
||||||
let expectedTrailingPipe =
|
let expectedTrailingPipe =
|
||||||
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "leading_only"));
|
((expectedStyle !== "no_leading_or_trailing") && (expectedStyle !== "leading_only"));
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const tables = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "table" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const tables = filterByTypes(micromarkTokens, [ "table" ]);
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
const rows = filterByTypes(table.children, [ "tableDelimiterRow", "tableRow" ]);
|
const rows = filterByTypes(
|
||||||
|
table.children,
|
||||||
|
[ "tableDelimiterRow", "tableRow" ]
|
||||||
|
);
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
// The following uses of first/lastOrNothing lack fallback handling
|
// The following uses of first/lastOrNothing lack fallback handling
|
||||||
// because it seems not to be possible (i.e., 0% coverage)
|
// because it seems not to be possible (i.e., 0% coverage)
|
||||||
|
|
|
||||||
28
lib/md056.js
28
lib/md056.js
|
|
@ -15,21 +15,27 @@ module.exports = {
|
||||||
"tags": [ "table" ],
|
"tags": [ "table" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD056(params, onError) {
|
"function": function MD056(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const tables = filterByTypes(
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
params.parsers.micromark.tokens,
|
||||||
const micromarkTokens =
|
[ "table" ]
|
||||||
// @ts-ignore
|
);
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const tables = filterByTypes(micromarkTokens, [ "table" ]);
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
const rows = filterByTypes(table.children, [ "tableDelimiterRow", "tableRow" ]);
|
const rows = filterByTypes(
|
||||||
|
table.children,
|
||||||
|
[ "tableDelimiterRow", "tableRow" ]
|
||||||
|
);
|
||||||
let expectedCount = 0;
|
let expectedCount = 0;
|
||||||
for (const row of rows) {
|
for (const row of rows) {
|
||||||
const cells = filterByTypes(row.children, [ "tableData", "tableDelimiter", "tableHeader" ]);
|
const cells = filterByTypes(
|
||||||
|
row.children,
|
||||||
|
[ "tableData", "tableDelimiter", "tableHeader" ]
|
||||||
|
);
|
||||||
const actualCount = cells.length;
|
const actualCount = cells.length;
|
||||||
expectedCount ||= actualCount;
|
expectedCount ||= actualCount;
|
||||||
let detail = null;
|
// eslint-disable-next-line no-undef-init
|
||||||
let range = null;
|
let detail = undefined;
|
||||||
|
// eslint-disable-next-line no-undef-init
|
||||||
|
let range = undefined;
|
||||||
if (actualCount < expectedCount) {
|
if (actualCount < expectedCount) {
|
||||||
detail = "Too few cells, row will be missing data";
|
detail = "Too few cells, row will be missing data";
|
||||||
range = [ row.endColumn - 1, 1 ];
|
range = [ row.endColumn - 1, 1 ];
|
||||||
|
|
@ -43,7 +49,7 @@ module.exports = {
|
||||||
expectedCount,
|
expectedCount,
|
||||||
actualCount,
|
actualCount,
|
||||||
detail,
|
detail,
|
||||||
null,
|
undefined,
|
||||||
range
|
range
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
lib/md058.js
12
lib/md058.js
|
|
@ -13,14 +13,12 @@ module.exports = {
|
||||||
"tags": [ "table" ],
|
"tags": [ "table" ],
|
||||||
"parser": "micromark",
|
"parser": "micromark",
|
||||||
"function": function MD058(params, onError) {
|
"function": function MD058(params, onError) {
|
||||||
// eslint-disable-next-line jsdoc/valid-types
|
const { lines, parsers } = params;
|
||||||
/** @type import("../helpers/micromark.cjs").Token[] */
|
|
||||||
const micromarkTokens =
|
|
||||||
// @ts-ignore
|
|
||||||
params.parsers.micromark.tokens;
|
|
||||||
const { lines } = params;
|
|
||||||
// For every table...
|
// For every table...
|
||||||
const tables = filterByTypes(micromarkTokens, [ "table" ]);
|
const tables = filterByTypes(
|
||||||
|
parsers.micromark.tokens,
|
||||||
|
[ "table" ]
|
||||||
|
);
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
// Look for a blank line above the table
|
// Look for a blank line above the table
|
||||||
const firstIndex = table.startLine - 1;
|
const firstIndex = table.startLine - 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue