TypeScript Version: 3.0.0-dev.20180620
vscode Version: 1.24.0 (6a6e02cef0f2122ee1469765b704faf5d0e0d859 2018-06-06T17:37:01.579Z)
OS Version: Ubuntu 16.04 LTS
Search Terms: organise organize imports tslint
Code
import { foo, _bar } from 'baz';
Expected behavior: tslint expects the imports to have _ before alphabetic characters, so Organize Imports should sort it to import { _bar, foo }
Actual behavior: It sorts it to import { foo, _bar }, which causes a tslint error.
A PR would be appreciated.
I can try my hands on this one, if no one else is working on it!
It looks like the issue is just using toUpperCase vs. tslint using toLowerCase, but given this
/* ...
*
* Case-insensitive comparisons compare both strings one code-point at a time using the integer
* value of each code-point after applying `toUpperCase` to each string. We always map both
* strings to their upper-case form as some unicode characters do not properly round-trip to
* lowercase (such as `谩潞啪` (German sharp capital s)).
*/
in core.ts:1698, should tslint be changed instead?
I would agree that changing the core.ts file in a stable sort function will not be a good idea. May be exploring the possibility of a change in tslint is the way to go.
I've raised an issue with TSLint https://github.com/palantir/tslint/issues/4063 and submitted a pull request there https://github.com/palantir/tslint/pull/4064, so let's see what they think about fixing this on their end.
Hi,
I'm new to open-source, can I solve this issue as it is still open?
Thanks
I believe that this is being looked into from tslint side of things.
Ohh, okay.
Thanks @Shobhit1
Thanks for the reminder. There was a request on my PR, I've addressed that now and updated the PR. (Personally I just forked the TSLint rule but it would be nicer to get this merged into master.)
Is this taken care of or should someone (maybe I can ? since it looks like it's tagged 'good first issue') take the lead on this ?
I'm constantly having this problem on an angular project where the MAT_DIALOG_DATA imports are always misplaced.
I think we decided it would be better to address this on the TSLint end but my PR there is waiting a major release despite having a backwards compatibility flag. I鈥檇 try bumping there myself. That said TSLint isn鈥檛 getting much love recently so I should get back to my PR on ESLint and address the issues that they had so it can be merged https://github.com/typescript-eslint/typescript-eslint/pull/256
Is anybody working on it or else i can work on the issue
My PR for TSLint https://github.com/palantir/tslint/pull/4064 to change their order to be consistent with Organise Imports actually got pushed 16 days ago (after more than a year) so once they make a release we should be able to close this issue.
Personally I would love it if TypeScript would break imports onto multiple lines in the same way as Prettier does as running Organise Imports and Prettier both conflict with each other, but maybe that's deserving of a new issue :)
I think that this issue can be closed now. Tslint (tested on v 6.1.1) now sorts like import { foo, _bar }
Yep, this is no longer a problem with the latest tslint.
As TSLint getting deprecated, we are trying to move to eslint-plugin-import's import/order, which has the same issue. I filed an issue on their end (https://github.com/benmosher/eslint-plugin-import/issues/1742).
Most helpful comment
My PR for TSLint https://github.com/palantir/tslint/pull/4064 to change their order to be consistent with
Organise Importsactually got pushed 16 days ago (after more than a year) so once they make a release we should be able to close this issue.Personally I would love it if TypeScript would break imports onto multiple lines in the same way as Prettier does as running
Organise ImportsandPrettierboth conflict with each other, but maybe that's deserving of a new issue :)