mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-19 15:30:13 +01:00
Add "enabled" and "severity"/"warning" to rule in Configuration object, add corresponding documentation and tests, update demo web app (fixes #254)”.
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
87ddc2e022
commit
0f5a8c701e
20 changed files with 3792 additions and 867 deletions
|
|
@ -190,6 +190,16 @@ function getConfigTestImplementation(config, expected) {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a config test scenario from errors to warnings.
|
||||
*
|
||||
* @param {Object.<string, string[]>} configTest Config test scenario.
|
||||
* @returns {Object.<string, string[]>} Converted scenario.
|
||||
*/
|
||||
function configTestAsWarnings(configTest) {
|
||||
return JSON.parse(JSON.stringify(configTest).replaceAll("error", "warning"));
|
||||
}
|
||||
|
||||
const configTestExpected = {
|
||||
"./test/atx_heading_spacing.md": [],
|
||||
"./test/first_heading_bad_atx.md": []
|
||||
|
|
@ -273,13 +283,23 @@ test("defaultError", getConfigTestImplementation(
|
|||
test("defaultWarning", getConfigTestImplementation(
|
||||
// @ts-ignore
|
||||
{ "default": "warning" },
|
||||
configTestAsWarnings(configTestExpected13511)
|
||||
));
|
||||
|
||||
test("defaultMultipleTrue", getConfigTestImplementation(
|
||||
{
|
||||
"default": true,
|
||||
"DEFAULT": false
|
||||
},
|
||||
configTestExpected13511
|
||||
));
|
||||
|
||||
test("defaultOff", getConfigTestImplementation(
|
||||
// @ts-ignore
|
||||
{ "default": "off" },
|
||||
configTestExpected13511
|
||||
test("defaultMultipleFalse", getConfigTestImplementation(
|
||||
{
|
||||
"DEFAULT": false,
|
||||
"default": true
|
||||
},
|
||||
configTestExpected
|
||||
));
|
||||
|
||||
test("disableRules", getConfigTestImplementation(
|
||||
|
|
@ -336,7 +356,7 @@ test("enableRulesTruthy", getConfigTestImplementation(
|
|||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesString", getConfigTestImplementation(
|
||||
test("enableRulesError", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": "error",
|
||||
"default": false,
|
||||
|
|
@ -346,6 +366,16 @@ test("enableRulesString", getConfigTestImplementation(
|
|||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesWarning", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": "warning",
|
||||
"default": false,
|
||||
"no-multiple-space-atx": "warning",
|
||||
"extra": "warning"
|
||||
},
|
||||
configTestAsWarnings(configTestExpected3511)
|
||||
));
|
||||
|
||||
test("enableRulesObjectEmpty", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {},
|
||||
|
|
@ -356,7 +386,7 @@ test("enableRulesObjectEmpty", getConfigTestImplementation(
|
|||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesObjectTruthy", getConfigTestImplementation(
|
||||
test("enableRulesObjectSeverityTruthy", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
// @ts-ignore
|
||||
|
|
@ -374,7 +404,7 @@ test("enableRulesObjectTruthy", getConfigTestImplementation(
|
|||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesObjectFalsy", getConfigTestImplementation(
|
||||
test("enableRulesObjectSeverityFalsy", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
// @ts-ignore
|
||||
|
|
@ -392,7 +422,7 @@ test("enableRulesObjectFalsy", getConfigTestImplementation(
|
|||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesObjectError", getConfigTestImplementation(
|
||||
test("enableRulesObjectSeverityError", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
"severity": "error"
|
||||
|
|
@ -408,42 +438,90 @@ test("enableRulesObjectError", getConfigTestImplementation(
|
|||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesObjectWarning", getConfigTestImplementation(
|
||||
test("enableRulesObjectSeverityWarning", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
// @ts-ignore
|
||||
"severity": "warning"
|
||||
},
|
||||
"default": false,
|
||||
"no-multiple-space-atx": {
|
||||
// @ts-ignore
|
||||
"severity": "warning"
|
||||
},
|
||||
"extra": {
|
||||
"severity": "warning"
|
||||
}
|
||||
},
|
||||
configTestAsWarnings(configTestExpected3511)
|
||||
));
|
||||
|
||||
test("enableRulesObjectEnabledTrue", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
"enabled": true
|
||||
},
|
||||
"default": false,
|
||||
"no-multiple-space-atx": {
|
||||
"enabled": true
|
||||
},
|
||||
"extra": {
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesObjectOff", getConfigTestImplementation(
|
||||
test("enableRulesObjectEnabledFalse", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
"enabled": false
|
||||
},
|
||||
"default": true,
|
||||
"no-multiple-space-atx": {
|
||||
"enabled": false
|
||||
},
|
||||
"extra": {
|
||||
"enabled": false
|
||||
}
|
||||
},
|
||||
configTestExpected1
|
||||
));
|
||||
|
||||
test("enableRulesObjectEnabledTruthy", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
// @ts-ignore
|
||||
"severity": "off"
|
||||
"enabled": 1
|
||||
},
|
||||
"default": false,
|
||||
"no-multiple-space-atx": {
|
||||
// @ts-ignore
|
||||
"severity": "off"
|
||||
"enabled": 1
|
||||
},
|
||||
"extra": {
|
||||
"severity": "off"
|
||||
"enabled": 1
|
||||
}
|
||||
},
|
||||
configTestExpected3511
|
||||
));
|
||||
|
||||
test("enableRulesObjectEnabledFalsy", getConfigTestImplementation(
|
||||
{
|
||||
"MD041": {
|
||||
// @ts-ignore
|
||||
"enabled": 0
|
||||
},
|
||||
"default": true,
|
||||
"no-multiple-space-atx": {
|
||||
// @ts-ignore
|
||||
"enabled": 0
|
||||
},
|
||||
"extra": {
|
||||
"enabled": 0
|
||||
}
|
||||
},
|
||||
configTestExpected1
|
||||
));
|
||||
|
||||
test("disableTag", getConfigTestImplementation(
|
||||
{
|
||||
"default": true,
|
||||
|
|
@ -491,7 +569,7 @@ test("enableTagTruthy", getConfigTestImplementation(
|
|||
configTestExpected135
|
||||
));
|
||||
|
||||
test("enableTagString", getConfigTestImplementation(
|
||||
test("enableTagError", getConfigTestImplementation(
|
||||
{
|
||||
"default": false,
|
||||
"spaces": "error",
|
||||
|
|
@ -500,6 +578,15 @@ test("enableTagString", getConfigTestImplementation(
|
|||
configTestExpected135
|
||||
));
|
||||
|
||||
test("enableTagWarning", getConfigTestImplementation(
|
||||
{
|
||||
"default": false,
|
||||
"spaces": "warning",
|
||||
"extra": "warning"
|
||||
},
|
||||
configTestAsWarnings(configTestExpected135)
|
||||
));
|
||||
|
||||
test("styleFiles", async(t) => {
|
||||
t.plan(8);
|
||||
const files = await fs.promises.readdir("./style");
|
||||
|
|
@ -1008,7 +1095,7 @@ test("readme", async(t) => {
|
|||
});
|
||||
|
||||
test("validateJsonUsingConfigSchemaStrict", async(t) => {
|
||||
t.plan(212);
|
||||
t.plan(215);
|
||||
// @ts-ignore
|
||||
const ajv = new Ajv(ajvOptions);
|
||||
const validateSchemaStrict = ajv.compile(configSchemaStrict);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue