eslint-plugin-import icon indicating copy to clipboard operation
eslint-plugin-import copied to clipboard

[Fix]: `no-unresolved`: Support importing only types when the module isn't installed

Open EdenGottlieb opened this issue 3 years ago • 2 comments

  • [x] write tests
  • [x] implement feature/fix bug
  • [x] update docs
  • [x] make a note in change log

Don't trigger an error when only typings are imported and the actual module is not installed (only its typings are installed under (node_modules/@types). This is useful when defining packages holding domain objects that only need to reference types, without using the actual module.

I chose memorystream for the test for several reasons:

  1. I needed a module that won't be added to the project any time soon (adding it would break the tests!)
  2. I needed to use a module with publicly available typings
  3. It's what I used for the initial debugging :)

Please feel free to comment on code logic, test strategy and documentation phrasing, all feedback is welcome!

EdenGottlieb avatar Mar 18 '21 01:03 EdenGottlieb

You should use eslint-import-resolver-typescript

JounQin avatar Mar 26 '21 15:03 JounQin

Indeed; with the typescript eslint resolver (which is required when using typescript) this shouldn't be an issue.

@EdenGottlieb can you confirm that using it solves the issue for you?

ljharb avatar Mar 26 '21 15:03 ljharb