Search code examples
angulartypescriptvisual-studio-codeprettier

Prettier - new line between function and comment


I would like to know if there's a rule to add a new line between function/statement and comment in typescript with prettier (.prettierrc at the root of the project).

Current behaviour:

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

Desired behaviour:

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

My current .prettierc:

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

Solution

  • No, prettier doesn't have that rule.

    Prettier has a sparse list of options by design, and this isn't one of'm.