markdownlint 0.37.2 → 0.37.4
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 +8 -0
- package/helpers/README.md +2 -2
- package/lib/configuration-strict.d.ts +104 -104
- package/lib/constants.mjs +1 -1
- package/lib/defer-require.cjs +16 -0
- package/lib/exports.d.mts +1 -0
- package/lib/exports.mjs +1 -0
- package/lib/markdownlint.mjs +9 -11
- package/lib/md039.mjs +3 -22
- package/lib/micromark-parse.mjs +2 -2
- package/lib/node-imports-browser.mjs +0 -2
- package/lib/node-imports-node.mjs +0 -3
- package/lib/resolve-module.cjs +52 -0
- package/lib/resolve-module.d.cts +34 -0
- package/package.json +11 -10
- package/schema/.markdownlint.jsonc +51 -51
- package/schema/.markdownlint.yaml +51 -51
- package/schema/markdownlint-config-schema-strict.json +106 -106
- package/schema/markdownlint-config-schema.json +106 -106
- package/lib/node-imports-browser-module.cjs +0 -7
package/lib/constants.mjs
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Calls require for markdownit.cjs. Used to synchronously defer loading because module.createRequire is buggy under webpack (https://github.com/webpack/webpack/issues/16724).
|
|
7
|
+
*
|
|
8
|
+
* @returns {any} Exported module content.
|
|
9
|
+
*/
|
|
10
|
+
function requireMarkdownItCjs() {
|
|
11
|
+
return require("./markdownit.cjs");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
requireMarkdownItCjs
|
|
16
|
+
};
|
package/lib/exports.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { resolveModule } from "./resolve-module.cjs";
|
|
1
2
|
export type Configuration = import("./markdownlint.mjs").Configuration;
|
|
2
3
|
export type ConfigurationParser = import("./markdownlint.mjs").ConfigurationParser;
|
|
3
4
|
export type ConfigurationStrict = import("./markdownlint.mjs").ConfigurationStrict;
|
package/lib/exports.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
export { applyFix, applyFixes, getVersion } from "./markdownlint.mjs";
|
|
4
|
+
export { resolveModule } from "./resolve-module.cjs";
|
|
4
5
|
|
|
5
6
|
/** @typedef {import("./markdownlint.mjs").Configuration} Configuration */
|
|
6
7
|
/** @typedef {import("./markdownlint.mjs").ConfigurationParser} ConfigurationParser */
|
package/lib/markdownlint.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
// @ts-ignore
|
|
4
|
-
import { fs as nodeFs,
|
|
5
|
-
const dynamicRequire = module.createRequire(import.meta.url);
|
|
4
|
+
import { fs as nodeFs, os, path } from "#node-imports";
|
|
6
5
|
import { initialize as cacheInitialize } from "./cache.mjs";
|
|
7
6
|
import { version } from "./constants.mjs";
|
|
7
|
+
import { requireMarkdownItCjs } from "./defer-require.cjs";
|
|
8
|
+
import { resolveModule } from "./resolve-module.cjs";
|
|
8
9
|
import rules from "./rules.mjs";
|
|
9
10
|
import { parse as micromarkParse } from "./micromark-parse.mjs";
|
|
10
11
|
import * as helpers from "../helpers/helpers.cjs";
|
|
@@ -501,7 +502,7 @@ function lintContent(
|
|
|
501
502
|
// Parse content into lines and get markdown-it tokens
|
|
502
503
|
const lines = content.split(helpers.newLineRe);
|
|
503
504
|
const markdownitTokens = needMarkdownItTokens ?
|
|
504
|
-
|
|
505
|
+
requireMarkdownItCjs().getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
|
|
505
506
|
[];
|
|
506
507
|
// Create (frozen) parameters for rules
|
|
507
508
|
/** @type {MarkdownParsers} */
|
|
@@ -1010,10 +1011,10 @@ function resolveConfigExtends(configFile, referenceId, fs, callback) {
|
|
|
1010
1011
|
if (err) {
|
|
1011
1012
|
// Not a file, try require.resolve
|
|
1012
1013
|
try {
|
|
1013
|
-
return callback(
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
)
|
|
1014
|
+
return callback(
|
|
1015
|
+
null,
|
|
1016
|
+
resolveModule(referenceId, [ configFileDirname ])
|
|
1017
|
+
);
|
|
1017
1018
|
} catch {
|
|
1018
1019
|
// Unable to resolve, use resolvedExtendsFile
|
|
1019
1020
|
}
|
|
@@ -1041,10 +1042,7 @@ function resolveConfigExtendsSync(configFile, referenceId, fs) {
|
|
|
1041
1042
|
// Not a file, try require.resolve
|
|
1042
1043
|
}
|
|
1043
1044
|
try {
|
|
1044
|
-
return
|
|
1045
|
-
referenceId,
|
|
1046
|
-
{ "paths": [ configFileDirname ] }
|
|
1047
|
-
);
|
|
1045
|
+
return resolveModule(referenceId, [ configFileDirname ]);
|
|
1048
1046
|
} catch {
|
|
1049
1047
|
// Unable to resolve, return resolvedExtendsFile
|
|
1050
1048
|
}
|
package/lib/md039.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import { addErrorContext } from "../helpers/helpers.cjs";
|
|
4
|
-
import {
|
|
4
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Adds an error for a label space issue.
|
|
@@ -35,18 +35,6 @@ function addLabelSpaceError(onError, label, labelText, isStart) {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/**
|
|
39
|
-
* Determines if a link is a valid link (and not a fake shortcut link due to parser tricks).
|
|
40
|
-
*
|
|
41
|
-
* @param {import("markdownlint").MicromarkToken} label Label token.
|
|
42
|
-
* @param {import("markdownlint").MicromarkToken} labelText LabelText token.
|
|
43
|
-
* @param {Map<string, any>} definitions Map of link definitions.
|
|
44
|
-
* @returns {boolean} True iff the link is valid.
|
|
45
|
-
*/
|
|
46
|
-
function validLink(label, labelText, definitions) {
|
|
47
|
-
return (label.parent?.children.length !== 1) || definitions.has(labelText.text.trim());
|
|
48
|
-
}
|
|
49
|
-
|
|
50
38
|
/** @type {import("markdownlint").Rule} */
|
|
51
39
|
export default {
|
|
52
40
|
"names": [ "MD039", "no-space-in-links" ],
|
|
@@ -54,22 +42,15 @@ export default {
|
|
|
54
42
|
"tags": [ "whitespace", "links" ],
|
|
55
43
|
"parser": "micromark",
|
|
56
44
|
"function": function MD039(params, onError) {
|
|
57
|
-
const { definitions } = getReferenceLinkImageData();
|
|
58
45
|
const labels = filterByTypesCached([ "label" ])
|
|
59
46
|
.filter((label) => label.parent?.type === "link");
|
|
60
47
|
for (const label of labels) {
|
|
61
48
|
const labelTexts = label.children.filter((child) => child.type === "labelText");
|
|
62
49
|
for (const labelText of labelTexts) {
|
|
63
|
-
if (
|
|
64
|
-
(labelText.text.trimStart().length !== labelText.text.length) &&
|
|
65
|
-
validLink(label, labelText, definitions)
|
|
66
|
-
) {
|
|
50
|
+
if (labelText.text.trimStart().length !== labelText.text.length) {
|
|
67
51
|
addLabelSpaceError(onError, label, labelText, true);
|
|
68
52
|
}
|
|
69
|
-
if (
|
|
70
|
-
(labelText.text.trimEnd().length !== labelText.text.length) &&
|
|
71
|
-
validLink(label, labelText, definitions)
|
|
72
|
-
) {
|
|
53
|
+
if (labelText.text.trimEnd().length !== labelText.text.length) {
|
|
73
54
|
addLabelSpaceError(onError, label, labelText, false);
|
|
74
55
|
}
|
|
75
56
|
}
|
package/lib/micromark-parse.mjs
CHANGED
|
@@ -6,8 +6,8 @@ import { gfmFootnote } from "micromark-extension-gfm-footnote";
|
|
|
6
6
|
import { gfmTable } from "micromark-extension-gfm-table";
|
|
7
7
|
import { math } from "micromark-extension-math";
|
|
8
8
|
import { parse as micromarkParse, postprocess as micromarkPostprocess, preprocess as micromarkPreprocess } from "micromark";
|
|
9
|
-
// micromark-core-commonmark
|
|
10
|
-
//
|
|
9
|
+
// micromark-core-commonmark must exactly match what's used by micromark for the shim below to work correctly
|
|
10
|
+
// Unfortunately, omitting this dependency from package.json breaks strict dependency resolution (e.g., pnpm)
|
|
11
11
|
import { labelEnd } from "micromark-core-commonmark";
|
|
12
12
|
import { isHtmlFlowComment } from "../helpers/micromark-helpers.cjs";
|
|
13
13
|
import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "../helpers/shared.cjs";
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
import { access, accessSync, readFile, readFileSync } from "node:fs";
|
|
4
4
|
export const fs = { access, accessSync, readFile, readFileSync };
|
|
5
5
|
|
|
6
|
-
import { createRequire } from "node:module";
|
|
7
|
-
export const module = { createRequire };
|
|
8
|
-
|
|
9
6
|
import { EOL, homedir } from "node:os";
|
|
10
7
|
export const os = { EOL, homedir };
|
|
11
8
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
// eslint-disable-next-line camelcase, no-inline-comments, no-undef
|
|
7
|
+
const nativeRequire = (typeof __non_webpack_require__ === "undefined") ? require : /* c8 ignore next */ __non_webpack_require__;
|
|
8
|
+
// Captures the native require implementation (even under webpack).
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef RequireResolveOptions
|
|
12
|
+
* @property {string[]} [paths] Additional paths to resolve from.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @callback RequireResolve
|
|
17
|
+
* @param {string} id Module name or path.
|
|
18
|
+
* @param {RequireResolveOptions} options Options to apply.
|
|
19
|
+
* @returns {string} Resolved module path.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Resolves modules according to Node's resolution rules.
|
|
24
|
+
*
|
|
25
|
+
* @param {RequireResolve} resolve Node-like require.resolve implementation.
|
|
26
|
+
* @param {string} id Module name or path.
|
|
27
|
+
* @param {string[]} [paths] Additional paths to resolve from.
|
|
28
|
+
* @returns {string} Resolved module path.
|
|
29
|
+
*/
|
|
30
|
+
const resolveModuleCustomResolve = (resolve, id, paths = []) => {
|
|
31
|
+
// resolve.paths is sometimes not present under webpack or VS Code
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
const resolvePaths = resolve.paths?.("") || [];
|
|
34
|
+
const allPaths = [ ...paths, ...resolvePaths ];
|
|
35
|
+
return resolve(id, { "paths": allPaths });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Resolves modules according to Node's resolution rules.
|
|
40
|
+
*
|
|
41
|
+
* @param {string} id Module name or path.
|
|
42
|
+
* @param {string[]} [paths] Additional paths to resolve from.
|
|
43
|
+
* @returns {string} Resolved module path.
|
|
44
|
+
*/
|
|
45
|
+
const resolveModule = (id, paths) => (
|
|
46
|
+
resolveModuleCustomResolve(nativeRequire.resolve, id, paths)
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
resolveModule,
|
|
51
|
+
resolveModuleCustomResolve
|
|
52
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type RequireResolveOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Additional paths to resolve from.
|
|
4
|
+
*/
|
|
5
|
+
paths?: string[];
|
|
6
|
+
};
|
|
7
|
+
export type RequireResolve = (id: string, options: RequireResolveOptions) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves modules according to Node's resolution rules.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} id Module name or path.
|
|
12
|
+
* @param {string[]} [paths] Additional paths to resolve from.
|
|
13
|
+
* @returns {string} Resolved module path.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveModule(id: string, paths?: string[]): string;
|
|
16
|
+
/**
|
|
17
|
+
* @typedef RequireResolveOptions
|
|
18
|
+
* @property {string[]} [paths] Additional paths to resolve from.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @callback RequireResolve
|
|
22
|
+
* @param {string} id Module name or path.
|
|
23
|
+
* @param {RequireResolveOptions} options Options to apply.
|
|
24
|
+
* @returns {string} Resolved module path.
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* Resolves modules according to Node's resolution rules.
|
|
28
|
+
*
|
|
29
|
+
* @param {RequireResolve} resolve Node-like require.resolve implementation.
|
|
30
|
+
* @param {string} id Module name or path.
|
|
31
|
+
* @param {string[]} [paths] Additional paths to resolve from.
|
|
32
|
+
* @returns {string} Resolved module path.
|
|
33
|
+
*/
|
|
34
|
+
export function resolveModuleCustomResolve(resolve: RequireResolve, id: string, paths?: string[]): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markdownlint",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.4",
|
|
4
4
|
"description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"build-config": "npm run build-config-schema && npm run build-config-example",
|
|
37
37
|
"build-config-example": "node schema/build-config-example.mjs",
|
|
38
38
|
"build-config-schema": "node schema/build-config-schema.mjs",
|
|
39
|
-
"build-declaration": "tsc --allowJs --checkJs --declaration --emitDeclarationOnly --module nodenext --outDir dts --rootDir . --target es2015 lib/exports.mjs lib/exports-async.mjs lib/exports-promise.mjs lib/exports-sync.mjs lib/markdownlint.mjs && node scripts/index.mjs copy dts/lib/exports.d.mts lib/exports.d.mts && node scripts/index.mjs copy dts/lib/exports-async.d.mts lib/exports-async.d.mts && node scripts/index.mjs copy dts/lib/exports-promise.d.mts lib/exports-promise.d.mts && node scripts/index.mjs copy dts/lib/exports-sync.d.mts lib/exports-sync.d.mts && node scripts/index.mjs copy dts/lib/markdownlint.d.mts lib/markdownlint.d.mts && node scripts/index.mjs remove dts",
|
|
39
|
+
"build-declaration": "tsc --allowJs --checkJs --declaration --emitDeclarationOnly --module nodenext --outDir dts --rootDir . --target es2015 lib/exports.mjs lib/exports-async.mjs lib/exports-promise.mjs lib/exports-sync.mjs lib/markdownlint.mjs lib/resolve-module.cjs && node scripts/index.mjs copy dts/lib/exports.d.mts lib/exports.d.mts && node scripts/index.mjs copy dts/lib/exports-async.d.mts lib/exports-async.d.mts && node scripts/index.mjs copy dts/lib/exports-promise.d.mts lib/exports-promise.d.mts && node scripts/index.mjs copy dts/lib/exports-sync.d.mts lib/exports-sync.d.mts && node scripts/index.mjs copy dts/lib/markdownlint.d.mts lib/markdownlint.d.mts && node scripts/index.mjs copy dts/lib/resolve-module.d.cts lib/resolve-module.d.cts && node scripts/index.mjs remove dts",
|
|
40
40
|
"build-demo": "node scripts/index.mjs copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && cd demo && webpack --no-stats",
|
|
41
41
|
"build-docs": "node doc-build/build-rules.mjs",
|
|
42
42
|
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos-*.mjs",
|
|
60
60
|
"serial-config-docs": "npm run build-config && npm run build-docs",
|
|
61
61
|
"serial-declaration-demo": "npm run build-declaration && npm-run-all --continue-on-error --parallel build-demo test-declaration",
|
|
62
|
-
"test": "ava --timeout=30s test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs helpers/test.cjs",
|
|
62
|
+
"test": "ava --timeout=30s test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs test/resolve-module-test.mjs helpers/test.cjs",
|
|
63
63
|
"test-cover": "c8 --100 npm test",
|
|
64
64
|
"test-declaration": "cd example/typescript && tsc --module commonjs && tsc --module nodenext && node type-check.js",
|
|
65
65
|
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
|
|
@@ -73,6 +73,7 @@
|
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"markdown-it": "14.1.0",
|
|
75
75
|
"micromark": "4.0.1",
|
|
76
|
+
"micromark-core-commonmark": "2.0.2",
|
|
76
77
|
"micromark-extension-directive": "3.0.2",
|
|
77
78
|
"micromark-extension-gfm-autolink-literal": "2.1.0",
|
|
78
79
|
"micromark-extension-gfm-footnote": "2.1.0",
|
|
@@ -81,21 +82,21 @@
|
|
|
81
82
|
"micromark-util-types": "2.0.1"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
|
-
"@eslint/js": "9.
|
|
85
|
-
"@stylistic/eslint-plugin": "2.
|
|
85
|
+
"@eslint/js": "9.18.0",
|
|
86
|
+
"@stylistic/eslint-plugin": "2.13.0",
|
|
86
87
|
"ajv": "8.17.1",
|
|
87
88
|
"ava": "6.2.0",
|
|
88
89
|
"c8": "10.1.3",
|
|
89
90
|
"character-entities": "2.0.2",
|
|
90
|
-
"eslint": "9.
|
|
91
|
+
"eslint": "9.18.0",
|
|
91
92
|
"eslint-plugin-jsdoc": "50.6.1",
|
|
92
|
-
"eslint-plugin-n": "17.15.
|
|
93
|
+
"eslint-plugin-n": "17.15.1",
|
|
93
94
|
"eslint-plugin-regexp": "2.7.0",
|
|
94
95
|
"eslint-plugin-unicorn": "56.0.1",
|
|
95
96
|
"gemoji": "8.1.0",
|
|
96
97
|
"globby": "14.0.2",
|
|
97
98
|
"js-yaml": "4.1.0",
|
|
98
|
-
"json-schema-to-typescript": "15.0.
|
|
99
|
+
"json-schema-to-typescript": "15.0.4",
|
|
99
100
|
"jsonc-parser": "3.3.1",
|
|
100
101
|
"markdown-it-for-inline": "2.0.1",
|
|
101
102
|
"markdown-it-sub": "2.0.0",
|
|
@@ -105,9 +106,9 @@
|
|
|
105
106
|
"npm-run-all": "4.1.5",
|
|
106
107
|
"terser-webpack-plugin": "5.3.11",
|
|
107
108
|
"toml": "3.0.0",
|
|
108
|
-
"typescript": "5.7.
|
|
109
|
+
"typescript": "5.7.3",
|
|
109
110
|
"webpack": "5.97.1",
|
|
110
|
-
"webpack-cli": "
|
|
111
|
+
"webpack-cli": "6.0.1"
|
|
111
112
|
},
|
|
112
113
|
"keywords": [
|
|
113
114
|
"markdown",
|