Bug: extra line break inserted when printing a node
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 363
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 3
Description
I have this code:
```
{
timeseries: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.number,
timestamp: PropTypes.number
})),
trendChangePercentage: PropTypes.number
};
```
I'm, trying to reprint it with recast (after parsing it with babel 7).
`recast.print(node, {"lineTerminator":"\n","tabWidth":2,"useTabs":false}).code`
but it gives me this:
```
{
timeseries: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.number,
timestamp: PropTypes.number
})),
trendChangePercentage: PropTypes.number
};
```
----
It seems that [it's happening on purpose](https://github.com/benjamn/recast/blob/da0018b3280146d874a347217f1fbc03bc32f7f3/lib/printer.js#L684).
```javascript
// Add an extra line break if the previous object property
// had a multi-line value.
parts.push(separator + (multiLine ? "\n\n" : "\n"));
```
Why would you do that?
Recast is not supposed to mess with my code, so this is a bug.
Contributor guide
No contributing guide indexed for this repository
Research direction
The extra separator is in lib/printer.js around line 684; first reproduce the Babel 7 parse and recast.print call shown in the issue. Verify the printer no longer emits a blank line between the two object properties.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100