Skip to content

Commit

Permalink
Fix: no-new-symbol false positive with Symbol as an argument (#13337)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic committed May 22, 2020
1 parent cc01451 commit 1710296
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/rules/no-new-symbol.js
Expand Up @@ -37,8 +37,9 @@ module.exports = {
if (variable && variable.defs.length === 0) {
variable.references.forEach(ref => {
const node = ref.identifier;
const parent = node.parent;

if (node.parent && node.parent.type === "NewExpression") {
if (parent && parent.type === "NewExpression" && parent.callee === node) {
context.report({
node,
messageId: "noNewSymbol"
Expand Down
4 changes: 3 additions & 1 deletion tests/lib/rules/no-new-symbol.js
Expand Up @@ -22,7 +22,9 @@ ruleTester.run("no-new-symbol", rule, {
valid: [
"var foo = Symbol('foo');",
"function bar(Symbol) { var baz = new Symbol('baz');}",
"function Symbol() {} new Symbol();"
"function Symbol() {} new Symbol();",
"new foo(Symbol);",
"new foo(bar, Symbol);"
],
invalid: [
{
Expand Down

0 comments on commit 1710296

Please sign in to comment.