diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index ce6b235b..5cec4c6e 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -2354,7 +2354,8 @@ function lintContent(ruleList, aliasToRuleNames, name, content, md, config, conf }); // eslint-disable-next-line jsdoc/require-jsdoc 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 function onError(errorInfo) { diff --git a/lib/markdownlint.js b/lib/markdownlint.js index 315cc9da..c01745e2 100644 --- a/lib/markdownlint.js +++ b/lib/markdownlint.js @@ -604,7 +604,8 @@ function lintContent( // eslint-disable-next-line jsdoc/require-jsdoc function throwError(property) { 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 function onError(errorInfo) { diff --git a/test/markdownlint-test-custom-rules.js b/test/markdownlint-test-custom-rules.js index ab2c742f..3f3db702 100644 --- a/test/markdownlint-test-custom-rules.js +++ b/test/markdownlint-test-custom-rules.js @@ -656,7 +656,8 @@ test("customRulesOnErrorNull", (t) => new Promise((resolve) => { t.is( // @ts-ignore 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." ); t.true(!result, "Got result for function thrown."); @@ -686,7 +687,8 @@ test("customRulesOnErrorNullSync", (t) => { 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." ); @@ -775,7 +777,8 @@ test("customRulesOnErrorBad", (t) => { }, { "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." ); @@ -845,7 +848,8 @@ test("customRulesOnErrorInvalid", (t) => { }, { "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." ); @@ -1052,7 +1056,8 @@ test("customRulesOnErrorInvalidHandled", (t) => new Promise((resolve) => { "ruleDescription": "description", "ruleInformation": null, "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, "errorRange": null, "fixInfo": null @@ -1093,7 +1098,8 @@ test("customRulesOnErrorInvalidHandledSync", (t) => { "ruleDescription": "description", "ruleInformation": null, "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, "errorRange": null, "fixInfo": null