angular - Prettier - 功能和评论之间的新线

标签 angular typescript visual-studio-code prettier

我想知道是否有一条规则可以在 typescript 中使用 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');
}

期望的行为:

 } 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');
}

我当前的 .prettierc:

{
    "useTabs": true,
    "tabWidth": 4,
    "printWidth": 120
}

最佳答案

不,prettier 没有这个规则。

Prettier 有一个稀疏的 list of options by design ,这不是其中之一。

关于angular - Prettier - 功能和评论之间的新线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69705929/

相关文章:

flutter - 如何从已创建的移动应用程序中为 web flutter 添加 web 文件夹

typescript - 如何添加自定义类型定义?

Angular 设置颜色取决于 true 或 false

javascript - 覆盖 app.get ('*' , func) 中的路由

angular - 试图了解 CanActivate 和 CanActivateChild 之间的区别

typescript - Angular2 没有服务错误的提供者

typescript - 如何解决 "Failed to load config "airbnb-typescript"to extend from."on Google Cloud Build?

javascript - 加载时如何更新 Angular2.RC1 子组件?

angularjs - TypeScript/angularJS HTTP GET 请求中的范围

visual-studio-code - Visual Studio Code 中的多行正则表达式搜索