mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Re-introduce validateJsonUsingConfigSchemaStrict for validating the content of markdownlint-configure-file in Markdown files.
This commit is contained in:
parent
0ebcf248ca
commit
300ee36a5f
1 changed files with 47 additions and 14 deletions
|
|
@ -75,33 +75,31 @@ test("simplePromise", (t) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("projectFiles", (t) => new Promise((resolve) => {
|
test("projectFiles", (t) => {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
import("globby")
|
return import("globby")
|
||||||
.then((module) => module.globby("doc/*.md"))
|
.then((module) => module.globby([
|
||||||
.then((files) => [
|
"*.md",
|
||||||
...files,
|
"doc/*.md",
|
||||||
"CHANGELOG.md",
|
"helpers/*.md",
|
||||||
"CONTRIBUTING.md",
|
"micromark/*.md",
|
||||||
"README.md",
|
"schema/*.md"
|
||||||
"helpers/README.md"
|
]))
|
||||||
])
|
|
||||||
.then((files) => {
|
.then((files) => {
|
||||||
|
t.is(files.length, 58);
|
||||||
const options = {
|
const options = {
|
||||||
files,
|
files,
|
||||||
"config": require("../.markdownlint.json")
|
"config": require("../.markdownlint.json")
|
||||||
};
|
};
|
||||||
markdownlint(options, function callback(err, actual) {
|
return markdownlint.promises.markdownlint(options).then((actual) => {
|
||||||
t.falsy(err);
|
|
||||||
const expected = {};
|
const expected = {};
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
expected[file] = [];
|
expected[file] = [];
|
||||||
}
|
}
|
||||||
t.deepEqual(actual, expected, "Issue(s) with project files.");
|
t.deepEqual(actual, expected, "Issue(s) with project files.");
|
||||||
resolve();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}));
|
});
|
||||||
|
|
||||||
test("stringInputLineEndings", (t) => new Promise((resolve) => {
|
test("stringInputLineEndings", (t) => new Promise((resolve) => {
|
||||||
t.plan(2);
|
t.plan(2);
|
||||||
|
|
@ -923,6 +921,41 @@ test("readme", (t) => new Promise((resolve) => {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
test("validateJsonUsingConfigSchemaStrict", (t) => {
|
||||||
|
t.plan(156);
|
||||||
|
const configRe =
|
||||||
|
/^[\s\S]*<!-- markdownlint-configure-file ([\s\S]*) -->[\s\S]*$/;
|
||||||
|
const ignoreFiles = new Set([
|
||||||
|
"README.md",
|
||||||
|
"test/inline-configure-file-invalid.md",
|
||||||
|
"test/inline-configure-file-violations.md",
|
||||||
|
"test/invalid-ul-style-style.md",
|
||||||
|
"test/wrong-types-in-config-file.md"
|
||||||
|
]);
|
||||||
|
return import("globby")
|
||||||
|
.then((module) => module.globby([
|
||||||
|
"*.md",
|
||||||
|
"doc/*.md",
|
||||||
|
"helpers/*.md",
|
||||||
|
"micromark/*.md",
|
||||||
|
"schema/*.md",
|
||||||
|
"test/*.md"
|
||||||
|
]))
|
||||||
|
.then((files) => {
|
||||||
|
const testFiles = files.filter((file) => !ignoreFiles.has(file));
|
||||||
|
for (const file of testFiles) {
|
||||||
|
const data = fs.readFileSync(file, "utf8");
|
||||||
|
if (configRe.test(data)) {
|
||||||
|
const config = data.replace(configRe, "$1");
|
||||||
|
t.true(
|
||||||
|
// @ts-ignore
|
||||||
|
tv4.validate(JSON.parse(config), configSchemaStrict),
|
||||||
|
file + "\n" + JSON.stringify(tv4.error, null, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test("validateConfigSchemaAllowsUnknownProperties", (t) => {
|
test("validateConfigSchemaAllowsUnknownProperties", (t) => {
|
||||||
t.plan(4);
|
t.plan(4);
|
||||||
const testCases = [
|
const testCases = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue