Add Rule.parser property for custom rules to specify which Markdown parser output they use, honor it strictly, and add full type support.

This commit is contained in:
David Anson 2024-03-09 16:17:50 -08:00
parent d2acc168d2
commit d5994ae4de
68 changed files with 635 additions and 115 deletions

63
lib/markdownlint.d.ts vendored
View file

@ -8,7 +8,7 @@ export = markdownlint;
*/
declare function markdownlint(options: Options | null, callback: LintCallback): void;
declare namespace markdownlint {
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownParsers, ParserMarkdownIt, MarkdownItToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
export { markdownlintSync as sync, readConfig, readConfigSync, getVersion, promises, RuleFunction, RuleParams, MarkdownParsers, ParserMarkdownIt, ParserMicromark, MarkdownItToken, MicromarkTokenType, MicromarkToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
}
/**
* Configuration options.
@ -123,11 +123,11 @@ type RuleParams = {
/**
* File/string lines.
*/
lines: string[];
lines: readonly string[];
/**
* Front matter lines.
*/
frontMatterLines: string[];
frontMatterLines: readonly string[];
/**
* Rule configuration.
*/
@ -138,9 +138,13 @@ type RuleParams = {
*/
type MarkdownParsers = {
/**
* Markdown parser data from markdown-it.
* Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
*/
markdownit: ParserMarkdownIt;
/**
* Markdown parser data from micromark (only present when Rule.parser is "micromark").
*/
micromark: ParserMicromark;
};
/**
* Markdown parser data from markdown-it.
@ -151,6 +155,15 @@ type ParserMarkdownIt = {
*/
tokens: MarkdownItToken[];
};
/**
* Markdown parser data from micromark.
*/
type ParserMicromark = {
/**
* Token objects from micromark.
*/
tokens: MicromarkToken[];
};
/**
* markdown-it token.
*/
@ -216,6 +229,44 @@ type MarkdownItToken = {
*/
line: string;
};
type MicromarkTokenType = import("markdownlint-micromark").TokenType;
/**
* micromark token.
*/
type MicromarkToken = {
/**
* Token type.
*/
type: MicromarkTokenType;
/**
* Start line (1-based).
*/
startLine: number;
/**
* Start column (1-based).
*/
startColumn: number;
/**
* End line (1-based).
*/
endLine: number;
/**
* End column (1-based).
*/
endColumn: number;
/**
* Token text.
*/
text: string;
/**
* Child tokens.
*/
children: MicromarkToken[];
/**
* Parent token.
*/
parent: MicromarkToken | null;
};
/**
* Error-reporting callback.
*/
@ -290,6 +341,10 @@ type Rule = {
* Rule tag(s).
*/
tags: string[];
/**
* Parser used.
*/
parser: "markdownit" | "micromark" | "none";
/**
* True if asynchronous.
*/

View file

@ -33,17 +33,16 @@ function validateRuleList(ruleList, synchronous) {
for (const [ index, rule ] of ruleList.entries()) {
const customIndex = index - rules.length;
// eslint-disable-next-line no-inner-declarations, jsdoc/require-jsdoc
function newError(property) {
function newError(property, value) {
return new Error(
"Property '" + property + "' of custom rule at index " +
customIndex + " is incorrect.");
`Property '${property}' of custom rule at index ${customIndex} is incorrect: '${value}'.`);
}
for (const property of [ "names", "tags" ]) {
const value = rule[property];
if (!result &&
(!value || !Array.isArray(value) || (value.length === 0) ||
!value.every(helpers.isString) || value.some(helpers.isEmptyString))) {
result = newError(property);
result = newError(property, value);
}
}
for (const propertyInfo of [
@ -53,22 +52,31 @@ function validateRuleList(ruleList, synchronous) {
const property = propertyInfo[0];
const value = rule[property];
if (!result && (!value || (typeof value !== propertyInfo[1]))) {
result = newError(property);
result = newError(property, value);
}
}
if (
!result &&
(rule.parser !== undefined) &&
(rule.parser !== "markdownit") &&
!((customIndex < 0) && (rule.parser === "micromark")) &&
(rule.parser !== "none")
) {
result = newError("parser", rule.parser);
}
if (
!result &&
rule.information &&
!helpers.isUrl(rule.information)
) {
result = newError("information");
result = newError("information", rule.information);
}
if (
!result &&
(rule.asynchronous !== undefined) &&
(typeof rule.asynchronous !== "boolean")
) {
result = newError("asynchronous");
result = newError("asynchronous", rule.asynchronous);
}
if (!result && rule.asynchronous && synchronous) {
result = new Error(
@ -563,18 +571,26 @@ function lintContent(
const lines = content.split(helpers.newLineRe);
annotateAndFreezeTokens(markdownitTokens, lines);
// Create (frozen) parameters for rules
const parsers = Object.freeze({
/** @type {MarkdownParsers} */
// @ts-ignore
const parsersMarkdownIt = Object.freeze({
"markdownit": Object.freeze({
"tokens": markdownitTokens
}),
})
});
/** @type {MarkdownParsers} */
// @ts-ignore
const parsersMicromark = Object.freeze({
"micromark": Object.freeze({
"tokens": micromarkTokens
})
});
/** @type {MarkdownParsers} */
// @ts-ignore
const parsersNone = Object.freeze({});
const paramsBase = {
name,
parsers,
"tokens": markdownitTokens,
"parsers": parsersMarkdownIt,
"lines": Object.freeze(lines),
"frontMatterLines": Object.freeze(frontMatterLines)
};
@ -583,9 +599,9 @@ function lintContent(
const codeBlockAndSpanRanges =
helpers.codeBlockAndSpanRanges(paramsBase, lineMetadata);
const flattenedLists =
helpers.flattenLists(paramsBase.parsers.markdownit.tokens);
helpers.flattenLists(markdownitTokens);
const referenceLinkImageData =
helpers.getReferenceLinkImageData(paramsBase);
helpers.getReferenceLinkImageData(micromarkTokens);
cache.set({
codeBlockAndSpanRanges,
flattenedLists,
@ -594,12 +610,27 @@ function lintContent(
});
// Function to run for each rule
let results = [];
// eslint-disable-next-line jsdoc/require-jsdoc
function forRule(rule) {
/**
* @param {Rule} rule Rule.
* @returns {Promise<void> | null} Promise.
*/
const forRule = (rule) => {
// Configure rule
const ruleName = rule.names[0].toUpperCase();
const tokens = {};
let parsers = parsersNone;
if (rule.parser === undefined) {
tokens.tokens = markdownitTokens;
parsers = parsersMarkdownIt;
} else if (rule.parser === "markdownit") {
parsers = parsersMarkdownIt;
} else if (rule.parser === "micromark") {
parsers = parsersMicromark;
}
const params = {
...paramsBase,
...tokens,
parsers,
"config": effectiveConfig[ruleName]
};
// eslint-disable-next-line jsdoc/require-jsdoc
@ -875,6 +906,7 @@ function lintInput(options, synchronous, callback) {
"description": rule.description,
"information": helpers.cloneIfUrl(rule.information),
"tags": helpers.cloneIfArray(rule.tags),
"parser": rule.parser,
"asynchronous": rule.asynchronous,
"function": rule.function
}));
@ -1281,22 +1313,27 @@ module.exports = markdownlint;
* @returns {void}
*/
/* eslint-disable jsdoc/valid-types */
/**
* Rule parameters.
*
* @typedef {Object} RuleParams
* @property {string} name File/string name.
* @property {MarkdownParsers} parsers Markdown parser data.
* @property {string[]} lines File/string lines.
* @property {string[]} frontMatterLines Front matter lines.
* @property {readonly string[]} lines File/string lines.
* @property {readonly string[]} frontMatterLines Front matter lines.
* @property {RuleConfiguration} config Rule configuration.
*/
/* eslint-enable jsdoc/valid-types */
/**
* Markdown parser data.
*
* @typedef {Object} MarkdownParsers
* @property {ParserMarkdownIt} markdownit Markdown parser data from markdown-it.
* @property {ParserMarkdownIt} markdownit Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
* @property {ParserMicromark} micromark Markdown parser data from micromark (only present when Rule.parser is "micromark").
*/
/**
@ -1306,6 +1343,13 @@ module.exports = markdownlint;
* @property {MarkdownItToken[]} tokens Token objects from markdown-it.
*/
/**
* Markdown parser data from micromark.
*
* @typedef {Object} ParserMicromark
* @property {MicromarkToken[]} tokens Token objects from micromark.
*/
/**
* markdown-it token.
*
@ -1327,6 +1371,22 @@ module.exports = markdownlint;
* @property {string} line Line content.
*/
/** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
/**
* micromark token.
*
* @typedef {Object} MicromarkToken
* @property {MicromarkTokenType} type Token type.
* @property {number} startLine Start line (1-based).
* @property {number} startColumn Start column (1-based).
* @property {number} endLine End line (1-based).
* @property {number} endColumn End column (1-based).
* @property {string} text Token text.
* @property {MicromarkToken[]} children Child tokens.
* @property {MicromarkToken | null} parent Parent token.
*/
/**
* Error-reporting callback.
*
@ -1365,6 +1425,7 @@ module.exports = markdownlint;
* @property {string} description Rule description.
* @property {URL} [information] Link to more information.
* @property {string[]} tags Rule tag(s).
* @property {"markdownit" | "micromark" | "none"} parser Parser used.
* @property {boolean} [asynchronous] True if asynchronous.
* @property {RuleFunction} function Rule implementation.
*/

View file

@ -10,6 +10,7 @@ module.exports = {
"names": [ "MD001", "heading-increment" ],
"description": "Heading levels should only increment by one level at a time",
"tags": [ "headings" ],
"parser": "markdownit",
"function": function MD001(params, onError) {
let prevLevel = 0;
filterTokens(params, "heading_open", function forToken(token) {

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD003", "heading-style" ],
"description": "Heading style",
"tags": [ "headings" ],
"parser": "markdownit",
"function": function MD003(params, onError) {
let style = String(params.config.style || "consistent");
filterTokens(params, "heading_open", function forToken(token) {

View file

@ -24,6 +24,7 @@ module.exports = {
"names": [ "MD004", "ul-style" ],
"description": "Unordered list style",
"tags": [ "bullet", "ul" ],
"parser": "none",
"function": function MD004(params, onError) {
const style = String(params.config.style || "consistent");
let expectedStyle = style;

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD005", "list-indent" ],
"description": "Inconsistent indentation for list items at the same level",
"tags": [ "bullet", "ul", "indentation" ],
"parser": "micromark",
"function": function MD005(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -21,6 +21,7 @@ module.exports = {
"names": [ "MD007", "ul-indent" ],
"description": "Unordered list indentation",
"tags": [ "bullet", "ul", "indentation" ],
"parser": "micromark",
"function": function MD007(params, onError) {
const indent = Number(params.config.indent || 2);
const startIndented = !!params.config.start_indented;

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD009", "no-trailing-spaces" ],
"description": "Trailing spaces",
"tags": [ "whitespace" ],
"parser": "markdownit",
"function": function MD009(params, onError) {
let brSpaces = params.config.br_spaces;
brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces);

View file

@ -14,6 +14,7 @@ module.exports = {
"names": [ "MD010", "no-hard-tabs" ],
"description": "Hard tabs",
"tags": [ "whitespace", "hard_tab" ],
"parser": "markdownit",
"function": function MD010(params, onError) {
const codeBlocks = params.config.code_blocks;
const includeCode = (codeBlocks === undefined) ? true : !!codeBlocks;

View file

@ -14,6 +14,7 @@ module.exports = {
"names": [ "MD011", "no-reversed-links" ],
"description": "Reversed link syntax",
"tags": [ "links" ],
"parser": "none",
"function": function MD011(params, onError) {
const exclusions = codeBlockAndSpanRanges();
forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD012", "no-multiple-blanks" ],
"description": "Multiple consecutive blank lines",
"tags": [ "whitespace", "blank_lines" ],
"parser": "none",
"function": function MD012(params, onError) {
const maximum = Number(params.config.maximum || 1);
let count = 0;

View file

@ -28,6 +28,7 @@ module.exports = {
"names": [ "MD013", "line-length" ],
"description": "Line length",
"tags": [ "line_length" ],
"parser": "markdownit",
"function": function MD013(params, onError) {
const lineLength = Number(params.config.line_length || 80);
const headingLineLength =

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD014", "commands-show-output" ],
"description": "Dollar signs used before commands without showing output",
"tags": [ "code" ],
"parser": "markdownit",
"function": function MD014(params, onError) {
for (const type of [ "code_block", "fence" ]) {
filterTokens(params, type, (token) => {

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD018", "no-missing-space-atx" ],
"description": "No space after hash on atx style heading",
"tags": [ "headings", "atx", "spaces" ],
"parser": "none",
"function": function MD018(params, onError) {
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
if (!inCode &&

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD019", "no-multiple-space-atx" ],
"description": "Multiple spaces after hash on atx style heading",
"tags": [ "headings", "atx", "spaces" ],
"parser": "markdownit",
"function": function MD019(params, onError) {
filterTokens(params, "heading_open", (token) => {
if (headingStyleFor(token) === "atx") {

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD020", "no-missing-space-closed-atx" ],
"description": "No space inside hashes on closed atx style heading",
"tags": [ "headings", "atx_closed", "spaces" ],
"parser": "none",
"function": function MD020(params, onError) {
forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
if (!inCode) {

View file

@ -13,6 +13,7 @@ module.exports = {
"names": [ "MD021", "no-multiple-space-closed-atx" ],
"description": "Multiple spaces inside hashes on closed atx style heading",
"tags": [ "headings", "atx_closed", "spaces" ],
"parser": "markdownit",
"function": function MD021(params, onError) {
filterTokens(params, "heading_open", (token) => {
if (headingStyleFor(token) === "atx_closed") {

View file

@ -37,6 +37,7 @@ module.exports = {
"names": [ "MD022", "blanks-around-headings" ],
"description": "Headings should be surrounded by blank lines",
"tags": [ "headings", "blank_lines" ],
"parser": "micromark",
"function": function MD022(params, onError) {
const getLinesAbove = getLinesFunction(params.config.lines_above);
const getLinesBelow = getLinesFunction(params.config.lines_below);

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD023", "heading-start-left" ],
"description": "Headings must start at the beginning of the line",
"tags": [ "headings", "spaces" ],
"parser": "markdownit",
"function": function MD023(params, onError) {
filterTokens(params, "heading_open", function forToken(token) {
const { lineNumber, line } = token;

View file

@ -10,6 +10,7 @@ module.exports = {
"names": [ "MD024", "no-duplicate-heading" ],
"description": "Multiple headings with the same content",
"tags": [ "headings" ],
"parser": "markdownit",
"function": function MD024(params, onError) {
const siblingsOnly = !!params.config.siblings_only || false;
const knownContents = [ null, [] ];

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD025", "single-title", "single-h1" ],
"description": "Multiple top-level headings in the same document",
"tags": [ "headings" ],
"parser": "markdownit",
"function": function MD025(params, onError) {
const level = Number(params.config.level || 1);
const tag = "h" + level;

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD026", "no-trailing-punctuation" ],
"description": "Trailing punctuation in heading",
"tags": [ "headings" ],
"parser": "micromark",
"function": function MD026(params, onError) {
let punctuation = params.config.punctuation;
punctuation = String(

View file

@ -11,6 +11,7 @@ module.exports = {
"names": ["MD027", "no-multiple-space-blockquote"],
"description": "Multiple spaces after blockquote symbol",
"tags": ["blockquote", "whitespace", "indentation"],
"parser": "micromark",
"function": function MD027(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -13,6 +13,7 @@ module.exports = {
"names": [ "MD028", "no-blanks-blockquote" ],
"description": "Blank line inside blockquote",
"tags": [ "blockquote", "whitespace" ],
"parser": "micromark",
"function": function MD028(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -18,6 +18,7 @@ module.exports = {
"names": [ "MD029", "ol-prefix" ],
"description": "Ordered list item prefix",
"tags": [ "ol" ],
"parser": "none",
"function": function MD029(params, onError) {
const style = String(params.config.style || "one_or_ordered");
const filteredLists = flattenedLists().filter((list) => !list.unordered);

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD030", "list-marker-space" ],
"description": "Spaces after list markers",
"tags": [ "ol", "ul", "whitespace" ],
"parser": "micromark",
"function": function MD030(params, onError) {
const ulSingle = Number(params.config.ul_single || 1);
const olSingle = Number(params.config.ol_single || 1);

View file

@ -13,6 +13,7 @@ module.exports = {
"names": [ "MD031", "blanks-around-fences" ],
"description": "Fenced code blocks should be surrounded by blank lines",
"tags": [ "code", "blank_lines" ],
"parser": "none",
"function": function MD031(params, onError) {
const listItems = params.config.list_items;
const includeListItems = (listItems === undefined) ? true : !!listItems;

View file

@ -41,6 +41,7 @@ module.exports = {
"names": [ "MD032", "blanks-around-lists" ],
"description": "Lists should be surrounded by blank lines",
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
"parser": "micromark",
"function": function MD032(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD033", "no-inline-html" ],
"description": "Inline HTML",
"tags": [ "html" ],
"parser": "micromark",
"function": function MD033(params, onError) {
let allowedElements = params.config.allowed_elements;
allowedElements = Array.isArray(allowedElements) ? allowedElements : [];

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD034", "no-bare-urls" ],
"description": "Bare URL used",
"tags": [ "links", "url" ],
"parser": "micromark",
"function": function MD034(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD035", "hr-style" ],
"description": "Horizontal rule style",
"tags": [ "hr" ],
"parser": "micromark",
"function": function MD035(params, onError) {
let style = String(params.config.style || "consistent").trim();
// eslint-disable-next-line jsdoc/valid-types

View file

@ -10,6 +10,7 @@ module.exports = {
"names": [ "MD036", "no-emphasis-as-heading" ],
"description": "Emphasis used instead of a heading",
"tags": [ "headings", "emphasis" ],
"parser": "markdownit",
"function": function MD036(params, onError) {
let punctuation = params.config.punctuation;
punctuation =

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD037", "no-space-in-emphasis" ],
"description": "Spaces inside emphasis markers",
"tags": [ "whitespace", "emphasis" ],
"parser": "micromark",
"function": function MD037(params, onError) {
// Initialize variables

View file

@ -25,6 +25,7 @@ module.exports = {
"names": [ "MD038", "no-space-in-code" ],
"description": "Spaces inside code span elements",
"tags": [ "whitespace", "code" ],
"parser": "micromark",
"function": function MD038(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -13,6 +13,7 @@ module.exports = {
"names": [ "MD039", "no-space-in-links" ],
"description": "Spaces inside link text",
"tags": [ "whitespace", "links" ],
"parser": "markdownit",
"function": function MD039(params, onError) {
filterTokens(params, "inline", (token) => {
const { children } = token;

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD040", "fenced-code-language" ],
"description": "Fenced code blocks should have a language specified",
"tags": [ "code", "language" ],
"parser": "micromark",
"function": function MD040(params, onError) {
let allowed = params.config.allowed_languages;
allowed = Array.isArray(allowed) ? allowed : [];

View file

@ -10,6 +10,7 @@ module.exports = {
"names": [ "MD041", "first-line-heading", "first-line-h1" ],
"description": "First line in a file should be a top-level heading",
"tags": [ "headings" ],
"parser": "markdownit",
"function": function MD041(params, onError) {
const level = Number(params.config.level || 1);
const tag = "h" + level;

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD042", "no-empty-links" ],
"description": "No empty links",
"tags": [ "links" ],
"parser": "markdownit",
"function": function MD042(params, onError) {
filterTokens(params, "inline", function forToken(token) {
let inLink = false;

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD043", "required-headings" ],
"description": "Required heading structure",
"tags": [ "headings" ],
"parser": "markdownit",
"function": function MD043(params, onError) {
const requiredHeadings = params.config.headings;
if (!Array.isArray(requiredHeadings)) {

View file

@ -17,6 +17,7 @@ module.exports = {
"names": [ "MD044", "proper-names" ],
"description": "Proper names should have the correct capitalization",
"tags": [ "spelling" ],
"parser": "micromark",
"function": function MD044(params, onError) {
let names = params.config.names;
names = Array.isArray(names) ? names : [];

View file

@ -13,6 +13,7 @@ module.exports = {
"names": [ "MD045", "no-alt-text" ],
"description": "Images should have alternate text (alt text)",
"tags": [ "accessibility", "images" ],
"parser": "micromark",
"function": function MD045(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -16,6 +16,7 @@ module.exports = {
"names": [ "MD046", "code-block-style" ],
"description": "Code block style",
"tags": [ "code" ],
"parser": "micromark",
"function": function MD046(params, onError) {
let expectedStyle = String(params.config.style || "consistent");
// eslint-disable-next-line jsdoc/valid-types

View file

@ -10,6 +10,7 @@ module.exports = {
"names": [ "MD047", "single-trailing-newline" ],
"description": "Files should end with a single newline character",
"tags": [ "blank_lines" ],
"parser": "none",
"function": function MD047(params, onError) {
const lastLineNumber = params.lines.length;
const lastLine = params.lines[lastLineNumber - 1];

View file

@ -11,6 +11,7 @@ module.exports = {
"names": [ "MD048", "code-fence-style" ],
"description": "Code fence style",
"tags": [ "code" ],
"parser": "micromark",
"function": function MD048(params, onError) {
const style = String(params.config.style || "consistent");
// eslint-disable-next-line jsdoc/valid-types

View file

@ -75,6 +75,7 @@ module.exports = [
"names": [ "MD049", "emphasis-style" ],
"description": "Emphasis style",
"tags": [ "emphasis" ],
"parser": "micromark",
"function": function MD049(params, onError) {
return impl(
params,
@ -91,6 +92,7 @@ module.exports = [
"names": [ "MD050", "strong-style" ],
"description": "Strong style",
"tags": [ "emphasis" ],
"parser": "micromark",
"function": function MD050(params, onError) {
return impl(
params,

View file

@ -67,6 +67,7 @@ module.exports = {
"names": [ "MD051", "link-fragments" ],
"description": "Link fragments should be valid",
"tags": [ "links" ],
"parser": "micromark",
"function": function MD051(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */

View file

@ -12,6 +12,7 @@ module.exports = {
"description":
"Reference links and images should use a label that is defined",
"tags": [ "images", "links" ],
"parser": "none",
"function": function MD052(params, onError) {
const { config, lines } = params;
const shortcutSyntax = config.shortcut_syntax || false;

View file

@ -12,6 +12,7 @@ module.exports = {
"names": [ "MD053", "link-image-reference-definitions" ],
"description": "Link and image reference definitions should be needed",
"tags": [ "images", "links" ],
"parser": "none",
"function": function MD053(params, onError) {
const ignored = new Set(params.config.ignored_definitions || [ "//" ]);
const lines = params.lines;

View file

@ -27,6 +27,7 @@ module.exports = {
"names": [ "MD054", "link-image-style" ],
"description": "Link and image style",
"tags": [ "images", "links" ],
"parser": "micromark",
"function": (params, onError) => {
const config = params.config;
const autolink = (config.autolink === undefined) || !!config.autolink;

View file

@ -19,6 +19,7 @@ module.exports = {
"names": [ "MD055", "table-pipe-style" ],
"description": "Table pipe style",
"tags": [ "table" ],
"parser": "micromark",
"function": function MD055(params, onError) {
const style = String(params.config.style || "consistent");
let expectedStyle = style;

View file

@ -13,6 +13,7 @@ module.exports = {
"names": [ "MD056", "table-column-count" ],
"description": "Table column count",
"tags": [ "table" ],
"parser": "micromark",
"function": function MD056(params, onError) {
// eslint-disable-next-line jsdoc/valid-types
/** @type import("../helpers/micromark.cjs").Token[] */