markdownlint 0.36.1 → 0.37.1
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 +11 -0
- package/README.md +70 -117
- package/doc/CustomRules.md +6 -6
- package/helpers/README.md +2 -2
- package/helpers/{helpers.js → helpers.cjs} +15 -6
- package/helpers/micromark-helpers.cjs +5 -3
- package/helpers/package.json +3 -6
- package/lib/{cache.js → cache.mjs} +9 -17
- package/lib/configuration-strict.d.ts +104 -104
- package/lib/configuration.d.ts +1 -1
- package/lib/{constants.js → constants.mjs} +4 -6
- package/lib/exports-async.d.mts +1 -0
- package/lib/exports-async.mjs +3 -0
- package/lib/exports-promise.d.mts +1 -0
- package/lib/exports-promise.mjs +3 -0
- package/lib/exports-sync.d.mts +1 -0
- package/lib/exports-sync.mjs +3 -0
- package/lib/exports.d.mts +28 -0
- package/lib/exports.mjs +31 -0
- package/lib/markdownit.cjs +9 -5
- package/lib/{markdownlint.d.ts → markdownlint.d.mts} +66 -76
- package/lib/{markdownlint.js → markdownlint.mjs} +66 -74
- package/lib/{md001.js → md001.mjs} +5 -8
- package/lib/{md003.js → md003.mjs} +5 -8
- package/lib/{md004.js → md004.mjs} +6 -9
- package/lib/{md005.js → md005.mjs} +4 -7
- package/lib/{md007.js → md007.mjs} +8 -13
- package/lib/{md009.js → md009.mjs} +5 -8
- package/lib/{md010.js → md010.mjs} +7 -11
- package/lib/{md011.js → md011.mjs} +7 -11
- package/lib/{md012.js → md012.mjs} +5 -8
- package/lib/{md013.js → md013.mjs} +8 -9
- package/lib/{md014.js → md014.mjs} +4 -7
- package/lib/{md018.js → md018.mjs} +5 -8
- package/lib/{md019-md021.js → md019-md021.mjs} +7 -10
- package/lib/{md020.js → md020.mjs} +5 -8
- package/lib/{md022.js → md022.mjs} +5 -8
- package/lib/{md023.js → md023.mjs} +4 -7
- package/lib/{md024.js → md024.mjs} +5 -8
- package/lib/{md025.js → md025.mjs} +5 -8
- package/lib/{md026.js → md026.mjs} +5 -8
- package/lib/{md027.js → md027.mjs} +12 -9
- package/lib/{md028.js → md028.mjs} +4 -7
- package/lib/{md029.js → md029.mjs} +6 -9
- package/lib/{md030.js → md030.mjs} +4 -7
- package/lib/{md031.js → md031.mjs} +7 -10
- package/lib/{md032.js → md032.mjs} +5 -8
- package/lib/{md033.js → md033.mjs} +5 -8
- package/lib/{md034.js → md034.mjs} +5 -6
- package/lib/{md035.js → md035.mjs} +4 -7
- package/lib/{md036.js → md036.mjs} +6 -9
- package/lib/{md037.js → md037.mjs} +4 -7
- package/lib/{md038.js → md038.mjs} +5 -8
- package/lib/{md039.js → md039.mjs} +9 -12
- package/lib/{md040.js → md040.mjs} +5 -8
- package/lib/{md041.js → md041.mjs} +4 -8
- package/lib/{md042.js → md042.mjs} +5 -8
- package/lib/{md043.js → md043.mjs} +5 -8
- package/lib/{md044.js → md044.mjs} +8 -11
- package/lib/{md045.js → md045.mjs} +5 -8
- package/lib/{md046.js → md046.mjs} +4 -7
- package/lib/{md047.js → md047.mjs} +3 -6
- package/lib/{md048.js → md048.mjs} +5 -8
- package/lib/{md049-md050.js → md049-md050.mjs} +8 -11
- package/lib/{md051.js → md051.mjs} +8 -12
- package/lib/{md052.js → md052.mjs} +4 -7
- package/lib/{md053.js → md053.mjs} +4 -7
- package/lib/{md054.js → md054.mjs} +5 -8
- package/lib/{md055.js → md055.mjs} +6 -7
- package/lib/{md056.js → md056.mjs} +7 -8
- package/lib/{md058.js → md058.mjs} +6 -7
- package/{helpers/micromark-parse.cjs → lib/micromark-parse.mjs} +29 -33
- package/lib/micromark-types.d.mts +11 -0
- package/lib/node-imports-browser-module.cjs +7 -0
- package/lib/node-imports-browser.mjs +22 -0
- package/lib/node-imports-node.mjs +14 -0
- package/lib/rules.mjs +118 -0
- package/lib/types.d.mts +13 -0
- package/package.json +44 -34
- 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/demo/markdownlint-browser.js +0 -7138
- package/helpers/test.cjs +0 -28
- package/lib/rules.js +0 -74
- /package/helpers/{shared.js → shared.cjs} +0 -0
|
@@ -1,19 +1,13 @@
|
|
|
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
3
|
// @ts-ignore
|
|
14
|
-
|
|
15
|
-
const dynamicRequire = (
|
|
16
|
-
|
|
4
|
+
import { fs as nodeFs, module, os, path } from "#node-imports";
|
|
5
|
+
const dynamicRequire = module.createRequire(import.meta.url);
|
|
6
|
+
import { initialize as cacheInitialize } from "./cache.mjs";
|
|
7
|
+
import { version } from "./constants.mjs";
|
|
8
|
+
import rules from "./rules.mjs";
|
|
9
|
+
import { parse as micromarkParse } from "./micromark-parse.mjs";
|
|
10
|
+
import * as helpers from "../helpers/helpers.cjs";
|
|
17
11
|
|
|
18
12
|
/**
|
|
19
13
|
* Validate the list of rules for structure and reuse.
|
|
@@ -497,7 +491,7 @@ function lintContent(
|
|
|
497
491
|
);
|
|
498
492
|
const customRulesPresent = (ruleList.length !== rules.length);
|
|
499
493
|
// Parse content into parser tokens
|
|
500
|
-
const micromarkTokens =
|
|
494
|
+
const micromarkTokens = micromarkParse(
|
|
501
495
|
content,
|
|
502
496
|
{ "freezeTokens": customRulesPresent }
|
|
503
497
|
);
|
|
@@ -507,7 +501,7 @@ function lintContent(
|
|
|
507
501
|
// Parse content into lines and get markdown-it tokens
|
|
508
502
|
const lines = content.split(helpers.newLineRe);
|
|
509
503
|
const markdownitTokens = needMarkdownItTokens ?
|
|
510
|
-
|
|
504
|
+
dynamicRequire("./markdownit.cjs").getMarkdownItTokens(markdownItPlugins, preClearedContent, lines) :
|
|
511
505
|
[];
|
|
512
506
|
// Create (frozen) parameters for rules
|
|
513
507
|
/** @type {MarkdownParsers} */
|
|
@@ -533,7 +527,7 @@ function lintContent(
|
|
|
533
527
|
"lines": Object.freeze(lines),
|
|
534
528
|
"frontMatterLines": Object.freeze(frontMatterLines)
|
|
535
529
|
};
|
|
536
|
-
|
|
530
|
+
cacheInitialize({
|
|
537
531
|
...paramsBase,
|
|
538
532
|
"parsers": parsersMicromark,
|
|
539
533
|
"config": null
|
|
@@ -751,7 +745,7 @@ function lintContent(
|
|
|
751
745
|
} catch (error) {
|
|
752
746
|
callbackError(error);
|
|
753
747
|
} finally {
|
|
754
|
-
|
|
748
|
+
cacheInitialize();
|
|
755
749
|
}
|
|
756
750
|
}
|
|
757
751
|
|
|
@@ -866,7 +860,7 @@ function lintInput(options, synchronous, callback) {
|
|
|
866
860
|
3 :
|
|
867
861
|
options.resultVersion;
|
|
868
862
|
const markdownItPlugins = options.markdownItPlugins || [];
|
|
869
|
-
const fs = options.fs ||
|
|
863
|
+
const fs = options.fs || nodeFs;
|
|
870
864
|
const aliasToRuleNames = mapAliasToRuleNames(ruleList);
|
|
871
865
|
const results = newResults(ruleList);
|
|
872
866
|
let done = false;
|
|
@@ -958,30 +952,35 @@ function lintInput(options, synchronous, callback) {
|
|
|
958
952
|
* @param {LintCallback} callback Callback (err, result) function.
|
|
959
953
|
* @returns {void}
|
|
960
954
|
*/
|
|
961
|
-
function
|
|
955
|
+
export function lintAsync(options, callback) {
|
|
962
956
|
return lintInput(options, false, callback);
|
|
963
957
|
}
|
|
964
958
|
|
|
965
|
-
const markdownlintPromisify = promisify && promisify(markdownlint);
|
|
966
|
-
|
|
967
959
|
/**
|
|
968
960
|
* Lint specified Markdown files.
|
|
969
961
|
*
|
|
970
|
-
* @param {Options} options Configuration options.
|
|
962
|
+
* @param {Options | null} options Configuration options.
|
|
971
963
|
* @returns {Promise<LintResults>} Results object.
|
|
972
964
|
*/
|
|
973
|
-
function
|
|
974
|
-
|
|
975
|
-
|
|
965
|
+
export function lintPromise(options) {
|
|
966
|
+
return new Promise((resolve, reject) => {
|
|
967
|
+
lintAsync(options, (error, results) => {
|
|
968
|
+
if (error || !results) {
|
|
969
|
+
reject(error);
|
|
970
|
+
} else {
|
|
971
|
+
resolve(results);
|
|
972
|
+
}
|
|
973
|
+
});
|
|
974
|
+
});
|
|
976
975
|
}
|
|
977
976
|
|
|
978
977
|
/**
|
|
979
|
-
* Lint specified Markdown files
|
|
978
|
+
* Lint specified Markdown files.
|
|
980
979
|
*
|
|
981
980
|
* @param {Options | null} options Configuration options.
|
|
982
981
|
* @returns {LintResults} Results object.
|
|
983
982
|
*/
|
|
984
|
-
function
|
|
983
|
+
export function lintSync(options) {
|
|
985
984
|
let results = null;
|
|
986
985
|
lintInput(options, true, function callback(error, res) {
|
|
987
986
|
if (error) {
|
|
@@ -1057,7 +1056,7 @@ function resolveConfigExtendsSync(configFile, referenceId, fs) {
|
|
|
1057
1056
|
*
|
|
1058
1057
|
* @param {Configuration} config Configuration object.
|
|
1059
1058
|
* @param {string} file Configuration file name.
|
|
1060
|
-
* @param {ConfigurationParser[]} parsers Parsing
|
|
1059
|
+
* @param {ConfigurationParser[] | undefined} parsers Parsing
|
|
1061
1060
|
* function(s).
|
|
1062
1061
|
* @param {Object} fs File system implementation.
|
|
1063
1062
|
* @param {ReadConfigCallback} callback Callback (err, result) function.
|
|
@@ -1068,10 +1067,10 @@ function extendConfig(config, file, parsers, fs, callback) {
|
|
|
1068
1067
|
if (configExtends) {
|
|
1069
1068
|
return resolveConfigExtends(
|
|
1070
1069
|
file,
|
|
1071
|
-
helpers.expandTildePath(configExtends,
|
|
1070
|
+
helpers.expandTildePath(configExtends, os),
|
|
1072
1071
|
fs,
|
|
1073
1072
|
// eslint-disable-next-line no-use-before-define
|
|
1074
|
-
(_, resolvedExtends) =>
|
|
1073
|
+
(_, resolvedExtends) => readConfigAsync(
|
|
1075
1074
|
// @ts-ignore
|
|
1076
1075
|
resolvedExtends,
|
|
1077
1076
|
parsers,
|
|
@@ -1093,33 +1092,38 @@ function extendConfig(config, file, parsers, fs, callback) {
|
|
|
1093
1092
|
return callback(null, config);
|
|
1094
1093
|
}
|
|
1095
1094
|
|
|
1096
|
-
const extendConfigPromisify = promisify && promisify(extendConfig);
|
|
1097
|
-
|
|
1098
1095
|
/**
|
|
1099
1096
|
* Extend specified configuration object.
|
|
1100
1097
|
*
|
|
1101
1098
|
* @param {Configuration} config Configuration object.
|
|
1102
1099
|
* @param {string} file Configuration file name.
|
|
1103
|
-
* @param {ConfigurationParser[]}
|
|
1104
|
-
* @param {Object}
|
|
1100
|
+
* @param {ConfigurationParser[] | undefined} parsers Parsing function(s).
|
|
1101
|
+
* @param {Object} fs File system implementation.
|
|
1105
1102
|
* @returns {Promise<Configuration>} Configuration object.
|
|
1106
1103
|
*/
|
|
1107
|
-
function extendConfigPromise(config, file, parsers, fs) {
|
|
1108
|
-
|
|
1109
|
-
|
|
1104
|
+
export function extendConfigPromise(config, file, parsers, fs) {
|
|
1105
|
+
return new Promise((resolve, reject) => {
|
|
1106
|
+
extendConfig(config, file, parsers, fs, (error, results) => {
|
|
1107
|
+
if (error || !results) {
|
|
1108
|
+
reject(error);
|
|
1109
|
+
} else {
|
|
1110
|
+
resolve(results);
|
|
1111
|
+
}
|
|
1112
|
+
});
|
|
1113
|
+
});
|
|
1110
1114
|
}
|
|
1111
1115
|
|
|
1112
1116
|
/**
|
|
1113
1117
|
* Read specified configuration file.
|
|
1114
1118
|
*
|
|
1115
1119
|
* @param {string} file Configuration file name.
|
|
1116
|
-
* @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
|
|
1120
|
+
* @param {ConfigurationParser[] | ReadConfigCallback} [parsers] Parsing
|
|
1117
1121
|
* function(s).
|
|
1118
1122
|
* @param {Object} [fs] File system implementation.
|
|
1119
1123
|
* @param {ReadConfigCallback} [callback] Callback (err, result) function.
|
|
1120
1124
|
* @returns {void}
|
|
1121
1125
|
*/
|
|
1122
|
-
function
|
|
1126
|
+
export function readConfigAsync(file, parsers, fs, callback) {
|
|
1123
1127
|
if (!callback) {
|
|
1124
1128
|
if (fs) {
|
|
1125
1129
|
callback = fs;
|
|
@@ -1132,10 +1136,10 @@ function readConfig(file, parsers, fs, callback) {
|
|
|
1132
1136
|
}
|
|
1133
1137
|
}
|
|
1134
1138
|
if (!fs) {
|
|
1135
|
-
fs =
|
|
1139
|
+
fs = nodeFs;
|
|
1136
1140
|
}
|
|
1137
1141
|
// Read file
|
|
1138
|
-
file = helpers.expandTildePath(file,
|
|
1142
|
+
file = helpers.expandTildePath(file, os);
|
|
1139
1143
|
fs.readFile(file, "utf8", (err, content) => {
|
|
1140
1144
|
if (err) {
|
|
1141
1145
|
// @ts-ignore
|
|
@@ -1154,8 +1158,6 @@ function readConfig(file, parsers, fs, callback) {
|
|
|
1154
1158
|
});
|
|
1155
1159
|
}
|
|
1156
1160
|
|
|
1157
|
-
const readConfigPromisify = promisify && promisify(readConfig);
|
|
1158
|
-
|
|
1159
1161
|
/**
|
|
1160
1162
|
* Read specified configuration file.
|
|
1161
1163
|
*
|
|
@@ -1164,26 +1166,31 @@ const readConfigPromisify = promisify && promisify(readConfig);
|
|
|
1164
1166
|
* @param {Object} [fs] File system implementation.
|
|
1165
1167
|
* @returns {Promise<Configuration>} Configuration object.
|
|
1166
1168
|
*/
|
|
1167
|
-
function readConfigPromise(file, parsers, fs) {
|
|
1168
|
-
|
|
1169
|
-
|
|
1169
|
+
export function readConfigPromise(file, parsers, fs) {
|
|
1170
|
+
return new Promise((resolve, reject) => {
|
|
1171
|
+
readConfigAsync(file, parsers, fs, (error, results) => {
|
|
1172
|
+
if (error || !results) {
|
|
1173
|
+
reject(error);
|
|
1174
|
+
} else {
|
|
1175
|
+
resolve(results);
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
});
|
|
1170
1179
|
}
|
|
1171
1180
|
|
|
1172
1181
|
/**
|
|
1173
|
-
* Read specified configuration file
|
|
1182
|
+
* Read specified configuration file.
|
|
1174
1183
|
*
|
|
1175
1184
|
* @param {string} file Configuration file name.
|
|
1176
1185
|
* @param {ConfigurationParser[]} [parsers] Parsing function(s).
|
|
1177
1186
|
* @param {Object} [fs] File system implementation.
|
|
1178
1187
|
* @returns {Configuration} Configuration object.
|
|
1179
|
-
* @throws An Error if processing fails.
|
|
1180
1188
|
*/
|
|
1181
|
-
function readConfigSync(file, parsers, fs) {
|
|
1189
|
+
export function readConfigSync(file, parsers, fs) {
|
|
1182
1190
|
if (!fs) {
|
|
1183
|
-
fs =
|
|
1191
|
+
fs = nodeFs;
|
|
1184
1192
|
}
|
|
1185
1193
|
// Read file
|
|
1186
|
-
const os = require("node:os");
|
|
1187
1194
|
file = helpers.expandTildePath(file, os);
|
|
1188
1195
|
const content = fs.readFileSync(file, "utf8");
|
|
1189
1196
|
// Try to parse file
|
|
@@ -1232,7 +1239,7 @@ function normalizeFixInfo(fixInfo, lineNumber = 0) {
|
|
|
1232
1239
|
* @param {string} [lineEnding] Line ending to use.
|
|
1233
1240
|
* @returns {string | null} Fixed content or null if deleted.
|
|
1234
1241
|
*/
|
|
1235
|
-
function applyFix(line, fixInfo, lineEnding = "\n") {
|
|
1242
|
+
export function applyFix(line, fixInfo, lineEnding = "\n") {
|
|
1236
1243
|
const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);
|
|
1237
1244
|
const editIndex = editColumn - 1;
|
|
1238
1245
|
return (deleteCount === -1) ?
|
|
@@ -1247,8 +1254,8 @@ function applyFix(line, fixInfo, lineEnding = "\n") {
|
|
|
1247
1254
|
* @param {RuleOnErrorInfo[]} errors RuleOnErrorInfo instances.
|
|
1248
1255
|
* @returns {string} Fixed content.
|
|
1249
1256
|
*/
|
|
1250
|
-
function applyFixes(input, errors) {
|
|
1251
|
-
const lineEnding = helpers.getPreferredLineEnding(input,
|
|
1257
|
+
export function applyFixes(input, errors) {
|
|
1258
|
+
const lineEnding = helpers.getPreferredLineEnding(input, os);
|
|
1252
1259
|
const lines = input.split(helpers.newLineRe);
|
|
1253
1260
|
// Normalize fixInfo objects
|
|
1254
1261
|
let fixInfos = errors
|
|
@@ -1267,8 +1274,7 @@ function applyFixes(input, errors) {
|
|
|
1267
1274
|
);
|
|
1268
1275
|
});
|
|
1269
1276
|
// Remove duplicate entries (needed for following collapse step)
|
|
1270
|
-
|
|
1271
|
-
/** @type RuleOnErrorFixInfo */
|
|
1277
|
+
/** @type {RuleOnErrorFixInfo} */
|
|
1272
1278
|
let lastFixInfo = {};
|
|
1273
1279
|
fixInfos = fixInfos.filter((fixInfo) => {
|
|
1274
1280
|
const unique = (
|
|
@@ -1326,24 +1332,10 @@ function applyFixes(input, errors) {
|
|
|
1326
1332
|
*
|
|
1327
1333
|
* @returns {string} SemVer string.
|
|
1328
1334
|
*/
|
|
1329
|
-
function getVersion() {
|
|
1335
|
+
export function getVersion() {
|
|
1330
1336
|
return version;
|
|
1331
1337
|
}
|
|
1332
1338
|
|
|
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
1339
|
// Type declarations
|
|
1348
1340
|
|
|
1349
1341
|
/**
|
|
@@ -1414,7 +1406,7 @@ module.exports = markdownlint;
|
|
|
1414
1406
|
* @property {string} line Line content.
|
|
1415
1407
|
*/
|
|
1416
1408
|
|
|
1417
|
-
/** @typedef {import("
|
|
1409
|
+
/** @typedef {import("micromark-util-types").TokenType} MicromarkTokenType */
|
|
1418
1410
|
|
|
1419
1411
|
/**
|
|
1420
1412
|
* micromark token.
|
|
@@ -1567,14 +1559,14 @@ module.exports = markdownlint;
|
|
|
1567
1559
|
* Configuration object for linting rules. For the JSON schema, see
|
|
1568
1560
|
* {@link ../schema/markdownlint-config-schema.json}.
|
|
1569
1561
|
*
|
|
1570
|
-
* @typedef {import("./configuration").Configuration} Configuration
|
|
1562
|
+
* @typedef {import("./configuration.d.ts").Configuration} Configuration
|
|
1571
1563
|
*/
|
|
1572
1564
|
|
|
1573
1565
|
/**
|
|
1574
1566
|
* Configuration object for linting rules strictly. For the JSON schema, see
|
|
1575
1567
|
* {@link ../schema/markdownlint-config-schema-strict.json}.
|
|
1576
1568
|
*
|
|
1577
|
-
* @typedef {import("./configuration-strict").ConfigurationStrict} ConfigurationStrict
|
|
1569
|
+
* @typedef {import("./configuration-strict.d.ts").ConfigurationStrict} ConfigurationStrict
|
|
1578
1570
|
*/
|
|
1579
1571
|
|
|
1580
1572
|
/**
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|
4
|
+
import { getHeadingLevel } from "../helpers/micromark-helpers.cjs";
|
|
5
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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("
|
|
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
|
-
|
|
3
|
+
import { addError, addErrorDetailIf } from "../helpers/helpers.cjs";
|
|
4
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
3
|
+
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|
4
|
+
import { getParentOfType } from "../helpers/micromark-helpers.cjs";
|
|
5
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
4
6
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
-
|
|
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("
|
|
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
|
-
|
|
3
|
+
import { addError } from "../helpers/helpers.cjs";
|
|
4
|
+
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
|
5
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
6
|
-
const { addRangeToSet } = require("../helpers/micromark-helpers.cjs");
|
|
7
|
-
const { filterByTypesCached } = require("./cache");
|
|
7
|
+
const reversedLinkRe = /(^|[^\\])\(([^()]+)\)\[([^\]^][^\]]*)\](?!\()/g;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
3
|
+
import { addErrorDetailIf } from "../helpers/helpers.cjs";
|
|
4
|
+
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
|
5
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
16
|
-
/** @
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
3
|
+
import { addErrorContext } from "../helpers/helpers.cjs";
|
|
4
|
+
import { addRangeToSet } from "../helpers/micromark-helpers.cjs";
|
|
5
|
+
import { filterByTypesCached } from "./cache.mjs";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
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" ],
|