Skip to content

Commit

Permalink
fix(eslint-plugin): unbound-method false positive when comparing to null
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk committed Aug 28, 2019
1 parent 344bafe commit 9bfa9fc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/eslint-plugin/src/rules/unbound-method.ts
Expand Up @@ -106,6 +106,7 @@ function isSafeUse(node: TSESTree.Node): boolean {
case AST_NODE_TYPES.SwitchStatement:
case AST_NODE_TYPES.UpdateExpression:
case AST_NODE_TYPES.WhileStatement:
case AST_NODE_TYPES.BinaryExpression:
return true;

case AST_NODE_TYPES.CallExpression:
Expand Down
12 changes: 12 additions & 0 deletions packages/eslint-plugin/tests/rules/unbound-method.test.ts
Expand Up @@ -52,15 +52,27 @@ instance.unbound\`\`;
if (instance.bound) { }
if (instance.unbound) { }
if (instance.bound !== undefined) { }
if (instance.unbound !== undefined) { }
if (ContainsMethods.boundStatic) { }
if (ContainsMethods.unboundStatic) { }
if (ContainsMethods.boundStatic !== undefined) { }
if (ContainsMethods.unboundStatic !== undefined) { }
while (instance.bound) { }
while (instance.unbound) { }
while (instance.bound !== undefined) { }
while (instance.unbound !== undefined) { }
while (ContainsMethods.boundStatic) { }
while (ContainsMethods.unboundStatic) { }
while (ContainsMethods.boundStatic !== undefined) { }
while (ContainsMethods.unboundStatic !== undefined) { }
instance.bound as any;
ContainsMethods.boundStatic as any;
Expand Down

0 comments on commit 9bfa9fc

Please sign in to comment.