Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: Fix: throw an error when disable a non-existent rule (fixes #9505) #10166

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/config/config-validator.js
Expand Up @@ -104,7 +104,7 @@ function validateRuleSchema(rule, localOptions) {
*/
function validateRuleOptions(rule, ruleId, options, source) {
if (!rule) {
return;
throw new Error(`Definition for rule '${ruleId}' was not found.`);
}
try {
const severity = validateRuleSeverity(options);
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/config/config-validator.js
Expand Up @@ -306,6 +306,12 @@ describe("Validator", () => {
assert.doesNotThrow(fn);
});

it("should throw an error when the rule does not exist", () => {
const fn = validator.validate.bind(null, { rules: { "non-exsistent-rule": "off" } }, "tests", ruleMapper, linter.environments);

assert.throws(fn, "Definition for rule 'non-exsistent-rule' was not found.");
});

it("should do nothing with an invalid config when severity is an array with 'off'", () => {
const fn = validator.validate.bind(null, { rules: { "mock-required-options-rule": ["off"] } }, "tests", ruleMapper, linter.environments);

Expand Down