From 665b7424ebe719ec569d61d81c35d30851f8299e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 17 Feb 2023 19:29:42 +0100 Subject: [PATCH] tools: fix bug in `prefer-primordials` lint rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/46659 Reviewed-By: Ruben Bridgewater Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig --- 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; }