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

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

JounQin opened this issue Sep 7, 2019 · 5 comments

Comments

@JounQin
Copy link

@JounQin 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

This comment has been minimized.

Copy link
Owner

@mysticatea mysticatea commented Sep 7, 2019

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

This comment has been minimized.

Copy link
Author

@JounQin 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

This comment has been minimized.

Copy link
Owner

@mysticatea mysticatea commented Sep 7, 2019

Ah, I got it.

@mysticatea

This comment has been minimized.

Copy link
Owner

@mysticatea mysticatea commented Sep 9, 2019

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

@JounQin

This comment has been minimized.

Copy link
Author

@JounQin JounQin commented Sep 11, 2019

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

https://github.com/rx-ts/eslint-import-resolver-ts

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.