Prettier - 功能和注释之间的新界线

Nek*_*u80 5 typescript visual-studio-code angular prettier

我想知道是否有规则在带有 prettier 的打字稿中的函数/语句和注释之间添加新行(项目根目录下的 .prettierrc )。

当前行为:

 } else if (request.type === 'membership-fee') {
    /**
     * If type is membership fee
     */
    this.form.get('total')?.setValue(this.gym?.membership_fee?.total);
} else {
    /**
     * Operation type not recognized
     */
    this.toast.error('Tipo di operazione non riconosciuto');
    ($('#editSaleModal') as any).modal('hide');
}
Run Code Online (Sandbox Code Playgroud)

期望的行为:

 } else if (request.type === 'membership-fee') {
    
    /**
     * If type is membership fee
     */
    this.form.get('total')?.setValue(this.gym?.membership_fee?.total);
} else {
    
    /**
     * Operation type not recognized
     */
    this.toast.error('Tipo di operazione non riconosciuto');
    ($('#editSaleModal') as any).modal('hide');
}
Run Code Online (Sandbox Code Playgroud)

我当前的 .prettierc:

{
    "useTabs": true,
    "tabWidth": 4,
    "printWidth": 120
}
Run Code Online (Sandbox Code Playgroud)

Cer*_*rus 3

不,Prettier 没有这个规则。

Prettier 在设计上有一个稀疏的选项列表,而这不是其中之一。

  • 所以我别无选择,只能看到每次我用 vscode“格式化文档”时我的新行消失? (2认同)