* @param {EslintContext} context * @return {{ * VariableDeclarator: {Function(node: CompilerNode): void}, * 'BlockStatement, Program': {Function (node: CompilerNode): void}, * }}
(context)
| 13 | * }} |
| 14 | */ |
| 15 | create(context) { |
| 16 | /** |
| 17 | * @param {CompilerNode} node |
| 18 | * @param {boolean=} renamable |
| 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 |
| 48 | * @return {boolean} |
| 49 | */ |
| 50 | function shouldBeIdempotent(node) { |
| 51 | while (node.type === 'MemberExpression') { |
| 52 | node = node.object; |
| 53 | } |
| 54 | |
| 55 | return node.type === 'Identifier' || node.type === 'ThisExpression'; |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * |
| 60 | * @param {Map<K, V>} map |
| 61 | * @param {K} key |
| 62 | * @param {CompilerNode} node |
| 63 | * @param {*} declaration |
| 64 | * @return {string[]} |
| 65 | */ |
| 66 | function setStruct(map, key, node, declaration) { |
| 67 | if (map.has(key)) { |
| 68 | const struct = map.get(key); |
| 69 | struct.nodes.add(node); |
| 70 | struct.declarations.add(declaration); |
| 71 | return map.get(key).names; |
| 72 | } else { |
nothing calls this directly
no test coverage detected