MCPcopy
hub / github.com/ampproject/amphtml / shouldBeDestructure

Function shouldBeDestructure

build-system/eslint-rules/prefer-destructuring.js:21–44  ·  view source on GitHub ↗

* @param {CompilerNode} node * @param {boolean=} renamable * @return {boolean}

(node, renamable = false)

Source from the content-addressed store, hash-verified

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

Callers 2

VariableDeclaratorFunction · 0.85
createFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected