How to disable reformat for JS empty bracket ?
Hi, is is possible to keep empty JS object in a single lline ?
I have:
showModal: () => {},
After format:
showModal: () => {
},
Is there an option to NOT reformat in such case ?
Thank you
Please sign in to leave a comment.
Try enabling Keep when reformatting | Simple methods in one line in Settings | Editor | Code Style | JavaScript | Wrapping and Braces - does it help?
The problem with your option is that this line below is not formatted anymore:
I think this would be acceptable only for one property key, but not more.
can't reproduce - similar code doesn't seem to be affected by Simple methods in one line option. Props are wrapped if the Objects wrapping is configured in Settings | Editor | Code Style | JavaScript | Wrapping and Braces
Ok you are right, but I don't really understand. Now, whatever the option you mention is enabled or not the code below does not change when formatted.
I have the same behaviour in JSON, JS, and JSX, that is very strange. Yesterday, the shortcut "ctrl + alt +l" has added me a break line at an empty bracket expression, maybe it was not this exact situation, I am not sure anymore.
My problem is solved then, but as we are here, do you think we could configure Intellij to format the code like that :
Thank you
Setting Objects to Wrap Always in in Settings | Editor | Code Style | JavaScript | Wrapping and Braces should do the thing...
Objects > Wrap always and Keep when reformatting > Simple methods in one line give "almost" what I wanted but the result makes sense, I will keep that behaviour :)
Thank you !!
is formatted as:
I was looking for the same thing in Java.