Open giladgd opened 2 years ago
This would fix the problem that caused https://github.com/xojs/xo/issues/522. This would also provide an elegant solution to https://github.com/microsoft/TypeScript/issues/16577.
@giladgd I have cherry picked and submitted your fix to the new repo which is being maintained: https://github.com/weiran-zsd/eslint-plugin-node/pull/20
Thanks @rosskevin!
Is this working? Because i'm still getting .ts
extensions on --fix.
eslint-plugin-n
is the maintained version of this module.
We switched to it in eg. eslint-config-standard
/ standard
and it is maintained by me and other members of the official ESLint community organization.
Try that module out and if it isn't fixed there, then open a new PR in that project.
The current situation
Given this configuration:
And this file: (a typescript file that imports from another typescript file)
eslint will suggest adding
.ts
extension to the import statement, which is invalid and breaks the compilation of typescript.The fix
When a typescript file (
.ts
/.cts
/.mts
files,.cts
and.mts
will 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
.ts
file imports another.ts
file, eslint will suggest using a.js
extension in the import statement.