substack/node-falafel — pull request #25 by nanodeath (2013-10-12 15:55:40+00:00)
Title: Adding a "remove" API for nodes which cleans up the parent node as well upon deletion

I'm open to how exactly you want to see this implemented. I'm calling in "remove" instead of "delete" because while delete might work, it's also a reserved word.

Originally, I was modifying the parent by checking particular fields:

if(node.parent && (params = /* FunctionExpression */ node.parent.params || /*VariableDeclaration */
node.parent.declarations || /* ArrayExpression*/ node.parent.elements)){`

But ultimately I generalized it to simply remove the element from all collection-y fields on the parent.

Also I have a plugin that removes trailing whitespace; I can try to revert that from the index.js file if you prefer. Beside this, I tried to match your style.