Berry
Berry

Reputation: 2308

Set prettier blank lines after import?

I like to keep my imports like this:

import { ValidationError } from "../errors/validation.error";
// Blank
// Blank
function doSomething() {


}

With two blank lines after the imports. Prettier formats the JS with only one blank line after the imports. How do I set it to as much blank lines as I want?

Upvotes: 8

Views: 7899

Answers (1)

GollyJer
GollyJer

Reputation: 26732

If you happen to be using ESLint in conjunction with Prettier...

  1. yarn add eslint-plugin-import --dev 👉 here

  2. Add this to your .eslintrc.js
    import/newline-after-import": ["error", { "count": 2 }] 👉 here

  3. Profit 💰💰💰

If you happen to be using the eslint settings for AirBnB Style Guide then just do #2 and you're done!

Upvotes: 8

Related Questions