markdownlint 0.41.0 → 0.42.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/CONTRIBUTING.md +62 -77
  3. package/README.md +7 -7
  4. package/doc/CustomRules.md +6 -4
  5. package/doc/Rules.md +87 -36
  6. package/doc/md010.md +0 -1
  7. package/doc/md024.md +1 -1
  8. package/doc/md029.md +11 -1
  9. package/doc/md043.md +47 -9
  10. package/doc/md051.md +19 -19
  11. package/doc/md055.md +6 -3
  12. package/doc/md060.md +3 -2
  13. package/helpers/README.md +2 -2
  14. package/helpers/helpers.cjs +23 -7
  15. package/helpers/micromark-helpers.cjs +8 -12
  16. package/helpers/package.json +1 -5
  17. package/helpers/shared.cjs +1 -1
  18. package/lib/cache.mjs +1 -0
  19. package/lib/configuration-strict.d.ts +124 -112
  20. package/lib/constants.mjs +1 -1
  21. package/lib/defer-require.cjs +1 -0
  22. package/lib/exports.d.mts +29 -1
  23. package/lib/markdownit.cjs +8 -1
  24. package/lib/markdownlint.d.mts +337 -195
  25. package/lib/markdownlint.mjs +83 -87
  26. package/lib/md004.mjs +1 -0
  27. package/lib/md005.mjs +1 -1
  28. package/lib/md007.mjs +2 -2
  29. package/lib/md009.mjs +2 -3
  30. package/lib/md010.mjs +1 -1
  31. package/lib/md011.mjs +10 -7
  32. package/lib/md012.mjs +1 -1
  33. package/lib/md013.mjs +13 -9
  34. package/lib/md018.mjs +1 -1
  35. package/lib/md019-md021.mjs +1 -0
  36. package/lib/md020.mjs +1 -1
  37. package/lib/md022.mjs +6 -6
  38. package/lib/md024.mjs +1 -1
  39. package/lib/md025.mjs +1 -1
  40. package/lib/md027.mjs +1 -1
  41. package/lib/md028.mjs +1 -2
  42. package/lib/md029.mjs +34 -23
  43. package/lib/md030.mjs +4 -4
  44. package/lib/md031.mjs +1 -1
  45. package/lib/md032.mjs +5 -4
  46. package/lib/md033.mjs +1 -1
  47. package/lib/md034.mjs +1 -1
  48. package/lib/md037.mjs +1 -2
  49. package/lib/md039.mjs +5 -1
  50. package/lib/md041.mjs +1 -1
  51. package/lib/md043.mjs +98 -44
  52. package/lib/md044.mjs +2 -2
  53. package/lib/md048.mjs +1 -3
  54. package/lib/md051.mjs +3 -3
  55. package/lib/md055.mjs +11 -1
  56. package/lib/md056.mjs +1 -1
  57. package/lib/md058.mjs +1 -1
  58. package/lib/md060.mjs +24 -4
  59. package/lib/micromark-parse.mjs +3 -2
  60. package/lib/resolve-module.cjs +3 -2
  61. package/lib/resolve-module.d.cts +15 -10
  62. package/package.json +33 -34
  63. package/schema/.markdownlint.jsonc +54 -54
  64. package/schema/.markdownlint.yaml +76 -76
  65. package/schema/markdownlint-config-schema-strict.json +126 -118
  66. package/schema/markdownlint-config-schema.json +126 -118
package/lib/md060.mjs CHANGED
@@ -4,21 +4,35 @@ import { filterByTypes } from "../helpers/micromark-helpers.cjs";
4
4
  import { filterByTypesCached } from "./cache.mjs";
5
5
  import stringWidth from "string-width";
6
6
 
7
- /** @typedef {import("micromark-extension-gfm-table")} */
7
+ /** @typedef {typeof import("micromark-extension-gfm-table")} _ambient_ */
8
8
  /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
9
9
  /** @typedef {import("markdownlint").RuleOnErrorInfo} RuleOnErrorInfo */
10
10
  /** @typedef {import("markdownlint").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
11
11
 
12
+ // Regular expression to match text that could represent an unordered list item prefix
13
+ const unorderedListPrefix = /^[>\s]*[-+*]$/;
14
+
12
15
  /**
13
16
  * Adds a RuleOnErrorInfo object to a list of RuleOnErrorInfo objects.
14
17
  *
15
18
  * @param {RuleOnErrorInfo[]} errors List of errors.
19
+ * @param {readonly string[]} lines File/string lines.
16
20
  * @param {number} lineNumber Line number.
17
21
  * @param {number} column Column number.
18
22
  * @param {string} detail Detail message.
19
23
  * @param {RuleOnErrorFixInfo} [fixInfo] Fix information.
24
+ * @returns {void}
20
25
  */
21
- function addError(errors, lineNumber, column, detail, fixInfo) {
26
+ function addError(errors, lines, lineNumber, column, detail, fixInfo) {
27
+ if (
28
+ fixInfo &&
29
+ (fixInfo.insertText === " ") &&
30
+ fixInfo.editColumn &&
31
+ unorderedListPrefix.test(lines[lineNumber - 1].slice(0, fixInfo.editColumn - 1))
32
+ ) {
33
+ // Do not apply edits that would change a table cell into an unordered list item
34
+ fixInfo = undefined;
35
+ }
22
36
  errors.push({
23
37
  lineNumber,
24
38
  detail,
@@ -70,7 +84,7 @@ function checkStyleAligned(lines, rows, detail) {
70
84
  const rowDividerColumns = getTableDividerColumns(lines, row);
71
85
  for (const dividerColumn of rowDividerColumns) {
72
86
  if ((remainingHeaderDividerColumns.size > 0) && !remainingHeaderDividerColumns.delete(dividerColumn.effective)) {
73
- addError(errorInfos, row.startLine, dividerColumn.actual, detail);
87
+ addError(errorInfos, lines, row.startLine, dividerColumn.actual, detail);
74
88
  }
75
89
  }
76
90
  }
@@ -128,6 +142,7 @@ export default {
128
142
  if (previous.text.length !== 1) {
129
143
  addError(
130
144
  errorsIfCompact,
145
+ lines,
131
146
  startLine,
132
147
  startColumn,
133
148
  "Table pipe has extra space to the left for style \"compact\"",
@@ -136,6 +151,7 @@ export default {
136
151
  }
137
152
  addError(
138
153
  errorsIfTight,
154
+ lines,
139
155
  startLine,
140
156
  startColumn,
141
157
  "Table pipe has space to the left for style \"tight\"",
@@ -144,6 +160,7 @@ export default {
144
160
  } else {
145
161
  addError(
146
162
  errorsIfCompact,
163
+ lines,
147
164
  startLine,
148
165
  startColumn,
149
166
  "Table pipe is missing space to the left for style \"compact\"",
@@ -158,6 +175,7 @@ export default {
158
175
  if (next.text.length !== 1) {
159
176
  addError(
160
177
  errorsIfCompact,
178
+ lines,
161
179
  startLine,
162
180
  startColumn,
163
181
  "Table pipe has extra space to the right for style \"compact\"",
@@ -166,6 +184,7 @@ export default {
166
184
  }
167
185
  addError(
168
186
  errorsIfTight,
187
+ lines,
169
188
  startLine,
170
189
  startColumn,
171
190
  "Table pipe has space to the right for style \"tight\"",
@@ -175,6 +194,7 @@ export default {
175
194
  } else {
176
195
  addError(
177
196
  errorsIfCompact,
197
+ lines,
178
198
  startLine,
179
199
  startColumn,
180
200
  "Table pipe is missing space to the right for style \"compact\"",
@@ -191,7 +211,7 @@ export default {
191
211
  let errorInfos = errorsIfAligned;
192
212
  if (
193
213
  styleCompactAllowed &&
194
- ((errorsIfCompact.length < errorInfos.length) || !styleAlignedAllowed)
214
+ (!styleAlignedAllowed || (errorsIfCompact.length < errorInfos.length))
195
215
  ) {
196
216
  errorInfos = errorsIfCompact;
197
217
  }
@@ -19,7 +19,7 @@ import { flatTokensSymbol, htmlFlowSymbol, newlineRe } from "../helpers/shared.c
19
19
  /** @typedef {import("micromark-util-types").Token} Token */
20
20
  /** @typedef {import("micromark-util-types").Tokenizer} Tokenizer */
21
21
  /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
22
- /** @typedef {import("./micromark-types.d.mts")} */
22
+ /** @typedef {typeof import("./micromark-types.d.mts")} _ambient_ */
23
23
 
24
24
  /**
25
25
  * Gets a modified micromark-extension-directive without support for inline directives.
@@ -297,9 +297,10 @@ function parseInternal(
297
297
  current
298
298
  );
299
299
  current.children = tokens;
300
+ // eslint-disable-next-line unicorn/comment-content
300
301
  // Avoid stack overflow of Array.push(...spread)
301
302
  // @ts-ignore
302
- // eslint-disable-next-line unicorn/prefer-spread
303
+ // eslint-disable-next-line unicorn/no-array-concat-in-loop
303
304
  flatTokens = flatTokens.concat(tokens[flatTokensSymbol]);
304
305
  }
305
306
  } else if (kind === "exit") {
@@ -3,9 +3,10 @@
3
3
  "use strict";
4
4
 
5
5
  // Captures the native require implementation (even under webpack).
6
+ /* node:coverage ignore next 3 */
6
7
  // @ts-ignore
7
- // eslint-disable-next-line no-underscore-dangle
8
- const nativeRequire = globalThis.__non_webpack_require__ ?? require;
8
+ // eslint-disable-next-line camelcase, no-undef
9
+ const nativeRequire = (typeof __non_webpack_require__ === "undefined") ? require : __non_webpack_require__;
9
10
 
10
11
  /**
11
12
  * @typedef RequireResolveOptions
@@ -1,18 +1,15 @@
1
+ declare const _exports: {
2
+ resolveModule: typeof resolveModule;
3
+ resolveModuleCustomResolve: typeof resolveModuleCustomResolve;
4
+ };
5
+ export = _exports;
1
6
  export type RequireResolveOptions = {
2
7
  /**
3
8
  * Additional paths to resolve from.
4
9
  */
5
- paths?: string[] | undefined;
10
+ paths?: string[];
6
11
  };
7
12
  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
13
  /**
17
14
  * @typedef RequireResolveOptions
18
15
  * @property {string[]} [paths] Additional paths to resolve from.
@@ -31,4 +28,12 @@ export function resolveModule(id: string, paths?: string[]): string;
31
28
  * @param {string[]} [paths] Additional paths to resolve from.
32
29
  * @returns {string} Resolved module path.
33
30
  */
34
- export function resolveModuleCustomResolve(resolve: RequireResolve, id: string, paths?: string[]): string;
31
+ declare const resolveModuleCustomResolve: (resolve: RequireResolve, id: string, paths?: string[]) => string;
32
+ /**
33
+ * Resolves modules according to Node's resolution rules.
34
+ *
35
+ * @param {string} id Module name or path.
36
+ * @param {string[]} [paths] Additional paths to resolve from.
37
+ * @returns {string} Resolved module path.
38
+ */
39
+ declare const resolveModule: (id: string, paths?: string[]) => string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "markdownlint",
3
- "version": "0.41.0",
4
- "description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
3
+ "version": "0.42.0",
4
+ "description": "A Node.js style checker and lint tool for Markdown/CommonMark files",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./lib/exports.mjs",
@@ -26,21 +26,16 @@
26
26
  "author": "David Anson (https://dlaa.me/)",
27
27
  "license": "MIT",
28
28
  "homepage": "https://github.com/DavidAnson/markdownlint",
29
- "repository": {
30
- "type": "git",
31
- "url": "git+https://github.com/DavidAnson/markdownlint.git"
32
- },
33
- "bugs": "https://github.com/DavidAnson/markdownlint/issues",
29
+ "repository": "github:DavidAnson/markdownlint",
34
30
  "funding": "https://github.com/sponsors/DavidAnson",
35
31
  "scripts": {
36
32
  "build-config": "npm run build-config-schema && npm run build-config-example",
37
33
  "build-config-example": "node schema/build-config-example.mjs",
38
34
  "build-config-schema": "node schema/build-config-schema.mjs",
39
35
  "build-declaration": "tsc --project ./declaration/tsconfig.json && 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
- "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",
36
+ "build-demo": "node scripts/index.mjs copy node_modules/markdown-it/dist/browser/markdown-it.umd.min.js demo/markdown-it.umd.min.js && cd demo && webpack --no-stats",
41
37
  "build-docs": "node doc-build/build-rules.mjs",
42
- "ci": "concurrently npm:build-demo npm:lint npm:serial-config-docs npm:serial-declaration npm:test && git diff --exit-code && echo PASS",
43
- "clone-test-repos-apache-airflow": "cd test-repos && git clone https://github.com/apache/airflow apache-airflow --depth 1 --no-tags --quiet",
38
+ "ci": "concurrently npm:build-demo npm:lint npm:serial-config-docs npm:serial-declaration npm:test npm:test-webpack && git diff --exit-code && echo PASS",
44
39
  "clone-test-repos-dotnet-docs": "cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet",
45
40
  "clone-test-repos-electron-electron": "cd test-repos && git clone https://github.com/electron/electron electron-electron --depth 1 --no-tags --quiet && cd electron-electron && node ../../scripts/index.mjs delete package.json && npm install --no-save --ignore-scripts @electron/lint-roller",
46
41
  "clone-test-repos-eslint-eslint": "cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet",
@@ -51,9 +46,9 @@
51
46
  "clone-test-repos-v8-v8-dev": "cd test-repos && git clone https://github.com/v8/v8.dev v8-v8-dev --depth 1 --no-tags --quiet",
52
47
  "clone-test-repos-webhintio-hint": "cd test-repos && git clone https://github.com/webhintio/hint webhintio-hint --depth 1 --no-tags --quiet",
53
48
  "clone-test-repos-webpack-webpack-js-org": "cd test-repos && git clone https://github.com/webpack/webpack.js.org webpack-webpack-js-org --depth 1 --no-tags --quiet",
54
- "clone-test-repos": "mkdir test-repos && cd test-repos && npm run clone-test-repos-apache-airflow && npm run clone-test-repos-dotnet-docs && npm run clone-test-repos-electron-electron && npm run clone-test-repos-eslint-eslint && npm run clone-test-repos-mdn-content && npm run clone-test-repos-mkdocs-mkdocs && npm run clone-test-repos-mochajs-mocha && npm run clone-test-repos-pi-hole-docs && npm run clone-test-repos-v8-v8-dev && npm run clone-test-repos-webhintio-hint && npm run clone-test-repos-webpack-webpack-js-org",
49
+ "clone-test-repos": "mkdir test-repos && cd test-repos && npm run clone-test-repos-dotnet-docs && npm run clone-test-repos-electron-electron && npm run clone-test-repos-eslint-eslint && npm run clone-test-repos-mdn-content && npm run clone-test-repos-mkdocs-mkdocs && npm run clone-test-repos-mochajs-mocha && npm run clone-test-repos-pi-hole-docs && npm run clone-test-repos-v8-v8-dev && npm run clone-test-repos-webhintio-hint && npm run clone-test-repos-webpack-webpack-js-org",
55
50
  "example": "cd example && node standalone.mjs",
56
- "lint": "eslint --max-warnings 0",
51
+ "lint": "cross-env RECHECK_BACKEND=pure eslint --max-warnings 0",
57
52
  "lint-test-repos": "node --test test/markdownlint-test-repos-*.mjs",
58
53
  "serial-config-docs": "npm run build-config && npm run build-docs",
59
54
  "serial-declaration": "npm run build-declaration && npm run test-declaration",
@@ -62,6 +57,7 @@
62
57
  "test-declaration-cts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-commonjs.cts && tsc --project tsconfig.cts.json",
63
58
  "test-declaration-mts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-nodenext.mts && tsc --project tsconfig.mts.json && node type-check-nodenext.mjs",
64
59
  "test-extra": "node --test test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
60
+ "test-webpack": "cd test && node resolve-module-webpack.mjs && webpack --entry ./resolve-module-webpack.mjs --output-path . --output-filename resolve-module-webpack.cjs --stats errors-only && node resolve-module-webpack.cjs",
65
61
  "update-snapshots": "node --test --test-update-snapshots test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs",
66
62
  "update-snapshots-test-repos": "node --test --test-update-snapshots test/markdownlint-test-repos-*.mjs",
67
63
  "update-test-repos": "node scripts/index.mjs remove ./test-repos && npm run clone-test-repos && npm run update-snapshots-test-repos"
@@ -70,51 +66,54 @@
70
66
  "node": ">=22"
71
67
  },
72
68
  "dependencies": {
73
- "micromark": "4.0.2",
74
- "micromark-core-commonmark": "2.0.3",
69
+ "micromark-core-commonmark": "2.0.4",
75
70
  "micromark-extension-directive": "4.0.0",
76
71
  "micromark-extension-gfm-autolink-literal": "2.1.0",
77
72
  "micromark-extension-gfm-footnote": "2.1.0",
78
- "micromark-extension-gfm-table": "2.1.1",
73
+ "micromark-extension-gfm-table": "2.1.2",
79
74
  "micromark-extension-math": "3.1.0",
80
- "micromark-util-types": "2.0.2",
81
- "string-width": "8.2.1"
75
+ "micromark-util-types": "2.0.3",
76
+ "micromark": "4.0.3",
77
+ "re2js": "2.8.6",
78
+ "string-width": "8.3.0"
82
79
  },
83
80
  "devDependencies": {
84
81
  "@eslint/js": "10.0.1",
85
82
  "@stylistic/eslint-plugin": "5.10.0",
86
- "@types/markdown-it": "14.1.2",
87
83
  "ajv": "8.20.0",
88
84
  "character-entities": "2.0.2",
89
- "concurrently": "10.0.3",
90
- "eslint": "10.4.1",
91
- "eslint-plugin-jsdoc": "63.0.2",
92
- "eslint-plugin-n": "18.1.0",
93
- "eslint-plugin-regexp": "3.1.0",
94
- "eslint-plugin-unicorn": "65.0.1",
85
+ "concurrently": "10.0.5",
86
+ "cross-env": "10.1.0",
87
+ "eslint-node-test": "1.0.1",
88
+ "eslint-package-json": "2.0.0",
89
+ "eslint-plugin-jsdoc": "65.1.0",
90
+ "eslint-plugin-n": "18.4.1",
91
+ "eslint-plugin-redos": "4.5.0",
92
+ "eslint-plugin-regexp": "3.3.1",
93
+ "eslint-plugin-unicorn": "77.0.0",
94
+ "eslint": "10.12.0",
95
95
  "gemoji": "8.1.0",
96
- "globby": "16.2.0",
97
- "js-yaml": "4.2.0",
98
- "json-schema-to-typescript": "15.0.4",
96
+ "globby": "16.2.4",
97
+ "js-yaml": "5.4.2",
98
+ "json-schema-to-typescript": "16.0.0",
99
99
  "json-stringify-safe": "5.0.1",
100
100
  "jsonc-parser": "3.3.1",
101
- "markdown-it": "14.2.0",
102
101
  "markdown-it-for-inline": "2.0.1",
103
102
  "markdown-it-sub": "2.0.0",
104
103
  "markdown-it-sup": "2.0.0",
104
+ "markdown-it": "15.0.2",
105
105
  "markdownlint-rule-extended-ascii": "0.2.1",
106
106
  "nano-spawn": "2.1.0",
107
+ "smol-toml": "1.9.0",
107
108
  "terser-webpack-plugin": "5.6.1",
108
- "toml": "4.1.1",
109
- "typescript": "6.0.3",
110
- "webpack": "5.107.2",
111
- "webpack-cli": "7.0.3"
109
+ "typescript": "7.0.2",
110
+ "webpack-cli": "7.2.3",
111
+ "webpack": "5.111.1"
112
112
  },
113
113
  "keywords": [
114
114
  "markdown",
115
115
  "lint",
116
116
  "md",
117
- "CommonMark",
118
- "markdownlint"
117
+ "commonmark"
119
118
  ]
120
119
  }