🐞 [bugfix] Add proper file extensions when importing a typescript file from a typescript file#303
Open
giladgd wants to merge 1 commit intomysticatea:masterfrom
Conversation
…erly add the right file extension when importing a typescript file from a typescript file. The current implementation is breaking typescript code.
Author
|
This would fix the problem that caused xojs/xo#522. |
rosskevin
added a commit
to rosskevin/eslint-plugin-node
that referenced
this pull request
Jun 1, 2022
…pescript file Cherry-picked from https://github.com/giladgd/eslint-plugin-node/tree/dev/giladgd/fixImportExtentionFixingInTypeScript and lingering PR mysticatea#303 Thanks @giladgd
|
@giladgd I have cherry picked and submitted your fix to the new repo which is being maintained: eslint-community#20 |
Author
|
Thanks @rosskevin! |
aladdin-add
pushed a commit
to eslint-community/eslint-plugin-n
that referenced
this pull request
Jun 2, 2022
… a typescript file (#20) Cherry-picked from https://github.com/giladgd/eslint-plugin-node/tree/dev/giladgd/fixImportExtentionFixingInTypeScript and lingering PR mysticatea#303 Thanks @giladgd
|
Is this working? Because i'm still getting |
|
We switched to it in eg. Try that module out and if it isn't fixed there, then open a new PR in that project. |
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.
The current situation
Given this configuration:
{ "node/file-extension-in-import": ["error", "always"] }And this file: (a typescript file that imports from another typescript file)
eslint will suggest adding
.tsextension to the import statement, which is invalid and breaks the compilation of typescript.The fix
When a typescript file (
.ts/.cts/.mtsfiles,.ctsand.mtswill be supported as of TypeScript 4.5) imports another typescript file, eslint will now use the proper matching file extension instead of the original referenced file extension.This means that, for example, when a
.tsfile imports another.tsfile, eslint will suggest using a.jsextension in the import statement.