Harden code to snapshot rule definitions against mutation, add comments to some helper functions.

This commit is contained in:
David Anson 2023-07-12 21:58:36 -07:00
parent 8fe7c109ed
commit 9897863130
4 changed files with 154 additions and 36 deletions

View file

@ -872,7 +872,14 @@ function lintInput(options, synchronous, callback) {
const customRuleList =
[ options.customRules || [] ]
.flat()
.map((rule) => ({ ...rule }));
.map((rule) => ({
"names": helpers.cloneIfArray(rule.names),
"description": rule.description,
"information": helpers.cloneIfUrl(rule.information),
"tags": helpers.cloneIfArray(rule.tags),
"asynchronous": rule.asynchronous,
"function": rule.function
}));
// eslint-disable-next-line unicorn/prefer-spread
const ruleList = rules.concat(customRuleList);
const ruleErr = validateRuleList(ruleList, synchronous);