mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Add rule name and file/string identifier to Error message thrown by onError validation for rules.
This commit is contained in:
parent
74f4163a10
commit
d2faf40e6a
3 changed files with 16 additions and 8 deletions
|
|
@ -2354,7 +2354,8 @@ function lintContent(ruleList, aliasToRuleNames, name, content, md, config, conf
|
||||||
});
|
});
|
||||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||||
function throwError(property) {
|
function throwError(property) {
|
||||||
throw new Error("Property '" + property + "' of onError parameter is incorrect.");
|
throw new Error( // eslint-disable-next-line max-len
|
||||||
|
"Value of '".concat(property, "' passed to onError by '").concat(ruleName, "' is incorrect for '").concat(name, "'."));
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||||
function onError(errorInfo) {
|
function onError(errorInfo) {
|
||||||
|
|
|
||||||
|
|
@ -604,7 +604,8 @@ function lintContent(
|
||||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||||
function throwError(property) {
|
function throwError(property) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Property '" + property + "' of onError parameter is incorrect.");
|
// eslint-disable-next-line max-len
|
||||||
|
`Value of '${property}' passed to onError by '${ruleName}' is incorrect for '${name}'.`);
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||||
function onError(errorInfo) {
|
function onError(errorInfo) {
|
||||||
|
|
|
||||||
|
|
@ -656,7 +656,8 @@ test("customRulesOnErrorNull", (t) => new Promise((resolve) => {
|
||||||
t.is(
|
t.is(
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
err.message,
|
err.message,
|
||||||
"Property 'lineNumber' of onError parameter is incorrect.",
|
// eslint-disable-next-line max-len
|
||||||
|
"Value of 'lineNumber' passed to onError by 'NAME' is incorrect for 'string'.",
|
||||||
"Did not get correct exception for null object."
|
"Did not get correct exception for null object."
|
||||||
);
|
);
|
||||||
t.true(!result, "Got result for function thrown.");
|
t.true(!result, "Got result for function thrown.");
|
||||||
|
|
@ -686,7 +687,8 @@ test("customRulesOnErrorNullSync", (t) => {
|
||||||
markdownlint.sync(options);
|
markdownlint.sync(options);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message": "Property 'lineNumber' of onError parameter is incorrect."
|
// eslint-disable-next-line max-len
|
||||||
|
"message": "Value of 'lineNumber' passed to onError by 'NAME' is incorrect for 'string'."
|
||||||
},
|
},
|
||||||
"Did not get correct exception for null object."
|
"Did not get correct exception for null object."
|
||||||
);
|
);
|
||||||
|
|
@ -775,7 +777,8 @@ test("customRulesOnErrorBad", (t) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message":
|
"message":
|
||||||
`Property '${propertyNames}' of onError parameter is incorrect.`
|
// eslint-disable-next-line max-len
|
||||||
|
`Value of '${propertyNames}' passed to onError by 'NAME' is incorrect for 'string'.`
|
||||||
},
|
},
|
||||||
"Did not get correct exception for bad object."
|
"Did not get correct exception for bad object."
|
||||||
);
|
);
|
||||||
|
|
@ -845,7 +848,8 @@ test("customRulesOnErrorInvalid", (t) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"message":
|
"message":
|
||||||
`Property '${propertyNames}' of onError parameter is incorrect.`
|
// eslint-disable-next-line max-len
|
||||||
|
`Value of '${propertyNames}' passed to onError by 'NAME' is incorrect for 'string'.`
|
||||||
},
|
},
|
||||||
"Did not get correct exception for invalid object."
|
"Did not get correct exception for invalid object."
|
||||||
);
|
);
|
||||||
|
|
@ -1052,7 +1056,8 @@ test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => {
|
||||||
"ruleDescription": "description",
|
"ruleDescription": "description",
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": "This rule threw an exception: " +
|
"errorDetail": "This rule threw an exception: " +
|
||||||
"Property 'lineNumber' of onError parameter is incorrect.",
|
// eslint-disable-next-line max-len
|
||||||
|
"Value of 'lineNumber' passed to onError by 'NAME' is incorrect for 'string'.",
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null,
|
"errorRange": null,
|
||||||
"fixInfo": null
|
"fixInfo": null
|
||||||
|
|
@ -1093,7 +1098,8 @@ test("customRulesOnErrorInvalidHandledSync", (t) => {
|
||||||
"ruleDescription": "description",
|
"ruleDescription": "description",
|
||||||
"ruleInformation": null,
|
"ruleInformation": null,
|
||||||
"errorDetail": "This rule threw an exception: " +
|
"errorDetail": "This rule threw an exception: " +
|
||||||
"Property 'lineNumber' of onError parameter is incorrect.",
|
// eslint-disable-next-line max-len
|
||||||
|
"Value of 'lineNumber' passed to onError by 'NAME' is incorrect for 'string'.",
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null,
|
"errorRange": null,
|
||||||
"fixInfo": null
|
"fixInfo": null
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue