This commit is contained in:
David Anson 2025-09-03 23:25:56 -07:00
parent f38368f6cb
commit 697b04834f
6 changed files with 112 additions and 3 deletions

View file

@ -445,7 +445,7 @@ export type Plugin = any[];
/** /**
* Function to pretty-print lint results. * Function to pretty-print lint results.
*/ */
export type ToStringCallback = (ruleAliases?: boolean) => string; export type ToStringCallback = () => string;
/** /**
* Lint results. * Lint results.
*/ */

View file

@ -1496,7 +1496,6 @@ export function getVersion() {
* Function to pretty-print lint results. * Function to pretty-print lint results.
* *
* @callback ToStringCallback * @callback ToStringCallback
* @param {boolean} [ruleAliases] True to use rule aliases.
* @returns {string} Pretty-printed results. * @returns {string} Pretty-printed results.
*/ */

View file

@ -65,7 +65,7 @@
"test-declaration-cts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-commonjs.cts && tsc --module commonjs --esModuleInterop type-check-commonjs.cts", "test-declaration-cts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-commonjs.cts && tsc --module commonjs --esModuleInterop type-check-commonjs.cts",
"test-declaration-mts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-nodenext.mts && tsc --module nodenext type-check-nodenext.mts && node type-check-nodenext.mjs", "test-declaration-mts": "cd example/typescript && node ../../scripts/index.mjs copy type-check.ts type-check-nodenext.mts && tsc --module nodenext type-check-nodenext.mts && node type-check-nodenext.mjs",
"test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs", "test-extra": "ava --timeout=10m test/markdownlint-test-extra-parse.mjs test/markdownlint-test-extra-type.mjs",
"update-snapshots": "ava --update-snapshots test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.mjs", "update-snapshots": "ava --update-snapshots test/markdownlint-test.mjs test/markdownlint-test-custom-rules.mjs test/markdownlint-test-exports.mjs test/markdownlint-test-micromark.mjs test/markdownlint-test-scenarios.mjs",
"update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.mjs", "update-snapshots-test-repos": "ava --timeout=10m --update-snapshots test/markdownlint-test-repos-*.mjs",
"update-test-repos": "node scripts/index.mjs remove ./test-repos && npm run clone-test-repos && npm run update-snapshots-test-repos", "update-test-repos": "node scripts/index.mjs remove ./test-repos && npm run clone-test-repos && npm run update-snapshots-test-repos",
"upgrade": "npx --yes npm-check-updates --upgrade" "upgrade": "npx --yes npm-check-updates --upgrade"

View file

@ -1392,6 +1392,29 @@ test("getVersion", (t) => {
t.is(actual, expected, "Version string not correct."); t.is(actual, expected, "Version string not correct.");
}); });
const matcherRe = /^(?<source>[^:]+):\s*(?<line>\d+)(?::(?<column>\d+))?:?\s(?<rule>\S+)\s(?<description>.+)$/;
test("problemMatcher", async(t) => {
t.plan(2);
const content = "# Heading\nText `code ` text ";
const options = {
"strings": {
"relative/path/file name.md": content
}
};
const results = await lintPromise(options);
const getMatches = (input) => input.split("\n").map((line) => matcherRe.exec(line)?.groups);
t.snapshot(getMatches(results.toString()));
// eslint-disable-next-line camelcase
const cli_0_45_0__cli2_0_18_1 =
`relative/path/file name.md:1:3 MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: "# Heading"]
relative/path/file name.md:1 MD022/blanks-around-headings Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# Heading"]
relative/path/file name.md:2:18 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
relative/path/file name.md:2:11 MD038/no-space-in-code Spaces inside code span elements [Context: "\`code \`"]
relative/path/file name.md:2:18 MD047/single-trailing-newline Files should end with a single newline character`;
t.snapshot(getMatches(cli_0_45_0__cli2_0_18_1));
});
test("constants", (t) => { test("constants", (t) => {
t.plan(2); t.plan(2);
// @ts-ignore // @ts-ignore

View file

@ -0,0 +1,87 @@
# Snapshot report for `test/markdownlint-test.mjs`
The actual snapshot is saved in `markdownlint-test.mjs.snap`.
Generated by [AVA](https://avajs.dev).
## problemMatcher
> Snapshot 1
[
{
column: undefined,
description: 'Trailing spaces [Expected: 0 or 2; Actual: 1]',
line: '2',
rule: 'MD009/no-trailing-spaces',
source: 'relative/path/file name.md',
},
{
column: undefined,
description: 'Multiple spaces after hash on atx style heading [Context: "# Heading"]',
line: '1',
rule: 'MD019/no-multiple-space-atx',
source: 'relative/path/file name.md',
},
{
column: undefined,
description: 'Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# Heading"]',
line: '1',
rule: 'MD022/blanks-around-headings',
source: 'relative/path/file name.md',
},
{
column: undefined,
description: 'Spaces inside code span elements [Context: "`code `"]',
line: '2',
rule: 'MD038/no-space-in-code',
source: 'relative/path/file name.md',
},
{
column: undefined,
description: 'Files should end with a single newline character',
line: '2',
rule: 'MD047/single-trailing-newline',
source: 'relative/path/file name.md',
},
]
> Snapshot 2
[
{
column: '3',
description: 'Multiple spaces after hash on atx style heading [Context: "# Heading"]',
line: '1',
rule: 'MD019/no-multiple-space-atx',
source: 'relative/path/file name.md',
},
{
column: undefined,
description: 'Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# Heading"]',
line: '1',
rule: 'MD022/blanks-around-headings',
source: 'relative/path/file name.md',
},
{
column: '18',
description: 'Trailing spaces [Expected: 0 or 2; Actual: 1]',
line: '2',
rule: 'MD009/no-trailing-spaces',
source: 'relative/path/file name.md',
},
{
column: '11',
description: 'Spaces inside code span elements [Context: "`code `"]',
line: '2',
rule: 'MD038/no-space-in-code',
source: 'relative/path/file name.md',
},
{
column: '18',
description: 'Files should end with a single newline character',
line: '2',
rule: 'MD047/single-trailing-newline',
source: 'relative/path/file name.md',
},
]

Binary file not shown.