Skip to content

Bug: [file-extension-in-import] does not work with allowImportingTsExtensions #422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task
Zamiell opened this issue Mar 11, 2025 · 4 comments
Open
1 task
Assignees
Labels

Comments

@Zamiell
Copy link

Zamiell commented Mar 11, 2025

Environment

Node version: 22.14.0
npm version: 11.1.0
ESLint version: 9.22.0
eslint-plugin-n version: 17.16.2
Operating System: Windows

See my simple reproduction repository below.

What rule do you want to report?

file-extension-in-import

Link to Minimal Reproducible Example

https://github.com/Zamiell/eslint-n-bug

What did you expect to happen?

no error to occur

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

@Zamiell Zamiell added the bug label Mar 11, 2025
@Zamiell
Copy link
Author

Zamiell commented Mar 11, 2025

Looks like this feature was implemented by Sebastian Good: #134 / #139

It seems I can't ping him directly here, maybe someone else can?

@scagood scagood self-assigned this Mar 12, 2025
@wycats
Copy link

wycats commented Mar 25, 2025

@Zamiell it looks like this was supposed to be fixed in v17. I'm confused... was it not fixed? Do you know of any workaround?

@wycats
Copy link

wycats commented Mar 25, 2025

Future travelers: I was trying to set typescriptExtensionMap at the top-level of settings when it needed to be nested under node. This configuration works:

{
  "settings": {
    "node": {
      "typescriptExtensionMap": [
        [
          "",
          ".ts"
        ],
        [
          ".ts",
          ".ts"
        ]
      ]
    }
  }
}

It's just a workaround, but it works.

@scagood
Copy link

scagood commented Mar 26, 2025

Sorry, struggling for time at the moment 👀

This was only implemented for "no-missing-*" before (in lib/util/get-try-extensions.js:65-71)


I think allowImportingTsExtensions handling needs to be add to lib/util/get-typescript-extension-map.js:64-72 to get the best effect.

Thanks for the example @wycats :)


Im not 100% sure what to do with the .tsx extension -- I will have to do some reading.

Currently these are the ones I think are correct:

[ ".ts", ".ts" ]
[".cts", ".cts"]
[".mts", ".mts"]

I am on the fence about:

["", ".ts"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants