From 910d54236a9309dc8baaaf69a9495aa18ec93ef8 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 14 Feb 2023 23:03:01 +0100 Subject: [PATCH] tools: fix bug in `prefer-primordials` lint rule --- test/parallel/test-eslint-prefer-primordials.js | 4 +++- tools/eslint-rules/prefer-primordials.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-eslint-prefer-primordials.js b/test/parallel/test-eslint-prefer-primordials.js index 30c8cd25355c5a..ba44e88cf9c4ec 100644 --- a/test/parallel/test-eslint-prefer-primordials.js +++ b/test/parallel/test-eslint-prefer-primordials.js @@ -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'] }] }, diff --git a/tools/eslint-rules/prefer-primordials.js b/tools/eslint-rules/prefer-primordials.js index 9afdfa41c00ac9..f8f5cb60c36a63 100644 --- a/tools/eslint-rules/prefer-primordials.js +++ b/tools/eslint-rules/prefer-primordials.js @@ -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; }