Skip to content

Commit

Permalink
tools: fix bug in prefer-primordials lint rule
Browse files Browse the repository at this point in the history
PR-URL: #46659
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
aduh95 authored and MylesBorins committed Feb 20, 2023
1 parent b4deb2f commit 1cd22e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test/parallel/test-eslint-prefer-primordials.js
Expand Up @@ -57,7 +57,9 @@ new RuleTester({
{
code: `
const { ObjectDefineProperty, Symbol } = primordials;
ObjectDefineProperty(o, Symbol.toStringTag, { value: "o" })
ObjectDefineProperty(o, Symbol.toStringTag, { value: "o" });
const val = Symbol.toStringTag;
const { toStringTag } = Symbol;
`,
options: [{ name: 'Symbol', ignore: ['toStringTag'] }]
},
Expand Down
2 changes: 1 addition & 1 deletion tools/eslint-rules/prefer-primordials.js
Expand Up @@ -114,7 +114,7 @@ module.exports = {
node,
);
const parentName = parent?.name;
if (!isTarget(nameMap, name) && !isTarget(nameMap, parentName)) {
if (!isTarget(nameMap, name) && (!isTarget(nameMap, parentName) || isIgnored(nameMap, parentName, name))) {
return;
}

Expand Down

0 comments on commit 1cd22e7

Please sign in to comment.