Home > front end >  Prettier - new line between function and comment
Prettier - new line between function and comment

Time:10-25

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
}

CodePudding user response:

No, prettier doesn't have that rule.

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

  • Related