[patch] order/TypeScript: ignore ordering of object imports#1831
Merged
Conversation
1 similar comment
Contributor
Author
|
So I just realized that the first approach wouldn't work out as something like import { ESLint } from "eslint";
import B = ESLint;
import A = B;Still would cause issues. |
ljharb
reviewed
Jun 19, 2020
ljharb
reviewed
Jun 21, 2020
neurolag
commented
Jun 22, 2020
ljharb
requested changes
Jun 22, 2020
ljharb
approved these changes
Jun 23, 2020
order/TypeScript: ignore ordering of object imports
This was referenced Mar 18, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forcing object-imports to be alphabetized might lead to issues as they might depend on each other.
Example:
Currently, this piece of code will report an error because
A.LintResulthas a lower rank thanESLint.Alphabetizing these imports would cause this code to fail:
I see three different approaches to fix this:
Sort object-imports with following conditions:Number of dots (e.g.tscomes beforets.protocolandts.protocolcomes beforets.protocol.Request)Import-Name''Though I'd like the first approach the most as it definitely would work and even would fix code like the one above, the second approach is ways easier to implement which is why I just went for it.
Remarks
The first approach won't work as, for example, this code still would cause an error:
Therefore I'd recommend to go for the second approach as done in this PR.
Feedback is welcome - do you guys think it's possible to implement the first mentioned approach at some point?