Skip to content

Commit

Permalink
refactor: code
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Dec 12, 2021
1 parent edb4d2b commit 52e5491
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rules/id-match.js
Expand Up @@ -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;
}

Expand Down

0 comments on commit 52e5491

Please sign in to comment.