How to prevent Visual Studio Code from pushing chained functions on to new line?

Scr*_*t47 7 javascript code-formatting visual-studio-code

How do I prevent Visual Studio Code from pushing chained JavaScript functions on to a new line as can be seen illustrated by the GIF below:

As you can see, it makes the code extremely hard to view and extends a simple if check in to multiple lines. I am using the extension called Prettier - Code Formatter and I have looked through the preferences and found the following:

// Format a file on save. A formatter must be available, the file must not be 
//auto-saved, and editor must not be shutting down.
"editor.formatOnSave": false
Run Code Online (Sandbox Code Playgroud)

Which stops it formatting completely when you hit save. I have looked through the other options and couldn't find a setting for this.

Does the above process have a name?

How can I retain formatOnSave but prevent it from formatting it in the way that it is?

Scr*_*t47 3

这似乎是不可配置的(不确定是否会配置),这是此问题的 Github 帖子的直接副本:

此功能的建议行为是:

  • 达到行长限制后换行
  • 3 个链式方法后换行
  • 在可配置数量的链接方法之后换行
  • 当满足两个条件之一时换行:
    • 已达到线路长度限制
    • 用户通过手动插入换行符来选择它,就像对象文字一样

最初的实现是(1)。

当前的实现是(2)。

(3) 不太可能发生,因为 prettier 试图避免配置。

由于希望最小化用户输入对 Prettier 输出的影响,所以一致反对 (4)。

我认为当前的实现 (2) 在大多数情况下都是有意义的,但我发现自己经常需要 (4),以至于我不再对 JS 使用 prettier。

基于此,目前没有办法修改此行为,也没有任何计划(截至撰写本文时)。

绝对不是我想要的答案,但这就是给出的答案。