mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Deprecate LintResults.toString() (at edit time; continue to support at run time), provide helper function formatLintResults, remove outdated grunt/gulp samples, improve typing.
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled
Some checks failed
Checkers / linkcheck (push) Has been cancelled
Checkers / spellcheck (push) Has been cancelled
CI / build (20, macos-latest) (push) Has been cancelled
CI / build (20, ubuntu-latest) (push) Has been cancelled
CI / build (20, windows-latest) (push) Has been cancelled
CI / build (22, macos-latest) (push) Has been cancelled
CI / build (22, ubuntu-latest) (push) Has been cancelled
CI / build (22, windows-latest) (push) Has been cancelled
CI / build (24, macos-latest) (push) Has been cancelled
CI / build (24, ubuntu-latest) (push) Has been cancelled
CI / build (24, windows-latest) (push) Has been cancelled
CI / pnpm (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
TestRepos / build (latest, ubuntu-latest) (push) Has been cancelled
UpdateTestRepos / update (push) Has been cancelled
This commit is contained in:
parent
2a06f0a871
commit
616c3f2c22
18 changed files with 161 additions and 207 deletions
|
|
@ -5,7 +5,7 @@ import path from "node:path";
|
|||
import test from "ava";
|
||||
import { characterEntities } from "character-entities";
|
||||
import { gemoji } from "gemoji";
|
||||
import helpers from "../helpers/helpers.cjs";
|
||||
import helpers, { formatLintResults } from "../helpers/helpers.cjs";
|
||||
import { lint } from "markdownlint/promise";
|
||||
import { forEachInlineCodeSpan } from "../lib/markdownit.cjs";
|
||||
import { getReferenceLinkImageData } from "../lib/cache.mjs";
|
||||
|
|
@ -529,3 +529,17 @@ test("hasOverlap", (t) => {
|
|||
t.false(helpers.hasOverlap(rangeB, rangeA), JSON.stringify({ rangeB, rangeA }));
|
||||
}
|
||||
});
|
||||
|
||||
test("formatLintResults", async(t) => {
|
||||
t.plan(2);
|
||||
t.deepEqual(formatLintResults(undefined), []);
|
||||
const lintResults = await lint({ "strings": { "content": "# Heading <br/>" } });
|
||||
t.deepEqual(
|
||||
formatLintResults(lintResults),
|
||||
[
|
||||
"content: 1: MD019/no-multiple-space-atx Multiple spaces after hash on atx style heading [Context: \"# Heading <br/>\"]",
|
||||
"content: 1: MD033/no-inline-html Inline HTML [Element: br]",
|
||||
"content: 1: MD047/single-trailing-newline Files should end with a single newline character"
|
||||
]
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const { join } = path.posix;
|
|||
import { globby } from "globby";
|
||||
import jsoncParser from "jsonc-parser";
|
||||
import jsYaml from "js-yaml";
|
||||
import { formatLintResults } from "markdownlint/helpers";
|
||||
import { lint, readConfig } from "markdownlint/promise";
|
||||
import { markdownlintParallel } from "./markdownlint-test-parallel.mjs";
|
||||
|
||||
|
|
@ -49,9 +50,8 @@ export function lintTestRepo(t, globPatterns, configPath, configOverrides, paral
|
|||
files,
|
||||
config
|
||||
}).then((results) => {
|
||||
const resultsString = results.toString();
|
||||
t.snapshot(
|
||||
resultsString,
|
||||
formatLintResults(results).join("\n"),
|
||||
"Expected linting violations"
|
||||
);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -49,46 +49,42 @@ function getMarkdownItFactory(markdownItPlugins) {
|
|||
}
|
||||
|
||||
test("simpleAsync", (t) => new Promise((resolve) => {
|
||||
t.plan(3);
|
||||
const options = {
|
||||
"strings": {
|
||||
"content": "# Heading"
|
||||
}
|
||||
};
|
||||
lintAsync(options, (err, actual) => {
|
||||
t.falsy(err);
|
||||
t.is(actual?.content.length, 1);
|
||||
t.is(actual?.content[0].ruleNames[0], "MD047");
|
||||
resolve();
|
||||
});
|
||||
}));
|
||||
|
||||
test("simpleSync", (t) => {
|
||||
t.plan(2);
|
||||
const options = {
|
||||
"strings": {
|
||||
"content": "# Heading"
|
||||
}
|
||||
};
|
||||
const expected = "content: 1: MD047/single-trailing-newline " +
|
||||
"Files should end with a single newline character";
|
||||
lintAsync(options, (err, actual) => {
|
||||
t.falsy(err);
|
||||
// @ts-ignore
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
resolve();
|
||||
});
|
||||
}));
|
||||
|
||||
test("simpleSync", (t) => {
|
||||
t.plan(1);
|
||||
const options = {
|
||||
"strings": {
|
||||
"content": "# Heading"
|
||||
}
|
||||
};
|
||||
const expected = "content: 1: MD047/single-trailing-newline " +
|
||||
"Files should end with a single newline character";
|
||||
const actual = lintSync(options).toString();
|
||||
t.is(actual, expected, "Unexpected results.");
|
||||
const actual = lintSync(options);
|
||||
t.is(actual.content.length, 1);
|
||||
t.is(actual.content[0].ruleNames[0], "MD047");
|
||||
});
|
||||
|
||||
test("simplePromise", (t) => {
|
||||
t.plan(1);
|
||||
t.plan(2);
|
||||
const options = {
|
||||
"strings": {
|
||||
"content": "# Heading"
|
||||
}
|
||||
};
|
||||
const expected = "content: 1: MD047/single-trailing-newline " +
|
||||
"Files should end with a single newline character";
|
||||
return lintPromise(options).then((actual) => {
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
t.is(actual.content.length, 1);
|
||||
t.is(actual.content[0].ruleNames[0], "MD047");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -1281,7 +1277,7 @@ test("token-map-spans", (t) => {
|
|||
});
|
||||
|
||||
test("configParsersInvalid", async(t) => {
|
||||
t.plan(1);
|
||||
t.plan(2);
|
||||
const options = {
|
||||
"strings": {
|
||||
"content": [
|
||||
|
|
@ -1294,10 +1290,9 @@ test("configParsersInvalid", async(t) => {
|
|||
].join("\n")
|
||||
}
|
||||
};
|
||||
const expected = "content: 1: MD041/first-line-heading/first-line-h1 " +
|
||||
"First line in a file should be a top-level heading [Context: \"Text\"]";
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), expected, "Unexpected results.");
|
||||
t.is(actual.content.length, 1);
|
||||
t.is(actual.content[0].ruleNames[0], "MD041");
|
||||
});
|
||||
|
||||
test("configParsersJSON", async(t) => {
|
||||
|
|
@ -1317,7 +1312,7 @@ test("configParsersJSON", async(t) => {
|
|||
}
|
||||
};
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
t.is(actual.content.length, 0);
|
||||
});
|
||||
|
||||
test("configParsersJSONC", async(t) => {
|
||||
|
|
@ -1339,7 +1334,7 @@ test("configParsersJSONC", async(t) => {
|
|||
"configParsers": [ jsoncParser.parse ]
|
||||
};
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
t.is(actual.content.length, 0);
|
||||
});
|
||||
|
||||
test("configParsersYAML", async(t) => {
|
||||
|
|
@ -1360,7 +1355,7 @@ test("configParsersYAML", async(t) => {
|
|||
};
|
||||
// @ts-ignore
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
t.is(actual.content.length, 0);
|
||||
});
|
||||
|
||||
test("configParsersTOML", async(t) => {
|
||||
|
|
@ -1382,7 +1377,7 @@ test("configParsersTOML", async(t) => {
|
|||
]
|
||||
};
|
||||
const actual = await lintPromise(options);
|
||||
t.is(actual.toString(), "", "Unexpected results.");
|
||||
t.is(actual.content.length, 0);
|
||||
});
|
||||
|
||||
test("getVersion", (t) => {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ Generated by [AVA](https://avajs.dev).
|
|||
'endOfLineHtmlEntityRe',
|
||||
'escapeForRegExp',
|
||||
'expandTildePath',
|
||||
'formatLintResults',
|
||||
'frontMatterHasTitle',
|
||||
'frontMatterRe',
|
||||
'getHtmlAttributeRe',
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -320,9 +320,6 @@ Generated by [AVA](https://avajs.dev).
|
|||
|
||||
`test-repos/mochajs-mocha/.github/CODE_OF_CONDUCT.md: 63: MD034/no-bare-urls Bare URL used [Context: "report@lists.openjsf.org"]␊
|
||||
test-repos/mochajs-mocha/.github/CONTRIBUTING.md: 42: MD051/link-fragments Link fragments should be valid [Context: "[⚽️ About Project Goals](#⚽️-about-project-goals)"]␊
|
||||
test-repos/mochajs-mocha/PROJECT_CHARTER.md: 51: MD051/link-fragments Link fragments should be valid [Context: "[§2: Scope](#%c2%a72-scope)"]␊
|
||||
test-repos/mochajs-mocha/PROJECT_CHARTER.md: 56: MD051/link-fragments Link fragments should be valid [Context: "[§2: Scope](#%c2%a72-scope)"]␊
|
||||
test-repos/mochajs-mocha/README.md: 39: MD045/no-alt-text Images should have alternate text (alt text)␊
|
||||
test-repos/mochajs-mocha/docs/changelogs/CHANGELOG_V3_older.md: 207: MD059/descriptive-link-text Link text should be descriptive [Context: "[more]"]␊
|
||||
test-repos/mochajs-mocha/docs/index.md: 34: MD051/link-fragments Link fragments should be valid [Context: "[global variable leak detection](#-check-leaks)"]␊
|
||||
test-repos/mochajs-mocha/docs/index.md: 35: MD051/link-fragments Link fragments should be valid [Context: "[optionally run tests that match a regexp](#-grep-regexp-g-regexp)"]␊
|
||||
|
|
@ -350,7 +347,10 @@ Generated by [AVA](https://avajs.dev).
|
|||
test-repos/mochajs-mocha/docs/index.md: 2432: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "caniuse-promises"] [Context: "[caniuse-promises]: https://ca..."]␊
|
||||
test-repos/mochajs-mocha/docs/index.md: 2463: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "mocha-website"] [Context: "[mocha-website]: https://mocha..."]␊
|
||||
test-repos/mochajs-mocha/docs/index.md: 2230: MD059/descriptive-link-text Link text should be descriptive [Context: "[here]"]␊
|
||||
test-repos/mochajs-mocha/docs/index.md: 2302: MD059/descriptive-link-text Link text should be descriptive [Context: "[here]"]`
|
||||
test-repos/mochajs-mocha/docs/index.md: 2302: MD059/descriptive-link-text Link text should be descriptive [Context: "[here]"]␊
|
||||
test-repos/mochajs-mocha/PROJECT_CHARTER.md: 51: MD051/link-fragments Link fragments should be valid [Context: "[§2: Scope](#%c2%a72-scope)"]␊
|
||||
test-repos/mochajs-mocha/PROJECT_CHARTER.md: 56: MD051/link-fragments Link fragments should be valid [Context: "[§2: Scope](#%c2%a72-scope)"]␊
|
||||
test-repos/mochajs-mocha/README.md: 39: MD045/no-alt-text Images should have alternate text (alt text)`
|
||||
|
||||
## https://github.com/pi-hole/docs
|
||||
|
||||
|
|
@ -738,12 +738,12 @@ Generated by [AVA](https://avajs.dev).
|
|||
`test-repos/webhintio-hint/packages/hint-apple-touch-icons/README.md: 198: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "icon scaling"] [Context: "[icon scaling]: https://realfa..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-apple-touch-icons/README.md: 202: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "web app manifest spec"] [Context: "[web app manifest spec]: https..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-axe/README.md: 170: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "axe rules"] [Context: "[axe rules]: https://github.co..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-compat-api/README.md: 48: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "npm docs"] [Context: "[npm docs]: https://docs.npmjs..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-compat-api/docs/html.md: 153: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "global-attr"] [Context: "[global-attr]: https://develop..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-detect-css-reflows/README.md: 96: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "understanding-critical-path"] [Context: "[understanding-critical-path]:..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-compat-api/README.md: 48: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "npm docs"] [Context: "[npm docs]: https://docs.npmjs..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-detect-css-reflows/docs/composite.md: 73: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "understanding-critical-path"] [Context: "[understanding-critical-path]:..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-detect-css-reflows/docs/layout.md: 73: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "understanding-critical-path"] [Context: "[understanding-critical-path]:..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-detect-css-reflows/docs/paint.md: 73: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "understanding-critical-path"] [Context: "[understanding-critical-path]:..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-detect-css-reflows/README.md: 96: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "understanding-critical-path"] [Context: "[understanding-critical-path]:..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-doctype/README.md: 130: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "npm docs"] [Context: "[npm docs]: https://docs.npmjs..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-highest-available-document-mode/README.md: 420: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "mod_mime"] [Context: "[mod_mime]: https://httpd.apac..."]␊
|
||||
test-repos/webhintio-hint/packages/hint-http-compression/README.md: 1087: MD053/link-image-reference-definitions Link and image reference definitions should be needed [Unused link or image reference definition: "gzip is not enough"] [Context: "[gzip is not enough]: https://..."]␊
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue