facebook / facebook/jscodeshift

Is there proper way to remove all comments?

Open
#293 4 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
JavaScript
Stars
10k
Forks
498
PR merge metrics
No merged PRs in 30d

Description

Now I have to iterate comment nodes and modify values, but comment's signature is staying untouched.
In:
```
// leading_comment
const definition = 'string'
/* block_comment */
```

Modification:

```
const j = api.jscodeshift
const root = j(file.source)

root.find(j.Comment).forEach(comment => (comment.value.value = ''))
```

Out:

```
//
const definition = 'string'
/**/
```

Expected:

```
const definition = 'string'
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.