markdownlint 0.37.4 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/CONTRIBUTING.md +2 -3
- package/README.md +39 -21
- package/doc/Rules.md +158 -35
- package/doc/md027.md +8 -0
- package/doc/md038.md +23 -11
- package/doc/md041.md +31 -16
- package/doc/md043.md +22 -4
- package/doc/md045.md +9 -1
- package/doc/md051.md +17 -0
- package/doc/md052.md +12 -0
- package/doc/md053.md +3 -3
- package/doc/md059.md +30 -0
- package/helpers/README.md +2 -2
- package/helpers/helpers.cjs +4 -6
- package/helpers/micromark-helpers.cjs +29 -3
- package/helpers/package.json +1 -1
- package/lib/cache.mjs +19 -5
- package/lib/configuration-strict.d.ts +190 -126
- package/lib/constants.mjs +1 -1
- package/lib/exports.d.mts +1 -0
- package/lib/exports.mjs +1 -0
- package/lib/markdownit.cjs +6 -13
- package/lib/markdownlint.d.mts +36 -2
- package/lib/markdownlint.mjs +306 -282
- package/lib/md025.mjs +23 -15
- package/lib/md027.mjs +11 -1
- package/lib/md036.mjs +12 -2
- package/lib/md038.mjs +52 -71
- package/lib/md041.mjs +54 -16
- package/lib/md043.mjs +2 -0
- package/lib/md045.mjs +3 -1
- package/lib/md051.mjs +13 -5
- package/lib/md052.mjs +2 -1
- package/lib/md059.mjs +71 -0
- package/lib/micromark-parse.mjs +14 -3
- package/lib/parse-configuration.mjs +46 -0
- package/lib/rules.mjs +3 -1
- package/package.json +28 -25
- package/schema/.markdownlint.jsonc +82 -60
- package/schema/.markdownlint.yaml +74 -56
- package/schema/markdownlint-config-schema-strict.json +259 -144
- package/schema/markdownlint-config-schema.json +259 -144
package/lib/constants.mjs
CHANGED
package/lib/exports.d.mts
CHANGED
|
@@ -7,6 +7,7 @@ export type LintCallback = import("./markdownlint.mjs").LintCallback;
|
|
|
7
7
|
export type LintContentCallback = import("./markdownlint.mjs").LintContentCallback;
|
|
8
8
|
export type LintError = import("./markdownlint.mjs").LintError;
|
|
9
9
|
export type LintResults = import("./markdownlint.mjs").LintResults;
|
|
10
|
+
export type MarkdownItFactory = import("./markdownlint.mjs").MarkdownItFactory;
|
|
10
11
|
export type MarkdownItToken = import("./markdownlint.mjs").MarkdownItToken;
|
|
11
12
|
export type MarkdownParsers = import("./markdownlint.mjs").MarkdownParsers;
|
|
12
13
|
export type MicromarkToken = import("./markdownlint.mjs").MicromarkToken;
|
package/lib/exports.mjs
CHANGED
|
@@ -11,6 +11,7 @@ export { resolveModule } from "./resolve-module.cjs";
|
|
|
11
11
|
/** @typedef {import("./markdownlint.mjs").LintContentCallback} LintContentCallback */
|
|
12
12
|
/** @typedef {import("./markdownlint.mjs").LintError} LintError */
|
|
13
13
|
/** @typedef {import("./markdownlint.mjs").LintResults} LintResults */
|
|
14
|
+
/** @typedef {import("./markdownlint.mjs").MarkdownItFactory} MarkdownItFactory */
|
|
14
15
|
/** @typedef {import("./markdownlint.mjs").MarkdownItToken} MarkdownItToken */
|
|
15
16
|
/** @typedef {import("./markdownlint.mjs").MarkdownParsers} MarkdownParsers */
|
|
16
17
|
/** @typedef {import("./markdownlint.mjs").MicromarkToken} MicromarkToken */
|
package/lib/markdownit.cjs
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
const { newLineRe } = require("../helpers");
|
|
6
6
|
|
|
7
7
|
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
|
8
|
+
/** @typedef {import("markdownlint").MarkdownIt} MarkdownIt */
|
|
8
9
|
/** @typedef {import("markdownlint").MarkdownItToken} MarkdownItToken */
|
|
9
|
-
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/52529
|
|
10
10
|
/** @typedef {import("markdownlint").Plugin} Plugin */
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -97,7 +97,7 @@ function freezeToken(token) {
|
|
|
97
97
|
/**
|
|
98
98
|
* Annotate tokens with line/lineNumber and freeze them.
|
|
99
99
|
*
|
|
100
|
-
* @param {
|
|
100
|
+
* @param {import("markdown-it").Token[]} tokens Array of markdown-it tokens.
|
|
101
101
|
* @param {string[]} lines Lines of Markdown content.
|
|
102
102
|
* @returns {void}
|
|
103
103
|
*/
|
|
@@ -152,21 +152,14 @@ function annotateAndFreezeTokens(tokens, lines) {
|
|
|
152
152
|
/**
|
|
153
153
|
* Gets an array of markdown-it tokens for the input.
|
|
154
154
|
*
|
|
155
|
-
* @param {
|
|
155
|
+
* @param {MarkdownIt} markdownIt Instance of the markdown-it parser.
|
|
156
156
|
* @param {string} content Markdown content.
|
|
157
157
|
* @param {string[]} lines Lines of Markdown content.
|
|
158
|
-
* @returns {MarkdownItToken} Array of markdown-it tokens.
|
|
158
|
+
* @returns {MarkdownItToken[]} Array of markdown-it tokens.
|
|
159
159
|
*/
|
|
160
|
-
function getMarkdownItTokens(
|
|
161
|
-
const
|
|
162
|
-
const md = markdownit({ "html": true });
|
|
163
|
-
for (const plugin of markdownItPlugins) {
|
|
164
|
-
// @ts-ignore
|
|
165
|
-
md.use(...plugin);
|
|
166
|
-
}
|
|
167
|
-
const tokens = md.parse(content, {});
|
|
160
|
+
function getMarkdownItTokens(markdownIt, content, lines) {
|
|
161
|
+
const tokens = markdownIt.parse(content, {});
|
|
168
162
|
annotateAndFreezeTokens(tokens, lines);
|
|
169
|
-
// @ts-ignore
|
|
170
163
|
return tokens;
|
|
171
164
|
};
|
|
172
165
|
|
package/lib/markdownlint.d.mts
CHANGED
|
@@ -82,6 +82,23 @@ export function applyFixes(input: string, errors: RuleOnErrorInfo[]): string;
|
|
|
82
82
|
* @returns {string} SemVer string.
|
|
83
83
|
*/
|
|
84
84
|
export function getVersion(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Result object for getEnabledRulesPerLineNumber.
|
|
87
|
+
*/
|
|
88
|
+
export type EnabledRulesPerLineNumberResult = {
|
|
89
|
+
/**
|
|
90
|
+
* Effective configuration.
|
|
91
|
+
*/
|
|
92
|
+
effectiveConfig: Configuration;
|
|
93
|
+
/**
|
|
94
|
+
* Enabled rules per line number.
|
|
95
|
+
*/
|
|
96
|
+
enabledRulesPerLineNumber: any[];
|
|
97
|
+
/**
|
|
98
|
+
* Enabled rule list.
|
|
99
|
+
*/
|
|
100
|
+
enabledRuleList: Rule[];
|
|
101
|
+
};
|
|
85
102
|
/**
|
|
86
103
|
* Function to implement rule logic.
|
|
87
104
|
*/
|
|
@@ -357,6 +374,23 @@ export type Rule = {
|
|
|
357
374
|
*/
|
|
358
375
|
function: RuleFunction;
|
|
359
376
|
};
|
|
377
|
+
/**
|
|
378
|
+
* Method used by the markdown-it parser to parse input.
|
|
379
|
+
*/
|
|
380
|
+
export type MarkdownItParse = (src: string, env: any) => any[];
|
|
381
|
+
/**
|
|
382
|
+
* Instance of the markdown-it parser.
|
|
383
|
+
*/
|
|
384
|
+
export type MarkdownIt = {
|
|
385
|
+
/**
|
|
386
|
+
* Method to parse input.
|
|
387
|
+
*/
|
|
388
|
+
parse: MarkdownItParse;
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Gets an instance of the markdown-it parser. Any plugins should already have been loaded.
|
|
392
|
+
*/
|
|
393
|
+
export type MarkdownItFactory = () => MarkdownIt | Promise<MarkdownIt>;
|
|
360
394
|
/**
|
|
361
395
|
* Configuration options.
|
|
362
396
|
*/
|
|
@@ -390,9 +424,9 @@ export type Options = {
|
|
|
390
424
|
*/
|
|
391
425
|
handleRuleFailures?: boolean;
|
|
392
426
|
/**
|
|
393
|
-
*
|
|
427
|
+
* Function to create a markdown-it parser.
|
|
394
428
|
*/
|
|
395
|
-
|
|
429
|
+
markdownItFactory?: MarkdownItFactory;
|
|
396
430
|
/**
|
|
397
431
|
* True to ignore HTML directives.
|
|
398
432
|
*/
|