Neku80
Neku80

Reputation: 421

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
}

Upvotes: 5

Views: 8989

Answers (2)

A1exandr Belan
A1exandr Belan

Reputation: 4780

But you can achive this behavior with ESLint:

enter image description here

And automaticly fix this issue for example on save in VSCode:

enter image description here

Check this rule for ESLinter. lines-around-comment

ESLinter gives you tonns of benefits.

Upvotes: 1

Cerbrus
Cerbrus

Reputation: 72867

No, prettier doesn't have that rule.

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

Upvotes: 3

Related Questions