Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove single comment by babel

Tags:

babeljs

I want to remove single comment from AST. I have babel plugin where I target a node. This node has some leadingComments. A node would be removed using path.remove() but the comments would remain present. How can I remove also the comment. I don't want to remove all the comments only some particular.

like image 268
Márius Rak Avatar asked Oct 20 '25 01:10

Márius Rak


1 Answers

Quite unintuitively, but Babel.types.removeComments(path.node); does the trick.

like image 178
Márius Rak Avatar answered Oct 22 '25 05:10

Márius Rak