diff --git a/lib/rules/id-match.js b/lib/rules/id-match.js index 1f2d9903f37..ed3cdfdd692 100644 --- a/lib/rules/id-match.js +++ b/lib/rules/id-match.js @@ -83,20 +83,20 @@ module.exports = { const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]); const DECLARATION_TYPES = new Set(["FunctionDeclaration", "VariableDeclarator"]); const IMPORT_TYPES = new Set(["ImportSpecifier", "ImportNamespaceSpecifier", "ImportDefaultSpecifier"]); + const BUILT_IN_REFERENCES = new Set(Object.keys(globals.builtin)); /** - * Checks if a string matches the provided pattern + * Checks if a string matches the provided pattern and is not a global built-in reference * @param {string} name The string to check. * @returns {boolean} if the string is a match * @private */ function isInvalid(name) { - const builtInReferences = new Set(Object.keys(globals.builtin)); const scope = context.getScope(); const variable = astUtils.getVariableByName(scope, name); - // Do not report global and built-in references - if (variable && variable.scope.type === "global" && builtInReferences.has(name)) { + // Do not report global built-in references + if (variable && variable.scope.type === "global" && BUILT_IN_REFERENCES.has(name)) { return false; }