Comment by xixixao

2 days ago

Should be easy with any standard parser. See astexplorer.net

I've been using Esprima and it's not trivial to get rid of, or collect all comments with it. The reason is that while it finds the ranges of all syntactic JavaScript elements, it does not consider comment to be a syntactic element, but just something between them.