* @param {CompilerNode} node * @param {boolean=} renamable * @return {boolean}
(node, renamable = false)
| 19 | * @return {boolean} |
| 20 | */ |
| 21 | function shouldBeDestructure(node, renamable = false) { |
| 22 | const {id, init} = node; |
| 23 | |
| 24 | if ( |
| 25 | !init || |
| 26 | id.type !== 'Identifier' || |
| 27 | init.type !== 'MemberExpression' |
| 28 | ) { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | const {name} = id; |
| 33 | const {computed, object, property} = init; |
| 34 | if ( |
| 35 | computed || |
| 36 | object.type === 'Super' || |
| 37 | context.getCommentsBefore(property).length > 0 || |
| 38 | property.type !== 'Identifier' |
| 39 | ) { |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | return renamable || property.name === name; |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * @param {CompilerNode} node |
no outgoing calls
no test coverage detected