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

Function fix

build-system/eslint-rules/prefer-destructuring.js:109–132  ·  view source on GitHub ↗
(fixer)

Source from the content-addressed store, hash-verified

107 node,
108 message: 'Combine repeated declarators into a destructure',
109 fix(fixer) {
110 const fixes = [];
111 const ids = [];
112
113 names.forEach((name) => ids.push(name));
114 const replacement = `{${ids.join(', ')}} = ${base}`;
115 fixes.push(fixer.replaceText(node, replacement));
116
117 declarations.forEach((declaration) => {
118 const {declarations} = declaration;
119 const all = declarations.every((decl) => nodes.has(decl));
120 if (!all) {
121 return;
122 }
123
124 fixes.push(fixer.remove(declaration));
125 declarations.forEach((decl) => nodes.delete(decl));
126 });
127
128 nodes.forEach((node) => {
129 fixes.push(fixer.remove(node));
130 });
131 return fixes;
132 },
133 });
134 }
135

Callers

nothing calls this directly

Calls 5

forEachMethod · 0.45
pushMethod · 0.45
hasMethod · 0.45
removeMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected