Closed Plondrein closed 7 years ago
Would you be able to provide an example here. Particularly what you have before sorting, and what result you would expect to have after ?
Sorry i had to use external site, code pasted here doesn't show what i mean.
i got: https://bpaste.net/show/b3c842970d16 After i perform 'Sort Imports' it becomes https://bpaste.net/show/3d3352ce45d8
and leaves missing comma at the end of the line. I'd love to have it automatically appended.
Correct me if I am wrong: Given:
import { Component, Input, OnChanges, ChangeDetectionStrategy, SimpleChanges, OnDestroy, Output, DebugElement } from '@angular/core';
The output after sorting with "importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.count": 105:
and
"importSorter.importStringConfiguration.tabSize": 4,
is
import {
ChangeDetectionStrategy, Component, DebugElement, Input, OnChanges, OnDestroy, Output, SimpleChanges
} from '@angular/core';
and you would expect to have the following
import {
ChangeDetectionStrategy, Component, DebugElement, Input, OnChanges, OnDestroy, Output, SimpleChanges,
} from '@angular/core';
which would add an extra comma at the end. Sure it can be done. I will call a new setting as importSorter.importStringConfiguration.hasMultiLineTrailingComma
with the default being false. I will try to add this somehow this week.
Exactly! It would be super cool to see this live :)
Added importSorter.importStringConfiguration.trailingComma
setting. This setting can have always
, multiLine
, or none
values. If you need a trailing comma only for multiple lines then use multiLine
, otherwise you can use always
. I have also added reading settings from the file so that it can be shared between a team and committed to the source control if needed. See read-me for this, if interested.
that's great to hear! Will it be possible to update import-sorter directly from vs code?
That is definitely possible. I have already bumped the version of the plugin. Depending on version of vscode, you should be able to open installed extensions and press update (if it is not done automatically). The plugin page is https://marketplace.visualstudio.com/items?itemName=mike-co.import-sorter.
I got it! It works just as i dreamed! Thanks 👍
When line is too long, it is automatically cut and it's great but is it possible to add also trailing commas?