Skip to content

Commit

Permalink
take optional chains into account when locating the left-most item in…
Browse files Browse the repository at this point in the history
… an expression. (close #1256)
  • Loading branch information
fabiosantoscode committed Oct 5, 2022
1 parent 350f965 commit bb2e20f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/utils/first_in_statement.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
AST_Binary,
AST_Conditional,
AST_Chain,
AST_Dot,
AST_Object,
AST_Sequence,
Expand All @@ -23,6 +24,7 @@ function first_in_statement(stack) {
(p instanceof AST_PrefixedTemplateString && p.prefix === node) ||
(p instanceof AST_Dot && p.expression === node) ||
(p instanceof AST_Sub && p.expression === node) ||
(p instanceof AST_Chain && p.expression === node) ||
(p instanceof AST_Conditional && p.condition === node) ||
(p instanceof AST_Binary && p.left === node) ||
(p instanceof AST_UnaryPostfix && p.expression === node)
Expand All @@ -41,6 +43,7 @@ function left_is_object(node) {
if (node.TYPE === "Call") return left_is_object(node.expression);
if (node instanceof AST_PrefixedTemplateString) return left_is_object(node.prefix);
if (node instanceof AST_Dot || node instanceof AST_Sub) return left_is_object(node.expression);
if (node instanceof AST_Chain) return left_is_object(node.expression);
if (node instanceof AST_Conditional) return left_is_object(node.condition);
if (node instanceof AST_Binary) return left_is_object(node.left);
if (node instanceof AST_UnaryPostfix) return left_is_object(node.expression);
Expand Down

0 comments on commit bb2e20f

Please sign in to comment.