gmsorrow / eslint-plugin-modules-newline

Eslint plugin to enforce placing import and export variables on separate lines
25 stars 17 forks source link

Options for newlines, and imported specifiers count #5

Open coderaiser opened 4 years ago

coderaiser commented 4 years ago

Hi, thank you for such a nice plugin :), would be amazing to have ability to transform such code:

const a, {x, y} from 'z'

Into

const a, {
    x,
    y,
} from 'z';

And also to ignore such cases:

const {x} from 'z';
const {x, y} from 'z';

Could you please add options for this :)? It can be something like:

import {x, y, z, a, b, c} from 'alphabet'

For this case, specifiersLengnth count, and it's much readable in one line :). What do you think about it?

Update: implemented in eslint-plugin-putout.

gmsorrow commented 4 years ago

Hello @coderaiser.

Thank you for a good suggestion. I'll allocate some time for implementation later. PRs are welcome =).

anlesk commented 4 years ago

+1 for leaving the default value with the curly on the same line.

Zamiell commented 4 years ago

Thanks so much gmsorrow for the excellent eslint plugin. I too, am greatly desiring the "only warn me if there are 4 or more things on the same import line" option, which I presume is what coderaiser means by "minSpecifiersCount". (This is exactly what the Airbnb style guide prescribes, which is the most popular style guide in the world, if I am not mistaken.)

hieunm22 commented 3 years ago

hi @gmsorrow how is this issue? is it implemented? this issue is also what I want

SeinopSys commented 3 years ago

I've since created eslint-plugin-import-newlines for this to use in my projects.

hieunm22 commented 3 years ago

@SeinopSys, is it possible to apply this rule for export, object destructuring...?

SeinopSys commented 3 years ago

Feel free to open as issue in my repo for it and I'll take a look when I have the time. I find Eslint's plugin documentation extremely lacking to say the least, so I can't make any promises if I'll be able to figure anything else out that my package doesn't already do.

Zamiell commented 3 years ago

For everyone reading this thread, I recommend this, which I have been using for a while and am very happy with: https://github.com/simonhaenisch/prettier-plugin-organize-imports