8000 Fix: no-new-symbol false positive with Symbol as an argument (#13337) · eslint/eslint@1710296 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1710296

Browse files
authored
Fix: no-new-symbol false positive with Symbol as an argument (#13337)
1 parent cc01451 commit 1710296

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/rules/no-new-symbol.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ module.exports = {
3737
if (variable && variable.defs.length === 0) {
3838
variable.references.forEach(ref => {
3939
const node = ref.identifier;
40+
const parent = node.parent;
4041

41-
if (node.parent && node.parent.type === "NewExpression") {
42+
if (parent && parent.type === "NewExpression" && parent.callee === node) {
4243
context.report({
4344
node,
4445
messageId: "noNewSymbol"

tests/lib/rules/no-new-symbol.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ ruleTester.run("no-new-symbol", rule, {
2222
valid: [
2323
"var foo = Symbol('foo');",
2424
"function bar(Symbol) { var baz = new Symbol('baz');}",
25-
"function Symbol() {} new Symbol();"
25+
"function Symbol() {} new Symbol();",
26+
"new foo(Symbol);",
27+
"new foo(bar, Symbol);"
2628
],
2729
invalid: [
2830
{

0 commit comments

Comments
 (0)
0