@@ -117,30 +117,32 @@ impl Rule for NoMultiAssign {
117117 }
118118
119119 fn run < ' a > ( & self , node : & AstNode < ' a > , ctx : & LintContext < ' a > ) {
120- // e.g. `var a = b = c;`
121- if let AstKind :: VariableDeclarator ( declarator) = node. kind ( ) {
122- let Some ( Expression :: AssignmentExpression ( assign_expr) ) = & declarator. init else {
123- return ;
124- } ;
125- ctx. diagnostic ( no_multi_assign_diagnostic ( assign_expr. span ) ) ;
126- }
127-
128- // e.g. `class A { a = b = 1; }`
129- if let AstKind :: PropertyDefinition ( prop_def) = node. kind ( ) {
130- let Some ( Expression :: AssignmentExpression ( assign_expr) ) = & prop_def. value else {
131- return ;
132- } ;
133- ctx. diagnostic ( no_multi_assign_diagnostic ( assign_expr. span ) ) ;
134- }
135-
136- // e.g. `let a; let b; a = b = 1;`
137- if !self . ignore_non_declaration
138- && let AstKind :: AssignmentExpression ( parent_expr) = node. kind ( )
139- {
140- let Expression :: AssignmentExpression ( expr) = & parent_expr. right else {
141- return ;
142- } ;
143- ctx. diagnostic ( no_multi_assign_diagnostic ( expr. span ) ) ;
120+ match node. kind ( ) {
121+ // e.g. `var a = b = c;`
122+ AstKind :: VariableDeclarator ( declarator) => {
123+ let Some ( Expression :: AssignmentExpression ( assign_expr) ) = & declarator. init else {
124+ return ;
125+ } ;
126+ ctx. diagnostic ( no_multi_assign_diagnostic ( assign_expr. span ) ) ;
127+ }
128+ // e.g. `class A { a = b = 1; }`
129+ AstKind :: PropertyDefinition ( prop_def) => {
130+ let Some ( Expression :: AssignmentExpression ( assign_expr) ) = & prop_def. value else {
131+ return ;
132+ } ;
133+ ctx. diagnostic ( no_multi_assign_diagnostic ( assign_expr. span ) ) ;
134+ }
135+ // e.g. `let a; let b; a = b = 1;`
136+ AstKind :: AssignmentExpression ( parent_expr) => {
137+ if self . ignore_non_declaration {
138+ return ;
139+ }
140+ let Expression :: AssignmentExpression ( expr) = & parent_expr. right else {
141+ return ;
142+ } ;
143+ ctx. diagnostic ( no_multi_assign_diagnostic ( expr. span ) ) ;
144+ }
145+ _ => { }
144146 }
145147 }
146148}
0 commit comments