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

[feature request]: functional resolvePackage option/setting support #186

Open
JounQin opened this issue Sep 7, 2019 · 5 comments
Open

Comments

@JounQin
Copy link

JounQin commented Sep 7, 2019

Motivation: I'm always using TypeScript personally, for most packages we can use following settings:

{
  resolvePaths: [path.resolve('node_modules/@types')],
  tryExtensions: [
    '.ts',
    '.tsx',
    '.d.ts',
    '.vue',
    '.js',
    '.jsx',
    '.json',
    '.node',
  ],
}

But it won't work for scoped packages like @babel/core, its typed definition is under @types/babel__core directory, so resolvePaths will not work for it. Of course, we can use allowModules for workaround, but it could be a mistake if we forget to install the @types/babel__core module.

@mysticatea
Copy link
Owner

In my understanding, when we install @types/foo, we have installed foo as well because @types/foo doesn't contain any implementation.

So resolvePaths: [path.resolve('node_modules/@types')] isn't needed.

@JounQin
Copy link
Author

JounQin commented Sep 7, 2019

@mysticatea We may only import types of foo, then there is no need to install foo itself.

And also, unist is a package which only has definitions without npm package.

unist (404)
@types/unist

@mysticatea
Copy link
Owner

Ah, I got it.

@mysticatea
Copy link
Owner

This enhancement needs design because ESLint doesn't support function type in rule options.

@JounQin
Copy link
Author

JounQin commented Sep 11, 2019

@mysticatea Is it possible to integrate with the resolvers for eslint-plugin-import?

https://github.com/alexgorbatchev/eslint-import-resolver-typescript

This resolver could help, or we can simply wrap it.

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

No branches or pull requests

2 participants