eslint-plugin-markdown-preferences 0.40.2 → 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/chunk-pbuEa-1d.js +13 -0
- package/lib/index.d.ts +8 -9
- package/lib/index.js +280 -323
- package/package.json +28 -29
- package/lib/chunk-BAz01cYq.js +0 -18
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as __exportAll } from "./chunk-pbuEa-1d.js";
|
|
2
2
|
import stringWidth from "string-width";
|
|
3
3
|
import emojiRegex from "emoji-regex-xs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -14,7 +14,6 @@ import { mathFromMarkdown } from "mdast-util-math";
|
|
|
14
14
|
import { markdownLineEnding, markdownSpace } from "micromark-util-character";
|
|
15
15
|
import { codes, constants, types } from "micromark-util-symbol";
|
|
16
16
|
import { factorySpace } from "micromark-factory-space";
|
|
17
|
-
|
|
18
17
|
//#region src/utils/index.ts
|
|
19
18
|
/**
|
|
20
19
|
* Define the rule.
|
|
@@ -37,7 +36,6 @@ function createRule(ruleName, rule) {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
|
-
|
|
41
39
|
//#endregion
|
|
42
40
|
//#region src/utils/ast.ts
|
|
43
41
|
const RE_HTML_COMMENT = /<!--(.*?)-->/gu;
|
|
@@ -158,7 +156,6 @@ function getHTMLComments(sourceCode, node) {
|
|
|
158
156
|
}
|
|
159
157
|
}
|
|
160
158
|
}
|
|
161
|
-
|
|
162
159
|
//#endregion
|
|
163
160
|
//#region src/utils/unicode.ts
|
|
164
161
|
/**
|
|
@@ -185,7 +182,6 @@ function isPunctuation(char) {
|
|
|
185
182
|
function isAsciiControlCharacter(char) {
|
|
186
183
|
return /^[\x00-\x1f\x7f]+$/u.test(char);
|
|
187
184
|
}
|
|
188
|
-
|
|
189
185
|
//#endregion
|
|
190
186
|
//#region src/utils/atx-heading.ts
|
|
191
187
|
/**
|
|
@@ -205,16 +201,16 @@ function parseATXHeading(sourceCode, node) {
|
|
|
205
201
|
if (parsedClosing == null) {
|
|
206
202
|
const textAfterOpening = sourceCode.text.slice(openingSequence.range[1] + parsedOpening.after.length, range[1]);
|
|
207
203
|
const contentText = textAfterOpening.trimEnd();
|
|
208
|
-
const contentRange
|
|
204
|
+
const contentRange = [openingSequence.range[1] + parsedOpening.after.length, openingSequence.range[1] + parsedOpening.after.length + contentText.length];
|
|
209
205
|
const after = contentText === textAfterOpening ? null : {
|
|
210
206
|
text: textAfterOpening.slice(contentText.length),
|
|
211
|
-
range: [contentRange
|
|
207
|
+
range: [contentRange[1], range[1]]
|
|
212
208
|
};
|
|
213
209
|
return {
|
|
214
210
|
openingSequence,
|
|
215
211
|
content: {
|
|
216
212
|
text: contentText,
|
|
217
|
-
range: contentRange
|
|
213
|
+
range: contentRange
|
|
218
214
|
},
|
|
219
215
|
closingSequence: null,
|
|
220
216
|
after
|
|
@@ -287,7 +283,6 @@ function parseATXHeadingClosingSequenceFromText(text) {
|
|
|
287
283
|
return result;
|
|
288
284
|
}
|
|
289
285
|
}
|
|
290
|
-
|
|
291
286
|
//#endregion
|
|
292
287
|
//#region src/utils/text-width.ts
|
|
293
288
|
let segmenter;
|
|
@@ -309,7 +304,6 @@ function getTextWidthBySegment(text, startWidth) {
|
|
|
309
304
|
else width += stringWidth(c);
|
|
310
305
|
return width;
|
|
311
306
|
}
|
|
312
|
-
|
|
313
307
|
//#endregion
|
|
314
308
|
//#region src/rules/atx-heading-closing-sequence-length.ts
|
|
315
309
|
var atx_heading_closing_sequence_length_default = createRule("atx-heading-closing-sequence-length", {
|
|
@@ -320,6 +314,7 @@ var atx_heading_closing_sequence_length_default = createRule("atx-heading-closin
|
|
|
320
314
|
categories: ["standard"],
|
|
321
315
|
listCategory: "Decorative"
|
|
322
316
|
},
|
|
317
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
323
318
|
fixable: "code",
|
|
324
319
|
hasSuggestions: false,
|
|
325
320
|
schema: [{
|
|
@@ -456,12 +451,12 @@ var atx_heading_closing_sequence_length_default = createRule("atx-heading-closin
|
|
|
456
451
|
}
|
|
457
452
|
}
|
|
458
453
|
});
|
|
459
|
-
|
|
460
454
|
//#endregion
|
|
461
455
|
//#region src/rules/atx-heading-closing-sequence.ts
|
|
462
456
|
var atx_heading_closing_sequence_default = createRule("atx-heading-closing-sequence", {
|
|
463
457
|
meta: {
|
|
464
458
|
type: "layout",
|
|
459
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
465
460
|
docs: {
|
|
466
461
|
description: "enforce consistent use of closing sequence in ATX headings.",
|
|
467
462
|
categories: ["standard"],
|
|
@@ -522,7 +517,6 @@ var atx_heading_closing_sequence_default = createRule("atx-heading-closing-seque
|
|
|
522
517
|
} };
|
|
523
518
|
}
|
|
524
519
|
});
|
|
525
|
-
|
|
526
520
|
//#endregion
|
|
527
521
|
//#region src/utils/blockquotes.ts
|
|
528
522
|
const cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -573,7 +567,6 @@ function getBlockquoteLevelFromLine(sourceCode, lineNumber) {
|
|
|
573
567
|
map.set(lineNumber, result);
|
|
574
568
|
return result;
|
|
575
569
|
}
|
|
576
|
-
|
|
577
570
|
//#endregion
|
|
578
571
|
//#region src/utils/width.ts
|
|
579
572
|
/**
|
|
@@ -631,12 +624,12 @@ function atWidth(str, target) {
|
|
|
631
624
|
}
|
|
632
625
|
return null;
|
|
633
626
|
}
|
|
634
|
-
|
|
635
627
|
//#endregion
|
|
636
628
|
//#region src/rules/blockquote-marker-alignment.ts
|
|
637
629
|
var blockquote_marker_alignment_default = createRule("blockquote-marker-alignment", {
|
|
638
630
|
meta: {
|
|
639
631
|
type: "layout",
|
|
632
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
640
633
|
docs: {
|
|
641
634
|
description: "enforce consistent alignment of blockquote markers",
|
|
642
635
|
categories: ["recommended", "standard"],
|
|
@@ -715,7 +708,6 @@ var blockquote_marker_alignment_default = createRule("blockquote-marker-alignmen
|
|
|
715
708
|
};
|
|
716
709
|
}
|
|
717
710
|
});
|
|
718
|
-
|
|
719
711
|
//#endregion
|
|
720
712
|
//#region src/rules/bullet-list-marker-style.ts
|
|
721
713
|
const MARKERS$1 = [
|
|
@@ -761,6 +753,7 @@ function parseOptions$9(options) {
|
|
|
761
753
|
var bullet_list_marker_style_default = createRule("bullet-list-marker-style", {
|
|
762
754
|
meta: {
|
|
763
755
|
type: "layout",
|
|
756
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
764
757
|
docs: {
|
|
765
758
|
description: "enforce consistent bullet list (unordered list) marker style",
|
|
766
759
|
categories: ["standard"],
|
|
@@ -884,7 +877,6 @@ var bullet_list_marker_style_default = createRule("bullet-list-marker-style", {
|
|
|
884
877
|
};
|
|
885
878
|
}
|
|
886
879
|
});
|
|
887
|
-
|
|
888
880
|
//#endregion
|
|
889
881
|
//#region src/utils/fenced-code-block.ts
|
|
890
882
|
const RE_OPENING_FENCE = /^(`{3,}|~{3,})/u;
|
|
@@ -914,12 +906,12 @@ function parseFencedCodeBlock(sourceCode, node) {
|
|
|
914
906
|
range: [range[0], range[0] + fenceText.length]
|
|
915
907
|
};
|
|
916
908
|
const languageRange = languageText ? [openingFence.range[1] + spaceAfterOpeningFenceLength, openingFence.range[1] + spaceAfterOpeningFenceLength + languageText.length] : null;
|
|
917
|
-
const language
|
|
909
|
+
const language = languageText && languageRange ? {
|
|
918
910
|
text: languageText,
|
|
919
911
|
range: languageRange
|
|
920
912
|
} : null;
|
|
921
|
-
const metaRange = language
|
|
922
|
-
const meta = language
|
|
913
|
+
const metaRange = language && metaText ? [language.range[1] + spaceAfterLanguageLength, language.range[1] + spaceAfterLanguageLength + metaText.length] : null;
|
|
914
|
+
const meta = language && metaText && metaRange ? {
|
|
923
915
|
text: metaText,
|
|
924
916
|
range: metaRange
|
|
925
917
|
} : null;
|
|
@@ -944,13 +936,13 @@ function parseFencedCodeBlock(sourceCode, node) {
|
|
|
944
936
|
closingFenceText = closingFenceText.trimStart();
|
|
945
937
|
if (!closingFenceText || !closingFenceText.startsWith(fenceText)) return {
|
|
946
938
|
openingFence,
|
|
947
|
-
language
|
|
939
|
+
language,
|
|
948
940
|
meta,
|
|
949
941
|
closingFence: null
|
|
950
942
|
};
|
|
951
943
|
return {
|
|
952
944
|
openingFence,
|
|
953
|
-
language
|
|
945
|
+
language,
|
|
954
946
|
meta,
|
|
955
947
|
closingFence: {
|
|
956
948
|
text: closingFenceText,
|
|
@@ -958,7 +950,6 @@ function parseFencedCodeBlock(sourceCode, node) {
|
|
|
958
950
|
}
|
|
959
951
|
};
|
|
960
952
|
}
|
|
961
|
-
|
|
962
953
|
//#endregion
|
|
963
954
|
//#region src/rules/canonical-code-block-language.ts
|
|
964
955
|
const DEFAULT_LANGUAGES = {
|
|
@@ -987,6 +978,7 @@ const DEFAULT_LANGUAGES = {
|
|
|
987
978
|
var canonical_code_block_language_default = createRule("canonical-code-block-language", {
|
|
988
979
|
meta: {
|
|
989
980
|
type: "suggestion",
|
|
981
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
990
982
|
docs: {
|
|
991
983
|
description: "enforce canonical language names in code blocks",
|
|
992
984
|
categories: [],
|
|
@@ -1007,10 +999,10 @@ var canonical_code_block_language_default = createRule("canonical-code-block-lan
|
|
|
1007
999
|
},
|
|
1008
1000
|
create(context) {
|
|
1009
1001
|
const sourceCode = context.sourceCode;
|
|
1010
|
-
const languages
|
|
1002
|
+
const languages = context.options[0]?.languages || DEFAULT_LANGUAGES;
|
|
1011
1003
|
return { code(node) {
|
|
1012
|
-
if (!node.lang || !languages
|
|
1013
|
-
const canonical = languages
|
|
1004
|
+
if (!node.lang || !languages[node.lang]) return;
|
|
1005
|
+
const canonical = languages[node.lang];
|
|
1014
1006
|
const current = node.lang;
|
|
1015
1007
|
if (current === canonical) return;
|
|
1016
1008
|
const parsed = parseFencedCodeBlock(sourceCode, node);
|
|
@@ -1033,12 +1025,12 @@ var canonical_code_block_language_default = createRule("canonical-code-block-lan
|
|
|
1033
1025
|
} };
|
|
1034
1026
|
}
|
|
1035
1027
|
});
|
|
1036
|
-
|
|
1037
1028
|
//#endregion
|
|
1038
1029
|
//#region src/rules/code-fence-length.ts
|
|
1039
1030
|
var code_fence_length_default = createRule("code-fence-length", {
|
|
1040
1031
|
meta: {
|
|
1041
1032
|
type: "layout",
|
|
1033
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
1042
1034
|
docs: {
|
|
1043
1035
|
description: "enforce consistent code fence length in fenced code blocks.",
|
|
1044
1036
|
categories: ["standard"],
|
|
@@ -1177,12 +1169,12 @@ var code_fence_length_default = createRule("code-fence-length", {
|
|
|
1177
1169
|
} };
|
|
1178
1170
|
}
|
|
1179
1171
|
});
|
|
1180
|
-
|
|
1181
1172
|
//#endregion
|
|
1182
1173
|
//#region src/rules/code-fence-spacing.ts
|
|
1183
1174
|
var code_fence_spacing_default = createRule("code-fence-spacing", {
|
|
1184
1175
|
meta: {
|
|
1185
1176
|
type: "layout",
|
|
1177
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
1186
1178
|
docs: {
|
|
1187
1179
|
description: "require or disallow spacing between opening code fence and language identifier",
|
|
1188
1180
|
categories: ["standard"],
|
|
@@ -1206,16 +1198,16 @@ var code_fence_spacing_default = createRule("code-fence-spacing", {
|
|
|
1206
1198
|
return { code(node) {
|
|
1207
1199
|
const parsed = parseFencedCodeBlock(sourceCode, node);
|
|
1208
1200
|
if (!parsed) return;
|
|
1209
|
-
const { openingFence, language
|
|
1210
|
-
if (!language
|
|
1211
|
-
const hasSpace = openingFence.range[1] < language
|
|
1201
|
+
const { openingFence, language } = parsed;
|
|
1202
|
+
if (!language) return;
|
|
1203
|
+
const hasSpace = openingFence.range[1] < language.range[0];
|
|
1212
1204
|
if (space === "always") {
|
|
1213
1205
|
if (hasSpace) return;
|
|
1214
1206
|
context.report({
|
|
1215
1207
|
node,
|
|
1216
1208
|
loc: {
|
|
1217
|
-
start: sourceCode.getLocFromIndex(language
|
|
1218
|
-
end: sourceCode.getLocFromIndex(language
|
|
1209
|
+
start: sourceCode.getLocFromIndex(language.range[0]),
|
|
1210
|
+
end: sourceCode.getLocFromIndex(language.range[1])
|
|
1219
1211
|
},
|
|
1220
1212
|
messageId: "expectedSpace",
|
|
1221
1213
|
fix(fixer) {
|
|
@@ -1228,23 +1220,23 @@ var code_fence_spacing_default = createRule("code-fence-spacing", {
|
|
|
1228
1220
|
node,
|
|
1229
1221
|
loc: {
|
|
1230
1222
|
start: sourceCode.getLocFromIndex(openingFence.range[1]),
|
|
1231
|
-
end: sourceCode.getLocFromIndex(language
|
|
1223
|
+
end: sourceCode.getLocFromIndex(language.range[0])
|
|
1232
1224
|
},
|
|
1233
1225
|
messageId: "unexpectedSpace",
|
|
1234
1226
|
fix(fixer) {
|
|
1235
|
-
return fixer.removeRange([openingFence.range[1], language
|
|
1227
|
+
return fixer.removeRange([openingFence.range[1], language.range[0]]);
|
|
1236
1228
|
}
|
|
1237
1229
|
});
|
|
1238
1230
|
}
|
|
1239
1231
|
} };
|
|
1240
1232
|
}
|
|
1241
1233
|
});
|
|
1242
|
-
|
|
1243
1234
|
//#endregion
|
|
1244
1235
|
//#region src/rules/code-fence-style.ts
|
|
1245
1236
|
var code_fence_style_default = createRule("code-fence-style", {
|
|
1246
1237
|
meta: {
|
|
1247
1238
|
type: "layout",
|
|
1239
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
1248
1240
|
docs: {
|
|
1249
1241
|
description: "enforce a consistent code fence style (backtick or tilde) in Markdown fenced code blocks.",
|
|
1250
1242
|
categories: ["standard"],
|
|
@@ -1290,7 +1282,6 @@ var code_fence_style_default = createRule("code-fence-style", {
|
|
|
1290
1282
|
} };
|
|
1291
1283
|
}
|
|
1292
1284
|
});
|
|
1293
|
-
|
|
1294
1285
|
//#endregion
|
|
1295
1286
|
//#region src/utils/custom-container.ts
|
|
1296
1287
|
const RE_OPENING_SEQUENCE = /^(:{3,})/u;
|
|
@@ -1351,12 +1342,12 @@ function parseCustomContainer(sourceCode, node) {
|
|
|
1351
1342
|
}
|
|
1352
1343
|
};
|
|
1353
1344
|
}
|
|
1354
|
-
|
|
1355
1345
|
//#endregion
|
|
1356
1346
|
//#region src/rules/custom-container-marker-spacing.ts
|
|
1357
1347
|
var custom_container_marker_spacing_default = createRule("custom-container-marker-spacing", {
|
|
1358
1348
|
meta: {
|
|
1359
1349
|
type: "layout",
|
|
1350
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
1360
1351
|
docs: {
|
|
1361
1352
|
description: "require or disallow spacing between opening custom container marker and info",
|
|
1362
1353
|
categories: ["standard"],
|
|
@@ -1412,7 +1403,6 @@ var custom_container_marker_spacing_default = createRule("custom-container-marke
|
|
|
1412
1403
|
} };
|
|
1413
1404
|
}
|
|
1414
1405
|
});
|
|
1415
|
-
|
|
1416
1406
|
//#endregion
|
|
1417
1407
|
//#region src/rules/definitions-last.ts
|
|
1418
1408
|
/**
|
|
@@ -1433,6 +1423,7 @@ function parseOptions$8(options) {
|
|
|
1433
1423
|
var definitions_last_default = createRule("definitions-last", {
|
|
1434
1424
|
meta: {
|
|
1435
1425
|
type: "layout",
|
|
1426
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
1436
1427
|
docs: {
|
|
1437
1428
|
description: "require link definitions and footnote definitions to be placed at the end of the document",
|
|
1438
1429
|
categories: [],
|
|
@@ -1678,7 +1669,6 @@ var definitions_last_default = createRule("definitions-last", {
|
|
|
1678
1669
|
};
|
|
1679
1670
|
}
|
|
1680
1671
|
});
|
|
1681
|
-
|
|
1682
1672
|
//#endregion
|
|
1683
1673
|
//#region src/utils/regexp.ts
|
|
1684
1674
|
const RE_REGEXP_STR = /^\/(.+)\/([A-Za-z]*)$/u;
|
|
@@ -1703,7 +1693,6 @@ function toRegExp(string) {
|
|
|
1703
1693
|
function isRegExp(string) {
|
|
1704
1694
|
return Boolean(RE_REGEXP_STR.test(string));
|
|
1705
1695
|
}
|
|
1706
|
-
|
|
1707
1696
|
//#endregion
|
|
1708
1697
|
//#region src/utils/resources/gh-emoji.ts
|
|
1709
1698
|
const GH_EMOJI_MAP = {
|
|
@@ -3621,7 +3610,6 @@ const GH_EMOJI_MAP = {
|
|
|
3621
3610
|
zombie_woman: "🧟♀",
|
|
3622
3611
|
zzz: "💤"
|
|
3623
3612
|
};
|
|
3624
|
-
|
|
3625
3613
|
//#endregion
|
|
3626
3614
|
//#region src/rules/emoji-notation.ts
|
|
3627
3615
|
var EmojiData = class {
|
|
@@ -3634,13 +3622,13 @@ var EmojiData = class {
|
|
|
3634
3622
|
get emojiToColon() {
|
|
3635
3623
|
if (this._emojiToColon) return this._emojiToColon;
|
|
3636
3624
|
const emojiToCode = this._emojiToColon = Object.create(null);
|
|
3637
|
-
for (const [name
|
|
3625
|
+
for (const [name, unicode] of this.entries) emojiToCode[unicode] = `:${name}:`;
|
|
3638
3626
|
return emojiToCode;
|
|
3639
3627
|
}
|
|
3640
3628
|
get colonToEmoji() {
|
|
3641
3629
|
if (this._colonToEmoji) return this._colonToEmoji;
|
|
3642
3630
|
const colonToEmoji = this._colonToEmoji = Object.create(null);
|
|
3643
|
-
for (const [name
|
|
3631
|
+
for (const [name, unicode] of this.entries) colonToEmoji[`:${name}:`] = unicode;
|
|
3644
3632
|
return colonToEmoji;
|
|
3645
3633
|
}
|
|
3646
3634
|
};
|
|
@@ -3648,6 +3636,7 @@ const emojiData = new EmojiData();
|
|
|
3648
3636
|
var emoji_notation_default = createRule("emoji-notation", {
|
|
3649
3637
|
meta: {
|
|
3650
3638
|
type: "suggestion",
|
|
3639
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
3651
3640
|
docs: {
|
|
3652
3641
|
description: "enforce consistent emoji notation style in Markdown files.",
|
|
3653
3642
|
categories: [],
|
|
@@ -3689,20 +3678,20 @@ var emoji_notation_default = createRule("emoji-notation", {
|
|
|
3689
3678
|
const ignoreUnknown = options.ignoreUnknown ?? true;
|
|
3690
3679
|
const ignoreList = (options.ignoreList || []).map((s) => toRegExp(s)).flatMap((re) => {
|
|
3691
3680
|
const result = [re];
|
|
3692
|
-
for (const [name
|
|
3681
|
+
for (const [name, unicode] of emojiData.entries) if (re.test(`:${name}:`) || re.test(unicode)) result.push(toRegExp(`:${name}:`), toRegExp(unicode));
|
|
3693
3682
|
return result;
|
|
3694
3683
|
});
|
|
3695
3684
|
const isIgnoreBase = (s) => ignoreList.some((re) => re.test(s));
|
|
3696
3685
|
if (prefer === "colon") {
|
|
3697
|
-
let isIgnore
|
|
3698
|
-
if (ignoreUnknown) isIgnore
|
|
3699
|
-
else isIgnore
|
|
3686
|
+
let isIgnore;
|
|
3687
|
+
if (ignoreUnknown) isIgnore = (s) => isIgnoreBase(s) || !emojiData.emojiToColon[s];
|
|
3688
|
+
else isIgnore = (s) => isIgnoreBase(s);
|
|
3700
3689
|
return { text(node) {
|
|
3701
3690
|
const re = emojiRegex();
|
|
3702
3691
|
const text = sourceCode.getText(node);
|
|
3703
3692
|
for (const match of text.matchAll(re)) {
|
|
3704
3693
|
const emoji = match[0];
|
|
3705
|
-
if (isIgnore
|
|
3694
|
+
if (isIgnore(emoji)) continue;
|
|
3706
3695
|
const emojiOffset = match.index;
|
|
3707
3696
|
const [nodeStart] = sourceCode.getRange(node);
|
|
3708
3697
|
const range = [nodeStart + emojiOffset, nodeStart + emojiOffset + emoji.length];
|
|
@@ -3757,7 +3746,6 @@ var emoji_notation_default = createRule("emoji-notation", {
|
|
|
3757
3746
|
} };
|
|
3758
3747
|
}
|
|
3759
3748
|
});
|
|
3760
|
-
|
|
3761
3749
|
//#endregion
|
|
3762
3750
|
//#region src/rules/emphasis-delimiters-style.ts
|
|
3763
3751
|
/**
|
|
@@ -3774,6 +3762,7 @@ function isIntrawordForUnderline(text, range) {
|
|
|
3774
3762
|
var emphasis_delimiters_style_default = createRule("emphasis-delimiters-style", {
|
|
3775
3763
|
meta: {
|
|
3776
3764
|
type: "layout",
|
|
3765
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
3777
3766
|
docs: {
|
|
3778
3767
|
description: "enforce a consistent delimiter style for emphasis and strong emphasis",
|
|
3779
3768
|
categories: ["standard"],
|
|
@@ -3950,12 +3939,12 @@ function parseStrongEmphasis(emphasis, strong, strongEmphasisOpt) {
|
|
|
3950
3939
|
closing: "___"
|
|
3951
3940
|
};
|
|
3952
3941
|
}
|
|
3953
|
-
|
|
3954
3942
|
//#endregion
|
|
3955
3943
|
//#region src/rules/hard-linebreak-style.ts
|
|
3956
3944
|
var hard_linebreak_style_default = createRule("hard-linebreak-style", {
|
|
3957
3945
|
meta: {
|
|
3958
3946
|
type: "layout",
|
|
3947
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
3959
3948
|
docs: {
|
|
3960
3949
|
description: "enforce consistent hard linebreak style.",
|
|
3961
3950
|
categories: ["recommended", "standard"],
|
|
@@ -3995,7 +3984,6 @@ var hard_linebreak_style_default = createRule("hard-linebreak-style", {
|
|
|
3995
3984
|
} };
|
|
3996
3985
|
}
|
|
3997
3986
|
});
|
|
3998
|
-
|
|
3999
3987
|
//#endregion
|
|
4000
3988
|
//#region src/resources/preserve-words.ts
|
|
4001
3989
|
const defaultPreserveWords = [
|
|
@@ -4459,7 +4447,6 @@ const defaultPreserveWords = [
|
|
|
4459
4447
|
"FAQ",
|
|
4460
4448
|
"YouTube"
|
|
4461
4449
|
];
|
|
4462
|
-
|
|
4463
4450
|
//#endregion
|
|
4464
4451
|
//#region src/resources/minor-words.ts
|
|
4465
4452
|
const articles = [
|
|
@@ -4494,7 +4481,6 @@ const defaultMinorWords = [
|
|
|
4494
4481
|
...conjunctions,
|
|
4495
4482
|
...prepositions
|
|
4496
4483
|
];
|
|
4497
|
-
|
|
4498
4484
|
//#endregion
|
|
4499
4485
|
//#region src/utils/word-casing.ts
|
|
4500
4486
|
/**
|
|
@@ -4524,7 +4510,6 @@ function convertWordCasing({ word, first, last }, { caseStyle, minorWords }) {
|
|
|
4524
4510
|
isMinorWord: false
|
|
4525
4511
|
};
|
|
4526
4512
|
}
|
|
4527
|
-
|
|
4528
4513
|
//#endregion
|
|
4529
4514
|
//#region src/utils/preserve-words.ts
|
|
4530
4515
|
var PreserveWordsContext = class {
|
|
@@ -4593,7 +4578,6 @@ var PreserveWordsContext = class {
|
|
|
4593
4578
|
function parsePreserveWordsOption(preserveWordsOption) {
|
|
4594
4579
|
return new PreserveWordsContext(preserveWordsOption);
|
|
4595
4580
|
}
|
|
4596
|
-
|
|
4597
4581
|
//#endregion
|
|
4598
4582
|
//#region src/utils/words.ts
|
|
4599
4583
|
const WELLKNOWN_WORDS = new Set(["I"]);
|
|
@@ -4632,12 +4616,12 @@ function parseWordsFromText(text, firstNode, lastNode) {
|
|
|
4632
4616
|
}
|
|
4633
4617
|
return words;
|
|
4634
4618
|
}
|
|
4635
|
-
|
|
4636
4619
|
//#endregion
|
|
4637
4620
|
//#region src/rules/heading-casing.ts
|
|
4638
4621
|
var heading_casing_default = createRule("heading-casing", {
|
|
4639
4622
|
meta: {
|
|
4640
4623
|
type: "suggestion",
|
|
4624
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
4641
4625
|
docs: {
|
|
4642
4626
|
description: "enforce consistent casing in headings.",
|
|
4643
4627
|
categories: [],
|
|
@@ -4766,7 +4750,6 @@ var heading_casing_default = createRule("heading-casing", {
|
|
|
4766
4750
|
} };
|
|
4767
4751
|
}
|
|
4768
4752
|
});
|
|
4769
|
-
|
|
4770
4753
|
//#endregion
|
|
4771
4754
|
//#region src/utils/character-cursor.ts
|
|
4772
4755
|
var CharacterCursor = class {
|
|
@@ -4790,10 +4773,10 @@ var CharacterCursor = class {
|
|
|
4790
4773
|
if (ch !== ">") return false;
|
|
4791
4774
|
const prefix = [ch];
|
|
4792
4775
|
for (let prev = index - 1; prev >= 0; prev--) {
|
|
4793
|
-
const prevCh
|
|
4794
|
-
if (prevCh
|
|
4795
|
-
if (isSpaceOrTab(prevCh
|
|
4796
|
-
prefix.unshift(prevCh
|
|
4776
|
+
const prevCh = this.text[prev];
|
|
4777
|
+
if (prevCh === "\n") break;
|
|
4778
|
+
if (isSpaceOrTab(prevCh) || prevCh === ">") {
|
|
4779
|
+
prefix.unshift(prevCh);
|
|
4797
4780
|
continue;
|
|
4798
4781
|
}
|
|
4799
4782
|
return false;
|
|
@@ -4882,7 +4865,6 @@ var BackwardCharacterCursor = class extends CharacterCursor {
|
|
|
4882
4865
|
return false;
|
|
4883
4866
|
}
|
|
4884
4867
|
};
|
|
4885
|
-
|
|
4886
4868
|
//#endregion
|
|
4887
4869
|
//#region src/utils/link-definition.ts
|
|
4888
4870
|
/**
|
|
@@ -4981,7 +4963,6 @@ function parseLinkDefinitionFromText(text) {
|
|
|
4981
4963
|
title
|
|
4982
4964
|
};
|
|
4983
4965
|
}
|
|
4984
|
-
|
|
4985
4966
|
//#endregion
|
|
4986
4967
|
//#region src/utils/link.ts
|
|
4987
4968
|
/**
|
|
@@ -5049,7 +5030,7 @@ function parseInlineLinkDestAndTitleFromText(text) {
|
|
|
5049
5030
|
}
|
|
5050
5031
|
cursor.skipSpaces();
|
|
5051
5032
|
if (cursor.curr() === ")") {
|
|
5052
|
-
const closingParenStartIndex
|
|
5033
|
+
const closingParenStartIndex = cursor.currIndex();
|
|
5053
5034
|
cursor.next();
|
|
5054
5035
|
cursor.skipSpaces();
|
|
5055
5036
|
if (!cursor.finished()) return null;
|
|
@@ -5057,7 +5038,7 @@ function parseInlineLinkDestAndTitleFromText(text) {
|
|
|
5057
5038
|
openingParen: { range: [0, 1] },
|
|
5058
5039
|
destination,
|
|
5059
5040
|
title: null,
|
|
5060
|
-
closingParen: { range: [closingParenStartIndex
|
|
5041
|
+
closingParen: { range: [closingParenStartIndex, closingParenStartIndex + 1] }
|
|
5061
5042
|
};
|
|
5062
5043
|
}
|
|
5063
5044
|
if (cursor.finished()) return null;
|
|
@@ -5089,7 +5070,6 @@ function parseInlineLinkDestAndTitleFromText(text) {
|
|
|
5089
5070
|
closingParen: { range: [closingParenStartIndex, closingParenStartIndex + 1] }
|
|
5090
5071
|
};
|
|
5091
5072
|
}
|
|
5092
|
-
|
|
5093
5073
|
//#endregion
|
|
5094
5074
|
//#region src/utils/link-reference.ts
|
|
5095
5075
|
/**
|
|
@@ -5108,12 +5088,12 @@ function parseLinkReference(sourceCode, node) {
|
|
|
5108
5088
|
label: null
|
|
5109
5089
|
};
|
|
5110
5090
|
if (node.referenceType === "collapsed") {
|
|
5111
|
-
const labelRange
|
|
5091
|
+
const labelRange = [textRange[1], textRange[1] + 1];
|
|
5112
5092
|
return {
|
|
5113
5093
|
text: { range: textRange },
|
|
5114
5094
|
label: {
|
|
5115
5095
|
type: "collapsed",
|
|
5116
|
-
range: labelRange
|
|
5096
|
+
range: labelRange
|
|
5117
5097
|
}
|
|
5118
5098
|
};
|
|
5119
5099
|
}
|
|
@@ -5136,7 +5116,6 @@ function parseLinkReference(sourceCode, node) {
|
|
|
5136
5116
|
}
|
|
5137
5117
|
};
|
|
5138
5118
|
}
|
|
5139
|
-
|
|
5140
5119
|
//#endregion
|
|
5141
5120
|
//#region src/utils/image.ts
|
|
5142
5121
|
/**
|
|
@@ -5230,7 +5209,6 @@ function parseImageFromText(text) {
|
|
|
5230
5209
|
closingParen: { range: [closingParenStartIndex, closingParenStartIndex + 1] }
|
|
5231
5210
|
};
|
|
5232
5211
|
}
|
|
5233
|
-
|
|
5234
5212
|
//#endregion
|
|
5235
5213
|
//#region src/utils/image-reference.ts
|
|
5236
5214
|
/**
|
|
@@ -5239,26 +5217,26 @@ function parseImageFromText(text) {
|
|
|
5239
5217
|
function parseImageReference(sourceCode, node) {
|
|
5240
5218
|
const nodeRange = sourceCode.getRange(node);
|
|
5241
5219
|
if (node.referenceType === "shortcut") {
|
|
5242
|
-
const textRange
|
|
5220
|
+
const textRange = [nodeRange[0] + 1, nodeRange[1]];
|
|
5243
5221
|
return {
|
|
5244
5222
|
text: {
|
|
5245
|
-
range: textRange
|
|
5246
|
-
text: sourceCode.text.slice(...textRange
|
|
5223
|
+
range: textRange,
|
|
5224
|
+
text: sourceCode.text.slice(...textRange)
|
|
5247
5225
|
},
|
|
5248
5226
|
label: null
|
|
5249
5227
|
};
|
|
5250
5228
|
}
|
|
5251
5229
|
if (node.referenceType === "collapsed") {
|
|
5252
|
-
const textRange
|
|
5253
|
-
const labelRange
|
|
5230
|
+
const textRange = [nodeRange[0] + 1, nodeRange[1] - 2];
|
|
5231
|
+
const labelRange = [textRange[1], nodeRange[1]];
|
|
5254
5232
|
return {
|
|
5255
5233
|
text: {
|
|
5256
|
-
range: textRange
|
|
5257
|
-
text: sourceCode.text.slice(...textRange
|
|
5234
|
+
range: textRange,
|
|
5235
|
+
text: sourceCode.text.slice(...textRange)
|
|
5258
5236
|
},
|
|
5259
5237
|
label: {
|
|
5260
5238
|
type: "collapsed",
|
|
5261
|
-
range: labelRange
|
|
5239
|
+
range: labelRange
|
|
5262
5240
|
}
|
|
5263
5241
|
};
|
|
5264
5242
|
}
|
|
@@ -5305,7 +5283,6 @@ function parseFullImageReferenceFromText(text) {
|
|
|
5305
5283
|
label
|
|
5306
5284
|
};
|
|
5307
5285
|
}
|
|
5308
|
-
|
|
5309
5286
|
//#endregion
|
|
5310
5287
|
//#region src/utils/list-item.ts
|
|
5311
5288
|
/**
|
|
@@ -5350,7 +5327,6 @@ function parseListItem(sourceCode, node) {
|
|
|
5350
5327
|
taskListItemMarker: null
|
|
5351
5328
|
};
|
|
5352
5329
|
}
|
|
5353
|
-
|
|
5354
5330
|
//#endregion
|
|
5355
5331
|
//#region src/utils/math-block.ts
|
|
5356
5332
|
/**
|
|
@@ -5368,12 +5344,12 @@ function parseMathBlock(sourceCode, node) {
|
|
|
5368
5344
|
};
|
|
5369
5345
|
const parsedClosing = parseMathClosingSequenceFromText(text);
|
|
5370
5346
|
if (parsedClosing == null || parsedClosing.closingSequence !== parsedOpening.openingSequence) {
|
|
5371
|
-
const contentRange
|
|
5347
|
+
const contentRange = [openingSequence.range[1] + parsedOpening.after.length, range[1]];
|
|
5372
5348
|
return {
|
|
5373
5349
|
openingSequence,
|
|
5374
5350
|
content: {
|
|
5375
5351
|
text: text.slice(parsedOpening.after.length),
|
|
5376
|
-
range: contentRange
|
|
5352
|
+
range: contentRange
|
|
5377
5353
|
},
|
|
5378
5354
|
closingSequence: null,
|
|
5379
5355
|
after: null
|
|
@@ -5458,7 +5434,6 @@ function parseMathClosingSequenceFromText(text) {
|
|
|
5458
5434
|
return result;
|
|
5459
5435
|
}
|
|
5460
5436
|
}
|
|
5461
|
-
|
|
5462
5437
|
//#endregion
|
|
5463
5438
|
//#region src/rules/indent.ts
|
|
5464
5439
|
/**
|
|
@@ -5475,6 +5450,7 @@ function parseOptions$7(options) {
|
|
|
5475
5450
|
var indent_default = createRule("indent", {
|
|
5476
5451
|
meta: {
|
|
5477
5452
|
type: "layout",
|
|
5453
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
5478
5454
|
docs: {
|
|
5479
5455
|
description: "enforce consistent indentation in Markdown files",
|
|
5480
5456
|
categories: ["standard"],
|
|
@@ -5916,9 +5892,9 @@ var indent_default = createRule("indent", {
|
|
|
5916
5892
|
column: 1
|
|
5917
5893
|
});
|
|
5918
5894
|
if (info.expectedIndentWidth > actualIndentWidth) {
|
|
5919
|
-
const before
|
|
5895
|
+
const before = sliceWidth(lineText, 0, actualIndentWidth);
|
|
5920
5896
|
const diffWidth = info.expectedIndentWidth - actualIndentWidth;
|
|
5921
|
-
return fixer.insertTextAfterRange([lineStartIndex, lineStartIndex + before
|
|
5897
|
+
return fixer.insertTextAfterRange([lineStartIndex, lineStartIndex + before.length], " ".repeat(diffWidth));
|
|
5922
5898
|
}
|
|
5923
5899
|
let before = sliceWidth(lineText, 0, info.expectedIndentWidth);
|
|
5924
5900
|
let between = sliceWidth(lineText, info.expectedIndentWidth, actualIndentWidth);
|
|
@@ -6419,7 +6395,6 @@ var indent_default = createRule("indent", {
|
|
|
6419
6395
|
}
|
|
6420
6396
|
}
|
|
6421
6397
|
});
|
|
6422
|
-
|
|
6423
6398
|
//#endregion
|
|
6424
6399
|
//#region src/utils/setext-heading.ts
|
|
6425
6400
|
/**
|
|
@@ -6523,12 +6498,12 @@ function parseUnderline(sourceCode, lineNumber) {
|
|
|
6523
6498
|
}
|
|
6524
6499
|
};
|
|
6525
6500
|
}
|
|
6526
|
-
|
|
6527
6501
|
//#endregion
|
|
6528
6502
|
//#region src/rules/level1-heading-style.ts
|
|
6529
6503
|
var level1_heading_style_default = createRule("level1-heading-style", {
|
|
6530
6504
|
meta: {
|
|
6531
6505
|
type: "layout",
|
|
6506
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
6532
6507
|
docs: {
|
|
6533
6508
|
description: "enforce consistent style for level 1 headings",
|
|
6534
6509
|
categories: ["standard"],
|
|
@@ -6606,12 +6581,12 @@ var level1_heading_style_default = createRule("level1-heading-style", {
|
|
|
6606
6581
|
} };
|
|
6607
6582
|
}
|
|
6608
6583
|
});
|
|
6609
|
-
|
|
6610
6584
|
//#endregion
|
|
6611
6585
|
//#region src/rules/level2-heading-style.ts
|
|
6612
6586
|
var level2_heading_style_default = createRule("level2-heading-style", {
|
|
6613
6587
|
meta: {
|
|
6614
6588
|
type: "layout",
|
|
6589
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
6615
6590
|
docs: {
|
|
6616
6591
|
description: "enforce consistent style for level 2 headings",
|
|
6617
6592
|
categories: ["standard"],
|
|
@@ -6689,12 +6664,12 @@ var level2_heading_style_default = createRule("level2-heading-style", {
|
|
|
6689
6664
|
} };
|
|
6690
6665
|
}
|
|
6691
6666
|
});
|
|
6692
|
-
|
|
6693
6667
|
//#endregion
|
|
6694
6668
|
//#region src/rules/link-bracket-newline.ts
|
|
6695
6669
|
var link_bracket_newline_default = createRule("link-bracket-newline", {
|
|
6696
6670
|
meta: {
|
|
6697
6671
|
type: "layout",
|
|
6672
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
6698
6673
|
docs: {
|
|
6699
6674
|
description: "enforce linebreaks after opening and before closing link brackets",
|
|
6700
6675
|
categories: ["standard"],
|
|
@@ -6723,11 +6698,11 @@ var link_bracket_newline_default = createRule("link-bracket-newline", {
|
|
|
6723
6698
|
},
|
|
6724
6699
|
create(context) {
|
|
6725
6700
|
const sourceCode = context.sourceCode;
|
|
6726
|
-
const optionProvider = parseOptions
|
|
6701
|
+
const optionProvider = parseOptions(context.options[0]);
|
|
6727
6702
|
/**
|
|
6728
6703
|
* Parse the options.
|
|
6729
6704
|
*/
|
|
6730
|
-
function parseOptions
|
|
6705
|
+
function parseOptions(option) {
|
|
6731
6706
|
const newline = option?.newline ?? "never";
|
|
6732
6707
|
const multiline = option?.multiline ?? false;
|
|
6733
6708
|
return (bracketsRange) => {
|
|
@@ -6863,7 +6838,6 @@ var link_bracket_newline_default = createRule("link-bracket-newline", {
|
|
|
6863
6838
|
}
|
|
6864
6839
|
}
|
|
6865
6840
|
});
|
|
6866
|
-
|
|
6867
6841
|
//#endregion
|
|
6868
6842
|
//#region src/rules/link-bracket-spacing.ts
|
|
6869
6843
|
/**
|
|
@@ -6895,6 +6869,7 @@ function parseOptions$6(option) {
|
|
|
6895
6869
|
var link_bracket_spacing_default = createRule("link-bracket-spacing", {
|
|
6896
6870
|
meta: {
|
|
6897
6871
|
type: "layout",
|
|
6872
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
6898
6873
|
docs: {
|
|
6899
6874
|
description: "enforce consistent spacing inside link brackets",
|
|
6900
6875
|
categories: ["standard"],
|
|
@@ -7055,7 +7030,6 @@ var link_bracket_spacing_default = createRule("link-bracket-spacing", {
|
|
|
7055
7030
|
}
|
|
7056
7031
|
}
|
|
7057
7032
|
});
|
|
7058
|
-
|
|
7059
7033
|
//#endregion
|
|
7060
7034
|
//#region src/rules/link-destination-style.ts
|
|
7061
7035
|
const STYLES$1 = {
|
|
@@ -7071,6 +7045,7 @@ const STYLES$1 = {
|
|
|
7071
7045
|
var link_destination_style_default = createRule("link-destination-style", {
|
|
7072
7046
|
meta: {
|
|
7073
7047
|
type: "layout",
|
|
7048
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7074
7049
|
docs: {
|
|
7075
7050
|
description: "enforce a consistent style for link destinations",
|
|
7076
7051
|
categories: ["standard"],
|
|
@@ -7194,12 +7169,12 @@ function hasLoneLastBackslash(text) {
|
|
|
7194
7169
|
while (text.endsWith(`${escapeText}\\`)) escapeText += "\\";
|
|
7195
7170
|
return escapeText.length % 2 === 1;
|
|
7196
7171
|
}
|
|
7197
|
-
|
|
7198
7172
|
//#endregion
|
|
7199
7173
|
//#region src/rules/link-paren-newline.ts
|
|
7200
7174
|
var link_paren_newline_default = createRule("link-paren-newline", {
|
|
7201
7175
|
meta: {
|
|
7202
7176
|
type: "layout",
|
|
7177
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7203
7178
|
docs: {
|
|
7204
7179
|
description: "enforce linebreaks after opening and before closing link parentheses",
|
|
7205
7180
|
categories: ["standard"],
|
|
@@ -7228,11 +7203,11 @@ var link_paren_newline_default = createRule("link-paren-newline", {
|
|
|
7228
7203
|
},
|
|
7229
7204
|
create(context) {
|
|
7230
7205
|
const sourceCode = context.sourceCode;
|
|
7231
|
-
const optionProvider = parseOptions
|
|
7206
|
+
const optionProvider = parseOptions(context.options[0]);
|
|
7232
7207
|
/**
|
|
7233
7208
|
* Parse the options.
|
|
7234
7209
|
*/
|
|
7235
|
-
function parseOptions
|
|
7210
|
+
function parseOptions(option) {
|
|
7236
7211
|
const newline = option?.newline ?? "never";
|
|
7237
7212
|
const multiline = option?.multiline ?? false;
|
|
7238
7213
|
return (openingParenIndex, closingParenIndex) => {
|
|
@@ -7349,12 +7324,12 @@ var link_paren_newline_default = createRule("link-paren-newline", {
|
|
|
7349
7324
|
}
|
|
7350
7325
|
}
|
|
7351
7326
|
});
|
|
7352
|
-
|
|
7353
7327
|
//#endregion
|
|
7354
7328
|
//#region src/rules/link-paren-spacing.ts
|
|
7355
7329
|
var link_paren_spacing_default = createRule("link-paren-spacing", {
|
|
7356
7330
|
meta: {
|
|
7357
7331
|
type: "layout",
|
|
7332
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7358
7333
|
docs: {
|
|
7359
7334
|
description: "enforce consistent spacing inside link parentheses",
|
|
7360
7335
|
categories: ["standard"],
|
|
@@ -7476,7 +7451,6 @@ var link_paren_spacing_default = createRule("link-paren-spacing", {
|
|
|
7476
7451
|
}
|
|
7477
7452
|
}
|
|
7478
7453
|
});
|
|
7479
|
-
|
|
7480
7454
|
//#endregion
|
|
7481
7455
|
//#region src/rules/link-title-style.ts
|
|
7482
7456
|
const STYLES = {
|
|
@@ -7502,6 +7476,7 @@ const STYLES = {
|
|
|
7502
7476
|
var link_title_style_default = createRule("link-title-style", {
|
|
7503
7477
|
meta: {
|
|
7504
7478
|
type: "layout",
|
|
7479
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7505
7480
|
docs: {
|
|
7506
7481
|
description: "enforce a consistent style for link titles",
|
|
7507
7482
|
categories: ["standard"],
|
|
@@ -7578,7 +7553,6 @@ var link_title_style_default = createRule("link-title-style", {
|
|
|
7578
7553
|
};
|
|
7579
7554
|
}
|
|
7580
7555
|
});
|
|
7581
|
-
|
|
7582
7556
|
//#endregion
|
|
7583
7557
|
//#region src/rules/list-marker-alignment.ts
|
|
7584
7558
|
const ALIGN_TO_POSITION_NAME = {
|
|
@@ -7588,6 +7562,7 @@ const ALIGN_TO_POSITION_NAME = {
|
|
|
7588
7562
|
var list_marker_alignment_default = createRule("list-marker-alignment", {
|
|
7589
7563
|
meta: {
|
|
7590
7564
|
type: "layout",
|
|
7565
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7591
7566
|
docs: {
|
|
7592
7567
|
description: "enforce consistent alignment of list markers",
|
|
7593
7568
|
categories: ["recommended", "standard"],
|
|
@@ -7689,7 +7664,6 @@ var list_marker_alignment_default = createRule("list-marker-alignment", {
|
|
|
7689
7664
|
return { list: checkListAlignment };
|
|
7690
7665
|
}
|
|
7691
7666
|
});
|
|
7692
|
-
|
|
7693
7667
|
//#endregion
|
|
7694
7668
|
//#region src/rules/max-len.ts
|
|
7695
7669
|
const URL_PATTERN = /https?:\/\/(?:w{3}\.)?[\w#%+\-.:=@~]{1,256}\.[\w()]{1,6}\b[\w#%&()+\-./:=?@~]*/gu;
|
|
@@ -7807,6 +7781,7 @@ function parseOptionsParNode(option) {
|
|
|
7807
7781
|
var max_len_default = createRule("max-len", {
|
|
7808
7782
|
meta: {
|
|
7809
7783
|
type: "layout",
|
|
7784
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7810
7785
|
docs: {
|
|
7811
7786
|
description: "enforce maximum length for various Markdown entities",
|
|
7812
7787
|
categories: [],
|
|
@@ -7892,7 +7867,6 @@ var max_len_default = createRule("max-len", {
|
|
|
7892
7867
|
};
|
|
7893
7868
|
}
|
|
7894
7869
|
});
|
|
7895
|
-
|
|
7896
7870
|
//#endregion
|
|
7897
7871
|
//#region src/rules/no-heading-trailing-punctuation.ts
|
|
7898
7872
|
const DEFAULT_PUNCTUATION = ".,;:!。、,;:!。、";
|
|
@@ -7930,20 +7904,20 @@ const HEADING_LEVELS = [
|
|
|
7930
7904
|
/**
|
|
7931
7905
|
* Parse heading level ranges and build a map of level -> punctuation string
|
|
7932
7906
|
*/
|
|
7933
|
-
function buildPunctuationMap(option, segmenter
|
|
7907
|
+
function buildPunctuationMap(option, segmenter) {
|
|
7934
7908
|
if (typeof option === "string" || option === void 0) {
|
|
7935
7909
|
const punctuation = option ?? DEFAULT_PUNCTUATION;
|
|
7936
|
-
const chars = new Set([...segmenter
|
|
7910
|
+
const chars = new Set([...segmenter.segment(punctuation)].map((s) => s.segment));
|
|
7937
7911
|
return Object.fromEntries(HEADING_LEVELS.map((level) => [level, chars]));
|
|
7938
7912
|
}
|
|
7939
7913
|
const defaultPunctuation = option.default ?? DEFAULT_PUNCTUATION;
|
|
7940
|
-
const defaultChars = new Set([...segmenter
|
|
7914
|
+
const defaultChars = new Set([...segmenter.segment(defaultPunctuation)].map((s) => s.segment));
|
|
7941
7915
|
const map = Object.fromEntries(HEADING_LEVELS.map((level) => [level, defaultChars]));
|
|
7942
7916
|
for (const [key, value] of Object.entries(option)) {
|
|
7943
7917
|
if (key === "default" || value == null) continue;
|
|
7944
7918
|
const range = LEVEL_RANGE_MAP[key];
|
|
7945
7919
|
if (!range) continue;
|
|
7946
|
-
const chars = new Set([...segmenter
|
|
7920
|
+
const chars = new Set([...segmenter.segment(value)].map((s) => s.segment));
|
|
7947
7921
|
for (let level = range[0]; level <= range[1]; level++) map[level] = chars;
|
|
7948
7922
|
}
|
|
7949
7923
|
return map;
|
|
@@ -7951,6 +7925,7 @@ function buildPunctuationMap(option, segmenter$1) {
|
|
|
7951
7925
|
var no_heading_trailing_punctuation_default = createRule("no-heading-trailing-punctuation", {
|
|
7952
7926
|
meta: {
|
|
7953
7927
|
type: "suggestion",
|
|
7928
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
7954
7929
|
docs: {
|
|
7955
7930
|
description: "disallow trailing punctuation in headings.",
|
|
7956
7931
|
categories: [],
|
|
@@ -7985,8 +7960,8 @@ var no_heading_trailing_punctuation_default = createRule("no-heading-trailing-pu
|
|
|
7985
7960
|
},
|
|
7986
7961
|
create(context) {
|
|
7987
7962
|
const sourceCode = context.sourceCode;
|
|
7988
|
-
const segmenter
|
|
7989
|
-
const punctuationMap = buildPunctuationMap(context.options[0]?.punctuation, segmenter
|
|
7963
|
+
const segmenter = new Intl.Segmenter("en", { granularity: "grapheme" });
|
|
7964
|
+
const punctuationMap = buildPunctuationMap(context.options[0]?.punctuation, segmenter);
|
|
7990
7965
|
const contentNodeTypes = new Set([
|
|
7991
7966
|
"inlineCode",
|
|
7992
7967
|
"image",
|
|
@@ -8002,7 +7977,7 @@ var no_heading_trailing_punctuation_default = createRule("no-heading-trailing-pu
|
|
|
8002
7977
|
if (!lastTextNode) return;
|
|
8003
7978
|
const trimmedText = sourceCode.getText(lastTextNode).trimEnd();
|
|
8004
7979
|
if (!trimmedText.length) return;
|
|
8005
|
-
const segments = [...segmenter
|
|
7980
|
+
const segments = [...segmenter.segment(trimmedText)];
|
|
8006
7981
|
const lastSegment = segments[segments.length - 1];
|
|
8007
7982
|
if (!lastSegment) return;
|
|
8008
7983
|
const lastChar = lastSegment.segment;
|
|
@@ -8047,12 +8022,12 @@ var no_heading_trailing_punctuation_default = createRule("no-heading-trailing-pu
|
|
|
8047
8022
|
}
|
|
8048
8023
|
}
|
|
8049
8024
|
});
|
|
8050
|
-
|
|
8051
8025
|
//#endregion
|
|
8052
8026
|
//#region src/rules/no-implicit-block-closing.ts
|
|
8053
8027
|
var no_implicit_block_closing_default = createRule("no-implicit-block-closing", {
|
|
8054
8028
|
meta: {
|
|
8055
8029
|
type: "suggestion",
|
|
8030
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
8056
8031
|
docs: {
|
|
8057
8032
|
description: "disallow implicit block closing for fenced code blocks, math blocks, and custom containers",
|
|
8058
8033
|
categories: ["recommended", "standard"],
|
|
@@ -8148,12 +8123,12 @@ function withinSameLengthOpeningCustomContainer(sourceCode, node, openingLength)
|
|
|
8148
8123
|
}
|
|
8149
8124
|
return false;
|
|
8150
8125
|
}
|
|
8151
|
-
|
|
8152
8126
|
//#endregion
|
|
8153
8127
|
//#region src/rules/no-laziness-blockquotes.ts
|
|
8154
8128
|
var no_laziness_blockquotes_default = createRule("no-laziness-blockquotes", {
|
|
8155
8129
|
meta: {
|
|
8156
8130
|
type: "problem",
|
|
8131
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
8157
8132
|
docs: {
|
|
8158
8133
|
description: "disallow laziness in blockquotes",
|
|
8159
8134
|
categories: ["recommended", "standard"],
|
|
@@ -8260,7 +8235,6 @@ var no_laziness_blockquotes_default = createRule("no-laziness-blockquotes", {
|
|
|
8260
8235
|
} };
|
|
8261
8236
|
}
|
|
8262
8237
|
});
|
|
8263
|
-
|
|
8264
8238
|
//#endregion
|
|
8265
8239
|
//#region src/utils/table.ts
|
|
8266
8240
|
/**
|
|
@@ -8422,12 +8396,12 @@ function parseTableDelimiterRowFromText(text) {
|
|
|
8422
8396
|
return null;
|
|
8423
8397
|
}
|
|
8424
8398
|
}
|
|
8425
|
-
|
|
8426
8399
|
//#endregion
|
|
8427
8400
|
//#region src/rules/no-multi-spaces.ts
|
|
8428
8401
|
var no_multi_spaces_default = createRule("no-multi-spaces", {
|
|
8429
8402
|
meta: {
|
|
8430
8403
|
type: "layout",
|
|
8404
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
8431
8405
|
docs: {
|
|
8432
8406
|
description: "disallow multiple spaces",
|
|
8433
8407
|
categories: ["standard"],
|
|
@@ -8668,12 +8642,12 @@ var no_multi_spaces_default = createRule("no-multi-spaces", {
|
|
|
8668
8642
|
}
|
|
8669
8643
|
}
|
|
8670
8644
|
});
|
|
8671
|
-
|
|
8672
8645
|
//#endregion
|
|
8673
8646
|
//#region src/rules/no-multiple-empty-lines.ts
|
|
8674
8647
|
var no_multiple_empty_lines_default = createRule("no-multiple-empty-lines", {
|
|
8675
8648
|
meta: {
|
|
8676
8649
|
type: "layout",
|
|
8650
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
8677
8651
|
docs: {
|
|
8678
8652
|
description: "disallow multiple empty lines in Markdown files.",
|
|
8679
8653
|
categories: ["standard"],
|
|
@@ -8843,7 +8817,6 @@ var no_multiple_empty_lines_default = createRule("no-multiple-empty-lines", {
|
|
|
8843
8817
|
}
|
|
8844
8818
|
}
|
|
8845
8819
|
});
|
|
8846
|
-
|
|
8847
8820
|
//#endregion
|
|
8848
8821
|
//#region src/rules/no-tabs.ts
|
|
8849
8822
|
/**
|
|
@@ -8861,6 +8834,7 @@ function parseOptions$4(options) {
|
|
|
8861
8834
|
var no_tabs_default = createRule("no-tabs", {
|
|
8862
8835
|
meta: {
|
|
8863
8836
|
type: "layout",
|
|
8837
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
8864
8838
|
docs: {
|
|
8865
8839
|
description: "disallow tab characters in Markdown files.",
|
|
8866
8840
|
categories: ["standard"],
|
|
@@ -8900,10 +8874,10 @@ var no_tabs_default = createRule("no-tabs", {
|
|
|
8900
8874
|
const { ignoreCodeBlocks, checkTargets, codeBlockTabWidth } = parseOptions$4(context.options[0]);
|
|
8901
8875
|
const codeBlocks = [];
|
|
8902
8876
|
/** Check if a language should be ignored based on ignoreCodeBlocks option */
|
|
8903
|
-
function shouldIgnoreLanguage(language
|
|
8877
|
+
function shouldIgnoreLanguage(language) {
|
|
8904
8878
|
if (ignoreCodeBlocks.length === 0) return false;
|
|
8905
8879
|
if (ignoreCodeBlocks.includes("*")) return true;
|
|
8906
|
-
return language
|
|
8880
|
+
return language !== null && ignoreCodeBlocks.includes(language);
|
|
8907
8881
|
}
|
|
8908
8882
|
/**
|
|
8909
8883
|
* Check if the given index is at indentation (beginning of line)
|
|
@@ -8998,12 +8972,12 @@ var no_tabs_default = createRule("no-tabs", {
|
|
|
8998
8972
|
};
|
|
8999
8973
|
}
|
|
9000
8974
|
});
|
|
9001
|
-
|
|
9002
8975
|
//#endregion
|
|
9003
8976
|
//#region src/rules/no-text-backslash-linebreak.ts
|
|
9004
8977
|
var no_text_backslash_linebreak_default = createRule("no-text-backslash-linebreak", {
|
|
9005
8978
|
meta: {
|
|
9006
8979
|
type: "layout",
|
|
8980
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9007
8981
|
docs: {
|
|
9008
8982
|
description: "disallow text backslash at the end of a line.",
|
|
9009
8983
|
categories: ["recommended", "standard"],
|
|
@@ -9045,13 +9019,13 @@ var no_text_backslash_linebreak_default = createRule("no-text-backslash-linebrea
|
|
|
9045
9019
|
} };
|
|
9046
9020
|
}
|
|
9047
9021
|
});
|
|
9048
|
-
|
|
9049
9022
|
//#endregion
|
|
9050
9023
|
//#region src/rules/no-trailing-spaces.ts
|
|
9051
9024
|
const htmlComment = /<!--.*?-->/su;
|
|
9052
9025
|
var no_trailing_spaces_default = createRule("no-trailing-spaces", {
|
|
9053
9026
|
meta: {
|
|
9054
9027
|
type: "layout",
|
|
9028
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9055
9029
|
docs: {
|
|
9056
9030
|
description: "disallow trailing whitespace at the end of lines in Markdown files.",
|
|
9057
9031
|
categories: ["standard"],
|
|
@@ -9175,12 +9149,12 @@ var no_trailing_spaces_default = createRule("no-trailing-spaces", {
|
|
|
9175
9149
|
};
|
|
9176
9150
|
}
|
|
9177
9151
|
});
|
|
9178
|
-
|
|
9179
9152
|
//#endregion
|
|
9180
9153
|
//#region src/rules/ordered-list-marker-sequence.ts
|
|
9181
9154
|
var ordered_list_marker_sequence_default = createRule("ordered-list-marker-sequence", {
|
|
9182
9155
|
meta: {
|
|
9183
9156
|
type: "layout",
|
|
9157
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9184
9158
|
docs: {
|
|
9185
9159
|
description: "enforce consistent ordered list marker numbering (sequential or flat)",
|
|
9186
9160
|
categories: ["standard"],
|
|
@@ -9300,12 +9274,12 @@ var ordered_list_marker_sequence_default = createRule("ordered-list-marker-seque
|
|
|
9300
9274
|
};
|
|
9301
9275
|
}
|
|
9302
9276
|
});
|
|
9303
|
-
|
|
9304
9277
|
//#endregion
|
|
9305
9278
|
//#region src/rules/ordered-list-marker-start.ts
|
|
9306
9279
|
var ordered_list_marker_start_default = createRule("ordered-list-marker-start", {
|
|
9307
9280
|
meta: {
|
|
9308
9281
|
type: "layout",
|
|
9282
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9309
9283
|
docs: {
|
|
9310
9284
|
description: "enforce that ordered list markers start with 1 or 0",
|
|
9311
9285
|
categories: ["standard"],
|
|
@@ -9388,7 +9362,6 @@ var ordered_list_marker_start_default = createRule("ordered-list-marker-start",
|
|
|
9388
9362
|
};
|
|
9389
9363
|
}
|
|
9390
9364
|
});
|
|
9391
|
-
|
|
9392
9365
|
//#endregion
|
|
9393
9366
|
//#region src/rules/ordered-list-marker-style.ts
|
|
9394
9367
|
const MARKER_KINDS = [".", ")"];
|
|
@@ -9431,6 +9404,7 @@ function isOrderedListItemMarker(itemMarker) {
|
|
|
9431
9404
|
var ordered_list_marker_style_default = createRule("ordered-list-marker-style", {
|
|
9432
9405
|
meta: {
|
|
9433
9406
|
type: "layout",
|
|
9407
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9434
9408
|
docs: {
|
|
9435
9409
|
description: "enforce consistent ordered list marker style",
|
|
9436
9410
|
categories: ["standard"],
|
|
@@ -9555,7 +9529,6 @@ var ordered_list_marker_style_default = createRule("ordered-list-marker-style",
|
|
|
9555
9529
|
};
|
|
9556
9530
|
}
|
|
9557
9531
|
});
|
|
9558
|
-
|
|
9559
9532
|
//#endregion
|
|
9560
9533
|
//#region src/rules/padded-custom-containers.ts
|
|
9561
9534
|
/**
|
|
@@ -9632,6 +9605,7 @@ var padded_custom_containers_default = createRule("padded-custom-containers", {
|
|
|
9632
9605
|
},
|
|
9633
9606
|
additionalProperties: false
|
|
9634
9607
|
}],
|
|
9608
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9635
9609
|
messages: {
|
|
9636
9610
|
expectedPaddingAfterOpeningMarker: "Expected padding after opening marker.",
|
|
9637
9611
|
expectedPaddingBeforeClosingMarker: "Expected padding before closing marker.",
|
|
@@ -9736,7 +9710,6 @@ var padded_custom_containers_default = createRule("padded-custom-containers", {
|
|
|
9736
9710
|
} };
|
|
9737
9711
|
}
|
|
9738
9712
|
});
|
|
9739
|
-
|
|
9740
9713
|
//#endregion
|
|
9741
9714
|
//#region src/rules/padding-line-between-blocks.ts
|
|
9742
9715
|
/**
|
|
@@ -9836,6 +9809,7 @@ function getBlockType(node) {
|
|
|
9836
9809
|
var padding_line_between_blocks_default = createRule("padding-line-between-blocks", {
|
|
9837
9810
|
meta: {
|
|
9838
9811
|
type: "layout",
|
|
9812
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
9839
9813
|
docs: {
|
|
9840
9814
|
description: "require or disallow padding lines between blocks",
|
|
9841
9815
|
categories: ["standard"],
|
|
@@ -9906,8 +9880,8 @@ var padding_line_between_blocks_default = createRule("padding-line-between-block
|
|
|
9906
9880
|
function matchesType(actualType, block, expected) {
|
|
9907
9881
|
if (Array.isArray(expected)) {
|
|
9908
9882
|
for (const e of expected) {
|
|
9909
|
-
const matched
|
|
9910
|
-
if (matched
|
|
9883
|
+
const matched = matchesType(actualType, block, e);
|
|
9884
|
+
if (matched) return matched;
|
|
9911
9885
|
}
|
|
9912
9886
|
return null;
|
|
9913
9887
|
}
|
|
@@ -9965,10 +9939,10 @@ var padding_line_between_blocks_default = createRule("padding-line-between-block
|
|
|
9965
9939
|
if (expected.blankLine === "always") {
|
|
9966
9940
|
if (hasBlankLine) continue;
|
|
9967
9941
|
let list = null;
|
|
9968
|
-
const stack
|
|
9969
|
-
let target
|
|
9970
|
-
while (target
|
|
9971
|
-
list = target
|
|
9942
|
+
const stack = [...containerStack];
|
|
9943
|
+
let target;
|
|
9944
|
+
while (target = stack.shift()) if (target.type === "listItem") {
|
|
9945
|
+
list = target;
|
|
9972
9946
|
break;
|
|
9973
9947
|
}
|
|
9974
9948
|
if (list && !list.spread) continue;
|
|
@@ -10048,12 +10022,12 @@ var padding_line_between_blocks_default = createRule("padding-line-between-block
|
|
|
10048
10022
|
}
|
|
10049
10023
|
}
|
|
10050
10024
|
});
|
|
10051
|
-
|
|
10052
10025
|
//#endregion
|
|
10053
10026
|
//#region src/rules/prefer-autolinks.ts
|
|
10054
10027
|
var prefer_autolinks_default = createRule("prefer-autolinks", {
|
|
10055
10028
|
meta: {
|
|
10056
10029
|
type: "layout",
|
|
10030
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10057
10031
|
docs: {
|
|
10058
10032
|
description: "enforce the use of autolinks for URLs",
|
|
10059
10033
|
categories: ["recommended", "standard"],
|
|
@@ -10086,12 +10060,12 @@ var prefer_autolinks_default = createRule("prefer-autolinks", {
|
|
|
10086
10060
|
} };
|
|
10087
10061
|
}
|
|
10088
10062
|
});
|
|
10089
|
-
|
|
10090
10063
|
//#endregion
|
|
10091
10064
|
//#region src/rules/prefer-fenced-code-blocks.ts
|
|
10092
10065
|
var prefer_fenced_code_blocks_default = createRule("prefer-fenced-code-blocks", {
|
|
10093
10066
|
meta: {
|
|
10094
10067
|
type: "layout",
|
|
10068
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10095
10069
|
docs: {
|
|
10096
10070
|
description: "enforce the use of fenced code blocks over indented code blocks",
|
|
10097
10071
|
categories: ["recommended", "standard"],
|
|
@@ -10175,7 +10149,6 @@ function normalizePrefix(prefix) {
|
|
|
10175
10149
|
else result += " ".repeat(4 - result.length % 4);
|
|
10176
10150
|
return result;
|
|
10177
10151
|
}
|
|
10178
|
-
|
|
10179
10152
|
//#endregion
|
|
10180
10153
|
//#region src/utils/search-words.ts
|
|
10181
10154
|
const RE_BOUNDARY = /^[\s\p{Letter_Number}\p{Modifier_Letter}\p{Modifier_Symbol}\p{Nonspacing_Mark}\p{Other_Letter}\p{Other_Symbol}\p{Script=Han}!"#$%&'()*+,./:;<=>?\\{|}~\u{2ffc}-\u{303d}\u{30a0}-\u{30fb}\u{3192}-\u{32bf}\u{fe10}-\u{fe1f}\u{fe30}-\u{fe6f}\u{ff00}-\u{ffef}\u{2ebf0}-\u{2ee5d}]*$/u;
|
|
@@ -10251,12 +10224,12 @@ function createSearchWordsIgnoreContext(ignores) {
|
|
|
10251
10224
|
}
|
|
10252
10225
|
};
|
|
10253
10226
|
}
|
|
10254
|
-
|
|
10255
10227
|
//#endregion
|
|
10256
10228
|
//#region src/rules/prefer-inline-code-words.ts
|
|
10257
10229
|
var prefer_inline_code_words_default = createRule("prefer-inline-code-words", {
|
|
10258
10230
|
meta: {
|
|
10259
10231
|
type: "suggestion",
|
|
10232
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10260
10233
|
docs: {
|
|
10261
10234
|
description: "enforce the use of inline code for specific words.",
|
|
10262
10235
|
categories: [],
|
|
@@ -10325,12 +10298,12 @@ var prefer_inline_code_words_default = createRule("prefer-inline-code-words", {
|
|
|
10325
10298
|
};
|
|
10326
10299
|
}
|
|
10327
10300
|
});
|
|
10328
|
-
|
|
10329
10301
|
//#endregion
|
|
10330
10302
|
//#region src/rules/prefer-link-reference-definitions.ts
|
|
10331
10303
|
var prefer_link_reference_definitions_default = createRule("prefer-link-reference-definitions", {
|
|
10332
10304
|
meta: {
|
|
10333
10305
|
type: "layout",
|
|
10306
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10334
10307
|
docs: {
|
|
10335
10308
|
description: "enforce using link reference definitions instead of inline links",
|
|
10336
10309
|
categories: [],
|
|
@@ -10465,11 +10438,11 @@ var prefer_link_reference_definitions_default = createRule("prefer-link-referenc
|
|
|
10465
10438
|
function getLinkInfo(link) {
|
|
10466
10439
|
const range = sourceCode.getRange(link);
|
|
10467
10440
|
if (link.type === "link") {
|
|
10468
|
-
const bracketsRange
|
|
10441
|
+
const bracketsRange = getLinkBracketsRange(link);
|
|
10469
10442
|
return {
|
|
10470
|
-
label: sourceCode.text.slice(...bracketsRange
|
|
10471
|
-
bracketsRange
|
|
10472
|
-
urlAndTitleRange: [sourceCode.text.indexOf("(", bracketsRange
|
|
10443
|
+
label: sourceCode.text.slice(...bracketsRange).slice(1, -1).trim(),
|
|
10444
|
+
bracketsRange,
|
|
10445
|
+
urlAndTitleRange: [sourceCode.text.indexOf("(", bracketsRange[1]), range[1]]
|
|
10473
10446
|
};
|
|
10474
10447
|
}
|
|
10475
10448
|
const bracketsRange = getImageBracketsRange(link);
|
|
@@ -10485,8 +10458,8 @@ var prefer_link_reference_definitions_default = createRule("prefer-link-referenc
|
|
|
10485
10458
|
function getLinkBracketsRange(link) {
|
|
10486
10459
|
const range = sourceCode.getRange(link);
|
|
10487
10460
|
if (link.children.length === 0) {
|
|
10488
|
-
const index
|
|
10489
|
-
return [range[0], index
|
|
10461
|
+
const index = sourceCode.text.indexOf("]", range[0] + 1);
|
|
10462
|
+
return [range[0], index + 1];
|
|
10490
10463
|
}
|
|
10491
10464
|
const lastRange = sourceCode.getRange(link.children[link.children.length - 1]);
|
|
10492
10465
|
const index = sourceCode.text.indexOf("]", lastRange[1]);
|
|
@@ -10502,7 +10475,6 @@ var prefer_link_reference_definitions_default = createRule("prefer-link-referenc
|
|
|
10502
10475
|
}
|
|
10503
10476
|
}
|
|
10504
10477
|
});
|
|
10505
|
-
|
|
10506
10478
|
//#endregion
|
|
10507
10479
|
//#region src/rules/prefer-linked-words.ts
|
|
10508
10480
|
var prefer_linked_words_default = createRule("prefer-linked-words", {
|
|
@@ -10530,6 +10502,7 @@ var prefer_linked_words_default = createRule("prefer-linked-words", {
|
|
|
10530
10502
|
required: ["words"],
|
|
10531
10503
|
additionalProperties: false
|
|
10532
10504
|
}],
|
|
10505
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10533
10506
|
messages: { requireLink: "The word \"{{name}}\" should be a link." }
|
|
10534
10507
|
},
|
|
10535
10508
|
create(context) {
|
|
@@ -10614,12 +10587,12 @@ var prefer_linked_words_default = createRule("prefer-linked-words", {
|
|
|
10614
10587
|
}
|
|
10615
10588
|
}
|
|
10616
10589
|
});
|
|
10617
|
-
|
|
10618
10590
|
//#endregion
|
|
10619
10591
|
//#region src/rules/setext-heading-underline-length.ts
|
|
10620
10592
|
var setext_heading_underline_length_default = createRule("setext-heading-underline-length", {
|
|
10621
10593
|
meta: {
|
|
10622
10594
|
type: "layout",
|
|
10595
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10623
10596
|
docs: {
|
|
10624
10597
|
description: "enforce setext heading underline length",
|
|
10625
10598
|
categories: ["standard"],
|
|
@@ -10856,7 +10829,6 @@ var setext_heading_underline_length_default = createRule("setext-heading-underli
|
|
|
10856
10829
|
}
|
|
10857
10830
|
}
|
|
10858
10831
|
});
|
|
10859
|
-
|
|
10860
10832
|
//#endregion
|
|
10861
10833
|
//#region src/utils/calc-shortest-edit-script.ts
|
|
10862
10834
|
/**
|
|
@@ -10905,12 +10877,12 @@ function calcShortestEditScript(a, b) {
|
|
|
10905
10877
|
});
|
|
10906
10878
|
}
|
|
10907
10879
|
}
|
|
10908
|
-
|
|
10909
10880
|
//#endregion
|
|
10910
10881
|
//#region src/rules/sort-definitions.ts
|
|
10911
10882
|
var sort_definitions_default = createRule("sort-definitions", {
|
|
10912
10883
|
meta: {
|
|
10913
10884
|
type: "layout",
|
|
10885
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
10914
10886
|
docs: {
|
|
10915
10887
|
description: "enforce a specific order for link definitions and footnote definitions",
|
|
10916
10888
|
categories: ["standard"],
|
|
@@ -11191,14 +11163,14 @@ var sort_definitions_default = createRule("sort-definitions", {
|
|
|
11191
11163
|
}
|
|
11192
11164
|
/** Compile order option */
|
|
11193
11165
|
function compileOption(orderOption) {
|
|
11194
|
-
const cache
|
|
11166
|
+
const cache = /* @__PURE__ */ new Map();
|
|
11195
11167
|
const compiled = compileOptionWithoutCache(orderOption);
|
|
11196
11168
|
return {
|
|
11197
11169
|
match: (node) => {
|
|
11198
|
-
const cached = cache
|
|
11170
|
+
const cached = cache.get(node);
|
|
11199
11171
|
if (cached != null) return cached;
|
|
11200
11172
|
const result = compiled.match(node);
|
|
11201
|
-
cache
|
|
11173
|
+
cache.set(node, result);
|
|
11202
11174
|
return result;
|
|
11203
11175
|
},
|
|
11204
11176
|
sort: compiled.sort
|
|
@@ -11222,7 +11194,7 @@ var sort_definitions_default = createRule("sort-definitions", {
|
|
|
11222
11194
|
}
|
|
11223
11195
|
/** Compile matcher */
|
|
11224
11196
|
function compileMatcher(pattern) {
|
|
11225
|
-
const rules
|
|
11197
|
+
const rules = [];
|
|
11226
11198
|
for (const p of pattern) {
|
|
11227
11199
|
let negative, patternStr;
|
|
11228
11200
|
if (p.startsWith("!")) {
|
|
@@ -11233,11 +11205,11 @@ var sort_definitions_default = createRule("sort-definitions", {
|
|
|
11233
11205
|
patternStr = p;
|
|
11234
11206
|
}
|
|
11235
11207
|
const regex = toRegExp(patternStr);
|
|
11236
|
-
if (isRegExp(patternStr)) rules
|
|
11208
|
+
if (isRegExp(patternStr)) rules.push({
|
|
11237
11209
|
negative,
|
|
11238
11210
|
match: (node) => regex.test(getDefinitionText(node))
|
|
11239
11211
|
});
|
|
11240
|
-
else rules
|
|
11212
|
+
else rules.push({
|
|
11241
11213
|
negative,
|
|
11242
11214
|
match: (node) => {
|
|
11243
11215
|
if (node.label === patternStr || node.identifier === patternStr) return true;
|
|
@@ -11253,8 +11225,8 @@ var sort_definitions_default = createRule("sort-definitions", {
|
|
|
11253
11225
|
});
|
|
11254
11226
|
}
|
|
11255
11227
|
return (node) => {
|
|
11256
|
-
let result = Boolean(rules
|
|
11257
|
-
for (const { negative, match } of rules
|
|
11228
|
+
let result = Boolean(rules[0]?.negative);
|
|
11229
|
+
for (const { negative, match } of rules) {
|
|
11258
11230
|
if (result === !negative) continue;
|
|
11259
11231
|
if (match(node)) result = !negative;
|
|
11260
11232
|
}
|
|
@@ -11293,12 +11265,12 @@ function normalizedURL(url) {
|
|
|
11293
11265
|
if (!urlObj) return url;
|
|
11294
11266
|
return urlObj.href.endsWith("/") ? urlObj.href : `${urlObj.href}/`;
|
|
11295
11267
|
}
|
|
11296
|
-
|
|
11297
11268
|
//#endregion
|
|
11298
11269
|
//#region src/rules/strikethrough-delimiters-style.ts
|
|
11299
11270
|
var strikethrough_delimiters_style_default = createRule("strikethrough-delimiters-style", {
|
|
11300
11271
|
meta: {
|
|
11301
11272
|
type: "layout",
|
|
11273
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
11302
11274
|
docs: {
|
|
11303
11275
|
description: "enforce a consistent delimiter style for strikethrough",
|
|
11304
11276
|
categories: ["standard"],
|
|
@@ -11334,12 +11306,12 @@ var strikethrough_delimiters_style_default = createRule("strikethrough-delimiter
|
|
|
11334
11306
|
} };
|
|
11335
11307
|
}
|
|
11336
11308
|
});
|
|
11337
|
-
|
|
11338
11309
|
//#endregion
|
|
11339
11310
|
//#region src/rules/table-header-casing.ts
|
|
11340
11311
|
var table_header_casing_default = createRule("table-header-casing", {
|
|
11341
11312
|
meta: {
|
|
11342
11313
|
type: "suggestion",
|
|
11314
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
11343
11315
|
fixable: "code",
|
|
11344
11316
|
docs: {
|
|
11345
11317
|
description: "enforce consistent casing in table header cells.",
|
|
@@ -11471,12 +11443,12 @@ var table_header_casing_default = createRule("table-header-casing", {
|
|
|
11471
11443
|
} };
|
|
11472
11444
|
}
|
|
11473
11445
|
});
|
|
11474
|
-
|
|
11475
11446
|
//#endregion
|
|
11476
11447
|
//#region src/rules/table-leading-trailing-pipes.ts
|
|
11477
11448
|
var table_leading_trailing_pipes_default = createRule("table-leading-trailing-pipes", {
|
|
11478
11449
|
meta: {
|
|
11479
11450
|
type: "layout",
|
|
11451
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
11480
11452
|
docs: {
|
|
11481
11453
|
description: "enforce consistent use of leading and trailing pipes in tables.",
|
|
11482
11454
|
categories: ["standard"],
|
|
@@ -11602,7 +11574,6 @@ var table_leading_trailing_pipes_default = createRule("table-leading-trailing-pi
|
|
|
11602
11574
|
} };
|
|
11603
11575
|
}
|
|
11604
11576
|
});
|
|
11605
|
-
|
|
11606
11577
|
//#endregion
|
|
11607
11578
|
//#region src/rules/table-pipe-spacing.ts
|
|
11608
11579
|
const currentOption = /* @__PURE__ */ new WeakMap();
|
|
@@ -11657,6 +11628,7 @@ function parseOptions$1(options) {
|
|
|
11657
11628
|
var table_pipe_spacing_default = createRule("table-pipe-spacing", {
|
|
11658
11629
|
meta: {
|
|
11659
11630
|
type: "layout",
|
|
11631
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
11660
11632
|
docs: {
|
|
11661
11633
|
description: "enforce consistent spacing around table pipes",
|
|
11662
11634
|
categories: ["standard"],
|
|
@@ -12001,7 +11973,6 @@ var table_pipe_spacing_default = createRule("table-pipe-spacing", {
|
|
|
12001
11973
|
}
|
|
12002
11974
|
}
|
|
12003
11975
|
});
|
|
12004
|
-
|
|
12005
11976
|
//#endregion
|
|
12006
11977
|
//#region src/rules/table-pipe-alignment.ts
|
|
12007
11978
|
/**
|
|
@@ -12039,6 +12010,7 @@ function parseOptions(options) {
|
|
|
12039
12010
|
var table_pipe_alignment_default = createRule("table-pipe-alignment", {
|
|
12040
12011
|
meta: {
|
|
12041
12012
|
type: "layout",
|
|
12013
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
12042
12014
|
docs: {
|
|
12043
12015
|
description: "enforce consistent alignment of table pipes",
|
|
12044
12016
|
categories: ["standard"],
|
|
@@ -12305,10 +12277,10 @@ var table_pipe_alignment_default = createRule("table-pipe-alignment", {
|
|
|
12305
12277
|
if (newLength < minimumDelimiterLength + spaceAfter.length) {
|
|
12306
12278
|
const edit = fixRemoveSpacesFromLeadingSpaces(Math.abs(newLength - minimumDelimiterLength) + spaceAfter.length);
|
|
12307
12279
|
if (!edit) return null;
|
|
12308
|
-
const delimiterPrefix
|
|
12309
|
-
const delimiterSuffix
|
|
12310
|
-
const newDelimiter
|
|
12311
|
-
return [edit, fixer.replaceTextRange([cell.delimiter.range[0], pipe.range[0]], delimiterPrefix
|
|
12280
|
+
const delimiterPrefix = cell.align === "left" || cell.align === "center" ? ":" : "";
|
|
12281
|
+
const delimiterSuffix = cell.align === "right" || cell.align === "center" ? ":" : "";
|
|
12282
|
+
const newDelimiter = "-".repeat(minimumDelimiterLength - delimiterPrefix.length - delimiterSuffix.length);
|
|
12283
|
+
return [edit, fixer.replaceTextRange([cell.delimiter.range[0], pipe.range[0]], delimiterPrefix + newDelimiter + delimiterSuffix + spaceAfter)];
|
|
12312
12284
|
}
|
|
12313
12285
|
const delimiterPrefix = cell.align === "left" || cell.align === "center" ? ":" : "";
|
|
12314
12286
|
const delimiterSuffix = cell.align === "right" || cell.align === "center" ? ":" : "";
|
|
@@ -12392,12 +12364,12 @@ function parsedTableDelimiterRowToRowData(parsedDelimiterRow) {
|
|
|
12392
12364
|
};
|
|
12393
12365
|
}) };
|
|
12394
12366
|
}
|
|
12395
|
-
|
|
12396
12367
|
//#endregion
|
|
12397
12368
|
//#region src/rules/thematic-break-character-style.ts
|
|
12398
12369
|
var thematic_break_character_style_default = createRule("thematic-break-character-style", {
|
|
12399
12370
|
meta: {
|
|
12400
12371
|
type: "layout",
|
|
12372
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
12401
12373
|
docs: {
|
|
12402
12374
|
description: "enforce consistent character style for thematic breaks (horizontal rules) in Markdown.",
|
|
12403
12375
|
categories: ["standard"],
|
|
@@ -12439,7 +12411,6 @@ var thematic_break_character_style_default = createRule("thematic-break-characte
|
|
|
12439
12411
|
} };
|
|
12440
12412
|
}
|
|
12441
12413
|
});
|
|
12442
|
-
|
|
12443
12414
|
//#endregion
|
|
12444
12415
|
//#region src/utils/thematic-break.ts
|
|
12445
12416
|
/**
|
|
@@ -12471,138 +12442,9 @@ function createThematicBreakFromPattern(pattern, length) {
|
|
|
12471
12442
|
}
|
|
12472
12443
|
return null;
|
|
12473
12444
|
}
|
|
12474
|
-
|
|
12475
|
-
//#endregion
|
|
12476
|
-
//#region src/rules/thematic-break-length.ts
|
|
12477
|
-
var thematic_break_length_default = createRule("thematic-break-length", {
|
|
12478
|
-
meta: {
|
|
12479
|
-
type: "layout",
|
|
12480
|
-
docs: {
|
|
12481
|
-
description: "enforce consistent length for thematic breaks (horizontal rules) in Markdown.",
|
|
12482
|
-
categories: ["standard"],
|
|
12483
|
-
listCategory: "Decorative"
|
|
12484
|
-
},
|
|
12485
|
-
fixable: "code",
|
|
12486
|
-
hasSuggestions: false,
|
|
12487
|
-
schema: [{
|
|
12488
|
-
type: "object",
|
|
12489
|
-
properties: { length: {
|
|
12490
|
-
type: "integer",
|
|
12491
|
-
minimum: 3
|
|
12492
|
-
} },
|
|
12493
|
-
additionalProperties: false
|
|
12494
|
-
}],
|
|
12495
|
-
messages: { unexpected: "Thematic break should be {{expected}} characters, but found {{actual}}." }
|
|
12496
|
-
},
|
|
12497
|
-
create(context) {
|
|
12498
|
-
const expectedLength = (context.options[0] || {}).length ?? 3;
|
|
12499
|
-
const sourceCode = context.sourceCode;
|
|
12500
|
-
return { thematicBreak(node) {
|
|
12501
|
-
const marker = getThematicBreakMarker(sourceCode, node);
|
|
12502
|
-
if (marker.text.length === expectedLength) return;
|
|
12503
|
-
context.report({
|
|
12504
|
-
node,
|
|
12505
|
-
messageId: "unexpected",
|
|
12506
|
-
data: {
|
|
12507
|
-
expected: String(expectedLength),
|
|
12508
|
-
actual: String(marker.text.length)
|
|
12509
|
-
},
|
|
12510
|
-
fix(fixer) {
|
|
12511
|
-
const sequence = replacementSequence(marker);
|
|
12512
|
-
if (!sequence) return null;
|
|
12513
|
-
return fixer.replaceText(node, sequence);
|
|
12514
|
-
}
|
|
12515
|
-
});
|
|
12516
|
-
} };
|
|
12517
|
-
/**
|
|
12518
|
-
* Replace the sequence in the thematic break marker with the expected length.
|
|
12519
|
-
*/
|
|
12520
|
-
function replacementSequence(marker) {
|
|
12521
|
-
if (marker.hasSpaces) {
|
|
12522
|
-
const pattern = inferSequencePattern(marker.text);
|
|
12523
|
-
if (pattern) return createThematicBreakFromPattern(pattern, expectedLength);
|
|
12524
|
-
return null;
|
|
12525
|
-
}
|
|
12526
|
-
return marker.kind.repeat(expectedLength);
|
|
12527
|
-
}
|
|
12528
|
-
/**
|
|
12529
|
-
* Infer sequence pattern from the original string.
|
|
12530
|
-
*/
|
|
12531
|
-
function inferSequencePattern(original) {
|
|
12532
|
-
for (let length = 2; length < original.length; length++) {
|
|
12533
|
-
const pattern = original.slice(0, length);
|
|
12534
|
-
if (isValidThematicBreakPattern(pattern, original)) return pattern;
|
|
12535
|
-
}
|
|
12536
|
-
return null;
|
|
12537
|
-
}
|
|
12538
|
-
}
|
|
12539
|
-
});
|
|
12540
|
-
|
|
12541
|
-
//#endregion
|
|
12542
|
-
//#region src/rules/thematic-break-sequence-pattern.ts
|
|
12543
|
-
var thematic_break_sequence_pattern_default = createRule("thematic-break-sequence-pattern", {
|
|
12544
|
-
meta: {
|
|
12545
|
-
type: "layout",
|
|
12546
|
-
docs: {
|
|
12547
|
-
description: "enforce consistent repeating patterns for thematic breaks (horizontal rules) in Markdown.",
|
|
12548
|
-
categories: ["standard"],
|
|
12549
|
-
listCategory: "Decorative"
|
|
12550
|
-
},
|
|
12551
|
-
fixable: "code",
|
|
12552
|
-
hasSuggestions: false,
|
|
12553
|
-
schema: [{
|
|
12554
|
-
type: "object",
|
|
12555
|
-
properties: { pattern: { anyOf: [
|
|
12556
|
-
{
|
|
12557
|
-
type: "string",
|
|
12558
|
-
minLength: 1,
|
|
12559
|
-
pattern: "^\\-[ \\-]*$"
|
|
12560
|
-
},
|
|
12561
|
-
{
|
|
12562
|
-
type: "string",
|
|
12563
|
-
minLength: 1,
|
|
12564
|
-
pattern: "^\\*[ *]*$"
|
|
12565
|
-
},
|
|
12566
|
-
{
|
|
12567
|
-
type: "string",
|
|
12568
|
-
minLength: 1,
|
|
12569
|
-
pattern: "^_[ _]*$"
|
|
12570
|
-
}
|
|
12571
|
-
] } },
|
|
12572
|
-
required: ["pattern"],
|
|
12573
|
-
additionalProperties: false
|
|
12574
|
-
}],
|
|
12575
|
-
messages: { inconsistentPattern: "Thematic break does not match the preferred repeating pattern '{{pattern}}'." }
|
|
12576
|
-
},
|
|
12577
|
-
create(context) {
|
|
12578
|
-
const pattern = (context.options[0] || {}).pattern ?? "-";
|
|
12579
|
-
const sourceCode = context.sourceCode;
|
|
12580
|
-
const patterns = {
|
|
12581
|
-
"-": pattern.replaceAll(/[*_]/gu, "-"),
|
|
12582
|
-
"*": pattern.replaceAll(/[-_]/gu, "*"),
|
|
12583
|
-
_: pattern.replaceAll(/[*-]/gu, "_")
|
|
12584
|
-
};
|
|
12585
|
-
return { thematicBreak(node) {
|
|
12586
|
-
const marker = getThematicBreakMarker(sourceCode, node);
|
|
12587
|
-
const patternForKind = patterns[marker.kind];
|
|
12588
|
-
if (isValidThematicBreakPattern(patternForKind, marker.text)) return;
|
|
12589
|
-
context.report({
|
|
12590
|
-
node,
|
|
12591
|
-
messageId: "inconsistentPattern",
|
|
12592
|
-
data: { pattern },
|
|
12593
|
-
fix(fixer) {
|
|
12594
|
-
const replacement = createThematicBreakFromPattern(patternForKind, marker.text.length);
|
|
12595
|
-
if (!replacement) return null;
|
|
12596
|
-
return fixer.replaceText(node, replacement);
|
|
12597
|
-
}
|
|
12598
|
-
});
|
|
12599
|
-
} };
|
|
12600
|
-
}
|
|
12601
|
-
});
|
|
12602
|
-
|
|
12603
12445
|
//#endregion
|
|
12604
12446
|
//#region src/utils/rules.ts
|
|
12605
|
-
const rules$
|
|
12447
|
+
const rules$3 = [
|
|
12606
12448
|
atx_heading_closing_sequence_length_default,
|
|
12607
12449
|
atx_heading_closing_sequence_default,
|
|
12608
12450
|
blockquote_marker_alignment_default,
|
|
@@ -12654,21 +12496,142 @@ const rules$1 = [
|
|
|
12654
12496
|
table_pipe_alignment_default,
|
|
12655
12497
|
table_pipe_spacing_default,
|
|
12656
12498
|
thematic_break_character_style_default,
|
|
12657
|
-
|
|
12658
|
-
|
|
12499
|
+
createRule("thematic-break-length", {
|
|
12500
|
+
meta: {
|
|
12501
|
+
type: "layout",
|
|
12502
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
12503
|
+
docs: {
|
|
12504
|
+
description: "enforce consistent length for thematic breaks (horizontal rules) in Markdown.",
|
|
12505
|
+
categories: ["standard"],
|
|
12506
|
+
listCategory: "Decorative"
|
|
12507
|
+
},
|
|
12508
|
+
fixable: "code",
|
|
12509
|
+
hasSuggestions: false,
|
|
12510
|
+
schema: [{
|
|
12511
|
+
type: "object",
|
|
12512
|
+
properties: { length: {
|
|
12513
|
+
type: "integer",
|
|
12514
|
+
minimum: 3
|
|
12515
|
+
} },
|
|
12516
|
+
additionalProperties: false
|
|
12517
|
+
}],
|
|
12518
|
+
messages: { unexpected: "Thematic break should be {{expected}} characters, but found {{actual}}." }
|
|
12519
|
+
},
|
|
12520
|
+
create(context) {
|
|
12521
|
+
const expectedLength = (context.options[0] || {}).length ?? 3;
|
|
12522
|
+
const sourceCode = context.sourceCode;
|
|
12523
|
+
return { thematicBreak(node) {
|
|
12524
|
+
const marker = getThematicBreakMarker(sourceCode, node);
|
|
12525
|
+
if (marker.text.length === expectedLength) return;
|
|
12526
|
+
context.report({
|
|
12527
|
+
node,
|
|
12528
|
+
messageId: "unexpected",
|
|
12529
|
+
data: {
|
|
12530
|
+
expected: String(expectedLength),
|
|
12531
|
+
actual: String(marker.text.length)
|
|
12532
|
+
},
|
|
12533
|
+
fix(fixer) {
|
|
12534
|
+
const sequence = replacementSequence(marker);
|
|
12535
|
+
if (!sequence) return null;
|
|
12536
|
+
return fixer.replaceText(node, sequence);
|
|
12537
|
+
}
|
|
12538
|
+
});
|
|
12539
|
+
} };
|
|
12540
|
+
/**
|
|
12541
|
+
* Replace the sequence in the thematic break marker with the expected length.
|
|
12542
|
+
*/
|
|
12543
|
+
function replacementSequence(marker) {
|
|
12544
|
+
if (marker.hasSpaces) {
|
|
12545
|
+
const pattern = inferSequencePattern(marker.text);
|
|
12546
|
+
if (pattern) return createThematicBreakFromPattern(pattern, expectedLength);
|
|
12547
|
+
return null;
|
|
12548
|
+
}
|
|
12549
|
+
return marker.kind.repeat(expectedLength);
|
|
12550
|
+
}
|
|
12551
|
+
/**
|
|
12552
|
+
* Infer sequence pattern from the original string.
|
|
12553
|
+
*/
|
|
12554
|
+
function inferSequencePattern(original) {
|
|
12555
|
+
for (let length = 2; length < original.length; length++) {
|
|
12556
|
+
const pattern = original.slice(0, length);
|
|
12557
|
+
if (isValidThematicBreakPattern(pattern, original)) return pattern;
|
|
12558
|
+
}
|
|
12559
|
+
return null;
|
|
12560
|
+
}
|
|
12561
|
+
}
|
|
12562
|
+
}),
|
|
12563
|
+
createRule("thematic-break-sequence-pattern", {
|
|
12564
|
+
meta: {
|
|
12565
|
+
type: "layout",
|
|
12566
|
+
languages: ["markdown/*", "markdown-preferences/*"],
|
|
12567
|
+
docs: {
|
|
12568
|
+
description: "enforce consistent repeating patterns for thematic breaks (horizontal rules) in Markdown.",
|
|
12569
|
+
categories: ["standard"],
|
|
12570
|
+
listCategory: "Decorative"
|
|
12571
|
+
},
|
|
12572
|
+
fixable: "code",
|
|
12573
|
+
hasSuggestions: false,
|
|
12574
|
+
schema: [{
|
|
12575
|
+
type: "object",
|
|
12576
|
+
properties: { pattern: { anyOf: [
|
|
12577
|
+
{
|
|
12578
|
+
type: "string",
|
|
12579
|
+
minLength: 1,
|
|
12580
|
+
pattern: "^\\-[ \\-]*$"
|
|
12581
|
+
},
|
|
12582
|
+
{
|
|
12583
|
+
type: "string",
|
|
12584
|
+
minLength: 1,
|
|
12585
|
+
pattern: "^\\*[ *]*$"
|
|
12586
|
+
},
|
|
12587
|
+
{
|
|
12588
|
+
type: "string",
|
|
12589
|
+
minLength: 1,
|
|
12590
|
+
pattern: "^_[ _]*$"
|
|
12591
|
+
}
|
|
12592
|
+
] } },
|
|
12593
|
+
required: ["pattern"],
|
|
12594
|
+
additionalProperties: false
|
|
12595
|
+
}],
|
|
12596
|
+
messages: { inconsistentPattern: "Thematic break does not match the preferred repeating pattern '{{pattern}}'." }
|
|
12597
|
+
},
|
|
12598
|
+
create(context) {
|
|
12599
|
+
const pattern = (context.options[0] || {}).pattern ?? "-";
|
|
12600
|
+
const sourceCode = context.sourceCode;
|
|
12601
|
+
const patterns = {
|
|
12602
|
+
"-": pattern.replaceAll(/[*_]/gu, "-"),
|
|
12603
|
+
"*": pattern.replaceAll(/[-_]/gu, "*"),
|
|
12604
|
+
_: pattern.replaceAll(/[*-]/gu, "_")
|
|
12605
|
+
};
|
|
12606
|
+
return { thematicBreak(node) {
|
|
12607
|
+
const marker = getThematicBreakMarker(sourceCode, node);
|
|
12608
|
+
const patternForKind = patterns[marker.kind];
|
|
12609
|
+
if (isValidThematicBreakPattern(patternForKind, marker.text)) return;
|
|
12610
|
+
context.report({
|
|
12611
|
+
node,
|
|
12612
|
+
messageId: "inconsistentPattern",
|
|
12613
|
+
data: { pattern },
|
|
12614
|
+
fix(fixer) {
|
|
12615
|
+
const replacement = createThematicBreakFromPattern(patternForKind, marker.text.length);
|
|
12616
|
+
if (!replacement) return null;
|
|
12617
|
+
return fixer.replaceText(node, replacement);
|
|
12618
|
+
}
|
|
12619
|
+
});
|
|
12620
|
+
} };
|
|
12621
|
+
}
|
|
12622
|
+
})
|
|
12659
12623
|
];
|
|
12660
|
-
|
|
12661
12624
|
//#endregion
|
|
12662
12625
|
//#region src/configs/recommended.ts
|
|
12663
|
-
var recommended_exports = /* @__PURE__ */
|
|
12626
|
+
var recommended_exports = /* @__PURE__ */ __exportAll({
|
|
12664
12627
|
files: () => files$1,
|
|
12665
12628
|
language: () => language$1,
|
|
12666
12629
|
languageOptions: () => languageOptions$1,
|
|
12667
|
-
name: () => name$
|
|
12630
|
+
name: () => name$3,
|
|
12668
12631
|
plugins: () => plugins$1,
|
|
12669
|
-
rules: () => rules$
|
|
12632
|
+
rules: () => rules$2
|
|
12670
12633
|
});
|
|
12671
|
-
const name$
|
|
12634
|
+
const name$3 = "markdown-preferences/recommended";
|
|
12672
12635
|
const files$1 = ["*.md", "**/*.md"];
|
|
12673
12636
|
const language$1 = "markdown/gfm";
|
|
12674
12637
|
const languageOptions$1 = { frontmatter: "yaml" };
|
|
@@ -12678,7 +12641,7 @@ const plugins$1 = {
|
|
|
12678
12641
|
return src_default;
|
|
12679
12642
|
}
|
|
12680
12643
|
};
|
|
12681
|
-
const rules$
|
|
12644
|
+
const rules$2 = {
|
|
12682
12645
|
"markdown-preferences/blockquote-marker-alignment": "error",
|
|
12683
12646
|
"markdown-preferences/hard-linebreak-style": "error",
|
|
12684
12647
|
"markdown-preferences/list-marker-alignment": "error",
|
|
@@ -12688,18 +12651,17 @@ const rules$3 = {
|
|
|
12688
12651
|
"markdown-preferences/prefer-autolinks": "error",
|
|
12689
12652
|
"markdown-preferences/prefer-fenced-code-blocks": "error"
|
|
12690
12653
|
};
|
|
12691
|
-
|
|
12692
12654
|
//#endregion
|
|
12693
12655
|
//#region src/configs/standard.ts
|
|
12694
|
-
var standard_exports = /* @__PURE__ */
|
|
12656
|
+
var standard_exports = /* @__PURE__ */ __exportAll({
|
|
12695
12657
|
files: () => files,
|
|
12696
12658
|
language: () => language,
|
|
12697
12659
|
languageOptions: () => languageOptions,
|
|
12698
|
-
name: () => name$
|
|
12660
|
+
name: () => name$2,
|
|
12699
12661
|
plugins: () => plugins,
|
|
12700
|
-
rules: () => rules$
|
|
12662
|
+
rules: () => rules$1
|
|
12701
12663
|
});
|
|
12702
|
-
const name$
|
|
12664
|
+
const name$2 = "markdown-preferences/recommended";
|
|
12703
12665
|
const files = ["*.md", "**/*.md"];
|
|
12704
12666
|
const language = "markdown/gfm";
|
|
12705
12667
|
const languageOptions = { frontmatter: "yaml" };
|
|
@@ -12709,7 +12671,7 @@ const plugins = {
|
|
|
12709
12671
|
return src_default;
|
|
12710
12672
|
}
|
|
12711
12673
|
};
|
|
12712
|
-
const rules$
|
|
12674
|
+
const rules$1 = {
|
|
12713
12675
|
"markdown-preferences/atx-heading-closing-sequence-length": "error",
|
|
12714
12676
|
"markdown-preferences/atx-heading-closing-sequence": "error",
|
|
12715
12677
|
"markdown-preferences/blockquote-marker-alignment": "error",
|
|
@@ -12754,16 +12716,18 @@ const rules$2 = {
|
|
|
12754
12716
|
"markdown-preferences/thematic-break-length": "error",
|
|
12755
12717
|
"markdown-preferences/thematic-break-sequence-pattern": "error"
|
|
12756
12718
|
};
|
|
12757
|
-
|
|
12719
|
+
//#endregion
|
|
12720
|
+
//#region package.json
|
|
12721
|
+
var name$1 = "eslint-plugin-markdown-preferences";
|
|
12722
|
+
var version$1 = "0.41.0";
|
|
12758
12723
|
//#endregion
|
|
12759
12724
|
//#region src/meta.ts
|
|
12760
|
-
var meta_exports = /* @__PURE__ */
|
|
12725
|
+
var meta_exports = /* @__PURE__ */ __exportAll({
|
|
12761
12726
|
name: () => name,
|
|
12762
12727
|
version: () => version
|
|
12763
12728
|
});
|
|
12764
|
-
const name =
|
|
12765
|
-
const version =
|
|
12766
|
-
|
|
12729
|
+
const name = name$1;
|
|
12730
|
+
const version = version$1;
|
|
12767
12731
|
//#endregion
|
|
12768
12732
|
//#region src/language/extensions/micromark-custom-container.ts
|
|
12769
12733
|
/**
|
|
@@ -12945,7 +12909,6 @@ function customContainer() {
|
|
|
12945
12909
|
}
|
|
12946
12910
|
}
|
|
12947
12911
|
}
|
|
12948
|
-
|
|
12949
12912
|
//#endregion
|
|
12950
12913
|
//#region src/language/extensions/mdast-custom-container.ts
|
|
12951
12914
|
/**
|
|
@@ -12977,7 +12940,6 @@ function customContainerFromMarkdown() {
|
|
|
12977
12940
|
}
|
|
12978
12941
|
};
|
|
12979
12942
|
}
|
|
12980
|
-
|
|
12981
12943
|
//#endregion
|
|
12982
12944
|
//#region src/language/extensions/micromark-import-code-snippet.ts
|
|
12983
12945
|
/**
|
|
@@ -13072,7 +13034,6 @@ function importCodeSnippet() {
|
|
|
13072
13034
|
}
|
|
13073
13035
|
}
|
|
13074
13036
|
}
|
|
13075
|
-
|
|
13076
13037
|
//#endregion
|
|
13077
13038
|
//#region src/language/extensions/mdast-import-code-snippet.ts
|
|
13078
13039
|
/**
|
|
@@ -13103,7 +13064,6 @@ function importCodeSnippetFromMarkdown() {
|
|
|
13103
13064
|
}
|
|
13104
13065
|
};
|
|
13105
13066
|
}
|
|
13106
|
-
|
|
13107
13067
|
//#endregion
|
|
13108
13068
|
//#region src/language/parser.ts
|
|
13109
13069
|
/**
|
|
@@ -13127,7 +13087,6 @@ function parseExtendedMarkdown(code) {
|
|
|
13127
13087
|
]
|
|
13128
13088
|
});
|
|
13129
13089
|
}
|
|
13130
|
-
|
|
13131
13090
|
//#endregion
|
|
13132
13091
|
//#region src/language/extended-markdown-language.ts
|
|
13133
13092
|
var ExtendedMarkdownLanguage = class {
|
|
@@ -13162,8 +13121,8 @@ var ExtendedMarkdownLanguage = class {
|
|
|
13162
13121
|
* @returns {void}
|
|
13163
13122
|
* @throws {Error} When the language options are invalid.
|
|
13164
13123
|
*/
|
|
13165
|
-
validateLanguageOptions(languageOptions
|
|
13166
|
-
return markdown.languages.gfm.validateLanguageOptions(languageOptions
|
|
13124
|
+
validateLanguageOptions(languageOptions) {
|
|
13125
|
+
return markdown.languages.gfm.validateLanguageOptions(languageOptions);
|
|
13167
13126
|
}
|
|
13168
13127
|
/**
|
|
13169
13128
|
* Parses the given file into an AST.
|
|
@@ -13195,14 +13154,13 @@ var ExtendedMarkdownLanguage = class {
|
|
|
13195
13154
|
return markdown.languages.gfm.createSourceCode(file, parseResult);
|
|
13196
13155
|
}
|
|
13197
13156
|
};
|
|
13198
|
-
|
|
13199
13157
|
//#endregion
|
|
13200
13158
|
//#region src/index.ts
|
|
13201
13159
|
const configs = {
|
|
13202
13160
|
recommended: recommended_exports,
|
|
13203
13161
|
standard: standard_exports
|
|
13204
13162
|
};
|
|
13205
|
-
const rules = rules$
|
|
13163
|
+
const rules = rules$3.reduce((obj, r) => {
|
|
13206
13164
|
obj[r.meta.docs.ruleName] = r;
|
|
13207
13165
|
return obj;
|
|
13208
13166
|
}, {});
|
|
@@ -13218,6 +13176,5 @@ var src_default = {
|
|
|
13218
13176
|
rules,
|
|
13219
13177
|
resources
|
|
13220
13178
|
};
|
|
13221
|
-
|
|
13222
13179
|
//#endregion
|
|
13223
|
-
export { configs, src_default as default, languages, meta_exports as meta, resources, rules };
|
|
13180
|
+
export { configs, src_default as default, languages, meta_exports as meta, resources, rules };
|