markdownlint 0.26.2 → 0.28.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 (95) hide show
  1. package/CHANGELOG.md +378 -0
  2. package/CONTRIBUTING.md +82 -59
  3. package/LICENSE +1 -1
  4. package/README.md +304 -305
  5. package/demo/markdownlint-browser.js +4973 -3379
  6. package/doc/CustomRules.md +99 -51
  7. package/doc/Prettier.md +14 -10
  8. package/doc/ReleaseProcess.md +20 -0
  9. package/doc/Rules.md +474 -311
  10. package/doc/md001.md +37 -0
  11. package/doc/md002.md +37 -0
  12. package/doc/md003.md +59 -0
  13. package/doc/md004.md +49 -0
  14. package/doc/md005.md +53 -0
  15. package/doc/md006.md +46 -0
  16. package/doc/md007.md +55 -0
  17. package/doc/md009.md +51 -0
  18. package/doc/md010.md +56 -0
  19. package/doc/md011.md +30 -0
  20. package/doc/md012.md +38 -0
  21. package/doc/md013.md +60 -0
  22. package/doc/md014.md +54 -0
  23. package/doc/md018.md +27 -0
  24. package/doc/md019.md +28 -0
  25. package/doc/md020.md +29 -0
  26. package/doc/md021.md +31 -0
  27. package/doc/md022.md +46 -0
  28. package/doc/md023.md +26 -0
  29. package/doc/md024.md +47 -0
  30. package/doc/md025.md +49 -0
  31. package/doc/md026.md +41 -0
  32. package/doc/md027.md +24 -0
  33. package/doc/md028.md +40 -0
  34. package/doc/md029.md +98 -0
  35. package/doc/md030.md +82 -0
  36. package/doc/md031.md +50 -0
  37. package/doc/md032.md +38 -0
  38. package/doc/md033.md +27 -0
  39. package/doc/md034.md +50 -0
  40. package/doc/md035.md +42 -0
  41. package/doc/md036.md +45 -0
  42. package/doc/md037.md +37 -0
  43. package/doc/md038.md +40 -0
  44. package/doc/md039.md +21 -0
  45. package/doc/md040.md +52 -0
  46. package/doc/md041.md +49 -0
  47. package/doc/md042.md +32 -0
  48. package/doc/md043.md +72 -0
  49. package/doc/md044.md +35 -0
  50. package/doc/md045.md +34 -0
  51. package/doc/md046.md +40 -0
  52. package/doc/md047.md +34 -0
  53. package/doc/md048.md +41 -0
  54. package/doc/md049.md +32 -0
  55. package/doc/md050.md +32 -0
  56. package/doc/md051.md +50 -0
  57. package/doc/md052.md +33 -0
  58. package/doc/md053.md +38 -0
  59. package/helpers/LICENSE +1 -1
  60. package/helpers/README.md +35 -15
  61. package/helpers/helpers.js +182 -162
  62. package/helpers/micromark.cjs +209 -0
  63. package/helpers/package.json +5 -2
  64. package/lib/constants.js +8 -1
  65. package/lib/markdownlint.d.ts +5 -5
  66. package/lib/markdownlint.js +46 -24
  67. package/lib/md002.js +1 -1
  68. package/lib/md011.js +2 -2
  69. package/lib/md013.js +7 -6
  70. package/lib/md019.js +1 -1
  71. package/lib/md022.js +15 -3
  72. package/lib/md023.js +1 -1
  73. package/lib/md026.js +1 -1
  74. package/lib/md027.js +1 -1
  75. package/lib/md028.js +1 -1
  76. package/lib/md033.js +47 -29
  77. package/lib/md034.js +54 -47
  78. package/lib/md035.js +9 -11
  79. package/lib/md036.js +1 -1
  80. package/lib/md037.js +2 -2
  81. package/lib/md038.js +81 -56
  82. package/lib/md039.js +1 -1
  83. package/lib/md040.js +21 -2
  84. package/lib/md041.js +1 -1
  85. package/lib/md043.js +4 -2
  86. package/lib/md044.js +58 -43
  87. package/lib/md046.js +1 -1
  88. package/lib/md048.js +3 -1
  89. package/lib/md051.js +37 -5
  90. package/lib/rules.js +1 -1
  91. package/package.json +43 -28
  92. package/schema/.markdownlint.jsonc +11 -4
  93. package/schema/.markdownlint.yaml +11 -6
  94. package/schema/markdownlint-config-schema.json +27 -3
  95. package/style/prettier.json +26 -0
package/lib/md046.js CHANGED
@@ -15,7 +15,7 @@ module.exports = {
15
15
  "tags": [ "code" ],
16
16
  "function": function MD046(params, onError) {
17
17
  let expectedStyle = String(params.config.style || "consistent");
18
- const codeBlocksAndFences = params.tokens.filter(
18
+ const codeBlocksAndFences = params.parsers.markdownit.tokens.filter(
19
19
  (token) => (token.type === "code_block") || (token.type === "fence")
20
20
  );
21
21
  for (const token of codeBlocksAndFences) {
package/lib/md048.js CHANGED
@@ -11,7 +11,9 @@ module.exports = {
11
11
  "function": function MD048(params, onError) {
12
12
  const style = String(params.config.style || "consistent");
13
13
  let expectedStyle = style;
14
- const fenceTokens = params.tokens.filter((token) => token.type === "fence");
14
+ const fenceTokens = params.parsers.markdownit.tokens.filter(
15
+ (token) => token.type === "fence"
16
+ );
15
17
  for (const fenceToken of fenceTokens) {
16
18
  const { lineNumber, markup } = fenceToken;
17
19
  if (expectedStyle === "consistent") {
package/lib/md051.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  "use strict";
4
4
 
5
- const { addError, escapeForRegExp, filterTokens, forEachInlineChild,
6
- forEachHeading, htmlElementRe } = require("../helpers");
5
+ const { addError, addErrorDetailIf, escapeForRegExp, filterTokens,
6
+ forEachInlineChild, forEachHeading, htmlElementRe } = require("../helpers");
7
7
 
8
8
  // Regular expression for identifying HTML anchor names
9
9
  const idRe = /\sid\s*=\s*['"]?([^'"\s>]+)/iu;
@@ -73,14 +73,46 @@ module.exports = {
73
73
  if (id && (id.length > 1) && (id[0] === "#") && !fragments.has(id)) {
74
74
  let context = id;
75
75
  let range = null;
76
+ let fixInfo = null;
76
77
  const match = line.match(
77
78
  new RegExp(`\\[.*?\\]\\(${escapeForRegExp(context)}\\)`)
78
79
  );
79
80
  if (match) {
80
- context = match[0];
81
- range = [ match.index + 1, match[0].length ];
81
+ [ context ] = match;
82
+ const index = match.index;
83
+ const length = context.length;
84
+ range = [ index + 1, length ];
85
+ fixInfo = {
86
+ "editColumn": index + (length - id.length),
87
+ "deleteCount": id.length,
88
+ "insertText": null
89
+ };
90
+ }
91
+ const idLower = id.toLowerCase();
92
+ const mixedCaseKey = [ ...fragments.keys() ]
93
+ .find((key) => idLower === key.toLowerCase());
94
+ if (mixedCaseKey) {
95
+ (fixInfo || {}).insertText = mixedCaseKey;
96
+ addErrorDetailIf(
97
+ onError,
98
+ lineNumber,
99
+ mixedCaseKey,
100
+ id,
101
+ undefined,
102
+ context,
103
+ range,
104
+ fixInfo
105
+ );
106
+ } else {
107
+ addError(
108
+ onError,
109
+ lineNumber,
110
+ undefined,
111
+ context,
112
+ // @ts-ignore
113
+ range
114
+ );
82
115
  }
83
- addError(onError, lineNumber, undefined, context, range);
84
116
  }
85
117
  });
86
118
  }
package/lib/rules.js CHANGED
@@ -58,6 +58,6 @@ for (const rule of rules) {
58
58
  const name = rule.names[0].toLowerCase();
59
59
  // eslint-disable-next-line dot-notation
60
60
  rule["information"] =
61
- new URL(`${homepage}/blob/v${version}/doc/Rules.md#${name}`);
61
+ new URL(`${homepage}/blob/v${version}/doc/${name}.md`);
62
62
  }
63
63
  module.exports = rules;
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "markdownlint",
3
- "version": "0.26.2",
3
+ "version": "0.28.0",
4
4
  "description": "A Node.js style checker and lint tool for Markdown/CommonMark files.",
5
5
  "type": "commonjs",
6
6
  "main": "./lib/markdownlint.js",
7
7
  "exports": {
8
8
  ".": "./lib/markdownlint.js",
9
- "./helpers": "./helpers/helpers.js"
9
+ "./helpers": "./helpers/helpers.js",
10
+ "./style/all": "./style/all.json",
11
+ "./style/cirosantilli": "./style/cirosantilli.json",
12
+ "./style/prettier": "./style/prettier.json",
13
+ "./style/relaxed": "./style/relaxed.json"
10
14
  },
11
15
  "types": "./lib/markdownlint.d.ts",
12
16
  "author": "David Anson (https://dlaa.me/)",
@@ -21,64 +25,75 @@
21
25
  "build-config": "npm run build-config-schema && npm run build-config-example",
22
26
  "build-config-example": "node schema/build-config-example.js",
23
27
  "build-config-schema": "node schema/build-config-schema.js",
24
- "build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts delete 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'",
25
- "build-demo": "node scripts copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && cd demo && webpack --no-stats",
28
+ "build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --module commonjs --resolveJsonModule --target es2015 lib/markdownlint.js && node scripts delete 'lib/{c,md,r}*.d.ts' 'micromark/*.d.cts' 'helpers/*.d.{cts,ts}'",
29
+ "build-demo": "node scripts copy node_modules/markdown-it/dist/markdown-it.min.js demo/markdown-it.min.js && node scripts copy node_modules/markdownlint-micromark/micromark-browser.js demo/micromark-browser.js && cd demo && webpack --no-stats",
30
+ "build-docs": "node doc-build/build-rules.mjs",
26
31
  "build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
27
- "ci": "npm-run-all --continue-on-error --parallel build-config lint serial-declaration-demo test-cover && git diff --exit-code",
32
+ "build-micromark": "cd micromark && npm run build",
33
+ "ci": "npm-run-all --continue-on-error --parallel lint serial-config-docs serial-declaration-demo test-cover && git diff --exit-code",
34
+ "clone-test-repos-apache-airflow": "cd test-repos && git clone https://github.com/apache/airflow apache-airflow --depth 1 --no-tags --quiet",
28
35
  "clone-test-repos-dotnet-docs": "cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet",
36
+ "clone-test-repos-electron-electron": "cd test-repos && git clone https://github.com/electron/electron electron-electron --depth 1 --no-tags --quiet",
29
37
  "clone-test-repos-eslint-eslint": "cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet",
38
+ "clone-test-repos-mdn-content": "cd test-repos && git clone https://github.com/mdn/content mdn-content --depth 1 --no-tags --quiet",
39
+ "clone-test-repos-mdn-translated-content": "cd test-repos && git clone https://github.com/mdn/translated-content mdn-translated-content --depth 1 --no-tags --quiet",
30
40
  "clone-test-repos-mkdocs-mkdocs": "cd test-repos && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet",
31
41
  "clone-test-repos-mochajs-mocha": "cd test-repos && git clone https://github.com/mochajs/mocha mochajs-mocha --depth 1 --no-tags --quiet",
32
42
  "clone-test-repos-pi-hole-docs": "cd test-repos && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet",
33
43
  "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",
34
44
  "clone-test-repos-webhintio-hint": "cd test-repos && git clone https://github.com/webhintio/hint webhintio-hint --depth 1 --no-tags --quiet",
35
45
  "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",
36
- "clone-test-repos": "mkdir test-repos && cd test-repos && npm run clone-test-repos-eslint-eslint && 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-webhintio-hint && npm run clone-test-repos-webpack-webpack-js-org",
37
- "clone-test-repos-large": "npm run clone-test-repos && cd test-repos && npm run clone-test-repos-dotnet-docs && npm run clone-test-repos-v8-v8-dev",
46
+ "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-mdn-translated-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",
38
47
  "declaration": "npm run build-declaration && npm run test-declaration",
39
48
  "example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
40
49
  "docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm install",
41
50
  "docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm run upgrade",
42
- "lint": "eslint --max-warnings 0 .",
43
- "lint-test-repos": "ava --timeout=5m test/markdownlint-test-repos.js",
51
+ "lint": "eslint --ext .js,.cjs,.mjs --max-warnings 0 .",
52
+ "lint-test-repos": "ava --timeout=10m test/markdownlint-test-repos.js",
53
+ "serial-config-docs": "npm run build-config && npm run build-docs",
44
54
  "serial-declaration-demo": "npm run build-declaration && npm-run-all --continue-on-error --parallel build-demo test-declaration",
45
- "test": "ava test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js",
46
- "test-cover": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 npm test",
55
+ "test": "ava test/markdownlint-test.js test/markdownlint-test-config.js test/markdownlint-test-custom-rules.js test/markdownlint-test-helpers.js test/markdownlint-test-micromark.mjs test/markdownlint-test-result-object.js test/markdownlint-test-scenarios.js",
56
+ "test-cover": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --exclude 'test/**' --exclude 'micromark/**' npm test",
47
57
  "test-declaration": "cd example/typescript && tsc && node type-check.js",
48
58
  "test-extra": "ava --timeout=5m test/markdownlint-test-extra-parse.js test/markdownlint-test-extra-type.js",
49
- "update-snapshots": "ava --update-snapshots test/markdownlint-test-scenarios.js",
59
+ "update-snapshots": "ava --update-snapshots test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.js",
50
60
  "upgrade": "npx --yes npm-check-updates --upgrade"
51
61
  },
52
62
  "engines": {
53
- "node": ">=14"
63
+ "node": ">=14.18.0"
54
64
  },
55
65
  "dependencies": {
56
- "markdown-it": "13.0.1"
66
+ "markdown-it": "13.0.1",
67
+ "markdownlint-micromark": "0.1.2"
57
68
  },
58
69
  "devDependencies": {
59
- "ava": "4.3.0",
60
- "c8": "7.11.3",
61
- "eslint": "8.18.0",
70
+ "ava": "5.2.0",
71
+ "babel-loader": "9.1.2",
72
+ "@babel/core": "7.21.3",
73
+ "@babel/preset-env": "7.20.2",
74
+ "c8": "7.13.0",
75
+ "eslint": "8.36.0",
62
76
  "eslint-plugin-es": "4.1.0",
63
- "eslint-plugin-jsdoc": "39.3.3",
64
- "eslint-plugin-node": "11.1.0",
65
- "eslint-plugin-unicorn": "42.0.0",
66
- "globby": "13.1.2",
77
+ "eslint-plugin-jsdoc": "40.1.0",
78
+ "eslint-plugin-n": "15.6.1",
79
+ "eslint-plugin-regexp": "1.13.0",
80
+ "eslint-plugin-unicorn": "46.0.0",
81
+ "globby": "13.1.3",
67
82
  "js-yaml": "4.1.0",
68
83
  "markdown-it-for-inline": "0.1.1",
69
84
  "markdown-it-sub": "1.0.0",
70
85
  "markdown-it-sup": "1.0.0",
71
86
  "markdown-it-texmath": "1.0.0",
72
- "markdownlint-rule-github-internal-links": "0.1.0",
73
- "markdownlint-rule-helpers": "0.16.0",
87
+ "markdownlint-rule-helpers": "0.18.0",
74
88
  "npm-run-all": "4.1.5",
75
- "strip-json-comments": "4.0.0",
89
+ "strip-json-comments": "5.0.0",
90
+ "terser-webpack-plugin": "5.3.7",
76
91
  "toml": "3.0.0",
77
- "ts-loader": "9.3.0",
78
92
  "tv4": "1.3.0",
79
- "typescript": "4.7.4",
80
- "webpack": "5.73.0",
81
- "webpack-cli": "4.10.0"
93
+ "typescript": "5.0.2",
94
+ "webpack": "5.76.3",
95
+ "webpack-cli": "5.0.1",
96
+ "yaml": "2.2.1"
82
97
  },
83
98
  "keywords": [
84
99
  "markdown",
@@ -1,5 +1,5 @@
1
+ // Example markdownlint configuration with all properties set to their default value
1
2
  {
2
- // Example markdownlint JSON(C) configuration with all properties set to their default value
3
3
 
4
4
  // Default state for all rules
5
5
  "default": true,
@@ -139,7 +139,7 @@
139
139
 
140
140
  // MD026/no-trailing-punctuation - Trailing punctuation in heading
141
141
  "MD026": {
142
- // Punctuation characters
142
+ // Punctuation characters not allowed at end of headings
143
143
  "punctuation": ".,;:!。,;:!"
144
144
  },
145
145
 
@@ -207,7 +207,12 @@
207
207
  "MD039": true,
208
208
 
209
209
  // MD040/fenced-code-language - Fenced code blocks should have a language specified
210
- "MD040": true,
210
+ "MD040": {
211
+ // List of languages
212
+ "allowed_languages": [],
213
+ // Require language only
214
+ "language_only": false
215
+ },
211
216
 
212
217
  // MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
213
218
  "MD041": {
@@ -225,7 +230,9 @@
225
230
  // List of headings
226
231
  "headings": [],
227
232
  // List of headings
228
- "headers": []
233
+ "headers": [],
234
+ // Match case of headings
235
+ "match_case": false
229
236
  },
230
237
 
231
238
  // MD044/proper-names - Proper names should have the correct capitalization
@@ -1,4 +1,4 @@
1
- # Example markdownlint YAML configuration with all properties set to their default value
1
+ # Example markdownlint configuration with all properties set to their default value
2
2
 
3
3
  # Default state for all rules
4
4
  default: true
@@ -127,7 +127,7 @@ MD025:
127
127
 
128
128
  # MD026/no-trailing-punctuation - Trailing punctuation in heading
129
129
  MD026:
130
- # Punctuation characters
130
+ # Punctuation characters not allowed at end of headings
131
131
  punctuation: ".,;:!。,;:!"
132
132
 
133
133
  # MD027/no-multiple-space-blockquote - Multiple spaces after blockquote symbol
@@ -188,7 +188,11 @@ MD038: true
188
188
  MD039: true
189
189
 
190
190
  # MD040/fenced-code-language - Fenced code blocks should have a language specified
191
- MD040: true
191
+ MD040:
192
+ # List of languages
193
+ allowed_languages: []
194
+ # Require language only
195
+ language_only: false
192
196
 
193
197
  # MD041/first-line-heading/first-line-h1 - First line in a file should be a top-level heading
194
198
  MD041:
@@ -206,6 +210,8 @@ MD043:
206
210
  headings: []
207
211
  # List of headings
208
212
  headers: []
213
+ # Match case of headings
214
+ match_case: false
209
215
 
210
216
  # MD044/proper-names - Proper names should have the correct capitalization
211
217
  MD044:
@@ -251,6 +257,5 @@ MD052: true
251
257
  # MD053/link-image-reference-definitions - Link and image reference definitions should be needed
252
258
  MD053:
253
259
  # Ignored definitions
254
- ignored_definitions: [
255
- "//"
256
- ]
260
+ ignored_definitions:
261
+ - "//"
@@ -456,7 +456,7 @@
456
456
  "default": true,
457
457
  "properties": {
458
458
  "punctuation": {
459
- "description": "Punctuation characters",
459
+ "description": "Punctuation characters not allowed at end of headings",
460
460
  "type": "string",
461
461
  "default": ".,;:!。,;:!"
462
462
  }
@@ -669,8 +669,27 @@
669
669
  },
670
670
  "MD040": {
671
671
  "description": "MD040/fenced-code-language - Fenced code blocks should have a language specified",
672
- "type": "boolean",
673
- "default": true
672
+ "type": [
673
+ "boolean",
674
+ "object"
675
+ ],
676
+ "default": true,
677
+ "properties": {
678
+ "allowed_languages": {
679
+ "description": "List of languages",
680
+ "type": "array",
681
+ "items": {
682
+ "type": "string"
683
+ },
684
+ "default": []
685
+ },
686
+ "language_only": {
687
+ "description": "Require language only",
688
+ "type": "boolean",
689
+ "default": false
690
+ }
691
+ },
692
+ "additionalProperties": false
674
693
  },
675
694
  "fenced-code-language": {
676
695
  "$ref": "#/properties/MD040"
@@ -737,6 +756,11 @@
737
756
  "pattern": "^(\\*|\\+|#{1,6} .*)$"
738
757
  },
739
758
  "default": []
759
+ },
760
+ "match_case": {
761
+ "description": "Match case of headings",
762
+ "type": "boolean",
763
+ "default": false
740
764
  }
741
765
  },
742
766
  "additionalProperties": false
@@ -0,0 +1,26 @@
1
+ {
2
+ "comment": "Disables rules that may conflict with Prettier",
3
+
4
+ "blanks-around-fences": false,
5
+ "blanks-around-headings": false,
6
+ "blanks-around-lists": false,
7
+ "code-fence-style": false,
8
+ "emphasis-style": false,
9
+ "heading-start-left": false,
10
+ "hr-style": false,
11
+ "line-length": false,
12
+ "list-indent": false,
13
+ "list-marker-space": false,
14
+ "no-blanks-blockquote": false,
15
+ "no-hard-tabs": false,
16
+ "no-missing-space-atx": false,
17
+ "no-missing-space-closed-atx": false,
18
+ "no-multiple-blanks": false,
19
+ "no-multiple-space-atx": false,
20
+ "no-multiple-space-blockquote": false,
21
+ "no-multiple-space-closed-atx": false,
22
+ "no-trailing-spaces": false,
23
+ "ol-prefix": false,
24
+ "strong-style": false,
25
+ "ul-indent": false
26
+ }