diff --git a/lib/markdownlint.d.mts b/lib/markdownlint.d.mts index 331262e9..1117fd0d 100644 --- a/lib/markdownlint.d.mts +++ b/lib/markdownlint.d.mts @@ -445,7 +445,7 @@ export type Plugin = any[]; /** * Function to pretty-print lint results. */ -export type ToStringCallback = (ruleAliases?: boolean) => string; +export type ToStringCallback = () => string; /** * Lint results. */ diff --git a/lib/markdownlint.mjs b/lib/markdownlint.mjs index b3d8f25f..3bbad333 100644 --- a/lib/markdownlint.mjs +++ b/lib/markdownlint.mjs @@ -1496,7 +1496,6 @@ export function getVersion() { * Function to pretty-print lint results. * * @callback ToStringCallback - * @param {boolean} [ruleAliases] True to use rule aliases. * @returns {string} Pretty-printed results. */ diff --git a/package.json b/package.json index c38697fd..d67605c3 100644 --- a/package.json +++ b/package.json @@ -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-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", - "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-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" diff --git a/test/markdownlint-test.mjs b/test/markdownlint-test.mjs index 06318fce..1d7879d4 100644 --- a/test/markdownlint-test.mjs +++ b/test/markdownlint-test.mjs @@ -1392,6 +1392,29 @@ test("getVersion", (t) => { t.is(actual, expected, "Version string not correct."); }); +const matcherRe = /^(?[^:]+):\s*(?\d+)(?::(?\d+))?:?\s(?\S+)\s(?.+)$/; + +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) => { t.plan(2); // @ts-ignore diff --git a/test/snapshots/markdownlint-test.mjs.md b/test/snapshots/markdownlint-test.mjs.md new file mode 100644 index 00000000..fbf5fee9 --- /dev/null +++ b/test/snapshots/markdownlint-test.mjs.md @@ -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', + }, + ] diff --git a/test/snapshots/markdownlint-test.mjs.snap b/test/snapshots/markdownlint-test.mjs.snap new file mode 100644 index 00000000..4163045e Binary files /dev/null and b/test/snapshots/markdownlint-test.mjs.snap differ