Skip to content
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

Bug: plugin doesn't seem to work with tsconfig paths #314

Closed
1 task
AaronPorts opened this issue Jul 25, 2024 · 5 comments · Fixed by #343
Closed
1 task

Bug: plugin doesn't seem to work with tsconfig paths #314

AaronPorts opened this issue Jul 25, 2024 · 5 comments · Fixed by #343

Comments

@AaronPorts
Copy link

Environment

Node version: 22.5.1
npm version: 10.2.5
ESLint version: 9.7.0
eslint-plugin-n version: 17.9.0
Operating System: Windows 11

What rule do you want to report?

n/no-missing-import

Link to Minimal Reproducible Example

https://eslint-online-playground.netlify.app/#eNp1U01vGyEQ/SuIS2LJxh+Nm8a+9JB7q0jtpbQRZccOLgsI2MqV5f/egYW1nTgHr2TeezPDm8eBBi+nsBet08BioCuqWmd9vOX0c2ubTgOnozU3dExjkNZs1JbtgjVIPHDPDSGcSts6pcF/cVFZEzhdkYIl9LcI8M3rdMopm6Z+nI5PeO2SYGMbmH+8gKPwW4g9DGExWyyuqJ8gWN2l7u/WcSK+XI6WToc7rsiPNF3/d6pMA3u0g9OflX08qxWiVzLPFH0HBagETpWRumtqUbwwDnJ20VzyiIa+aoaWbjoj0y3I/nZUB/UQO29yp3VWpk/6wT4tijSwEZ2OZL/GkhC0MpENixr2SQzZeNtmExNl4nS3VWaChuF2Cyf+cxCkVy5+zWiVnM4nvTqL3kzwWl7GuEVqZIy9AwfmARPUAtrQjBN3QNC9jRZxekaYDC5m6iF9CNHCbDuxhZLAtOSyYpCt+A4+4PGK3GAxCPEGpT3qhA9Dbs9UiHi7AxlLLC6i3/euxAo9WRsflV+R3kvWQhSsUd6IFhNS6JiRGiacO31HuDQn5B8c/vSucoqSXX2a65WzmNMG/j6CS24YqaBkuiSzrifJfj2wezYrshz2vIFpz3l+3mUp8j6xuwX7cEZ8E5FMm9+zh4t6V2JR6s3YbCK0exFsOb8qKMwlW7I7TvPzSW/i+B8huoFz

What did you expect to happen?

Couldn't get the plugin to work with paths alias in tsconfig. I expected no error to be received since typescript-eslint works correctly.

Participation

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

Additional comments

No response

@AaronPorts AaronPorts added the bug label Jul 25, 2024
@AaronPorts AaronPorts changed the title Bug: (fill in) Bug: plugin doesn't seem to work with tsconfig paths Jul 25, 2024
@scagood
Copy link

scagood commented Jul 25, 2024

Thank you for the report and good example :)


🤔 This feels like a bug in here:

https://github.com/eslint-community/eslint-plugin-n/blob/master/lib/util/import-target.js#L42-L55

@Sparticuz
Copy link

I started getting this after upgrading to typescript-eslint v8. It looks like the example reproduction is also using v8

@Sparticuz
Copy link

🤔 This feels like a bug in here:

master/lib/util/import-target.js#L42-L55

I received this as the output of that function:
[ { name: '~', alias: [ './src' ] } ]

and my tsconfig is

"paths": {
  "~/*": ["./src/*"]
}

@eladchen
Copy link

eladchen commented Sep 3, 2024

Any idea what needs to be done here?

@scagood
Copy link

scagood commented Sep 4, 2024

Sorry, I just have not had any time to look recently. I don't think I will have time for the a little while. I may try next week, to get some issues resolved, but no promises!


In terms of what this needs first, the most amazing thing would be a set of failing tests to work with.

The two I can see here that I assume are borked:

input target
@module ./module/index.ts
~/* ./src/*

From there we can work out how that should be implemented in enhanced-resolve using the Alias option


I am really not a fan of the way tsconfig.json#paths has been implemented. I wonder whether a rule suggesting avoiding tsconfig.json#paths which suggests using package.json#imports instead is a good idea too. 🤔

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

Successfully merging a pull request may close this issue.

4 participants