我想知道是否有一条规则可以在 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/