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

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