(ops, first, last)
| 37 | |
| 38 | // Generate the optional chaining expression |
| 39 | function generateOptionalChaining(ops, first, last) { |
| 40 | return ops.slice(first, last + 1).reduce((chain, node, i) => { |
| 41 | const property = node.computed ? |
| 42 | `[${sourceCode.getText(node.property)}]` : |
| 43 | sourceCode.getText(node.property); |
| 44 | return i === 0 ? sourceCode.getText(node) : `${chain}?.${property}`; |
| 45 | }, ''); |
| 46 | } |
| 47 | |
| 48 | return { |
| 49 | 'LogicalExpression[operator=&&]:exit'(node) { |