mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Convert markdownlint library to an ECMAScript module, replace markdownlint-micromark with micromark, stop publishing (large) markdownlint-browser.js, see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c for guidance.
This commit is contained in:
parent
191226f070
commit
1e71f6f44e
140 changed files with 1087 additions and 10428 deletions
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const helpers = require("../helpers");
|
||||
const { filterByTypes } = require("../helpers/micromark-helpers.cjs");
|
||||
import { getReferenceLinkImageData as helpersGetReferenceLinkImageData } from "../helpers/helpers.cjs";
|
||||
import { filterByTypes } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
/** @type {Map<string, object>} */
|
||||
const map = new Map();
|
||||
|
|
@ -12,10 +10,10 @@ let params = undefined;
|
|||
/**
|
||||
* Initializes (resets) the cache.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleParams} [p] Rule parameters object.
|
||||
* @param {import("./markdownlint.mjs").RuleParams} [p] Rule parameters object.
|
||||
* @returns {void}
|
||||
*/
|
||||
function initialize(p) {
|
||||
export function initialize(p) {
|
||||
map.clear();
|
||||
params = p;
|
||||
}
|
||||
|
|
@ -39,11 +37,11 @@ function getCached(name, getValue) {
|
|||
/**
|
||||
* Filters a list of Micromark tokens by type and caches the result.
|
||||
*
|
||||
* @param {import("./markdownlint").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {import("./markdownlint.mjs").MicromarkTokenType[]} types Types to allow.
|
||||
* @param {boolean} [htmlFlow] Whether to include htmlFlow content.
|
||||
* @returns {import("./markdownlint").MicromarkToken[]} Filtered tokens.
|
||||
* @returns {import("./markdownlint.mjs").MicromarkToken[]} Filtered tokens.
|
||||
*/
|
||||
function filterByTypesCached(types, htmlFlow) {
|
||||
export function filterByTypesCached(types, htmlFlow) {
|
||||
return getCached(
|
||||
// eslint-disable-next-line prefer-rest-params
|
||||
JSON.stringify(arguments),
|
||||
|
|
@ -56,15 +54,9 @@ function filterByTypesCached(types, htmlFlow) {
|
|||
*
|
||||
* @returns {Object} Reference link and image data object.
|
||||
*/
|
||||
function getReferenceLinkImageData() {
|
||||
export function getReferenceLinkImageData() {
|
||||
return getCached(
|
||||
getReferenceLinkImageData.name,
|
||||
() => helpers.getReferenceLinkImageData(params.parsers.micromark.tokens)
|
||||
() => helpersGetReferenceLinkImageData(params.parsers.micromark.tokens)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
initialize,
|
||||
filterByTypesCached,
|
||||
getReferenceLinkImageData
|
||||
};
|
||||
2
lib/configuration.d.ts
vendored
2
lib/configuration.d.ts
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { ConfigurationStrict } from "./configuration-strict";
|
||||
import type { ConfigurationStrict } from "./configuration-strict.d.ts";
|
||||
|
||||
export interface Configuration extends ConfigurationStrict {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports.deprecatedRuleNames = [];
|
||||
module.exports.fixableRuleNames = [
|
||||
export const deprecatedRuleNames = [];
|
||||
export const fixableRuleNames = [
|
||||
"MD004", "MD005", "MD007", "MD009", "MD010", "MD011",
|
||||
"MD012", "MD014", "MD018", "MD019", "MD020", "MD021",
|
||||
"MD022", "MD023", "MD026", "MD027", "MD030", "MD031",
|
||||
|
|
@ -11,5 +9,5 @@ module.exports.fixableRuleNames = [
|
|||
"MD047", "MD049", "MD050", "MD051", "MD053", "MD054",
|
||||
"MD058"
|
||||
];
|
||||
module.exports.homepage = "https://github.com/DavidAnson/markdownlint";
|
||||
module.exports.version = "0.36.1";
|
||||
export const homepage = "https://github.com/DavidAnson/markdownlint";
|
||||
export const version = "0.36.1";
|
||||
|
|
@ -4,6 +4,11 @@
|
|||
|
||||
const { newLineRe } = require("../helpers");
|
||||
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */
|
||||
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
||||
/** @typedef {import("./markdownlint.mjs").Plugin} Plugin */
|
||||
|
||||
/**
|
||||
* @callback InlineCodeSpanCallback
|
||||
* @param {string} code Code content.
|
||||
|
|
@ -67,7 +72,7 @@ function forEachInlineCodeSpan(input, handler) {
|
|||
/**
|
||||
* Freeze all freeze-able members of a token and its children.
|
||||
*
|
||||
* @param {import("./markdownlint").MarkdownItToken} token A markdown-it token.
|
||||
* @param {MarkdownItToken} token A markdown-it token.
|
||||
* @returns {void}
|
||||
*/
|
||||
function freezeToken(token) {
|
||||
|
|
@ -98,8 +103,7 @@ function freezeToken(token) {
|
|||
*/
|
||||
function annotateAndFreezeTokens(tokens, lines) {
|
||||
let trMap = null;
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").MarkdownItToken[] */
|
||||
/** @type {MarkdownItToken[]} */
|
||||
// @ts-ignore
|
||||
const markdownItTokens = tokens;
|
||||
for (const token of markdownItTokens) {
|
||||
|
|
@ -148,10 +152,10 @@ function annotateAndFreezeTokens(tokens, lines) {
|
|||
/**
|
||||
* Gets an array of markdown-it tokens for the input.
|
||||
*
|
||||
* @param {import("./markdownlint").Plugin[]} markdownItPlugins Additional plugins.
|
||||
* @param {Plugin[]} markdownItPlugins Additional plugins.
|
||||
* @param {string} content Markdown content.
|
||||
* @param {string[]} lines Lines of Markdown content.
|
||||
* @returns {import("../lib/markdownlint").MarkdownItToken} Array of markdown-it tokens.
|
||||
* @returns {MarkdownItToken} Array of markdown-it tokens.
|
||||
*/
|
||||
function getMarkdownItTokens(markdownItPlugins, content, lines) {
|
||||
const markdownit = require("markdown-it");
|
||||
|
|
|
|||
|
|
@ -1,79 +1,12 @@
|
|||
export = markdownlint;
|
||||
/**
|
||||
* 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, readConfig, readConfigSync, getVersion, promises, applyFix, applyFixes, RuleFunction, RuleParams, MarkdownParsers, ParserMarkdownIt, ParserMicromark, MarkdownItToken, MicromarkTokenType, MicromarkToken, RuleOnError, RuleOnErrorInfo, RuleOnErrorFixInfo, RuleOnErrorFixInfoNormalized, Rule, Options, Plugin, ToStringCallback, LintResults, LintError, FixInfo, LintContentCallback, LintCallback, Configuration, ConfigurationStrict, RuleConfiguration, ConfigurationParser, ReadConfigCallback, ResolveConfigExtendsCallback };
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
declare namespace promises {
|
||||
export { markdownlintPromise as markdownlint };
|
||||
export { extendConfigPromise as extendConfig };
|
||||
export { readConfigPromise as readConfig };
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
export default markdownlint;
|
||||
/**
|
||||
* Function to implement rule logic.
|
||||
*/
|
||||
type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
export type RuleFunction = (params: RuleParams, onError: RuleOnError) => void;
|
||||
/**
|
||||
* Rule parameters.
|
||||
*/
|
||||
type RuleParams = {
|
||||
export type RuleParams = {
|
||||
/**
|
||||
* File/string name.
|
||||
*/
|
||||
|
|
@ -102,7 +35,7 @@ type RuleParams = {
|
|||
/**
|
||||
* Markdown parser data.
|
||||
*/
|
||||
type MarkdownParsers = {
|
||||
export type MarkdownParsers = {
|
||||
/**
|
||||
* Markdown parser data from markdown-it (only present when Rule.parser is "markdownit").
|
||||
*/
|
||||
|
|
@ -115,7 +48,7 @@ type MarkdownParsers = {
|
|||
/**
|
||||
* Markdown parser data from markdown-it.
|
||||
*/
|
||||
type ParserMarkdownIt = {
|
||||
export type ParserMarkdownIt = {
|
||||
/**
|
||||
* Token objects from markdown-it.
|
||||
*/
|
||||
|
|
@ -124,7 +57,7 @@ type ParserMarkdownIt = {
|
|||
/**
|
||||
* Markdown parser data from micromark.
|
||||
*/
|
||||
type ParserMicromark = {
|
||||
export type ParserMicromark = {
|
||||
/**
|
||||
* Token objects from micromark.
|
||||
*/
|
||||
|
|
@ -133,7 +66,7 @@ type ParserMicromark = {
|
|||
/**
|
||||
* markdown-it token.
|
||||
*/
|
||||
type MarkdownItToken = {
|
||||
export type MarkdownItToken = {
|
||||
/**
|
||||
* HTML attributes.
|
||||
*/
|
||||
|
|
@ -195,11 +128,11 @@ type MarkdownItToken = {
|
|||
*/
|
||||
line: string;
|
||||
};
|
||||
type MicromarkTokenType = import("markdownlint-micromark").TokenType;
|
||||
export type MicromarkTokenType = import("micromark-util-types").TokenType;
|
||||
/**
|
||||
* micromark token.
|
||||
*/
|
||||
type MicromarkToken = {
|
||||
export type MicromarkToken = {
|
||||
/**
|
||||
* Token type.
|
||||
*/
|
||||
|
|
@ -236,11 +169,11 @@ type MicromarkToken = {
|
|||
/**
|
||||
* Error-reporting callback.
|
||||
*/
|
||||
type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
export type RuleOnError = (onErrorInfo: RuleOnErrorInfo) => void;
|
||||
/**
|
||||
* Fix information for RuleOnError callback.
|
||||
*/
|
||||
type RuleOnErrorInfo = {
|
||||
export type RuleOnErrorInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
|
@ -269,7 +202,7 @@ type RuleOnErrorInfo = {
|
|||
/**
|
||||
* Fix information for RuleOnErrorInfo.
|
||||
*/
|
||||
type RuleOnErrorFixInfo = {
|
||||
export type RuleOnErrorFixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
|
@ -290,7 +223,7 @@ type RuleOnErrorFixInfo = {
|
|||
/**
|
||||
* RuleOnErrorInfo with all optional properties present.
|
||||
*/
|
||||
type RuleOnErrorFixInfoNormalized = {
|
||||
export type RuleOnErrorFixInfoNormalized = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
|
@ -311,7 +244,7 @@ type RuleOnErrorFixInfoNormalized = {
|
|||
/**
|
||||
* Rule definition.
|
||||
*/
|
||||
type Rule = {
|
||||
export type Rule = {
|
||||
/**
|
||||
* Rule name(s).
|
||||
*/
|
||||
|
|
@ -344,7 +277,7 @@ type Rule = {
|
|||
/**
|
||||
* Configuration options.
|
||||
*/
|
||||
type Options = {
|
||||
export type Options = {
|
||||
/**
|
||||
* Configuration object.
|
||||
*/
|
||||
|
|
@ -395,21 +328,21 @@ type Options = {
|
|||
/**
|
||||
* A markdown-it plugin.
|
||||
*/
|
||||
type Plugin = any[];
|
||||
export type Plugin = any[];
|
||||
/**
|
||||
* Function to pretty-print lint results.
|
||||
*/
|
||||
type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
export type ToStringCallback = (ruleAliases?: boolean) => string;
|
||||
/**
|
||||
* Lint results (for resultVersion 3).
|
||||
*/
|
||||
type LintResults = {
|
||||
export type LintResults = {
|
||||
[x: string]: LintError[];
|
||||
};
|
||||
/**
|
||||
* Lint error.
|
||||
*/
|
||||
type LintError = {
|
||||
export type LintError = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
|
@ -446,7 +379,7 @@ type LintError = {
|
|||
/**
|
||||
* Fix information.
|
||||
*/
|
||||
type FixInfo = {
|
||||
export type FixInfo = {
|
||||
/**
|
||||
* Line number (1-based).
|
||||
*/
|
||||
|
|
@ -467,37 +400,92 @@ type FixInfo = {
|
|||
/**
|
||||
* Called with the result of linting a string or document.
|
||||
*/
|
||||
type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||
export type LintContentCallback = (error: Error | null, result?: LintError[]) => void;
|
||||
/**
|
||||
* Called with the result of the lint function.
|
||||
*/
|
||||
type LintCallback = (error: Error | null, results?: LintResults) => void;
|
||||
export type LintCallback = (error: Error | null, results?: LintResults) => void;
|
||||
/**
|
||||
* Configuration object for linting rules. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema.json}.
|
||||
*/
|
||||
type Configuration = import("./configuration").Configuration;
|
||||
export type Configuration = import("./configuration.d.ts").Configuration;
|
||||
/**
|
||||
* Configuration object for linting rules strictly. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema-strict.json}.
|
||||
*/
|
||||
type ConfigurationStrict = import("./configuration-strict").ConfigurationStrict;
|
||||
export type ConfigurationStrict = import("./configuration-strict.d.ts").ConfigurationStrict;
|
||||
/**
|
||||
* Rule configuration.
|
||||
*/
|
||||
type RuleConfiguration = boolean | any;
|
||||
export type RuleConfiguration = boolean | any;
|
||||
/**
|
||||
* Parses a configuration string and returns a configuration object.
|
||||
*/
|
||||
type ConfigurationParser = (text: string) => Configuration;
|
||||
export type ConfigurationParser = (text: string) => Configuration;
|
||||
/**
|
||||
* Called with the result of the readConfig function.
|
||||
*/
|
||||
type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
|
||||
export type ReadConfigCallback = (err: Error | null, config?: Configuration) => void;
|
||||
/**
|
||||
* Called with the result of the resolveConfigExtends function.
|
||||
*/
|
||||
type ResolveConfigExtendsCallback = (err: Error | null, path?: string) => void;
|
||||
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.
|
||||
*
|
||||
|
|
@ -524,3 +512,20 @@ declare function extendConfigPromise(config: Configuration, file: string, parser
|
|||
* @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;
|
||||
|
|
@ -1,19 +1,16 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const path = require("node:path");
|
||||
const { promisify } = require("node:util");
|
||||
const micromark = require("../helpers/micromark-parse.cjs");
|
||||
const { version } = require("./constants");
|
||||
const rules = require("./rules");
|
||||
const helpers = require("../helpers");
|
||||
const cache = require("./cache");
|
||||
|
||||
// @ts-ignore
|
||||
// eslint-disable-next-line camelcase, no-inline-comments, no-undef
|
||||
const dynamicRequire = (typeof __non_webpack_require__ === "undefined") ? require : /* c8 ignore next */ __non_webpack_require__;
|
||||
// Capture native require implementation for dynamic loading of modules
|
||||
import * as nodeFs from "node:fs";
|
||||
import { createRequire } from "node:module";
|
||||
const dynamicRequire = createRequire(import.meta.url);
|
||||
import * as os from "node:os";
|
||||
import path from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
import { initialize as cacheInitialize } from "./cache.mjs";
|
||||
import { version } from "./constants.mjs";
|
||||
import rules from "./rules.mjs";
|
||||
import { parse as micromarkParse } from "../helpers/micromark-parse.mjs";
|
||||
import * as helpers from "../helpers/helpers.cjs";
|
||||
|
||||
/**
|
||||
* Validate the list of rules for structure and reuse.
|
||||
|
|
@ -497,7 +494,7 @@ function lintContent(
|
|||
);
|
||||
const customRulesPresent = (ruleList.length !== rules.length);
|
||||
// Parse content into parser tokens
|
||||
const micromarkTokens = micromark.parse(
|
||||
const micromarkTokens = micromarkParse(
|
||||
content,
|
||||
{ "freezeTokens": customRulesPresent }
|
||||
);
|
||||
|
|
@ -507,7 +504,7 @@ function lintContent(
|
|||
// Parse content into lines and get markdown-it tokens
|
||||
const lines = content.split(helpers.newLineRe);
|
||||
const markdownitTokens = needMarkdownItTokens ?
|
||||
require("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
|
||||
dynamicRequire("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
|
||||
[];
|
||||
// Create (frozen) parameters for rules
|
||||
/** @type {MarkdownParsers} */
|
||||
|
|
@ -533,7 +530,7 @@ function lintContent(
|
|||
"lines": Object.freeze(lines),
|
||||
"frontMatterLines": Object.freeze(frontMatterLines)
|
||||
};
|
||||
cache.initialize({
|
||||
cacheInitialize({
|
||||
...paramsBase,
|
||||
"parsers": parsersMicromark,
|
||||
"config": null
|
||||
|
|
@ -751,7 +748,7 @@ function lintContent(
|
|||
} catch (error) {
|
||||
callbackError(error);
|
||||
} finally {
|
||||
cache.initialize();
|
||||
cacheInitialize();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -866,7 +863,7 @@ function lintInput(options, synchronous, callback) {
|
|||
3 :
|
||||
options.resultVersion;
|
||||
const markdownItPlugins = options.markdownItPlugins || [];
|
||||
const fs = options.fs || require("node:fs");
|
||||
const fs = options.fs || nodeFs;
|
||||
const aliasToRuleNames = mapAliasToRuleNames(ruleList);
|
||||
const results = newResults(ruleList);
|
||||
let done = false;
|
||||
|
|
@ -1068,7 +1065,7 @@ function extendConfig(config, file, parsers, fs, callback) {
|
|||
if (configExtends) {
|
||||
return resolveConfigExtends(
|
||||
file,
|
||||
helpers.expandTildePath(configExtends, require("node:os")),
|
||||
helpers.expandTildePath(configExtends, os),
|
||||
fs,
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
(_, resolvedExtends) => readConfig(
|
||||
|
|
@ -1132,10 +1129,10 @@ function readConfig(file, parsers, fs, callback) {
|
|||
}
|
||||
}
|
||||
if (!fs) {
|
||||
fs = require("node:fs");
|
||||
fs = nodeFs;
|
||||
}
|
||||
// Read file
|
||||
file = helpers.expandTildePath(file, require("node:os"));
|
||||
file = helpers.expandTildePath(file, os);
|
||||
fs.readFile(file, "utf8", (err, content) => {
|
||||
if (err) {
|
||||
// @ts-ignore
|
||||
|
|
@ -1180,10 +1177,9 @@ function readConfigPromise(file, parsers, fs) {
|
|||
*/
|
||||
function readConfigSync(file, parsers, fs) {
|
||||
if (!fs) {
|
||||
fs = require("node:fs");
|
||||
fs = nodeFs;
|
||||
}
|
||||
// Read file
|
||||
const os = require("node:os");
|
||||
file = helpers.expandTildePath(file, os);
|
||||
const content = fs.readFileSync(file, "utf8");
|
||||
// Try to parse file
|
||||
|
|
@ -1248,7 +1244,7 @@ function applyFix(line, fixInfo, lineEnding = "\n") {
|
|||
* @returns {string} Fixed content.
|
||||
*/
|
||||
function applyFixes(input, errors) {
|
||||
const lineEnding = helpers.getPreferredLineEnding(input, require("node:os"));
|
||||
const lineEnding = helpers.getPreferredLineEnding(input, os);
|
||||
const lines = input.split(helpers.newLineRe);
|
||||
// Normalize fixInfo objects
|
||||
let fixInfos = errors
|
||||
|
|
@ -1267,8 +1263,7 @@ function applyFixes(input, errors) {
|
|||
);
|
||||
});
|
||||
// Remove duplicate entries (needed for following collapse step)
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type RuleOnErrorFixInfo */
|
||||
/** @type {RuleOnErrorFixInfo} */
|
||||
let lastFixInfo = {};
|
||||
fixInfos = fixInfos.filter((fixInfo) => {
|
||||
const unique = (
|
||||
|
|
@ -1342,7 +1337,7 @@ markdownlint.promises = {
|
|||
};
|
||||
markdownlint.applyFix = applyFix;
|
||||
markdownlint.applyFixes = applyFixes;
|
||||
module.exports = markdownlint;
|
||||
export default markdownlint;
|
||||
|
||||
// Type declarations
|
||||
|
||||
|
|
@ -1414,7 +1409,7 @@ module.exports = markdownlint;
|
|||
* @property {string} line Line content.
|
||||
*/
|
||||
|
||||
/** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
|
||||
/** @typedef {import("micromark-util-types").TokenType} MicromarkTokenType */
|
||||
|
||||
/**
|
||||
* micromark token.
|
||||
|
|
@ -1567,14 +1562,14 @@ module.exports = markdownlint;
|
|||
* Configuration object for linting rules. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema.json}.
|
||||
*
|
||||
* @typedef {import("./configuration").Configuration} Configuration
|
||||
* @typedef {import("./configuration.d.ts").Configuration} Configuration
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration object for linting rules strictly. For the JSON schema, see
|
||||
* {@link ../schema/markdownlint-config-schema-strict.json}.
|
||||
*
|
||||
* @typedef {import("./configuration-strict").ConfigurationStrict} ConfigurationStrict
|
||||
* @typedef {import("./configuration-strict.d.ts").ConfigurationStrict} ConfigurationStrict
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD001", "heading-increment" ],
|
||||
"description": "Heading levels should only increment by one level at a time",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD003", "heading-style" ],
|
||||
"description": "Heading style",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType, getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType, getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const markerToStyle = {
|
||||
"-": "dash",
|
||||
|
|
@ -29,9 +27,8 @@ const validStyles = new Set([
|
|||
"sublist"
|
||||
]);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD004", "ul-style" ],
|
||||
"description": "Unordered list style",
|
||||
"tags": [ "bullet", "ul" ],
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD005", "list-indent" ],
|
||||
"description": "Inconsistent indentation for list items at the same level",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
||||
|
|
@ -1,23 +1,18 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("markdownlint-micromark").TokenType[] */
|
||||
/** @type {import("micromark-util-types").TokenType[]} */
|
||||
const unorderedListTypes =
|
||||
[ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("markdownlint-micromark").TokenType[] */
|
||||
/** @type {import("micromark-util-types").TokenType[]} */
|
||||
const unorderedParentTypes =
|
||||
[ "blockQuote", "listOrdered", "listUnordered" ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD007", "ul-indent" ],
|
||||
"description": "Unordered list indentation",
|
||||
"tags": [ "bullet", "ul", "indentation" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD009", "no-trailing-spaces" ],
|
||||
"description": "Trailing spaces",
|
||||
"tags": [ "whitespace" ],
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, hasOverlap } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const tabRe = /\t+/g;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD010", "no-hard-tabs" ],
|
||||
"description": "Hard tabs",
|
||||
"tags": [ "whitespace", "hard_tab" ],
|
||||
|
|
@ -26,8 +23,7 @@ module.exports = {
|
|||
const spaceMultiplier = (spacesPerTab === undefined) ?
|
||||
1 :
|
||||
Math.max(0, Number(spacesPerTab));
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../helpers/micromark-helpers.cjs").TokenType[] */
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[]} */
|
||||
const exclusionTypes = [];
|
||||
if (includeCode) {
|
||||
if (ignoreCodeLanguages.size > 0) {
|
||||
|
|
@ -60,7 +56,7 @@ module.exports = {
|
|||
const lineNumber = lineIndex + 1;
|
||||
const column = match.index + 1;
|
||||
const length = match[0].length;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
|
||||
if (!codeRanges.some((codeRange) => hasOverlap(codeRange, range))) {
|
||||
addError(
|
||||
|
|
@ -1,17 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, hasOverlap } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
const reversedLinkRe =
|
||||
/(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD011", "no-reversed-links" ],
|
||||
"description": "Reversed link syntax",
|
||||
"tags": [ "links" ],
|
||||
|
|
@ -34,7 +30,7 @@ module.exports = {
|
|||
) {
|
||||
const column = match.index + preChar.length + 1;
|
||||
const length = match[0].length - preChar.length;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
|
||||
if (!codeTexts.some((codeText) => hasOverlap(codeText, range))) {
|
||||
addError(
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD012", "no-multiple-blanks" ],
|
||||
"description": "Multiple consecutive blank lines",
|
||||
"tags": [ "whitespace", "blank_lines" ],
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
const { addRangeToSet, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached, getReferenceLinkImageData } from "./cache.mjs";
|
||||
import { addRangeToSet, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const longLineRePrefix = "^.{";
|
||||
const longLineRePostfixRelaxed = "}.*\\s.*$";
|
||||
const longLineRePostfixStrict = "}.+$";
|
||||
const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD013", "line-length" ],
|
||||
"description": "Line length",
|
||||
"tags": [ "line_length" ],
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const dollarCommandRe = /^(\s*)(\$\s+)/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD014", "commands-show-output" ],
|
||||
"description": "Dollar signs used before commands without showing output",
|
||||
"tags": [ "code" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD018", "no-missing-space-atx" ],
|
||||
"description": "No space after hash on atx style heading",
|
||||
"tags": [ "headings", "atx", "spaces" ],
|
||||
|
|
@ -1,16 +1,14 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers/helpers");
|
||||
const { getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getHeadingStyle } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Validate heading sequence and whitespace length at start or end.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint").MicromarkToken} heading ATX heading token.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint.mjs").MicromarkToken} heading ATX heading token.
|
||||
* @param {number} delta Direction to scan.
|
||||
* @returns {void}
|
||||
*/
|
||||
|
|
@ -47,9 +45,8 @@ function validateHeadingSpaces(onError, heading, delta) {
|
|||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule[] */
|
||||
module.exports = [
|
||||
/** @type {import("./markdownlint.mjs").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD019", "no-multiple-space-atx" ],
|
||||
"description": "Multiple spaces after hash on atx style heading",
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD020", "no-missing-space-closed-atx" ],
|
||||
"description": "No space inside hashes on closed atx style heading",
|
||||
"tags": [ "headings", "atx_closed", "spaces" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, isBlankLine } = require("../helpers");
|
||||
const { getBlockQuotePrefixText, getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getBlockQuotePrefixText, getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const defaultLines = 1;
|
||||
|
||||
|
|
@ -21,9 +19,8 @@ const getLinesFunction = (linesParam) => {
|
|||
return () => lines;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD022", "blanks-around-headings" ],
|
||||
"description": "Headings should be surrounded by blank lines",
|
||||
"tags": [ "headings", "blank_lines" ],
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD023", "heading-start-left" ],
|
||||
"description": "Headings must start at the beginning of the line",
|
||||
"tags": [ "headings", "spaces" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD024", "no-duplicate-heading" ],
|
||||
"description": "Multiple headings with the same content",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext, frontMatterHasTitle } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD025", "single-title", "single-h1" ],
|
||||
"description": "Multiple top-level headings in the same document",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, allPunctuationNoQuestion, endOfLineGemojiCodeRe,
|
||||
endOfLineHtmlEntityRe, escapeForRegExp } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD026", "no-trailing-punctuation" ],
|
||||
"description": "Trailing punctuation in heading",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD027", "no-multiple-space-blockquote" ],
|
||||
"description": "Multiple spaces after blockquote symbol",
|
||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const ignoreTypes = new Set([ "lineEnding", "listItemIndent", "linePrefix" ]);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD028", "no-blanks-blockquote" ],
|
||||
"description": "Blank line inside blockquote",
|
||||
"tags": [ "blockquote", "whitespace" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const listStyleExamples = {
|
||||
"one": "1/1/1",
|
||||
|
|
@ -22,9 +20,8 @@ function getOrderedListItemValue(listItemPrefix) {
|
|||
return Number(getDescendantsByType(listItemPrefix, [ "listItemValue" ])[0].text);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD029", "ol-prefix" ],
|
||||
"description": "Ordered list item prefix",
|
||||
"tags": [ "ol" ],
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD030", "list-marker-space" ],
|
||||
"description": "Spaces after list markers",
|
||||
"tags": [ "ol", "ul", "whitespace" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const codeFencePrefixRe = /^(.*?)[`~]/;
|
||||
|
||||
|
|
@ -14,7 +12,7 @@ const codeFencePrefixRe = /^(.*?)[`~]/;
|
|||
/**
|
||||
* Adds an error for the top or bottom of a code fence.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("./markdownlint.mjs").RuleOnError} onError Error-reporting callback.
|
||||
* @param {ReadonlyStringArray} lines Lines of Markdown content.
|
||||
* @param {number} lineNumber Line number.
|
||||
* @param {boolean} top True iff top fence.
|
||||
|
|
@ -24,7 +22,7 @@ function addError(onError, lines, lineNumber, top) {
|
|||
const line = lines[lineNumber - 1];
|
||||
const [ , prefix ] = line.match(codeFencePrefixRe) || [];
|
||||
const fixInfo = (prefix === undefined) ?
|
||||
null :
|
||||
undefined :
|
||||
{
|
||||
"lineNumber": lineNumber + (top ? 0 : 1),
|
||||
"insertText": `${prefix.replace(/[^>]/g, " ").trim()}\n`
|
||||
|
|
@ -40,9 +38,8 @@ function addError(onError, lines, lineNumber, top) {
|
|||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD031", "blanks-around-fences" ],
|
||||
"description": "Fenced code blocks should be surrounded by blank lines",
|
||||
"tags": [ "code", "blank_lines" ],
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { filterByPredicate, getBlockQuotePrefixText, nonContentTokens } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getBlockQuotePrefixText, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const isList = (token) => (
|
||||
(token.type === "listOrdered") || (token.type === "listUnordered")
|
||||
);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD032", "blanks-around-lists" ],
|
||||
"description": "Lists should be surrounded by blank lines",
|
||||
"tags": [ "bullet", "ul", "ol", "blank_lines" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, nextLinesRe } = require("../helpers");
|
||||
const { getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD033", "no-inline-html" ],
|
||||
"description": "Inline HTML",
|
||||
"tags": [ "html" ],
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getHtmlTagInfo, inHtmlFlow } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { filterByPredicate, getHtmlTagInfo, inHtmlFlow } = require("../helpers/micromark-helpers.cjs");
|
||||
/** @typedef {import("micromark-extension-gfm-autolink-literal")} */
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD034", "no-bare-urls" ],
|
||||
"description": "Bare URL used",
|
||||
"tags": [ "links", "url" ],
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD035", "hr-style" ],
|
||||
"description": "Horizontal rule style",
|
||||
"tags": [ "hr" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, allPunctuation } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
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 */
|
||||
/** @type {TokenType[][]} */
|
||||
|
|
@ -13,9 +11,8 @@ const emphasisTypes = [
|
|||
[ "strong", "strongText" ]
|
||||
];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD036", "no-emphasis-as-heading" ],
|
||||
"description": "Emphasis used instead of a heading",
|
||||
"tags": [ "headings", "emphasis" ],
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, inHtmlFlow } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByPredicate, inHtmlFlow } = require("../helpers/micromark-helpers.cjs");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD037", "no-space-in-emphasis" ],
|
||||
"description": "Spaces inside emphasis markers",
|
||||
"tags": [ "whitespace", "emphasis" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const leftSpaceRe = /^\s(?:[^`]|$)/;
|
||||
const rightSpaceRe = /[^`]\s$/;
|
||||
|
|
@ -19,9 +17,8 @@ const trimCodeText = (text, start, end) => {
|
|||
return text;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD038", "no-space-in-code" ],
|
||||
"description": "Spaces inside code span elements",
|
||||
"tags": [ "whitespace", "code" ],
|
||||
|
|
@ -1,14 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Adds an error for a label space issue.
|
||||
*
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @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 {boolean} isStart True iff error is at the start of the link.
|
||||
|
|
@ -49,9 +47,8 @@ function validLink(label, labelText, definitions) {
|
|||
return (label.parent?.children.length !== 1) || definitions.has(labelText.text.trim());
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD039", "no-space-in-links" ],
|
||||
"description": "Spaces inside link text",
|
||||
"tags": [ "whitespace", "links" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addError, addErrorContext } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD040", "fenced-code-language" ],
|
||||
"description": "Fenced code blocks should have a language specified",
|
||||
"tags": [ "code", "language" ],
|
||||
|
|
@ -1,14 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, frontMatterHasTitle } from "../helpers/helpers.cjs";
|
||||
import { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const { addErrorContext, frontMatterHasTitle } = require("../helpers");
|
||||
const { filterByTypes, getHeadingLevel, getHtmlTagInfo, isHtmlFlowComment, nonContentTokens } =
|
||||
require("../helpers/micromark-helpers.cjs");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD041", "first-line-heading", "first-line-h1" ],
|
||||
"description": "First line in a file should be a top-level heading",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD042", "no-empty-links" ],
|
||||
"description": "No empty links",
|
||||
"tags": [ "links" ],
|
||||
|
|
@ -1,14 +1,11 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getHeadingLevel, getHeadingText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext, addErrorDetailIf } = require("../helpers");
|
||||
const { getHeadingLevel, getHeadingText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD043", "required-headings" ],
|
||||
"description": "Required heading structure",
|
||||
"tags": [ "headings" ],
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, escapeForRegExp, hasOverlap } = require("../helpers");
|
||||
const { filterByPredicate, filterByTypes } = require("../helpers/micromark-helpers.cjs");
|
||||
const { parse } = require("../helpers/micromark-parse.cjs");
|
||||
import { addErrorDetailIf, escapeForRegExp, hasOverlap } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, filterByTypes } from "../helpers/micromark-helpers.cjs";
|
||||
import { parse } from "../helpers/micromark-parse.mjs";
|
||||
|
||||
const ignoredChildTypes = new Set(
|
||||
[ "codeFencedFence", "definition", "reference", "resource" ]
|
||||
);
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD044", "proper-names" ],
|
||||
"description": "Proper names should have the correct capitalization",
|
||||
"tags": [ "spelling" ],
|
||||
|
|
@ -48,7 +45,7 @@ module.exports = {
|
|||
token.children.filter((t) => !ignoredChildTypes.has(t.type))
|
||||
)
|
||||
);
|
||||
/** @type {import("../helpers").FileRange[]} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange[]} */
|
||||
const exclusions = [];
|
||||
const scannedTokens = new Set();
|
||||
for (const name of names) {
|
||||
|
|
@ -64,7 +61,7 @@ module.exports = {
|
|||
const column = token.startColumn + match.index + leftMatch.length;
|
||||
const length = nameMatch.length;
|
||||
const lineNumber = token.startLine;
|
||||
/** @type {import("../helpers").FileRange} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange} */
|
||||
const nameRange = {
|
||||
"startLine": lineNumber,
|
||||
"startColumn": column,
|
||||
|
|
@ -75,7 +72,7 @@ module.exports = {
|
|||
!names.includes(nameMatch) &&
|
||||
!exclusions.some((exclusion) => hasOverlap(exclusion, nameRange))
|
||||
) {
|
||||
/** @type {import("../helpers").FileRange[]} */
|
||||
/** @type {import("../helpers/helpers.cjs").FileRange[]} */
|
||||
let autolinkRanges = [];
|
||||
if (!scannedTokens.has(token)) {
|
||||
autolinkRanges = filterByTypes(parse(token.text), [ "literalAutolink" ])
|
||||
|
|
@ -1,16 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, getHtmlAttributeRe, nextLinesRe } = require("../helpers");
|
||||
const { getHtmlTagInfo, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, getHtmlAttributeRe, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getHtmlTagInfo, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const altRe = getHtmlAttributeRe("alt");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD045", "no-alt-text" ],
|
||||
"description": "Images should have alternate text (alt text)",
|
||||
"tags": [ "accessibility", "images" ],
|
||||
|
|
@ -1,18 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const tokenTypeToStyle = {
|
||||
"codeFenced": "fenced",
|
||||
"codeIndented": "indented"
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD046", "code-block-style" ],
|
||||
"description": "Code block style",
|
||||
"tags": [ "code" ],
|
||||
|
|
@ -1,12 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError, isBlankLine } from "../helpers/helpers.cjs";
|
||||
|
||||
const { addError, isBlankLine } = require("../helpers");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD047", "single-trailing-newline" ],
|
||||
"description": "Files should end with a single newline character",
|
||||
"tags": [ "blank_lines" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
/**
|
||||
* Return the string representation of a fence markup character.
|
||||
|
|
@ -21,9 +19,8 @@ function fencedCodeBlockStyleFor(markup) {
|
|||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD048", "code-fence-style" ],
|
||||
"description": "Code fence style",
|
||||
"tags": [ "code" ],
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { filterByPredicate, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
|
||||
const intrawordRe = /^\w$/;
|
||||
|
||||
|
|
@ -23,10 +21,10 @@ function emphasisOrStrongStyleFor(markup) {
|
|||
};
|
||||
|
||||
/**
|
||||
* @param {import("./markdownlint").RuleParams} params Rule parameters.
|
||||
* @param {import("./markdownlint").RuleOnError} onError Error-reporting callback.
|
||||
* @param {import("markdownlint-micromark").TokenType} type Token type.
|
||||
* @param {import("markdownlint-micromark").TokenType} typeSequence Token sequence type.
|
||||
* @param {import("./markdownlint.mjs").RuleParams} params Rule parameters.
|
||||
* @param {import("./markdownlint.mjs").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.
|
||||
* @param {"_" | "__"} underline Underline kind.
|
||||
* @param {"asterisk" | "consistent" | "underscore"} style Style string.
|
||||
|
|
@ -78,9 +76,8 @@ const impl =
|
|||
}
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule[] */
|
||||
module.exports = [
|
||||
/** @type {import("./markdownlint.mjs").Rule[]} */
|
||||
export default [
|
||||
{
|
||||
"names": [ "MD049", "emphasis-style" ],
|
||||
"description": "Emphasis style",
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, getHtmlAttributeRe } = require("../helpers");
|
||||
const { filterByPredicate, filterByTypes, getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addError, getHtmlAttributeRe } from "../helpers/helpers.cjs";
|
||||
import { filterByPredicate, filterByTypes, getHtmlTagInfo } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
// Regular expression for identifying HTML anchor names
|
||||
const idRe = getHtmlAttributeRe("id");
|
||||
|
|
@ -60,9 +58,8 @@ function unescapeStringTokenText(token) {
|
|||
.join("");
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD051", "link-fragments" ],
|
||||
"description": "Link fragments should be valid",
|
||||
"tags": [ "links" ],
|
||||
|
|
@ -104,8 +101,7 @@ module.exports = {
|
|||
}
|
||||
|
||||
// Process link and definition fragments
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("../helpers/micromark-helpers.cjs").TokenType[][] */
|
||||
/** @type {import("../helpers/micromark-helpers.cjs").TokenType[][]} */
|
||||
const parentChilds = [
|
||||
[ "link", "resourceDestinationString" ],
|
||||
[ "definition", "definitionDestinationString" ]
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addError } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData } from "./cache.mjs";
|
||||
|
||||
const { addError } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD052", "reference-links-images" ],
|
||||
"description":
|
||||
"Reference links and images should use a label that is defined",
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addError, ellipsify } = require("../helpers");
|
||||
const { getReferenceLinkImageData } = require("./cache");
|
||||
import { addError, ellipsify } from "../helpers/helpers.cjs";
|
||||
import { getReferenceLinkImageData } from "./cache.mjs";
|
||||
|
||||
const linkReferenceDefinitionRe = /^ {0,3}\[([^\]]*[^\\])\]:/;
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD053", "link-image-reference-definitions" ],
|
||||
"description": "Link and image reference definitions should be needed",
|
||||
"tags": [ "images", "links" ],
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorContext, nextLinesRe } = require("../helpers");
|
||||
const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { getReferenceLinkImageData, filterByTypesCached } = require("./cache");
|
||||
import { addErrorContext, nextLinesRe } from "../helpers/helpers.cjs";
|
||||
import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
|
||||
import { getReferenceLinkImageData, filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const backslashEscapeRe = /\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g;
|
||||
const removeBackslashEscapes = (text) => text.replace(backslashEscapeRe, "$1");
|
||||
|
|
@ -20,9 +18,8 @@ const autolinkAble = (destination) => {
|
|||
return !autolinkDisallowedRe.test(destination);
|
||||
};
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD054", "link-image-style" ],
|
||||
"description": "Link and image style",
|
||||
"tags": [ "images", "links" ],
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const whitespaceTypes = new Set([ "linePrefix", "whitespace" ]);
|
||||
const ignoreWhitespace = (tokens) => tokens.filter(
|
||||
|
|
@ -13,9 +11,10 @@ const firstOrNothing = (items) => items[0];
|
|||
const lastOrNothing = (items) => items[items.length - 1];
|
||||
const makeRange = (start, end) => [ start, end - start + 1 ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD055", "table-pipe-style" ],
|
||||
"description": "Table pipe style",
|
||||
"tags": [ "table" ],
|
||||
|
|
@ -1,16 +1,15 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf } = require("../helpers");
|
||||
const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
||||
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const makeRange = (start, end) => [ start, end - start + 1 ];
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD056", "table-column-count" ],
|
||||
"description": "Table column count",
|
||||
"tags": [ "table" ],
|
||||
|
|
@ -1,14 +1,13 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
import { addErrorContext, isBlankLine } from "../helpers/helpers.cjs";
|
||||
import { getBlockQuotePrefixText } from "../helpers/micromark-helpers.cjs";
|
||||
import { filterByTypesCached } from "./cache.mjs";
|
||||
|
||||
const { addErrorContext, isBlankLine } = require("../helpers");
|
||||
const { getBlockQuotePrefixText } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
/** @typedef {import("micromark-extension-gfm-table")} */
|
||||
|
||||
// eslint-disable-next-line jsdoc/valid-types
|
||||
/** @type import("./markdownlint").Rule */
|
||||
module.exports = {
|
||||
/** @type {import("./markdownlint.mjs").Rule} */
|
||||
export default {
|
||||
"names": [ "MD058", "blanks-around-tables" ],
|
||||
"description": "Tables should be surrounded by blank lines",
|
||||
"tags": [ "table" ],
|
||||
74
lib/rules.js
74
lib/rules.js
|
|
@ -1,74 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const { homepage, version } = require("./constants");
|
||||
|
||||
// @ts-ignore
|
||||
const [ md019, md021 ] = require("./md019-md021");
|
||||
// @ts-ignore
|
||||
const [ md049, md050 ] = require("./md049-md050");
|
||||
|
||||
const rules = [
|
||||
require("./md001"),
|
||||
// md002: Deprecated and removed
|
||||
require("./md003"),
|
||||
require("./md004"),
|
||||
require("./md005"),
|
||||
// md006: Deprecated and removed
|
||||
require("./md007"),
|
||||
require("./md009"),
|
||||
require("./md010"),
|
||||
require("./md011"),
|
||||
require("./md012"),
|
||||
require("./md013"),
|
||||
require("./md014"),
|
||||
require("./md018"),
|
||||
md019,
|
||||
require("./md020"),
|
||||
md021,
|
||||
require("./md022"),
|
||||
require("./md023"),
|
||||
require("./md024"),
|
||||
require("./md025"),
|
||||
require("./md026"),
|
||||
require("./md027"),
|
||||
require("./md028"),
|
||||
require("./md029"),
|
||||
require("./md030"),
|
||||
require("./md031"),
|
||||
require("./md032"),
|
||||
require("./md033"),
|
||||
require("./md034"),
|
||||
require("./md035"),
|
||||
require("./md036"),
|
||||
require("./md037"),
|
||||
require("./md038"),
|
||||
require("./md039"),
|
||||
require("./md040"),
|
||||
require("./md041"),
|
||||
require("./md042"),
|
||||
require("./md043"),
|
||||
require("./md044"),
|
||||
require("./md045"),
|
||||
require("./md046"),
|
||||
require("./md047"),
|
||||
require("./md048"),
|
||||
md049,
|
||||
md050,
|
||||
require("./md051"),
|
||||
require("./md052"),
|
||||
require("./md053"),
|
||||
require("./md054"),
|
||||
require("./md055"),
|
||||
require("./md056"),
|
||||
// md057: See https://github.com/markdownlint/markdownlint
|
||||
require("./md058")
|
||||
];
|
||||
for (const rule of rules) {
|
||||
const name = rule.names[0].toLowerCase();
|
||||
// eslint-disable-next-line dot-notation
|
||||
rule["information"] =
|
||||
new URL(`${homepage}/blob/v${version}/doc/${name}.md`);
|
||||
}
|
||||
module.exports = rules;
|
||||
118
lib/rules.mjs
Normal file
118
lib/rules.mjs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
// @ts-check
|
||||
|
||||
import { homepage, version } from "./constants.mjs";
|
||||
|
||||
import md001 from "./md001.mjs";
|
||||
import md003 from "./md003.mjs";
|
||||
import md004 from "./md004.mjs";
|
||||
import md005 from "./md005.mjs";
|
||||
import md007 from "./md007.mjs";
|
||||
import md009 from "./md009.mjs";
|
||||
import md010 from "./md010.mjs";
|
||||
import md011 from "./md011.mjs";
|
||||
import md012 from "./md012.mjs";
|
||||
import md013 from "./md013.mjs";
|
||||
import md014 from "./md014.mjs";
|
||||
import md018 from "./md018.mjs";
|
||||
import md019md021 from "./md019-md021.mjs";
|
||||
const [ md019, md021 ] = md019md021;
|
||||
import md020 from "./md020.mjs";
|
||||
import md022 from "./md022.mjs";
|
||||
import md023 from "./md023.mjs";
|
||||
import md024 from "./md024.mjs";
|
||||
import md025 from "./md025.mjs";
|
||||
import md026 from "./md026.mjs";
|
||||
import md027 from "./md027.mjs";
|
||||
import md028 from "./md028.mjs";
|
||||
import md029 from "./md029.mjs";
|
||||
import md030 from "./md030.mjs";
|
||||
import md031 from "./md031.mjs";
|
||||
import md032 from "./md032.mjs";
|
||||
import md033 from "./md033.mjs";
|
||||
import md034 from "./md034.mjs";
|
||||
import md035 from "./md035.mjs";
|
||||
import md036 from "./md036.mjs";
|
||||
import md037 from "./md037.mjs";
|
||||
import md038 from "./md038.mjs";
|
||||
import md039 from "./md039.mjs";
|
||||
import md040 from "./md040.mjs";
|
||||
import md041 from "./md041.mjs";
|
||||
import md042 from "./md042.mjs";
|
||||
import md043 from "./md043.mjs";
|
||||
import md044 from "./md044.mjs";
|
||||
import md045 from "./md045.mjs";
|
||||
import md046 from "./md046.mjs";
|
||||
import md047 from "./md047.mjs";
|
||||
import md048 from "./md048.mjs";
|
||||
import md049md050 from "./md049-md050.mjs";
|
||||
const [ md049, md050 ] = md049md050;
|
||||
import md051 from "./md051.mjs";
|
||||
import md052 from "./md052.mjs";
|
||||
import md053 from "./md053.mjs";
|
||||
import md054 from "./md054.mjs";
|
||||
import md055 from "./md055.mjs";
|
||||
import md056 from "./md056.mjs";
|
||||
import md058 from "./md058.mjs";
|
||||
|
||||
const rules = [
|
||||
md001,
|
||||
// md002: Deprecated and removed
|
||||
md003,
|
||||
md004,
|
||||
md005,
|
||||
// md006: Deprecated and removed
|
||||
md007,
|
||||
md009,
|
||||
md010,
|
||||
md011,
|
||||
md012,
|
||||
md013,
|
||||
md014,
|
||||
md018,
|
||||
md019,
|
||||
md020,
|
||||
md021,
|
||||
md022,
|
||||
md023,
|
||||
md024,
|
||||
md025,
|
||||
md026,
|
||||
md027,
|
||||
md028,
|
||||
md029,
|
||||
md030,
|
||||
md031,
|
||||
md032,
|
||||
md033,
|
||||
md034,
|
||||
md035,
|
||||
md036,
|
||||
md037,
|
||||
md038,
|
||||
md039,
|
||||
md040,
|
||||
md041,
|
||||
md042,
|
||||
md043,
|
||||
md044,
|
||||
md045,
|
||||
md046,
|
||||
md047,
|
||||
md048,
|
||||
md049,
|
||||
md050,
|
||||
md051,
|
||||
md052,
|
||||
md053,
|
||||
md054,
|
||||
md055,
|
||||
md056,
|
||||
// md057: See https://github.com/markdownlint/markdownlint
|
||||
md058
|
||||
];
|
||||
for (const rule of rules) {
|
||||
const name = rule.names[0].toLowerCase();
|
||||
// eslint-disable-next-line dot-notation
|
||||
rule["information"] = new URL(`${homepage}/blob/v${version}/doc/${name}.md`);
|
||||
}
|
||||
export default rules;
|
||||
Loading…
Add table
Add a link
Reference in a new issue