diff --git a/lib/linter/linter.js b/lib/linter/linter.js index 1d021d1e82e7..9783f9d487be 100644 --- a/lib/linter/linter.js +++ b/lib/linter/linter.js @@ -393,7 +393,9 @@ function getDirectiveComments(filename, ast, ruleMapper, warnInlineConfig) { } try { - validator.validateRuleOptions(rule, name, ruleValue); + const cloneRuleValue = lodash.cloneDeep(ruleValue); + + validator.validateRuleOptions(rule, name, cloneRuleValue); } catch (err) { problems.push(createLintingProblem({ ruleId: name, @@ -584,10 +586,17 @@ function stripUnicodeBOM(text) { /** * Get the options for a rule (not including severity), if any * @param {Array|number} ruleConfig rule configuration + * @param {string} ruleId rule id + * @param {Object} rule rule schema * @returns {Array} of rule options, empty Array if none */ -function getRuleOptions(ruleConfig) { +function getRuleOptions(ruleConfig, ruleId = "", rule = {}) { if (Array.isArray(ruleConfig)) { + if (ruleId !== "" && Object.keys(rule) !== 0) { + const cloneRuleValue = lodash.cloneDeep(ruleConfig); + + validator.validateRuleOptions(rule, ruleId, cloneRuleValue); + } return ruleConfig.slice(1); } return []; @@ -892,7 +901,7 @@ function runRules(sourceCode, configuredRules, ruleMapper, parserOptions, parser Object.create(sharedTraversalContext), { id: ruleId, - options: getRuleOptions(configuredRules[ruleId]), + options: getRuleOptions(configuredRules[ruleId], ruleId, ruleMapper(ruleId)), report(...args) { /*