_From @ssi-hu-tasi-norbert on April 20, 2018 9:9_
Sort should be optional. I have imports from 3rd parties above and app imports below and I don't want to mix them. With a separator( for me it is a comment // app) these two sections can be sort separatedly.
Anyway, this is a great feature.
Thanks,
Norbert
_Copied from original issue: Microsoft/vscode#48263_
We should already be sorting global imports in front of local imports, i.e.:
import * as z from "zexternal";
import * as a from "./alpha";
is preserved. We also order things from higher directories (../zexternal) over local ones. So as long as your 3rd party libraries are in node_modules or in some upper directory like ../include, sorting should leave them at the top.
In angular for locals I can use absolute path and with paths specs I can use abbreviations and from 6.x.x I can create libraries nested. So the followings are local imports:
import { Service } from 'app/shared/service'; // absolute path
import { Comp } from'@shared/test.component';// custom path for'@shared'defined in tsconfig
import {UIModule} from 'projects/ui'; // own library import
So the sorting should check if the library is under node_modules(higher) or not(lower).
Thanks,
tano
seems to be the same underlying suggestion as in https://github.com/Microsoft/TypeScript/issues/22926, to use the target of the import instead of the text of the import to sort.
Sorting on _Organize imports_ has conflicting behavior with _Auto Import_, which is adding the import at the bottom of the list: this is causing unnecessary merging conflicts and line changes.
Not only we should be able to enable/disable sorting, but also:
when enabled => _Auto Import_ should insert the new import in the correct sorted position (should sort automatically if not sorted);
when disabled => _Auto Import_ should append the new import at the bottom of the imports list.
This has been pending for 15 months. What else is needed to move it forward?
Most helpful comment
Sorting on _Organize imports_ has conflicting behavior with _Auto Import_, which is adding the import at the bottom of the list: this is causing unnecessary merging conflicts and line changes.
Not only we should be able to enable/disable sorting, but also:
when enabled => _Auto Import_ should insert the new import in the correct sorted position (should sort automatically if not sorted);
when disabled => _Auto Import_ should append the new import at the bottom of the imports list.
This has been pending for 15 months. What else is needed to move it forward?