| 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 | |