Snapshot custom rule definitions to prevent them from changing dynamically.

This commit is contained in:
David Anson 2023-07-11 22:17:53 -07:00
parent c699b8e22b
commit 14a7529ce7
3 changed files with 54 additions and 2 deletions

View file

@ -2628,8 +2628,11 @@ function lintInput(options, synchronous, callback) {
// Normalize inputs
options = options || {};
callback = callback || function noop() {};
var customRuleList = [options.customRules || []].flat().map(function (rule) {
return _objectSpread({}, rule);
});
// eslint-disable-next-line unicorn/prefer-spread
var ruleList = rules.concat(options.customRules || []);
var ruleList = rules.concat(customRuleList);
var ruleErr = validateRuleList(ruleList, synchronous);
if (ruleErr) {
callback(ruleErr);