amatiasq / vsc-sort-imports

Sort ES6 imports automatically.
ISC License
58 stars 24 forks source link

Add options to allow format of multiple imports from a module #3

Closed rfgamaral closed 6 years ago

rfgamaral commented 6 years ago

I really like this extension but it's missing one tiny thing from point of view. We need options to allow one to pick the format one wants for multiple imports from a module. For instance:

import {a, b, c} from 'module';

import { a, b, c } from 'module';

import {
    a,
    b,
    c
} from 'module';

Spaces or no spaces between multiple imports is also another option that should be available.

Basically, adding some formatting options to this "sorting" plugin.

Just a suggestion :)

amatiasq commented 6 years ago

Agree 100%, the tricky part is that the sorting itself is not done by this library but by it's dependency import-sort. I'm not sure if there is a way to configure that.

In any case it's sure a good feature to have, please feel free to open a PR if you find a way :)

cliffkoh commented 6 years ago

@rfgamaral The underlying import-sort module allows you to toggle these by declaring it as a style. You should then make use of the "package.json" method (or any way supported by import-sort-config) to load the style you want to be used by the extension... in theory.

amatiasq commented 6 years ago

Thanks @cliffkoh for the solution.

rfgamaral commented 6 years ago

@cliffkoh I other words, I just need to properly configure my own style configuration and this plugin will automatically read that without any issues?

cliffkoh commented 6 years ago

@rfgamaral Yes. I have tested and verified this method does work :)