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

Function VariableDeclarator

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

* @param {CompilerNode} node

(node)

Source from the content-addressed store, hash-verified

138 * @param {CompilerNode} node
139 */
140 VariableDeclarator(node) {
141 if (!shouldBeDestructure(node)) {
142 return;
143 }
144
145 const {init} = node;
146 if (context.getCommentsInside(node).length > 0) {
147 return;
148 }
149
150 context.report({
151 node,
152 message: 'Use object destructuring',
153 fix(fixer) {
154 const sourceCode = context.getSourceCode();
155 const {object, property} = init;
156 const {name} = property;
157 const base = sourceCode.getText(object);
158 return fixer.replaceText(node, `{${name}} = ${base}`);
159 },
160 });
161 },
162
163 /**
164 * @param {CompilerNode} node

Callers

nothing calls this directly

Calls 2

shouldBeDestructureFunction · 0.85
reportMethod · 0.45

Tested by

no test coverage detected