mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Allow unknown (custom) rule names in .markdownlint.json schema.
This commit is contained in:
parent
3f637ba8e5
commit
6061cce169
3 changed files with 44 additions and 4 deletions
|
|
@ -28,7 +28,12 @@ const schema = {
|
|||
"/main/schema/markdownlint-config-schema.json"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
"additionalProperties": {
|
||||
"type:": [
|
||||
"boolean",
|
||||
"object"
|
||||
]
|
||||
}
|
||||
};
|
||||
const tags = {};
|
||||
|
||||
|
|
|
|||
|
|
@ -1547,5 +1547,10 @@
|
|||
"default": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
"additionalProperties": {
|
||||
"type:": [
|
||||
"boolean",
|
||||
"object"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -22,6 +22,10 @@ const homepage = packageJson.homepage;
|
|||
const version = packageJson.version;
|
||||
|
||||
const deprecatedRuleNames = new Set([ "MD002", "MD006" ]);
|
||||
const configSchemaStrict = {
|
||||
...configSchema,
|
||||
"additionalProperties": false
|
||||
};
|
||||
|
||||
tape("simpleAsync", (test) => {
|
||||
test.plan(2);
|
||||
|
|
@ -940,7 +944,7 @@ tape("rules", (test) => {
|
|||
});
|
||||
});
|
||||
|
||||
tape("validateConfigSchema", (test) => {
|
||||
tape("validateJsonUsingConfigSchemaStrict", (test) => {
|
||||
const jsonFileRe = /\.json$/i;
|
||||
const resultsFileRe = /\.results\.json$/i;
|
||||
const jsConfigFileRe = /^jsconfig\.json$/i;
|
||||
|
|
@ -958,12 +962,38 @@ tape("validateConfigSchema", (test) => {
|
|||
"utf8"
|
||||
);
|
||||
test.ok(
|
||||
tv4.validate(JSON.parse(data), configSchema),
|
||||
// @ts-ignore
|
||||
tv4.validate(JSON.parse(data), configSchemaStrict),
|
||||
file + "\n" + JSON.stringify(tv4.error, null, 2));
|
||||
});
|
||||
test.end();
|
||||
});
|
||||
|
||||
tape("validateConfigSchemaAllowsUnknownProperties", (test) => {
|
||||
test.plan(4);
|
||||
const testCases = [
|
||||
{
|
||||
"property": true
|
||||
},
|
||||
{
|
||||
"property": {
|
||||
"object": 1
|
||||
}
|
||||
}
|
||||
];
|
||||
testCases.forEach((testCase) => {
|
||||
test.ok(
|
||||
// @ts-ignore
|
||||
tv4.validate(testCase, configSchema),
|
||||
"Unknown property blocked by default: " + JSON.stringify(testCase));
|
||||
test.notok(
|
||||
// @ts-ignore
|
||||
tv4.validate(testCase, configSchemaStrict),
|
||||
"Unknown property allowed when strict: " + JSON.stringify(testCase));
|
||||
});
|
||||
test.end();
|
||||
});
|
||||
|
||||
tape("configSingle", (test) => {
|
||||
test.plan(2);
|
||||
markdownlint.readConfig("./test/config/config-child.json",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue