markdownlint 0.40.0 → 0.41.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/lib/md060.mjs CHANGED
@@ -7,6 +7,7 @@ import stringWidth from "string-width";
7
7
  /** @typedef {import("micromark-extension-gfm-table")} */
8
8
  /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
9
9
  /** @typedef {import("markdownlint").RuleOnErrorInfo} RuleOnErrorInfo */
10
+ /** @typedef {import("markdownlint").RuleOnErrorFixInfo} RuleOnErrorFixInfo */
10
11
 
11
12
  /**
12
13
  * Adds a RuleOnErrorInfo object to a list of RuleOnErrorInfo objects.
@@ -15,12 +16,14 @@ import stringWidth from "string-width";
15
16
  * @param {number} lineNumber Line number.
16
17
  * @param {number} column Column number.
17
18
  * @param {string} detail Detail message.
19
+ * @param {RuleOnErrorFixInfo} [fixInfo] Fix information.
18
20
  */
19
- function addError(errors, lineNumber, column, detail) {
21
+ function addError(errors, lineNumber, column, detail, fixInfo) {
20
22
  errors.push({
21
23
  lineNumber,
22
24
  detail,
23
- "range": [ column, 1 ]
25
+ "range": [ column, 1 ],
26
+ fixInfo
24
27
  });
25
28
  }
26
29
 
@@ -123,11 +126,29 @@ export default {
123
126
  if (previous) {
124
127
  if (previous.type === "whitespace") {
125
128
  if (previous.text.length !== 1) {
126
- addError(errorsIfCompact, startLine, startColumn, "Table pipe has extra space to the left for style \"compact\"");
129
+ addError(
130
+ errorsIfCompact,
131
+ startLine,
132
+ startColumn,
133
+ "Table pipe has extra space to the left for style \"compact\"",
134
+ { "editColumn": previous.startColumn, "deleteCount": previous.text.length - 1 }
135
+ );
127
136
  }
128
- addError(errorsIfTight, startLine, startColumn, "Table pipe has space to the left for style \"tight\"");
137
+ addError(
138
+ errorsIfTight,
139
+ startLine,
140
+ startColumn,
141
+ "Table pipe has space to the left for style \"tight\"",
142
+ { "editColumn": previous.startColumn, "deleteCount": previous.text.length }
143
+ );
129
144
  } else {
130
- addError(errorsIfCompact, startLine, startColumn, "Table pipe is missing space to the left for style \"compact\"");
145
+ addError(
146
+ errorsIfCompact,
147
+ startLine,
148
+ startColumn,
149
+ "Table pipe is missing space to the left for style \"compact\"",
150
+ { "editColumn": previous.endColumn, "insertText": " " }
151
+ );
131
152
  }
132
153
  }
133
154
  const next = tokensOfInterest[i + 1];
@@ -135,12 +156,30 @@ export default {
135
156
  if (next.type === "whitespace") {
136
157
  if (next.endColumn !== row.endColumn) {
137
158
  if (next.text.length !== 1) {
138
- addError(errorsIfCompact, startLine, startColumn, "Table pipe has extra space to the right for style \"compact\"");
159
+ addError(
160
+ errorsIfCompact,
161
+ startLine,
162
+ startColumn,
163
+ "Table pipe has extra space to the right for style \"compact\"",
164
+ { "editColumn": next.startColumn, "deleteCount": next.text.length - 1 }
165
+ );
139
166
  }
140
- addError(errorsIfTight, startLine, startColumn, "Table pipe has space to the right for style \"tight\"");
167
+ addError(
168
+ errorsIfTight,
169
+ startLine,
170
+ startColumn,
171
+ "Table pipe has space to the right for style \"tight\"",
172
+ { "editColumn": next.startColumn, "deleteCount": next.text.length }
173
+ );
141
174
  }
142
175
  } else {
143
- addError(errorsIfCompact, startLine, startColumn, "Table pipe is missing space to the right for style \"compact\"");
176
+ addError(
177
+ errorsIfCompact,
178
+ startLine,
179
+ startColumn,
180
+ "Table pipe is missing space to the right for style \"compact\"",
181
+ { "editColumn": next.startColumn, "insertText": " " }
182
+ );
144
183
  }
145
184
  }
146
185
  }
@@ -10,9 +10,10 @@ import { parse as micromarkParse, postprocess as micromarkPostprocess, preproces
10
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
- import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "../helpers/shared.cjs";
13
+ import { flatTokensSymbol, htmlFlowSymbol, newlineRe } from "../helpers/shared.cjs";
14
14
 
15
15
  /** @typedef {import("micromark-util-types").Event} Event */
16
+ /** @typedef {import("micromark-util-types").Extension} Extension */
16
17
  /** @typedef {import("micromark-util-types").ParseOptions} MicromarkParseOptions */
17
18
  /** @typedef {import("micromark-util-types").State} State */
18
19
  /** @typedef {import("micromark-util-types").Token} Token */
@@ -20,6 +21,20 @@ import { flatTokensSymbol, htmlFlowSymbol, newLineRe } from "../helpers/shared.c
20
21
  /** @typedef {import("markdownlint").MicromarkToken} MicromarkToken */
21
22
  /** @typedef {import("./micromark-types.d.mts")} */
22
23
 
24
+ /**
25
+ * Gets a modified micromark-extension-directive without support for inline directives.
26
+ *
27
+ * @see {@link https://github.com/DavidAnson/markdownlint/issues/2080}
28
+ * @returns {Extension} Modified implementation.
29
+ */
30
+ function directiveNoInline() {
31
+ const extension = {
32
+ ...directive()
33
+ };
34
+ delete extension.text;
35
+ return extension;
36
+ }
37
+
23
38
  /**
24
39
  * Gets the Markdown text for a Micromark token.
25
40
  *
@@ -51,7 +66,7 @@ export function getEvents(
51
66
  ) {
52
67
  // Customize extensions list to add useful extensions
53
68
  const extensions = [
54
- directive(),
69
+ directiveNoInline(),
55
70
  gfmAutolinkLiteral(),
56
71
  gfmFootnote(),
57
72
  gfmTable(),
@@ -66,7 +81,7 @@ export function getEvents(
66
81
 
67
82
  /** @type {Tokenizer} */
68
83
  function tokenizeShim(effects, okOriginal, nokOriginal) {
69
- // eslint-disable-next-line consistent-this, unicorn/no-this-assignment, no-invalid-this
84
+ // eslint-disable-next-line consistent-this, no-invalid-this, unicorn/no-this-assignment, unicorn/no-this-outside-of-class
70
85
  const tokenizeContext = this;
71
86
  const events = tokenizeContext.events;
72
87
 
@@ -269,7 +284,7 @@ function parseInternal(
269
284
  }
270
285
  ]
271
286
  };
272
- lines = markdown.split(newLineRe);
287
+ lines = markdown.split(newlineRe);
273
288
  }
274
289
  const reparseMarkdown = lines
275
290
  .slice(current.startLine - 1, current.endLine)
@@ -2,10 +2,10 @@
2
2
 
3
3
  "use strict";
4
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
5
  // Captures the native require implementation (even under webpack).
6
+ // @ts-ignore
7
+ // eslint-disable-next-line no-underscore-dangle
8
+ const nativeRequire = globalThis.__non_webpack_require__ ?? require;
9
9
 
10
10
  /**
11
11
  * @typedef RequireResolveOptions
@@ -2,7 +2,7 @@ export type RequireResolveOptions = {
2
2
  /**
3
3
  * Additional paths to resolve from.
4
4
  */
5
- paths?: string[];
5
+ paths?: string[] | undefined;
6
6
  };
7
7
  export type RequireResolve = (id: string, options: RequireResolveOptions) => string;
8
8
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdownlint",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -36,10 +36,10 @@
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 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",
39
+ "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
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
- "ci": "npm-run-all --continue-on-error --parallel build-demo lint serial-config-docs serial-declaration test-cover && git diff --exit-code",
42
+ "ci": "concurrently npm:build-demo npm:lint npm:serial-config-docs npm:serial-declaration npm:test && git diff --exit-code && echo PASS",
43
43
  "clone-test-repos-apache-airflow": "cd test-repos && git clone https://github.com/apache/airflow apache-airflow --depth 1 --no-tags --quiet",
44
44
  "clone-test-repos-dotnet-docs": "cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet",
45
45
  "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",
@@ -52,25 +52,22 @@
52
52
  "clone-test-repos-webhintio-hint": "cd test-repos && git clone https://github.com/webhintio/hint webhintio-hint --depth 1 --no-tags --quiet",
53
53
  "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
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",
55
- "declaration": "npm run build-declaration && npm run test-declaration",
56
55
  "example": "cd example && node standalone.mjs",
57
56
  "lint": "eslint --max-warnings 0",
58
- "lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos-*.mjs",
57
+ "lint-test-repos": "node --test test/markdownlint-test-repos-*.mjs",
59
58
  "serial-config-docs": "npm run build-config && npm run build-docs",
60
59
  "serial-declaration": "npm run build-declaration && npm run test-declaration",
61
- "test": "ava --timeout=30s test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-project.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs test/parse-configuration-test.mjs test/resolve-module-test.mjs helpers/test.cjs",
62
- "test-cover": "c8 --100 npm test",
63
- "test-declaration": "npm-run-all --continue-on-error --parallel test-declaration-cts test-declaration-mts",
64
- "test-declaration-cts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-commonjs.cts && tsc --module commonjs --esModuleInterop type-check-commonjs.cts",
65
- "test-declaration-mts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-nodenext.mts && tsc --module nodenext type-check-nodenext.mts && node type-check-nodenext.mjs",
66
- "test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
67
- "update-snapshots": "ava --update-snapshots test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.mjs",
68
- "update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.mjs",
69
- "update-test-repos": "node scripts/index.mjs remove ./test-repos && npm run clone-test-repos && npm run update-snapshots-test-repos",
70
- "upgrade": "npx --yes npm-check-updates --upgrade"
60
+ "test": "node --test --experimental-test-coverage --test-coverage-branches=100 --test-coverage-functions=100 --test-coverage-lines=100 --test-coverage-exclude=test/**/* test/markdownlint-test.mjs test/markdownlint-test-config.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-fixes.mjs test/markdownlint-test-helpers.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-project.mjs test/markdownlint-test-result-object.mjs test/markdownlint-test-scenarios.mjs test/parse-configuration-test.mjs test/resolve-module-test.mjs helpers/test.cjs",
61
+ "test-declaration": "concurrently npm:test-declaration-cts npm:test-declaration-mts",
62
+ "test-declaration-cts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-commonjs.cts && tsc --project tsconfig.cts.json",
63
+ "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
+ "test-extra": "node --test test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
65
+ "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
+ "update-snapshots-test-repos": "node --test --test-update-snapshots test/markdownlint-test-repos-*.mjs",
67
+ "update-test-repos": "node scripts/index.mjs remove ./test-repos && npm run clone-test-repos && npm run update-snapshots-test-repos"
71
68
  },
72
69
  "engines": {
73
- "node": ">=20"
70
+ "node": ">=22"
74
71
  },
75
72
  "dependencies": {
76
73
  "micromark": "4.0.2",
@@ -81,37 +78,37 @@
81
78
  "micromark-extension-gfm-table": "2.1.1",
82
79
  "micromark-extension-math": "3.1.0",
83
80
  "micromark-util-types": "2.0.2",
84
- "string-width": "8.1.0"
81
+ "string-width": "8.2.1"
85
82
  },
86
83
  "devDependencies": {
87
- "@eslint/js": "9.39.1",
88
- "@stylistic/eslint-plugin": "5.6.1",
89
- "ajv": "8.17.1",
90
- "ava": "6.4.1",
91
- "c8": "10.1.3",
84
+ "@eslint/js": "10.0.1",
85
+ "@stylistic/eslint-plugin": "5.10.0",
86
+ "@types/markdown-it": "14.1.2",
87
+ "ajv": "8.20.0",
92
88
  "character-entities": "2.0.2",
93
- "eslint": "9.39.1",
94
- "eslint-plugin-jsdoc": "61.4.1",
95
- "eslint-plugin-n": "17.23.1",
96
- "eslint-plugin-regexp": "2.10.0",
97
- "eslint-plugin-unicorn": "62.0.0",
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",
98
95
  "gemoji": "8.1.0",
99
- "globby": "16.0.0",
100
- "js-yaml": "4.1.1",
96
+ "globby": "16.2.0",
97
+ "js-yaml": "4.2.0",
101
98
  "json-schema-to-typescript": "15.0.4",
99
+ "json-stringify-safe": "5.0.1",
102
100
  "jsonc-parser": "3.3.1",
103
- "markdown-it": "14.1.0",
101
+ "markdown-it": "14.2.0",
104
102
  "markdown-it-for-inline": "2.0.1",
105
103
  "markdown-it-sub": "2.0.0",
106
104
  "markdown-it-sup": "2.0.0",
107
105
  "markdownlint-rule-extended-ascii": "0.2.1",
108
- "nano-spawn": "2.0.0",
109
- "npm-run-all": "4.1.5",
110
- "terser-webpack-plugin": "5.3.14",
111
- "toml": "3.0.0",
112
- "typescript": "5.9.3",
113
- "webpack": "5.103.0",
114
- "webpack-cli": "6.0.1"
106
+ "nano-spawn": "2.1.0",
107
+ "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"
115
112
  },
116
113
  "keywords": [
117
114
  "markdown",
@@ -120,4 +117,4 @@
120
117
  "CommonMark",
121
118
  "markdownlint"
122
119
  ]
123
- }
120
+ }