Reimplement MD013/line-length using micromark tokens.

This commit is contained in:
David Anson 2024-08-13 20:57:00 -07:00
parent 4072cf7417
commit 3b581a7f6d
10 changed files with 173 additions and 185 deletions

View file

@ -72,3 +72,15 @@ Long lines inside HTML comments should also produce a violation of the line-leng
<!-- Long lines inside HTML comments should also produce a violation of the line-length rule. {MD013} -->
Long lines inside HTML comments should also <!-- produce a violation of the line-length rule. {MD013} -->
<https://example.com/long-line-comprised-entirely-of-an-autolink-long-line-comprised-entirely-of-an-autolink>
https://example.com/long-line-comprised-entirely-of-a-bare-link-long-line-comprised-entirely-of-a-bare-link
Long <https://example.com/line-comprised-mostly-of-an-autolink-long-line-comprised-mostly-of-an-autolink> {MD013}
Long https://example.com/long-line-comprised-mostly-of-a-bare-link-long-line-comprised-mostly-of-a-bare-link {MD013}
<!-- markdownlint-configure-file {
"no-bare-urls": false
} -->

View file

@ -214,24 +214,6 @@ test("isBlankLine", (t) => {
}
});
test("includesSorted", (t) => {
t.plan(154);
const inputs = [
[ ],
[ 8 ],
[ 7, 11 ],
[ 0, 1, 2, 3, 5, 8, 13 ],
[ 2, 3, 5, 7, 11, 13, 17, 19 ],
[ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 ],
[ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
];
for (const input of inputs) {
for (let i = 0; i <= 21; i++) {
t.is(helpers.includesSorted(input, i), input.includes(i));
}
}
});
test("forEachInlineCodeSpan", (t) => {
t.plan(99);
const testCases =

View file

@ -945,7 +945,7 @@ test("readme", async(t) => {
});
test("validateJsonUsingConfigSchemaStrict", async(t) => {
t.plan(178);
t.plan(179);
// @ts-ignore
const ajv = new Ajv(ajvOptions);
const validateSchemaStrict = ajv.compile(configSchemaStrict);

View file

@ -37472,6 +37472,38 @@ Generated by [AVA](https://avajs.dev).
'line-length',
],
},
{
errorContext: null,
errorDetail: 'Expected: 80; Actual: 113',
errorRange: [
81,
33,
],
fixInfo: null,
lineNumber: 80,
ruleDescription: 'Line length',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md013.md',
ruleNames: [
'MD013',
'line-length',
],
},
{
errorContext: null,
errorDetail: 'Expected: 80; Actual: 116',
errorRange: [
81,
36,
],
fixInfo: null,
lineNumber: 82,
ruleDescription: 'Line length',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md013.md',
ruleNames: [
'MD013',
'line-length',
],
},
{
errorContext: null,
errorDetail: 'Expected: indented; Actual: fenced',
@ -37736,6 +37768,18 @@ Generated by [AVA](https://avajs.dev).
<!-- Long lines inside HTML comments should also produce a violation of the line-length rule. {MD013} -->
Long lines inside HTML comments should also <!-- produce a violation of the line-length rule. {MD013} -->
<https://example.com/long-line-comprised-entirely-of-an-autolink-long-line-comprised-entirely-of-an-autolink>
https://example.com/long-line-comprised-entirely-of-a-bare-link-long-line-comprised-entirely-of-a-bare-link␊
Long <https://example.com/line-comprised-mostly-of-an-autolink-long-line-comprised-mostly-of-an-autolink> {MD013}␊
Long https://example.com/long-line-comprised-mostly-of-a-bare-link-long-line-comprised-mostly-of-a-bare-link {MD013}␊
<!-- markdownlint-configure-file {␊
"no-bare-urls": false␊
} -->␊
`,
}