JsFormat rule for newline in es6 imports

北城余情 提交于 2019-12-04 03:15:36

问题


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?


回答1:


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.




回答2:


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

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").



来源:https://stackoverflow.com/questions/33765418/jsformat-rule-for-newline-in-es6-imports

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!