markdownlint 0.36.1 → 0.37.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 (84) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +70 -117
  3. package/doc/CustomRules.md +6 -6
  4. package/helpers/README.md +2 -2
  5. package/helpers/{helpers.js → helpers.cjs} +15 -6
  6. package/helpers/micromark-helpers.cjs +5 -3
  7. package/helpers/package.json +2 -5
  8. package/lib/{cache.js → cache.mjs} +9 -17
  9. package/lib/configuration-strict.d.ts +104 -104
  10. package/lib/configuration.d.ts +1 -1
  11. package/lib/{constants.js → constants.mjs} +4 -6
  12. package/lib/exports-async.d.mts +1 -0
  13. package/lib/exports-async.mjs +3 -0
  14. package/lib/exports-promise.d.mts +1 -0
  15. package/lib/exports-promise.mjs +3 -0
  16. package/lib/exports-sync.d.mts +1 -0
  17. package/lib/exports-sync.mjs +3 -0
  18. package/lib/exports.d.mts +28 -0
  19. package/lib/exports.mjs +31 -0
  20. package/lib/markdownit.cjs +9 -5
  21. package/lib/{markdownlint.d.ts → markdownlint.d.mts} +66 -76
  22. package/lib/{markdownlint.js → markdownlint.mjs} +69 -75
  23. package/lib/{md001.js → md001.mjs} +5 -8
  24. package/lib/{md003.js → md003.mjs} +5 -8
  25. package/lib/{md004.js → md004.mjs} +6 -9
  26. package/lib/{md005.js → md005.mjs} +4 -7
  27. package/lib/{md007.js → md007.mjs} +8 -13
  28. package/lib/{md009.js → md009.mjs} +5 -8
  29. package/lib/{md010.js → md010.mjs} +7 -11
  30. package/lib/{md011.js → md011.mjs} +7 -11
  31. package/lib/{md012.js → md012.mjs} +5 -8
  32. package/lib/{md013.js → md013.mjs} +8 -9
  33. package/lib/{md014.js → md014.mjs} +4 -7
  34. package/lib/{md018.js → md018.mjs} +5 -8
  35. package/lib/{md019-md021.js → md019-md021.mjs} +7 -10
  36. package/lib/{md020.js → md020.mjs} +5 -8
  37. package/lib/{md022.js → md022.mjs} +5 -8
  38. package/lib/{md023.js → md023.mjs} +4 -7
  39. package/lib/{md024.js → md024.mjs} +5 -8
  40. package/lib/{md025.js → md025.mjs} +5 -8
  41. package/lib/{md026.js → md026.mjs} +5 -8
  42. package/lib/{md027.js → md027.mjs} +12 -9
  43. package/lib/{md028.js → md028.mjs} +4 -7
  44. package/lib/{md029.js → md029.mjs} +6 -9
  45. package/lib/{md030.js → md030.mjs} +4 -7
  46. package/lib/{md031.js → md031.mjs} +7 -10
  47. package/lib/{md032.js → md032.mjs} +5 -8
  48. package/lib/{md033.js → md033.mjs} +5 -8
  49. package/lib/{md034.js → md034.mjs} +5 -6
  50. package/lib/{md035.js → md035.mjs} +4 -7
  51. package/lib/{md036.js → md036.mjs} +6 -9
  52. package/lib/{md037.js → md037.mjs} +4 -7
  53. package/lib/{md038.js → md038.mjs} +5 -8
  54. package/lib/{md039.js → md039.mjs} +9 -12
  55. package/lib/{md040.js → md040.mjs} +5 -8
  56. package/lib/{md041.js → md041.mjs} +4 -8
  57. package/lib/{md042.js → md042.mjs} +5 -8
  58. package/lib/{md043.js → md043.mjs} +5 -8
  59. package/lib/{md044.js → md044.mjs} +8 -11
  60. package/lib/{md045.js → md045.mjs} +5 -8
  61. package/lib/{md046.js → md046.mjs} +4 -7
  62. package/lib/{md047.js → md047.mjs} +3 -6
  63. package/lib/{md048.js → md048.mjs} +5 -8
  64. package/lib/{md049-md050.js → md049-md050.mjs} +8 -11
  65. package/lib/{md051.js → md051.mjs} +8 -12
  66. package/lib/{md052.js → md052.mjs} +4 -7
  67. package/lib/{md053.js → md053.mjs} +4 -7
  68. package/lib/{md054.js → md054.mjs} +5 -8
  69. package/lib/{md055.js → md055.mjs} +6 -7
  70. package/lib/{md056.js → md056.mjs} +7 -8
  71. package/lib/{md058.js → md058.mjs} +6 -7
  72. package/{helpers/micromark-parse.cjs → lib/micromark-parse.mjs} +29 -33
  73. package/lib/micromark-types.d.mts +11 -0
  74. package/lib/rules.mjs +118 -0
  75. package/lib/types.d.mts +12 -0
  76. package/package.json +36 -32
  77. package/schema/.markdownlint.jsonc +51 -51
  78. package/schema/.markdownlint.yaml +51 -51
  79. package/schema/markdownlint-config-schema-strict.json +106 -106
  80. package/schema/markdownlint-config-schema.json +106 -106
  81. package/demo/markdownlint-browser.js +0 -7138
  82. package/helpers/test.cjs +0 -28
  83. package/lib/rules.js +0 -74
  84. /package/helpers/{shared.js → shared.cjs} +0 -0
@@ -1,19 +1,15 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const path = require("node:path");
6
- const { promisify } = require("node:util");
7
- const micromark = require("../helpers/micromark-parse.cjs");
8
- const { version } = require("./constants");
9
- const rules = require("./rules");
10
- const helpers = require("../helpers");
11
- const cache = require("./cache");
12
-
13
- // @ts-ignore
14
- // eslint-disable-next-line camelcase, no-inline-comments, no-undef
15
- const dynamicRequire = (typeof __non_webpack_require__ === "undefined") ? require : /* c8 ignore next */ __non_webpack_require__;
16
- // Capture native require implementation for dynamic loading of modules
3
+ import * as nodeFs from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ const dynamicRequire = createRequire(import.meta.url);
6
+ import * as os from "node:os";
7
+ import path from "node:path";
8
+ import { initialize as cacheInitialize } from "./cache.mjs";
9
+ import { version } from "./constants.mjs";
10
+ import rules from "./rules.mjs";
11
+ import { parse as micromarkParse } from "./micromark-parse.mjs";
12
+ import * as helpers from "../helpers/helpers.cjs";
17
13
 
18
14
  /**
19
15
  * Validate the list of rules for structure and reuse.
@@ -497,7 +493,7 @@ function lintContent(
497
493
  );
498
494
  const customRulesPresent = (ruleList.length !== rules.length);
499
495
  // Parse content into parser tokens
500
- const micromarkTokens = micromark.parse(
496
+ const micromarkTokens = micromarkParse(
501
497
  content,
502
498
  { "freezeTokens": customRulesPresent }
503
499
  );
@@ -507,7 +503,7 @@ function lintContent(
507
503
  // Parse content into lines and get markdown-it tokens
508
504
  const lines = content.split(helpers.newLineRe);
509
505
  const markdownitTokens = needMarkdownItTokens ?
510
- require("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
506
+ dynamicRequire("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
511
507
  [];
512
508
  // Create (frozen) parameters for rules
513
509
  /** @type {MarkdownParsers} */
@@ -533,7 +529,7 @@ function lintContent(
533
529
  "lines": Object.freeze(lines),
534
530
  "frontMatterLines": Object.freeze(frontMatterLines)
535
531
  };
536
- cache.initialize({
532
+ cacheInitialize({
537
533
  ...paramsBase,
538
534
  "parsers": parsersMicromark,
539
535
  "config": null
@@ -751,7 +747,7 @@ function lintContent(
751
747
  } catch (error) {
752
748
  callbackError(error);
753
749
  } finally {
754
- cache.initialize();
750
+ cacheInitialize();
755
751
  }
756
752
  }
757
753
 
@@ -866,7 +862,7 @@ function lintInput(options, synchronous, callback) {
866
862
  3 :
867
863
  options.resultVersion;
868
864
  const markdownItPlugins = options.markdownItPlugins || [];
869
- const fs = options.fs || require("node:fs");
865
+ const fs = options.fs || nodeFs;
870
866
  const aliasToRuleNames = mapAliasToRuleNames(ruleList);
871
867
  const results = newResults(ruleList);
872
868
  let done = false;
@@ -958,30 +954,35 @@ function lintInput(options, synchronous, callback) {
958
954
  * @param {LintCallback} callback Callback (err, result) function.
959
955
  * @returns {void}
960
956
  */
961
- function markdownlint(options, callback) {
957
+ export function lintAsync(options, callback) {
962
958
  return lintInput(options, false, callback);
963
959
  }
964
960
 
965
- const markdownlintPromisify = promisify && promisify(markdownlint);
966
-
967
961
  /**
968
962
  * Lint specified Markdown files.
969
963
  *
970
- * @param {Options} options Configuration options.
964
+ * @param {Options | null} options Configuration options.
971
965
  * @returns {Promise<LintResults>} Results object.
972
966
  */
973
- function markdownlintPromise(options) {
974
- // @ts-ignore
975
- return markdownlintPromisify(options);
967
+ export function lintPromise(options) {
968
+ return new Promise((resolve, reject) => {
969
+ lintAsync(options, (error, results) => {
970
+ if (error || !results) {
971
+ reject(error);
972
+ } else {
973
+ resolve(results);
974
+ }
975
+ });
976
+ });
976
977
  }
977
978
 
978
979
  /**
979
- * Lint specified Markdown files synchronously.
980
+ * Lint specified Markdown files.
980
981
  *
981
982
  * @param {Options | null} options Configuration options.
982
983
  * @returns {LintResults} Results object.
983
984
  */
984
- function markdownlintSync(options) {
985
+ export function lintSync(options) {
985
986
  let results = null;
986
987
  lintInput(options, true, function callback(error, res) {
987
988
  if (error) {
@@ -1057,7 +1058,7 @@ function resolveConfigExtendsSync(configFile, referenceId, fs) {
1057
1058
  *
1058
1059
  * @param {Configuration} config Configuration object.
1059
1060
  * @param {string} file Configuration file name.
1060
- * @param {ConfigurationParser[]} parsers Parsing
1061
+ * @param {ConfigurationParser[] | undefined} parsers Parsing
1061
1062
  * function(s).
1062
1063
  * @param {Object} fs File system implementation.
1063
1064
  * @param {ReadConfigCallback} callback Callback (err, result) function.
@@ -1068,10 +1069,10 @@ function extendConfig(config, file, parsers, fs, callback) {
1068
1069
  if (configExtends) {
1069
1070
  return resolveConfigExtends(
1070
1071
  file,
1071
- helpers.expandTildePath(configExtends, require("node:os")),
1072
+ helpers.expandTildePath(configExtends, os),
1072
1073
  fs,
1073
1074
  // eslint-disable-next-line no-use-before-define
1074
- (_, resolvedExtends) => readConfig(
1075
+ (_, resolvedExtends) => readConfigAsync(
1075
1076
  // @ts-ignore
1076
1077
  resolvedExtends,
1077
1078
  parsers,
@@ -1093,33 +1094,38 @@ function extendConfig(config, file, parsers, fs, callback) {
1093
1094
  return callback(null, config);
1094
1095
  }
1095
1096
 
1096
- const extendConfigPromisify = promisify && promisify(extendConfig);
1097
-
1098
1097
  /**
1099
1098
  * Extend specified configuration object.
1100
1099
  *
1101
1100
  * @param {Configuration} config Configuration object.
1102
1101
  * @param {string} file Configuration file name.
1103
- * @param {ConfigurationParser[]} [parsers] Parsing function(s).
1104
- * @param {Object} [fs] File system implementation.
1102
+ * @param {ConfigurationParser[] | undefined} parsers Parsing function(s).
1103
+ * @param {Object} fs File system implementation.
1105
1104
  * @returns {Promise<Configuration>} Configuration object.
1106
1105
  */
1107
- function extendConfigPromise(config, file, parsers, fs) {
1108
- // @ts-ignore
1109
- return extendConfigPromisify(config, file, parsers, fs);
1106
+ export function extendConfigPromise(config, file, parsers, fs) {
1107
+ return new Promise((resolve, reject) => {
1108
+ extendConfig(config, file, parsers, fs, (error, results) => {
1109
+ if (error || !results) {
1110
+ reject(error);
1111
+ } else {
1112
+ resolve(results);
1113
+ }
1114
+ });
1115
+ });
1110
1116
  }
1111
1117
 
1112
1118
  /**
1113
1119
  * Read specified configuration file.
1114
1120
  *
1115
1121
  * @param {string} file Configuration file name.
1116
- * @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
1122
+ * @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing
1117
1123
  * function(s).
1118
1124
  * @param {Object} [fs] File system implementation.
1119
1125
  * @param {ReadConfigCallback} [callback] Callback (err, result) function.
1120
1126
  * @returns {void}
1121
1127
  */
1122
- function readConfig(file, parsers, fs, callback) {
1128
+ export function readConfigAsync(file, parsers, fs, callback) {
1123
1129
  if (!callback) {
1124
1130
  if (fs) {
1125
1131
  callback = fs;
@@ -1132,10 +1138,10 @@ function readConfig(file, parsers, fs, callback) {
1132
1138
  }
1133
1139
  }
1134
1140
  if (!fs) {
1135
- fs = require("node:fs");
1141
+ fs = nodeFs;
1136
1142
  }
1137
1143
  // Read file
1138
- file = helpers.expandTildePath(file, require("node:os"));
1144
+ file = helpers.expandTildePath(file, os);
1139
1145
  fs.readFile(file, "utf8", (err, content) => {
1140
1146
  if (err) {
1141
1147
  // @ts-ignore
@@ -1154,8 +1160,6 @@ function readConfig(file, parsers, fs, callback) {
1154
1160
  });
1155
1161
  }
1156
1162
 
1157
- const readConfigPromisify = promisify && promisify(readConfig);
1158
-
1159
1163
  /**
1160
1164
  * Read specified configuration file.
1161
1165
  *
@@ -1164,26 +1168,31 @@ const readConfigPromisify = promisify && promisify(readConfig);
1164
1168
  * @param {Object} [fs] File system implementation.
1165
1169
  * @returns {Promise<Configuration>} Configuration object.
1166
1170
  */
1167
- function readConfigPromise(file, parsers, fs) {
1168
- // @ts-ignore
1169
- return readConfigPromisify(file, parsers, fs);
1171
+ export function readConfigPromise(file, parsers, fs) {
1172
+ return new Promise((resolve, reject) => {
1173
+ readConfigAsync(file, parsers, fs, (error, results) => {
1174
+ if (error || !results) {
1175
+ reject(error);
1176
+ } else {
1177
+ resolve(results);
1178
+ }
1179
+ });
1180
+ });
1170
1181
  }
1171
1182
 
1172
1183
  /**
1173
- * Read specified configuration file synchronously.
1184
+ * Read specified configuration file.
1174
1185
  *
1175
1186
  * @param {string} file Configuration file name.
1176
1187
  * @param {ConfigurationParser[]} [parsers] Parsing function(s).
1177
1188
  * @param {Object} [fs] File system implementation.
1178
1189
  * @returns {Configuration} Configuration object.
1179
- * @throws An Error if processing fails.
1180
1190
  */
1181
- function readConfigSync(file, parsers, fs) {
1191
+ export function readConfigSync(file, parsers, fs) {
1182
1192
  if (!fs) {
1183
- fs = require("node:fs");
1193
+ fs = nodeFs;
1184
1194
  }
1185
1195
  // Read file
1186
- const os = require("node:os");
1187
1196
  file = helpers.expandTildePath(file, os);
1188
1197
  const content = fs.readFileSync(file, "utf8");
1189
1198
  // Try to parse file
@@ -1232,7 +1241,7 @@ function normalizeFixInfo(fixInfo, lineNumber = 0) {
1232
1241
  * @param {string} [lineEnding] Line ending to use.
1233
1242
  * @returns {string | null} Fixed content or null if deleted.
1234
1243
  */
1235
- function applyFix(line, fixInfo, lineEnding = "\n") {
1244
+ export function applyFix(line, fixInfo, lineEnding = "\n") {
1236
1245
  const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);
1237
1246
  const editIndex = editColumn - 1;
1238
1247
  return (deleteCount === -1) ?
@@ -1247,8 +1256,8 @@ function applyFix(line, fixInfo, lineEnding = "\n") {
1247
1256
  * @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
1248
1257
  * @returns {string} Fixed content.
1249
1258
  */
1250
- function applyFixes(input, errors) {
1251
- const lineEnding = helpers.getPreferredLineEnding(input, require("node:os"));
1259
+ export function applyFixes(input, errors) {
1260
+ const lineEnding = helpers.getPreferredLineEnding(input, os);
1252
1261
  const lines = input.split(helpers.newLineRe);
1253
1262
  // Normalize fixInfo objects
1254
1263
  let fixInfos = errors
@@ -1267,8 +1276,7 @@ function applyFixes(input, errors) {
1267
1276
  );
1268
1277
  });
1269
1278
  // Remove duplicate entries (needed for following collapse step)
1270
- // eslint-disable-next-line jsdoc/valid-types
1271
- /** @type RuleOnErrorFixInfo */
1279
+ /** @type {RuleOnErrorFixInfo} */
1272
1280
  let lastFixInfo = {};
1273
1281
  fixInfos = fixInfos.filter((fixInfo) => {
1274
1282
  const unique = (
@@ -1326,24 +1334,10 @@ function applyFixes(input, errors) {
1326
1334
  *
1327
1335
  * @returns {string} SemVer string.
1328
1336
  */
1329
- function getVersion() {
1337
+ export function getVersion() {
1330
1338
  return version;
1331
1339
  }
1332
1340
 
1333
- // Export a/synchronous/Promise APIs
1334
- markdownlint.sync = markdownlintSync;
1335
- markdownlint.readConfig = readConfig;
1336
- markdownlint.readConfigSync = readConfigSync;
1337
- markdownlint.getVersion = getVersion;
1338
- markdownlint.promises = {
1339
- "markdownlint": markdownlintPromise,
1340
- "extendConfig": extendConfigPromise,
1341
- "readConfig": readConfigPromise
1342
- };
1343
- markdownlint.applyFix = applyFix;
1344
- markdownlint.applyFixes = applyFixes;
1345
- module.exports = markdownlint;
1346
-
1347
1341
  // Type declarations
1348
1342
 
1349
1343
  /**
@@ -1414,7 +1408,7 @@ module.exports = markdownlint;
1414
1408
  * @property {string} line Line content.
1415
1409
  */
1416
1410
 
1417
- /** @typedef {import("markdownlint-micromark").TokenType} MicromarkTokenType */
1411
+ /** @typedef {import("micromark-util-types").TokenType} MicromarkTokenType */
1418
1412
 
1419
1413
  /**
1420
1414
  * micromark token.
@@ -1567,14 +1561,14 @@ module.exports = markdownlint;
1567
1561
  * Configuration object for linting rules. For the JSON schema, see
1568
1562
  * {@link ../schema/markdownlint-config-schema.json}.
1569
1563
  *
1570
- * @typedef {import("./configuration").Configuration} Configuration
1564
+ * @typedef {import("./configuration.d.ts").Configuration} Configuration
1571
1565
  */
1572
1566
 
1573
1567
  /**
1574
1568
  * Configuration object for linting rules strictly. For the JSON schema, see
1575
1569
  * {@link ../schema/markdownlint-config-schema-strict.json}.
1576
1570
  *
1577
- * @typedef {import("./configuration-strict").ConfigurationStrict} ConfigurationStrict
1571
+ * @typedef {import("./configuration-strict.d.ts").ConfigurationStrict} ConfigurationStrict
1578
1572
  */
1579
1573
 
1580
1574
  /**
@@ -1,14 +1,11 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addErrorDetailIf } = require("../helpers");
6
- const { getHeadingLevel } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
8
-
9
- // eslint-disable-next-line jsdoc/valid-types
10
- /** @type import("./markdownlint").Rule */
11
- module.exports = {
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
12
9
  "names": [ "MD001", "heading-increment" ],
13
10
  "description": "Heading levels should only increment by one level at a time",
14
11
  "tags": [ "headings" ],
@@ -1,14 +1,11 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { getHeadingLevel, getHeadingStyle } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addErrorDetailIf } = require("../helpers");
6
- const { getHeadingLevel, getHeadingStyle } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
8
-
9
- // eslint-disable-next-line jsdoc/valid-types
10
- /** @type import("./markdownlint").Rule */
11
- module.exports = {
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
12
9
  "names": [ "MD003", "heading-style" ],
13
10
  "description": "Heading style",
14
11
  "tags": [ "headings" ],
@@ -1,10 +1,8 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const { addErrorDetailIf } = require("../helpers");
6
- const { getDescendantsByType, getParentOfType } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
3
+ import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { getDescendantsByType, getParentOfType } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
8
6
 
9
7
  const markerToStyle = {
10
8
  "-": "dash",
@@ -29,9 +27,8 @@ const validStyles = new Set([
29
27
  "sublist"
30
28
  ]);
31
29
 
32
- // eslint-disable-next-line jsdoc/valid-types
33
- /** @type import("./markdownlint").Rule */
34
- module.exports = {
30
+ /** @type {import("markdownlint").Rule} */
31
+ export default {
35
32
  "names": [ "MD004", "ul-style" ],
36
33
  "description": "Unordered list style",
37
34
  "tags": [ "bullet", "ul" ],
@@ -43,7 +40,7 @@ module.exports = {
43
40
  for (const listUnordered of filterByTypesCached([ "listUnordered" ])) {
44
41
  let nesting = 0;
45
42
  if (style === "sublist") {
46
- /** @type {import("../helpers/micromark-helpers.cjs").Token | null} */
43
+ /** @type {import("markdownlint").MicromarkToken | null} */
47
44
  let parent = listUnordered;
48
45
  // @ts-ignore
49
46
  while ((parent = getParentOfType(parent, [ "listOrdered", "listUnordered" ]))) {
@@ -1,13 +1,10 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { filterByTypesCached } from "./cache.mjs";
4
5
 
5
- const { addError, addErrorDetailIf } = require("../helpers");
6
- const { filterByTypesCached } = require("./cache");
7
-
8
- // eslint-disable-next-line jsdoc/valid-types
9
- /** @type import("./markdownlint").Rule */
10
- module.exports = {
6
+ /** @type {import("markdownlint").Rule} */
7
+ export default {
11
8
  "names": [ "MD005", "list-indent" ],
12
9
  "description": "Inconsistent indentation for list items at the same level",
13
10
  "tags": [ "bullet", "ul", "indentation" ],
@@ -1,23 +1,18 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { getParentOfType } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addErrorDetailIf } = require("../helpers");
6
- const { getParentOfType } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
8
-
9
- // eslint-disable-next-line jsdoc/valid-types
10
- /** @type import("markdownlint-micromark").TokenType[] */
7
+ /** @type {import("micromark-util-types").TokenType[]} */
11
8
  const unorderedListTypes =
12
9
  [ "blockQuotePrefix", "listItemPrefix", "listUnordered" ];
13
- // eslint-disable-next-line jsdoc/valid-types
14
- /** @type import("markdownlint-micromark").TokenType[] */
10
+ /** @type {import("micromark-util-types").TokenType[]} */
15
11
  const unorderedParentTypes =
16
12
  [ "blockQuote", "listOrdered", "listUnordered" ];
17
13
 
18
- // eslint-disable-next-line jsdoc/valid-types
19
- /** @type import("./markdownlint").Rule */
20
- module.exports = {
14
+ /** @type {import("markdownlint").Rule} */
15
+ export default {
21
16
  "names": [ "MD007", "ul-indent" ],
22
17
  "description": "Unordered list indentation",
23
18
  "tags": [ "bullet", "ul", "indentation" ],
@@ -35,7 +30,7 @@ module.exports = {
35
30
  lastBlockQuotePrefix = token;
36
31
  } else if (type === "listUnordered") {
37
32
  let nesting = 0;
38
- /** @type {import("../helpers/micromark-helpers.cjs").Token | null} */
33
+ /** @type {import("markdownlint").MicromarkToken | null} */
39
34
  let current = token;
40
35
  while (
41
36
  // @ts-ignore
@@ -1,14 +1,11 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addError } from "../helpers/helpers.cjs";
4
+ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addError } = require("../helpers");
6
- const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
8
-
9
- // eslint-disable-next-line jsdoc/valid-types
10
- /** @type import("./markdownlint").Rule */
11
- module.exports = {
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
12
9
  "names": [ "MD009", "no-trailing-spaces" ],
13
10
  "description": "Trailing spaces",
14
11
  "tags": [ "whitespace" ],
@@ -1,16 +1,13 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const { addError, hasOverlap } = require("../helpers");
6
- const { getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
3
+ import { addError, hasOverlap } from "../helpers/helpers.cjs";
4
+ import { getDescendantsByType } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
8
6
 
9
7
  const tabRe = /\t+/g;
10
8
 
11
- // eslint-disable-next-line jsdoc/valid-types
12
- /** @type import("./markdownlint").Rule */
13
- module.exports = {
9
+ /** @type {import("markdownlint").Rule} */
10
+ export default {
14
11
  "names": [ "MD010", "no-hard-tabs" ],
15
12
  "description": "Hard tabs",
16
13
  "tags": [ "whitespace", "hard_tab" ],
@@ -26,8 +23,7 @@ module.exports = {
26
23
  const spaceMultiplier = (spacesPerTab === undefined) ?
27
24
  1 :
28
25
  Math.max(0, Number(spacesPerTab));
29
- // eslint-disable-next-line jsdoc/valid-types
30
- /** @type import("../helpers/micromark-helpers.cjs").TokenType[] */
26
+ /** @type {import("markdownlint").MicromarkTokenType[]} */
31
27
  const exclusionTypes = [];
32
28
  if (includeCode) {
33
29
  if (ignoreCodeLanguages.size > 0) {
@@ -60,7 +56,7 @@ module.exports = {
60
56
  const lineNumber = lineIndex + 1;
61
57
  const column = match.index + 1;
62
58
  const length = match[0].length;
63
- /** @type {import("../helpers").FileRange} */
59
+ /** @type {import("../helpers/helpers.cjs").FileRange} */
64
60
  const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
65
61
  if (!codeRanges.some((codeRange) => hasOverlap(codeRange, range))) {
66
62
  addError(
@@ -1,17 +1,13 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addError, hasOverlap } from "../helpers/helpers.cjs";
4
+ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addError, hasOverlap } = require("../helpers");
6
- const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
7
+ const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
8
8
 
9
- const reversedLinkRe =
10
- /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
11
-
12
- // eslint-disable-next-line jsdoc/valid-types
13
- /** @type import("./markdownlint").Rule */
14
- module.exports = {
9
+ /** @type {import("markdownlint").Rule} */
10
+ export default {
15
11
  "names": [ "MD011", "no-reversed-links" ],
16
12
  "description": "Reversed link syntax",
17
13
  "tags": [ "links" ],
@@ -34,7 +30,7 @@ module.exports = {
34
30
  ) {
35
31
  const column = match.index + preChar.length + 1;
36
32
  const length = match[0].length - preChar.length;
37
- /** @type {import("../helpers").FileRange} */
33
+ /** @type {import("../helpers/helpers.cjs").FileRange} */
38
34
  const range = { "startLine": lineNumber, "startColumn": column, "endLine": lineNumber, "endColumn": column + length - 1 };
39
35
  if (!codeTexts.some((codeText) => hasOverlap(codeText, range))) {
40
36
  addError(
@@ -1,14 +1,11 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addErrorDetailIf } = require("../helpers");
6
- const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
8
-
9
- // eslint-disable-next-line jsdoc/valid-types
10
- /** @type import("./markdownlint").Rule */
11
- module.exports = {
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
12
9
  "names": [ "MD012", "no-multiple-blanks" ],
13
10
  "description": "Multiple consecutive blank lines",
14
11
  "tags": [ "whitespace", "blank_lines" ],
@@ -1,20 +1,19 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const { addErrorDetailIf } = require("../helpers");
6
- const { getReferenceLinkImageData } = require("./cache");
7
- const { addRangeToSet, getDescendantsByType } = require("../helpers/micromark-helpers.cjs");
8
- const { filterByTypesCached } = require("./cache");
3
+ import { addErrorDetailIf } from "../helpers/helpers.cjs";
4
+ import { filterByTypesCached, getReferenceLinkImageData } from "./cache.mjs";
5
+ import { addRangeToSet, getDescendantsByType } from "../helpers/micromark-helpers.cjs";
9
6
 
10
7
  const longLineRePrefix = "^.{";
11
8
  const longLineRePostfixRelaxed = "}.*\\s.*$";
12
9
  const longLineRePostfixStrict = "}.+$";
13
10
  const sternModeRe = /^(?:[#>\s]*\s)?\S*$/;
14
11
 
15
- // eslint-disable-next-line jsdoc/valid-types
16
- /** @type import("./markdownlint").Rule */
17
- module.exports = {
12
+ /** @typedef {import("micromark-extension-gfm-autolink-literal")} */
13
+ /** @typedef {import("micromark-extension-gfm-table")} */
14
+
15
+ /** @type {import("markdownlint").Rule} */
16
+ export default {
18
17
  "names": [ "MD013", "line-length" ],
19
18
  "description": "Line length",
20
19
  "tags": [ "line_length" ],
@@ -1,15 +1,12 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
4
-
5
- const { addErrorContext } = require("../helpers");
6
- const { filterByTypesCached } = require("./cache");
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { filterByTypesCached } from "./cache.mjs";
7
5
 
8
6
  const dollarCommandRe = /^(\s*)(\$\s+)/;
9
7
 
10
- // eslint-disable-next-line jsdoc/valid-types
11
- /** @type import("./markdownlint").Rule */
12
- module.exports = {
8
+ /** @type {import("markdownlint").Rule} */
9
+ export default {
13
10
  "names": [ "MD014", "commands-show-output" ],
14
11
  "description": "Dollar signs used before commands without showing output",
15
12
  "tags": [ "code" ],
@@ -1,14 +1,11 @@
1
1
  // @ts-check
2
2
 
3
- "use strict";
3
+ import { addErrorContext } from "../helpers/helpers.cjs";
4
+ import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
5
+ import { filterByTypesCached } from "./cache.mjs";
4
6
 
5
- const { addErrorContext } = require("../helpers");
6
- const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
7
- const { filterByTypesCached } = require("./cache");
8
-
9
- // eslint-disable-next-line jsdoc/valid-types
10
- /** @type import("./markdownlint").Rule */
11
- module.exports = {
7
+ /** @type {import("markdownlint").Rule} */
8
+ export default {
12
9
  "names": [ "MD018", "no-missing-space-atx" ],
13
10
  "description": "No space after hash on atx style heading",
14
11
  "tags": [ "headings", "atx", "spaces" ],