Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JsFormat rule for newline in es6 imports

JsFormat for Sublime Text 3 conforms to most ES6 standards, however, when auto-formatting import statements, it adds a new line to object imports. Here is what the pre-formatted line looks like:

import {func1, func2, func3} from 'some-module';

When auto-formatting, it turns into:

import {
    func1, func2, func3
}
from 'some-module';

Is there a way to disable this kind of formatting?

like image 367
ZekeDroid Avatar asked Nov 17 '15 19:11

ZekeDroid


2 Answers

According to the Github repo, JsFormat uses js-beautify to do the formatting. That project has an open issue where folks complain about various formatting issues, one of them being this very thing. There's a mildly long comment thread which ends in "Pull requests welcome", so unfortunately it looks like there is currently no way to disable this kind of formatting.

like image 118
Ryan Kennedy Avatar answered Nov 16 '22 03:11

Ryan Kennedy


On http://jsbeautifier.org/, there is check box to enable this setting: "Preserve inline braces/code blocks".

enter image description here

This feature was added in recent version for the beautifier as the preserve-inline option for brace-style. This will keep inline (all on the same line) brace blocks unchanged. It works as a modifier for the base setting (for example, brace-style: "collapse,preserve-inline").

like image 22
BitwiseMan Avatar answered Nov 16 '22 04:11

BitwiseMan