Ramon Balthazar
Ramon Balthazar

Reputation: 4290

How to set up formatting to remove newlines between imports?

Given a code like this

import foo from 'foo';

import bar from 'bar';

Does anyone know a way of configuring either Prettier or ESLint to remove the space between imports with auto-formatting?

Thank you

Upvotes: 0

Views: 40

Answers (2)

Ramon Balthazar
Ramon Balthazar

Reputation: 4290

The eslint-plugin-import package supports this.

The rule import/order has an option newlines-between: 'never' that achieves just that!

Upvotes: 0

Lastik
Lastik

Reputation: 981

Unfortunately, there is no ready to use plugin to achieve it. But it still might be done by using custom-made eslint plugin.

Please, have a look at eslint-plugin-import plugin, it's new-line-after-import rule (see this link). This rule only supports new line addition (lines count > 0). But you might just create your own plugin. It's totally achievable by using this plugin's source code as a starting point.

Upvotes: 0

Related Questions