Skip to content

Commit

Permalink
Update tests to account for new markdownlint library version.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidAnson committed Aug 30, 2024
1 parent 39c6feb commit 48a1cd4
Show file tree
Hide file tree
Showing 16 changed files with 1,468 additions and 1,121 deletions.
2 changes: 1 addition & 1 deletion doc/OutputFormatters.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ For a `.markdownlint-cli2.jsonc` like:
[formatter-junit]: ../formatter-junit/markdownlint-cli2-formatter-junit.js
[formatter-sarif]: ../formatter-sarif/markdownlint-cli2-formatter-sarif.js
[markdownlint-cli2-formatter]: https://www.npmjs.com/search?q=keywords:markdownlint-cli2-formatter
[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.34.0/lib/markdownlint.d.ts
[markdownlint-d-ts]: https://github.com/DavidAnson/markdownlint/blob/v0.35.0/lib/markdownlint.d.ts
4 changes: 2 additions & 2 deletions schema/markdownlint-cli2-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"default": "https://raw.githubusercontent.com/DavidAnson/markdownlint-cli2/v0.13.0/schema/markdownlint-cli2-config-schema.json"
},
"config": {
"description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.34.0/schema/.markdownlint.jsonc",
"$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.34.0/schema/markdownlint-config-schema.json",
"description": "markdownlint configuration schema : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/schema/.markdownlint.jsonc",
"$ref": "https://raw.githubusercontent.com/DavidAnson/markdownlint/v0.35.0/schema/markdownlint-config-schema.json",
"default": {}
},
"customRules": {
Expand Down
220 changes: 115 additions & 105 deletions schema/markdownlint-config-schema.json

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions test/config-relative-commonjs/config/any-blockquote.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

"use strict";

const { URL } = require("url");
const { filterTokens } = require("markdownlint/helpers");

/** @type import("markdownlint").Rule */
module.exports = {
"names": [ "any-blockquote" ],
"description": "Rule that reports an error for any blockquote",
"information": new URL(
"https://github.com/DavidAnson/markdownlint" +
"/blob/master/test/rules/any-blockquote.js"
"/blob/main/test/rules/any-blockquote.js"
),
"tags": [ "test" ],
"parser": "markdownit",
"function": (params, onError) => {
filterTokens(params, "blockquote_open", (blockquote) => {
const blockquotes = params.parsers.markdownit.tokens.
filter((token => token.type === "blockquote_open"));
for (const blockquote of blockquotes) {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
});
}
}
};
13 changes: 7 additions & 6 deletions test/config-relative-module/config/any-blockquote.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
// @ts-check

import { URL } from "url";
import { filterTokens } from "markdownlint/helpers";

/** @type import("markdownlint").Rule */
const rule = {
"names": [ "any-blockquote" ],
"description": "Rule that reports an error for any blockquote",
"information": new URL(
"https://github.com/DavidAnson/markdownlint" +
"/blob/master/test/rules/any-blockquote.js"
"/blob/main/test/rules/any-blockquote.js"
),
"tags": [ "test" ],
"parser": "markdownit",
"function": (params, onError) => {
filterTokens(params, "blockquote_open", (blockquote) => {
const blockquotes = params.parsers.markdownit.tokens.
filter((token => token.type === "blockquote_open"));
for (const blockquote of blockquotes) {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
});
}
}
};

Expand Down
13 changes: 7 additions & 6 deletions test/customRules-pre-imported/rules/any-blockquote.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

"use strict";

const { URL } = require("url");
const { filterTokens } = require("markdownlint/helpers");

/** @type import("markdownlint").Rule */
module.exports = {
"names": [ "any-blockquote" ],
"description": "Rule that reports an error for any blockquote",
"information": new URL(
"https://github.com/DavidAnson/markdownlint" +
"/blob/master/test/rules/any-blockquote.js"
"/blob/main/test/rules/any-blockquote.js"
),
"tags": [ "test" ],
"parser": "markdownit",
"function": (params, onError) => {
filterTokens(params, "blockquote_open", (blockquote) => {
const blockquotes = params.parsers.markdownit.tokens.
filter((token => token.type === "blockquote_open"));
for (const blockquote of blockquotes) {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
});
}
}
};
13 changes: 7 additions & 6 deletions test/customRules/rules/any-blockquote.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,26 @@

"use strict";

const { URL } = require("url");
const { filterTokens } = require("markdownlint/helpers");

/** @type import("markdownlint").Rule */
module.exports = {
"names": [ "any-blockquote" ],
"description": "Rule that reports an error for any blockquote",
"information": new URL(
"https://github.com/DavidAnson/markdownlint" +
"/blob/master/test/rules/any-blockquote.js"
"/blob/main/test/rules/any-blockquote.js"
),
"tags": [ "test" ],
"parser": "markdownit",
"function": (params, onError) => {
filterTokens(params, "blockquote_open", (blockquote) => {
const blockquotes = params.parsers.markdownit.tokens.
filter((token => token.type === "blockquote_open"));
for (const blockquote of blockquotes) {
const lines = blockquote.map[1] - blockquote.map[0];
onError({
"lineNumber": blockquote.lineNumber,
"detail": "Blockquote spans " + lines + " line(s).",
"context": blockquote.line.substr(0, 7)
});
});
}
}
};
10 changes: 5 additions & 5 deletions test/markdownlint-cli2-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ test("custom fs, using node:fs", (t) => {
"directory": "test/markdownlint-cli2-jsonc",
"argv": [ "**/*.md" ],
"optionsOverride": {
"outputFormatters": [ [ outputFormatterLengthIs(t, 9) ] ]
"outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ]
},
"fs": require("node:fs")
}).
Expand All @@ -573,7 +573,7 @@ test("custom fs, using node:fs and noRequire=false", (t) => {
"directory": "test/markdownlint-cjs",
"argv": [ "**/*.md" ],
"optionsOverride": {
"outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ]
"outputFormatters": [ [ outputFormatterLengthIs(t, 11) ] ]
},
"fs": require("node:fs"),
"noRequire": false
Expand All @@ -589,7 +589,7 @@ test("custom fs, using node:fs and noRequire=true", (t) => {
"directory": "test/markdownlint-cjs",
"argv": [ "**/*.md" ],
"optionsOverride": {
"outputFormatters": [ [ outputFormatterLengthIs(t, 13) ] ]
"outputFormatters": [ [ outputFormatterLengthIs(t, 14) ] ]
},
"fs": require("node:fs"),
"noRequire": true
Expand All @@ -605,7 +605,7 @@ test("custom fs, using fsMock", (t) => {
"directory": "/mock",
"argv": [ "**/*.md", "viewme.md" ],
"optionsOverride": {
"outputFormatters": [ [ outputFormatterLengthIs(t, 9) ] ]
"outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ]
},
"fs": new FsMock(path.join(__dirname, "markdownlint-cli2-jsonc")),
"noRequire": true
Expand All @@ -621,7 +621,7 @@ test("custom fs, using fsMock simulating symbolic links", (t) => {
"directory": "/mock",
"argv": [ "**/*.md", "viewme.md" ],
"optionsOverride": {
"outputFormatters": [ [ outputFormatterLengthIs(t, 9) ] ]
"outputFormatters": [ [ outputFormatterLengthIs(t, 10) ] ]
},
"fs": new FsMock(path.join(__dirname, "markdownlint-cli2-jsonc"), true),
"noRequire": true
Expand Down
Loading

0 comments on commit 48a1cd4

Please sign in to comment.