RunJS icon indicating copy to clipboard operation
RunJS copied to clipboard

Bug - `Pretty` code formatting bug

Open shahul01 opened this issue 3 years ago • 2 comments

This Code on formatting with alt + shift + f ,


let arr = [1,2,3];


arr.indexOf(1)

let cplxArr = [
  {id: 1},
  {id: 2},
  {id: 3}
];

cplxArr.findIndex(el => el.id === 1);

produces the following which is wrong.


let arr = [1, 2, 3];

arr.indexOf(1);
arr.indexOf(1)
let cplxArr = [{ id: 1 }, { id: 2 }, { id: 3 }];
let cplxArr = [
cplxArr.findIndex((el) => el.id === 1);

using v 2.2.2.0

shahul01 avatar Jan 28 '22 19:01 shahul01

Thanks @shahul01. I'm able to see the issue. It seems to be caused by the line arr.indexOf(1) not having a semi-colon.

This functionality is handled by Prettier: https://prettier.io/ I'll take a look and see if this is a known issue there.

lukehaas avatar Jan 31 '22 10:01 lukehaas

Yeah Its the semicolon, classic.

shahul01 avatar Jan 31 '22 14:01 shahul01

Resolved in the latest release.

lukehaas avatar Mar 13 '23 16:03 lukehaas