mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update to use named exports via / /async /promise /sync, simplify references via self-referencing, refine examples.
This commit is contained in:
parent
e41f034bef
commit
8da43dd246
96 changed files with 635 additions and 548 deletions
|
|
@ -10,7 +10,7 @@ let params = undefined;
|
|||
/**
|
||||
* Initializes (resets) the cache.
|
||||
*
|
||||
* @param {import("./markdownlint.mjs").RuleParams} [p] Rule parameters object.
|
||||
* @param {import("markdownlint").RuleParams} [p] Rule parameters object.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function initialize(p) {
|
||||
|
|
@ -37,9 +37,9 @@ function getCached(name, getValue) {
|
|||
/**
|
||||
* Filters a list of Micromark tokens by type and caches the result.
|
||||
*
|
||||
* @param {import("./markdownlint.mjs").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {import("markdownlint").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {boolean} [htmlFlow] Whether to include htmlFlow content.
|
||||
* @returns {import("./markdownlint.mjs").MicromarkToken[]} Filtered tokens.
|
||||
* @returns {import("markdownlint").MicromarkToken[]} Filtered tokens.
|
||||
*/
|
||||
export function filterByTypesCached(types, htmlFlow) {
|
||||
return getCached(
|
||||
|
|
|
|||
1
lib/exports-async.d.mts
Normal file
1
lib/exports-async.d.mts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { lintAsync as lint, readConfigAsync as readConfig } from "./markdownlint.mjs";
|
||||
3
lib/exports-async.mjs
Normal file
3
lib/exports-async.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// @ts-check
|
||||
|
||||
export { lintAsync as lint, readConfigAsync as readConfig } from "./markdownlint.mjs";
|
||||
1
lib/exports-promise.d.mts
Normal file
1
lib/exports-promise.d.mts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { extendConfigPromise as extendConfig, lintPromise as lint, readConfigPromise as readConfig } from "./markdownlint.mjs";
|
||||
3
lib/exports-promise.mjs
Normal file
3
lib/exports-promise.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// @ts-check
|
||||
|
||||
export { extendConfigPromise as extendConfig, lintPromise as lint, readConfigPromise as readConfig } from "./markdownlint.mjs";
|
||||
1
lib/exports-sync.d.mts
Normal file
1
lib/exports-sync.d.mts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { lintSync as lint, readConfigSync as readConfig } from "./markdownlint.mjs";
|
||||
3
lib/exports-sync.mjs
Normal file
3
lib/exports-sync.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// @ts-check
|
||||
|
||||
export { lintSync as lint, readConfigSync as readConfig } from "./markdownlint.mjs";
|
||||
28
lib/exports.d.mts
Normal file
28
lib/exports.d.mts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
export type Configuration = import("./markdownlint.mjs").Configuration;
|
||||
export type ConfigurationParser = import("./markdownlint.mjs").ConfigurationParser;
|
||||
export type ConfigurationStrict = import("./markdownlint.mjs").ConfigurationStrict;
|
||||
export type FixInfo = import("./markdownlint.mjs").FixInfo;
|
||||
export type LintCallback = import("./markdownlint.mjs").LintCallback;
|
||||
export type LintContentCallback = import("./markdownlint.mjs").LintContentCallback;
|
||||
export type LintError = import("./markdownlint.mjs").LintError;
|
||||
export type LintResults = import("./markdownlint.mjs").LintResults;
|
||||
export type MarkdownItToken = import("./markdownlint.mjs").MarkdownItToken;
|
||||
export type MarkdownParsers = import("./markdownlint.mjs").MarkdownParsers;
|
||||
export type MicromarkToken = import("./markdownlint.mjs").MicromarkToken;
|
||||
export type MicromarkTokenType = import("./markdownlint.mjs").MicromarkTokenType;
|
||||
export type Options = import("./markdownlint.mjs").Options;
|
||||
export type ParserMarkdownIt = import("./markdownlint.mjs").ParserMarkdownIt;
|
||||
export type ParserMicromark = import("./markdownlint.mjs").ParserMicromark;
|
||||
export type Plugin = import("./markdownlint.mjs").Plugin;
|
||||
export type ReadConfigCallback = import("./markdownlint.mjs").ReadConfigCallback;
|
||||
export type ResolveConfigExtendsCallback = import("./markdownlint.mjs").ResolveConfigExtendsCallback;
|
||||
export type Rule = import("./markdownlint.mjs").Rule;
|
||||
export type RuleConfiguration = import("./markdownlint.mjs").RuleConfiguration;
|
||||
export type RuleFunction = import("./markdownlint.mjs").RuleFunction;
|
||||
export type RuleOnError = import("./markdownlint.mjs").RuleOnError;
|
||||
export type RuleOnErrorFixInfo = import("./markdownlint.mjs").RuleOnErrorFixInfo;
|
||||
export type RuleOnErrorFixInfoNormalized = import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized;
|
||||
export type RuleOnErrorInfo = import("./markdownlint.mjs").RuleOnErrorInfo;
|
||||
export type RuleParams = import("./markdownlint.mjs").RuleParams;
|
||||
export type ToStringCallback = import("./markdownlint.mjs").ToStringCallback;
|
||||
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
||||
31
lib/exports.mjs
Normal file
31
lib/exports.mjs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// @ts-check
|
||||
|
||||
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
||||
|
||||
/** @typedef {import("./markdownlint.mjs").Configuration} Configuration */
|
||||
/** @typedef {import("./markdownlint.mjs").ConfigurationParser} ConfigurationParser */
|
||||
/** @typedef {import("./markdownlint.mjs").ConfigurationStrict} ConfigurationStrict */
|
||||
/** @typedef {import("./markdownlint.mjs").FixInfo} FixInfo */
|
||||
/** @typedef {import("./markdownlint.mjs").LintCallback} LintCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").LintContentCallback} LintContentCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").LintError} LintError */
|
||||
/** @typedef {import("./markdownlint.mjs").LintResults} LintResults */
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownParsers} MarkdownParsers */
|
||||
/** @typedef {import("./markdownlint.mjs").MicromarkToken} MicromarkToken */
|
||||
/** @typedef {import("./markdownlint.mjs").MicromarkTokenType} MicromarkTokenType */
|
||||
/** @typedef {import("./markdownlint.mjs").Options} Options */
|
||||
/** @typedef {import("./markdownlint.mjs").ParserMarkdownIt} ParserMarkdownIt */
|
||||
/** @typedef {import("./markdownlint.mjs").ParserMicromark} ParserMicromark */
|
||||
/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */
|
||||
/** @typedef {import("./markdownlint.mjs").ReadConfigCallback} ReadConfigCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").ResolveConfigExtendsCallback} ResolveConfigExtendsCallback */
|
||||
/** @typedef {import("./markdownlint.mjs").Rule} Rule */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleConfiguration} RuleConfiguration */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleFunction} RuleFunction */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnError} RuleOnError */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnErrorFixInfoNormalized} RuleOnErrorFixInfoNormalized */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleOnErrorInfo} RuleOnErrorInfo */
|
||||
/** @typedef {import("./markdownlint.mjs").RuleParams} RuleParams */
|
||||
/** @typedef {import("./markdownlint.mjs").ToStringCallback} ToStringCallback */
|
||||
|
|
@ -5,9 +5,9 @@
|
|||
const { newLineRe } = require("../helpers");
|
||||
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */
|
||||
/** @typedef {import("markdownlint").MarkdownItToken} MarkdownItToken */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */
|
||||
/** @typedef {import("markdownlint").Plugin} Plugin */
|
||||
|
||||
/**
|
||||
* @callback InlineCodeSpanCallback
|
||||
|
|
|
|||
|
|
@ -1,4 +1,87 @@
|
|||
export default markdownlint;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function lintAsync(options: Options | null, callback: LintCallback): void;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {Promise<LintResults>} Results object.
|
||||
*/
|
||||
export function lintPromise(options: Options | null): Promise<LintResults>;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
export function lintSync(options: Options | null): LintResults;
|
||||
/**
|
||||
* Extend specified configuration object.
|
||||
*
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | undefined} parsers Parsing function(s).
|
||||
* @param {Object} fs File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
export function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: any): Promise<Configuration>;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing
|
||||
* function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
export function readConfigAsync(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
export function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise<Configuration>;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
*/
|
||||
export function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration;
|
||||
/**
|
||||
* Applies the specified fix to a Markdown content line.
|
||||
*
|
||||
* @param {string} line Line of Markdown content.
|
||||
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
|
||||
* @param {string} [lineEnding] Line ending to use.
|
||||
* @returns {string | null} Fixed content or null if deleted.
|
||||
*/
|
||||
export function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null;
|
||||
/**
|
||||
* Applies as many of the specified fixes as possible to Markdown content.
|
||||
*
|
||||
* @param {string} input Lines of Markdown content.
|
||||
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
||||
* @returns {string} Fixed content.
|
||||
*/
|
||||
export function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
export function getVersion(): string;
|
||||
/**
|
||||
* Function to implement rule logic.
|
||||
*/
|
||||
|
|
@ -431,101 +514,3 @@ export type ReadConfigCallback = (err: Error | null, config?: Configuration) =>
|
|||
* Called with the result of the resolveConfigExtends function.
|
||||
*/
|
||||
export type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function markdownlint(options: Options | null, callback: LintCallback): void;
|
||||
declare namespace markdownlint {
|
||||
export { markdownlintSync as sync };
|
||||
export { readConfig };
|
||||
export { readConfigSync };
|
||||
export { getVersion };
|
||||
export namespace promises {
|
||||
export { markdownlintPromise as markdownlint };
|
||||
export { extendConfigPromise as extendConfig };
|
||||
export { readConfigPromise as readConfig };
|
||||
}
|
||||
export { applyFix };
|
||||
export { applyFixes };
|
||||
}
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
declare function markdownlintSync(options: Options | null): LintResults;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing
|
||||
* function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
declare function readConfig(file: string, parsers?: ConfigurationParser[] | ReadConfigCallback, fs?: any, callback?: ReadConfigCallback): void;
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
* @throws An Error if processing fails.
|
||||
*/
|
||||
declare function readConfigSync(file: string, parsers?: ConfigurationParser[], fs?: any): Configuration;
|
||||
/**
|
||||
* Gets the (semantic) version of the library.
|
||||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
declare function getVersion(): string;
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @returns {Promise<LintResults>} Results object.
|
||||
*/
|
||||
declare function markdownlintPromise(options: Options): Promise<LintResults>;
|
||||
/**
|
||||
* Extend specified configuration object.
|
||||
*
|
||||
* @param {Configuration} config Configuration object.
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[] | undefined} parsers Parsing function(s).
|
||||
* @param {Object} fs File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
declare function extendConfigPromise(config: Configuration, file: string, parsers: ConfigurationParser[] | undefined, fs: any): Promise<Configuration>;
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
declare function readConfigPromise(file: string, parsers?: ConfigurationParser[], fs?: any): Promise<Configuration>;
|
||||
/**
|
||||
* Applies the specified fix to a Markdown content line.
|
||||
*
|
||||
* @param {string} line Line of Markdown content.
|
||||
* @param {RuleOnErrorFixInfo} fixInfo RuleOnErrorFixInfo instance.
|
||||
* @param {string} [lineEnding] Line ending to use.
|
||||
* @returns {string | null} Fixed content or null if deleted.
|
||||
*/
|
||||
declare function applyFix(line: string, fixInfo: RuleOnErrorFixInfo, lineEnding?: string): string | null;
|
||||
/**
|
||||
* Applies as many of the specified fixes as possible to Markdown content.
|
||||
*
|
||||
* @param {string} input Lines of Markdown content.
|
||||
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
||||
* @returns {string} Fixed content.
|
||||
*/
|
||||
declare function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
||||
|
|
|
|||
|
|
@ -954,19 +954,19 @@ function lintInput(options, synchronous, callback) {
|
|||
* @param {LintCallback} callback Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
function markdownlint(options, callback) {
|
||||
export function lintAsync(options, callback) {
|
||||
return lintInput(options, false, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options} options Configuration options.
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {Promise<LintResults>} Results object.
|
||||
*/
|
||||
function markdownlintPromise(options) {
|
||||
export function lintPromise(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
markdownlint(options, (error, results) => {
|
||||
lintAsync(options, (error, results) => {
|
||||
if (error || !results) {
|
||||
reject(error);
|
||||
} else {
|
||||
|
|
@ -977,12 +977,12 @@ function markdownlintPromise(options) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Lint specified Markdown files synchronously.
|
||||
* Lint specified Markdown files.
|
||||
*
|
||||
* @param {Options | null} options Configuration options.
|
||||
* @returns {LintResults} Results object.
|
||||
*/
|
||||
function markdownlintSync(options) {
|
||||
export function lintSync(options) {
|
||||
let results = null;
|
||||
lintInput(options, true, function callback(error, res) {
|
||||
if (error) {
|
||||
|
|
@ -1072,7 +1072,7 @@ function extendConfig(config, file, parsers, fs, callback) {
|
|||
helpers.expandTildePath(configExtends, os),
|
||||
fs,
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
(_, resolvedExtends) => readConfig(
|
||||
(_, resolvedExtends) => readConfigAsync(
|
||||
// @ts-ignore
|
||||
resolvedExtends,
|
||||
parsers,
|
||||
|
|
@ -1103,7 +1103,7 @@ function extendConfig(config, file, parsers, fs, callback) {
|
|||
* @param {Object} fs File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
function extendConfigPromise(config, file, parsers, fs) {
|
||||
export function extendConfigPromise(config, file, parsers, fs) {
|
||||
return new Promise((resolve, reject) => {
|
||||
extendConfig(config, file, parsers, fs, (error, results) => {
|
||||
if (error || !results) {
|
||||
|
|
@ -1125,7 +1125,7 @@ function extendConfigPromise(config, file, parsers, fs) {
|
|||
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
||||
* @returns {void}
|
||||
*/
|
||||
function readConfig(file, parsers, fs, callback) {
|
||||
export function readConfigAsync(file, parsers, fs, callback) {
|
||||
if (!callback) {
|
||||
if (fs) {
|
||||
callback = fs;
|
||||
|
|
@ -1168,9 +1168,9 @@ function readConfig(file, parsers, fs, callback) {
|
|||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Promise<Configuration>} Configuration object.
|
||||
*/
|
||||
function readConfigPromise(file, parsers, fs) {
|
||||
export function readConfigPromise(file, parsers, fs) {
|
||||
return new Promise((resolve, reject) => {
|
||||
readConfig(file, parsers, fs, (error, results) => {
|
||||
readConfigAsync(file, parsers, fs, (error, results) => {
|
||||
if (error || !results) {
|
||||
reject(error);
|
||||
} else {
|
||||
|
|
@ -1181,15 +1181,14 @@ function readConfigPromise(file, parsers, fs) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Read specified configuration file synchronously.
|
||||
* Read specified configuration file.
|
||||
*
|
||||
* @param {string} file Configuration file name.
|
||||
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
||||
* @param {Object} [fs] File system implementation.
|
||||
* @returns {Configuration} Configuration object.
|
||||
* @throws An Error if processing fails.
|
||||
*/
|
||||
function readConfigSync(file, parsers, fs) {
|
||||
export function readConfigSync(file, parsers, fs) {
|
||||
if (!fs) {
|
||||
fs = nodeFs;
|
||||
}
|
||||
|
|
@ -1242,7 +1241,7 @@ function normalizeFixInfo(fixInfo, lineNumber = 0) {
|
|||
* @param {string} [lineEnding] Line ending to use.
|
||||
* @returns {string | null} Fixed content or null if deleted.
|
||||
*/
|
||||
function applyFix(line, fixInfo, lineEnding = "\n") {
|
||||
export function applyFix(line, fixInfo, lineEnding = "\n") {
|
||||
const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);
|
||||
const editIndex = editColumn - 1;
|
||||
return (deleteCount === -1) ?
|
||||
|
|
@ -1257,7 +1256,7 @@ function applyFix(line, fixInfo, lineEnding = "\n") {
|
|||
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
||||
* @returns {string} Fixed content.
|
||||
*/
|
||||
function applyFixes(input, errors) {
|
||||
export function applyFixes(input, errors) {
|
||||
const lineEnding = helpers.getPreferredLineEnding(input, os);
|
||||
const lines = input.split(helpers.newLineRe);
|
||||
// Normalize fixInfo objects
|
||||
|
|
@ -1335,24 +1334,10 @@ function applyFixes(input, errors) {
|
|||
*
|
||||
* @returns {string} SemVer string.
|
||||
*/
|
||||
function getVersion() {
|
||||
export function getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
// Export a/synchronous/Promise APIs
|
||||
markdownlint.sync = markdownlintSync;
|
||||
markdownlint.readConfig = readConfig;
|
||||
markdownlint.readConfigSync = readConfigSync;
|
||||
markdownlint.getVersion = getVersion;
|
||||
markdownlint.promises = {
|
||||
"markdownlint": markdownlintPromise,
|
||||
"extendConfig": extendConfigPromise,
|
||||
"readConfig": readConfigPromise
|
||||
};
|
||||
markdownlint.applyFix = applyFix;
|
||||
markdownlint.applyFixes = applyFixes;
|
||||
export default markdownlint;
|
||||
|
||||
// Type declarations
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|||
import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD001", "heading-increment" ],
|
||||
"description": "Heading levels should only increment by one level at a time",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|||
import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD003", "heading-style" ],
|
||||
"description": "Heading style",
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ const validStyles = new Set([
|
|||
"sublist"
|
||||
]);
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD004", "ul-style" ],
|
||||
"description": "Unordered list style",
|
||||
|
|
@ -40,7 +40,7 @@ export default {
|
|||
for (const listUnordered of filterByTypesCached([ "listUnordered" ])) {
|
||||
let nesting = 0;
|
||||
if (style === "sublist") {
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").Token | null} */
|
||||
/** @type {import("markdownlint").MicromarkToken | null} */
|
||||
let parent = listUnordered;
|
||||
// @ts-ignore
|
||||
while ((parent = getParentOfType(parent, [ "listOrdered", "listUnordered" ]))) {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD005", "list-indent" ],
|
||||
"description": "Inconsistent indentation for list items at the same level",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const unorderedListTypes =
|
|||
const unorderedParentTypes =
|
||||
[ "blockQuote", "listOrdered", "listUnordered" ];
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD007", "ul-indent" ],
|
||||
"description": "Unordered list indentation",
|
||||
|
|
@ -30,7 +30,7 @@ export default {
|
|||
lastBlockQuotePrefix = token;
|
||||
} else if (type === "listUnordered") {
|
||||
let nesting = 0;
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").Token | null} */
|
||||
/** @type {import("markdownlint").MicromarkToken | null} */
|
||||
let current = token;
|
||||
while (
|
||||
// @ts-ignore
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addError } from "../helpers/helpers.cjs";
|
|||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD009", "no-trailing-spaces" ],
|
||||
"description": "Trailing spaces",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
|
||||
const tabRe = /\t+/g;
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD010", "no-hard-tabs" ],
|
||||
"description": "Hard tabs",
|
||||
|
|
@ -23,7 +23,7 @@ export default {
|
|||
const spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
|
||||
/** @type {import("markdownlint").MicromarkTokenType[]} */
|
||||
const exclusionTypes = [];
|
||||
if (includeCode) {
|
||||
if (ignoreCodeLanguages.size > 0) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
|
||||
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD011", "no-reversed-links" ],
|
||||
"description": "Reversed link syntax",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD012", "no-multiple-blanks" ],
|
||||
"description": "Multiple consecutive blank lines",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
|
|||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD013", "line-length" ],
|
||||
"description": "Line length",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
|
||||
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD014", "commands-show-output" ],
|
||||
"description": "Dollar signs used before commands without showing output",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs";
|
|||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD018", "no-missing-space-atx" ],
|
||||
"description": "No space after hash on atx style heading",
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
/**
|
||||
* Validate heading sequence and whitespace length at start or end.
|
||||
*
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint.mjs").MicromarkToken} heading ATX heading token.
|
||||
* @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint").MicromarkToken} heading ATX heading token.
|
||||
* @param {number} delta Direction to scan.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
|
@ -45,7 +45,7 @@ function validateHeadingSpaces(onError, heading, delta) {
|
|||
}
|
||||
}
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule[]} */
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD019", "no-multiple-space-atx" ],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs";
|
|||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
||||
"description": "No space inside hashes on closed atx style heading",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ const getLinesFunction = (linesParam) => {
|
|||
return () => lines;
|
||||
};
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD022", "blanks-around-headings" ],
|
||||
"description": "Headings should be surrounded by blank lines",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD023", "heading-start-left" ],
|
||||
"description": "Headings must start at the beginning of the line",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs";
|
|||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD024", "no-duplicate-heading" ],
|
||||
"description": "Multiple headings with the same content",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
|||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD025", "single-title", "single-h1" ],
|
||||
"description": "Multiple top-level headings in the same document",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
|||
endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||
"description": "Trailing punctuation in heading",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"description": "Multiple spaces after blockquote symbol",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
|
||||
const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD028", "no-blanks-blockquote" ],
|
||||
"description": "Blank line inside blockquote",
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ const listStyleExamples = {
|
|||
/**
|
||||
* Gets the value of an ordered list item prefix token.
|
||||
*
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} listItemPrefix List item prefix token.
|
||||
* @param {import("markdownlint").MicromarkToken} listItemPrefix List item prefix token.
|
||||
* @returns {number} List item value.
|
||||
*/
|
||||
function getOrderedListItemValue(listItemPrefix) {
|
||||
return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text);
|
||||
}
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD029", "ol-prefix" ],
|
||||
"description": "Ordered list item prefix",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD030", "list-marker-space" ],
|
||||
"description": "Spaces after list markers",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ const codeFencePrefixRe = /^(.*?)[`~]/;
|
|||
/**
|
||||
* Adds an error for the top or bottom of a code fence.
|
||||
*
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {ReadonlyStringArray} lines Lines of Markdown content.
|
||||
* @param {number} lineNumber Line number.
|
||||
* @param {boolean} top True iff top fence.
|
||||
|
|
@ -38,7 +38,7 @@ function addError(onError, lines, lineNumber, top) {
|
|||
);
|
||||
}
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD031", "blanks-around-fences" ],
|
||||
"description": "Fenced code blocks should be surrounded by blank lines",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const isList = (token) => (
|
|||
(token.type === "listOrdered") || (token.type === "listUnordered")
|
||||
);
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD032", "blanks-around-lists" ],
|
||||
"description": "Lists should be surrounded by blank lines",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addError, nextLinesRe } from "../helpers/helpers.cjs";
|
|||
import { getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD033", "no-inline-html" ],
|
||||
"description": "Inline HTML",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { filterByPredicate, getHtmlTagInfo, inHtmlFlow } from "../helpers/microm
|
|||
|
||||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD034", "no-bare-urls" ],
|
||||
"description": "Bare URL used",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD035", "hr-style" ],
|
||||
"description": "Horizontal rule style",
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ import { addErrorContext, allPunctuation } from "../helpers/helpers.cjs";
|
|||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @typedef {import("../helpers/micromark-helpers.cjs").TokenType} TokenType */
|
||||
/** @typedef {import("markdownlint").MicromarkTokenType} TokenType */
|
||||
/** @type {TokenType[][]} */
|
||||
const emphasisTypes = [
|
||||
[ "emphasis", "emphasisText" ],
|
||||
[ "strong", "strongText" ]
|
||||
];
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD036", "no-emphasis-as-heading" ],
|
||||
"description": "Emphasis used instead of a heading",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, inHtmlFlow } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD037", "no-space-in-emphasis" ],
|
||||
"description": "Spaces inside emphasis markers",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ const trimCodeText = (text, start, end) => {
|
|||
return text;
|
||||
};
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD038", "no-space-in-code" ],
|
||||
"description": "Spaces inside code span elements",
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
|||
/**
|
||||
* Adds an error for a label space issue.
|
||||
*
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} label Label token.
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} labelText LabelText token.
|
||||
* @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint").MicromarkToken} label Label token.
|
||||
* @param {import("markdownlint").MicromarkToken} labelText LabelText token.
|
||||
* @param {boolean} isStart True iff error is at the start of the link.
|
||||
*/
|
||||
function addLabelSpaceError(onError, label, labelText, isStart) {
|
||||
|
|
@ -38,8 +38,8 @@ function addLabelSpaceError(onError, label, labelText, isStart) {
|
|||
/**
|
||||
* Determines if a link is a valid link (and not a fake shortcut link due to parser tricks).
|
||||
*
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} label Label token.
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} labelText LabelText token.
|
||||
* @param {import("markdownlint").MicromarkToken} label Label token.
|
||||
* @param {import("markdownlint").MicromarkToken} labelText LabelText token.
|
||||
* @param {Map<string, any>} definitions Map of link definitions.
|
||||
* @returns {boolean} True iff the link is valid.
|
||||
*/
|
||||
|
|
@ -47,7 +47,7 @@ function validLink(label, labelText, definitions) {
|
|||
return (label.parent?.children.length !== 1) || definitions.has(labelText.text.trim());
|
||||
}
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD039", "no-space-in-links" ],
|
||||
"description": "Spaces inside link text",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addError, addErrorContext } from "../helpers/helpers.cjs";
|
|||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD040", "fenced-code-language" ],
|
||||
"description": "Fenced code blocks should have a language specified",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
||||
import { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD041", "first-line-heading", "first-line-h1" ],
|
||||
"description": "First line in a file should be a top-level heading",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorContext } from "../helpers/helpers.cjs";
|
|||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD042", "no-empty-links" ],
|
||||
"description": "No empty links",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { addErrorContext, addErrorDetailIf } from "../helpers/helpers.cjs";
|
|||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD043", "required-headings" ],
|
||||
"description": "Required heading structure",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const ignoredChildTypes = new Set(
|
|||
[ "codeFencedFence", "definition", "reference", "resource" ]
|
||||
);
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD044", "proper-names" ],
|
||||
"description": "Proper names should have the correct capitalization",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
|
||||
const altRe = getHtmlAttributeRe("alt");
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD045", "no-alt-text" ],
|
||||
"description": "Images should have alternate text (alt text)",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const tokenTypeToStyle = {
|
|||
"codeIndented": "indented"
|
||||
};
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD046", "code-block-style" ],
|
||||
"description": "Code block style",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import { addError, isBlankLine } from "../helpers/helpers.cjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD047", "single-trailing-newline" ],
|
||||
"description": "Files should end with a single newline character",
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function fencedCodeBlockStyleFor(markup) {
|
|||
}
|
||||
};
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD048", "code-fence-style" ],
|
||||
"description": "Code fence style",
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ function emphasisOrStrongStyleFor(markup) {
|
|||
};
|
||||
|
||||
/**
|
||||
* @param {import("./markdownlint.mjs").RuleParams} params Rule parameters.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint").RuleParams} params Rule parameters.
|
||||
* @param {import("markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("micromark-util-types").TokenType} type Token type.
|
||||
* @param {import("micromark-util-types").TokenType} typeSequence Token sequence type.
|
||||
* @param {"*" | "**"} asterisk Asterisk kind.
|
||||
|
|
@ -76,7 +76,7 @@ const impl =
|
|||
}
|
||||
};
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule[]} */
|
||||
/** @type {import("markdownlint").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD049", "emphasis-style" ],
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ const tokensInclude = new Set(
|
|||
* Converts a Markdown heading into an HTML fragment according to the rules
|
||||
* used by GitHub.
|
||||
*
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} headingText Heading text token.
|
||||
* @param {import("markdownlint").MicromarkToken} headingText Heading text token.
|
||||
* @returns {string} Fragment string for heading.
|
||||
*/
|
||||
function convertHeadingToHTMLFragment(headingText) {
|
||||
|
|
@ -49,7 +49,7 @@ function convertHeadingToHTMLFragment(headingText) {
|
|||
/**
|
||||
* Unescapes the text of a String-type micromark Token.
|
||||
*
|
||||
* @param {import("../helpers/micromark-helpers.cjs").Token} token String-type micromark Token.
|
||||
* @param {import("markdownlint").MicromarkToken} token String-type micromark Token.
|
||||
* @returns {string} Unescaped token text.
|
||||
*/
|
||||
function unescapeStringTokenText(token) {
|
||||
|
|
@ -58,7 +58,7 @@ function unescapeStringTokenText(token) {
|
|||
.join("");
|
||||
}
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD051", "link-fragments" ],
|
||||
"description": "Link fragments should be valid",
|
||||
|
|
@ -101,7 +101,7 @@ export default {
|
|||
}
|
||||
|
||||
// Process link and definition fragments
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[][]} */
|
||||
/** @type {import("markdownlint").MicromarkTokenType[][]} */
|
||||
const parentChilds = [
|
||||
[ "link", "resourceDestinationString" ],
|
||||
[ "definition", "definitionDestinationString" ]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData } from "./cache.mjs";
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD052", "reference-links-images" ],
|
||||
"description":
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { getReferenceLinkImageData } from "./cache.mjs";
|
|||
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])\]:/;
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD053", "link-image-reference-definitions" ],
|
||||
"description": "Link and image reference definitions should be needed",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const autolinkAble = (destination) => {
|
|||
return !autolinkDisallowedRe.test(destination);
|
||||
};
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD054", "link-image-style" ],
|
||||
"description": "Link and image style",
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const makeRange = (start, end) => [ start, end - start + 1 ];
|
|||
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD055", "table-pipe-style" ],
|
||||
"description": "Table pipe style",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const makeRange = (start, end) => [ start, end - start + 1 ];
|
|||
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD056", "table-column-count" ],
|
||||
"description": "Table column count",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { filterByTypesCached } from "./cache.mjs";
|
|||
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
/** @type {import("markdownlint").Rule} */
|
||||
export default {
|
||||
"names": [ "MD058", "blanks-around-tables" ],
|
||||
"description": "Tables should be surrounded by blank lines",
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "../helpers/shared.c
|
|||
/** @typedef {import("micromark-util-types").State} State */
|
||||
/** @typedef {import("micromark-util-types").Token} Token */
|
||||
/** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */
|
||||
/** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
|
||||
/** @typedef {import("./micromark-types.d.mts")} */
|
||||
/** @typedef {import("../lib/markdownlint.mjs").MicromarkToken} MicromarkToken */
|
||||
|
||||
/**
|
||||
* Parse options.
|
||||
|
|
|
|||
12
lib/types.d.mts
Normal file
12
lib/types.d.mts
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
declare module "markdownlint" {
|
||||
export * from "./exports.mjs";
|
||||
}
|
||||
declare module "markdownlint/async" {
|
||||
export * from "./exports-async.mjs";
|
||||
}
|
||||
declare module "markdownlint/promise" {
|
||||
export * from "./exports-promise.mjs";
|
||||
}
|
||||
declare module "markdownlint/sync" {
|
||||
export * from "./exports-sync.mjs";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue