mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-21 21:30:47 +02:00
Add support for delta line numbers to test scenario tagging syntax: {MD000:+3}.
This commit is contained in:
parent
c5be0ccd34
commit
fa462fe3fc
6 changed files with 21 additions and 14 deletions
|
@ -37,18 +37,25 @@ function createTestForFile(file) {
|
|||
error.ruleInformation.replace(/v\d+\.\d+\.\d+/, "v0.0.0");
|
||||
}
|
||||
// Match identified issues by MD### markers
|
||||
const marker = /\{(MD\d+)(?::(\d+))?\}/g;
|
||||
const marker = /\{(MD\d+)(?::([-+]?)(\d+))?\}/g;
|
||||
const lines = content.split(helpers.newLineRe);
|
||||
const expected = {};
|
||||
// @ts-ignore
|
||||
for (const [ index, line ] of lines.entries()) {
|
||||
let match = null;
|
||||
while ((match = marker.exec(line))) {
|
||||
const rule = match[1];
|
||||
const [ , rule, delta, value ] = match;
|
||||
let lineNumber = index + 1;
|
||||
if (value) {
|
||||
const valueInt = Number.parseInt(value, 10);
|
||||
if (delta) {
|
||||
lineNumber += ((delta === "+") ? 1 : -1) * valueInt;
|
||||
} else {
|
||||
lineNumber = valueInt;
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line no-multi-assign
|
||||
const indices = expected[rule] = expected[rule] || [];
|
||||
const lineNumber =
|
||||
match[2] ? Number.parseInt(match[2], 10) : index + 1;
|
||||
if (!indices.includes(lineNumber)) {
|
||||
indices.push(lineNumber);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ Execute `via the node.js engine`
|
|||
node.js is runtime
|
||||
|
||||
```js
|
||||
javascript is code {MD046:18}
|
||||
javascript is code {MD046:-1}
|
||||
node.js is runtime
|
||||
```
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ Text [https://example.com/directory/text.file](https://example.com/directory/tex
|
|||
Text [https://example.com/directory/text%20text.file](https://example.com/directory/text%20text.file) text
|
||||
Text [https://example.com/directory/text%20text.file](https://example.com/directory/text%20text.file) text
|
||||
|
||||
{MD044:55}
|
||||
{MD044:+2}
|
||||
|
||||
<!-- markdownlint-configure-file {
|
||||
"proper-names": {
|
||||
|
|
|
@ -50,7 +50,7 @@ HTML <u>javascript</u> {MD044}
|
|||
node.js is runtime {MD044}
|
||||
|
||||
```javascript
|
||||
javascript is code {MD044} {MD046:52}
|
||||
javascript is code {MD044} {MD046:-1}
|
||||
node.js is runtime {MD044}
|
||||
```
|
||||
|
||||
|
@ -92,7 +92,7 @@ Text referencing mULTIPLEcASE name.
|
|||
<img src="img/javascript/image.png" alt="Description" error="{MD044}">
|
||||
|
||||
<script type="text/javascript">
|
||||
{MD044:94}
|
||||
{MD044:-1}
|
||||
javascript {MD044}
|
||||
</script>
|
||||
|
||||
|
@ -118,7 +118,7 @@ javascript {MD044}
|
|||
javascript {MD044}
|
||||
</div>
|
||||
|
||||
{MD044:107} {MD044:109} {MD044:112} {MD044:117}
|
||||
{MD044:-14} {MD044:-12} {MD044:-9} {MD044:-4}
|
||||
|
||||
<!-- markdownlint-configure-file {
|
||||
"no-inline-html": false,
|
||||
|
|
|
@ -41815,7 +41815,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
node.js is runtime␊
|
||||
␊
|
||||
\`\`\`js␊
|
||||
javascript is code {MD046:18}␊
|
||||
javascript is code {MD046:-1}␊
|
||||
node.js is runtime␊
|
||||
\`\`\`␊
|
||||
␊
|
||||
|
@ -42649,7 +42649,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
Text [https://example.com/directory/text%20text.file](https://example.com/directory/text%20text.file) text␊
|
||||
Text [https://example.com/directory/text%20text.file](https://example.com/directory/text%20text.file) text␊
|
||||
␊
|
||||
{MD044:55}␊
|
||||
{MD044:+2}␊
|
||||
␊
|
||||
<!-- markdownlint-configure-FILE {␊
|
||||
"proper-names": {␊
|
||||
|
@ -43560,7 +43560,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
Node.js is runtime {MD044}␊
|
||||
␊
|
||||
\`\`\`javascript␊
|
||||
JavaScript is code {MD044} {MD046:52}␊
|
||||
JavaScript is code {MD044} {MD046:-1}␊
|
||||
Node.js is runtime {MD044}␊
|
||||
\`\`\`␊
|
||||
␊
|
||||
|
@ -43602,7 +43602,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
<img src="img/JavaScript/image.png" alt="Description" error="{MD044}">␊
|
||||
␊
|
||||
<script type="text/JavaScript">␊
|
||||
{MD044:94}␊
|
||||
{MD044:-1}␊
|
||||
JavaScript {MD044}␊
|
||||
</script>␊
|
||||
␊
|
||||
|
@ -43628,7 +43628,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
JavaScript {MD044}␊
|
||||
</div>␊
|
||||
␊
|
||||
{MD044:107} {MD044:109} {MD044:112} {MD044:117}␊
|
||||
{MD044:-14} {MD044:-12} {MD044:-9} {MD044:-4}␊
|
||||
␊
|
||||
<!-- markdownlint-configure-file {␊
|
||||
"no-inline-html": false,␊
|
||||
|
|
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue