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

eslint --fix does not work properly if baseUrl is omitted #75

Open
vrosa opened this issue May 27, 2024 · 2 comments
Open

eslint --fix does not work properly if baseUrl is omitted #75

vrosa opened this issue May 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@vrosa
Copy link

vrosa commented May 27, 2024

First of all, thanks for creating this plugin, it is really useful.

I'd like to report that if the tsconfig.json file does not contain the compilerOptions.baseUrl property, eslint --fix incorrectly updates affected files. For instance, for the following config:

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

And the following import in .src/tests/test/test.ts to import ./src/routers/userRouter.ts:

import { userRouter } from '../../routers/userRouter';

When you run eslint, it shows the error Update import to ~/uters/userRouter, that is, it cuts off the first 2 characters from the alias. Running eslint --fix then updates the file with the wrong and invalid import { userRouter } from '~/uters/userRouter'; import statement. The workaround is to set a baseUrl field so paths under paths can be absolute; however, it's not ideal because baseUrl has other side effects, such as potential module resolution conflicts with node_modules.

@vitonsky vitonsky added the bug Something isn't working label May 27, 2024
@vitonsky
Copy link
Owner

Thank you for report. It is a known intermediate problem, but i did not known about potential problems due to baseUrl option.

Will be fixed in next release.

@brunano21
Copy link

Hi -- is there any update on this issue? I'm facing the same and I'd love to use this plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

3 participants