Repository navigation
Commit 7018480
committed
Fix unstable trailing comment on a parenthesized arrow chain
`x = (a) => ((b) => {} /* comment */)` printed the comment before the
semicolon on the first pass and after it on the second, so the file never
settled.
The parentheses are redundant, so they are dropped. That moves the comment
next to the statement's semicolon, where the next format attaches it to the
ExpressionStatement instead of to the arrow it was written against. The same
thing happens with a nested assignment, which is already handled by attaching
the comment to the statement up front; this extends that to a chain that
passes through arrow bodies.1 parent 0283c88 commit 7018480
3 files changed
Lines changed: 15 additions & 7 deletions
File tree
- src/language-js/comments
- tests
- config/format-test
- format/js/arrows/__snapshots__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1204 | 1204 | | |
1205 | 1205 | | |
1206 | 1206 | | |
1207 | | - | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
1208 | 1211 | | |
1209 | 1212 | | |
1210 | 1213 | | |
| |||
1255 | 1258 | | |
1256 | 1259 | | |
1257 | 1260 | | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
1258 | 1266 | | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
1262 | 1271 | | |
1263 | 1272 | | |
1264 | 1273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
308 | | - | |
| 308 | + | |
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| |||
0 commit comments