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

[named] flow-typed definitions are not used unless node_modules are ignored #931

Closed
IanVS opened this issue Sep 20, 2017 · 6 comments · Fixed by #1057
Closed

[named] flow-typed definitions are not used unless node_modules are ignored #931

IanVS opened this issue Sep 20, 2017 · 6 comments · Fixed by #1057

Comments

@IanVS
Copy link

IanVS commented Sep 20, 2017

eslint-plugin-import: 7.2.0

I was having the same issue as #708, where modules whose types are defined in a flow-typed definition were throwing false positive import/named errors about not being found.

I realized that adding the following to my .eslintrc solves the problem:

settings:
    import/ignore:
      - node_modules

So, it seems that if node_modules are not ignored, this plugin will look into the node_module for the type definition, and if it doesn't find it, it throws an error. Ideally, it would also look in flow-typed (using whatever method it's currently using when node_modules are ignored) before reporting the error.

@krainboltgreene
Copy link

Honestly just ignoring import type ... would be amazing.

@benmosher
Copy link
Member

Honestly just ignoring import type ... would be amazing.

this would be a great start, I would support this. not sure how to discriminate between flow imports and others, but I think an extra line or two in the checkSpecifiers function in the rule def would accomplish this. just need someone to figure out what the right predicate is to filter them out, apparently the ESTree node type must be the same. would guess there is some extra flag.

@benmosher
Copy link
Member

btw, adding node_modules to import/ignore means it's just not bothering to parse them at all, which is fine if that works for you but is not really ideal since the non-flow imports (all of them) are also then ignored.

@ljharb ljharb added the flow label Nov 2, 2017
KevinGrandon added a commit to KevinGrandon/eslint-plugin-import that referenced this issue Dec 24, 2017
I was running into this issue and was curious if you all would entertain PRs for typing support.

Refs import-js#931
ljharb pushed a commit to KevinGrandon/eslint-plugin-import that referenced this issue Jan 4, 2018
@mgmeyers
Copy link

mgmeyers commented Mar 29, 2018

It looks like #988 fixed this for no-extraneous-dependencies, but not named which is what this issue is referring to. I still get flow related import/named errors in 2.9.0.

@IanVS
Copy link
Author

IanVS commented Apr 13, 2018

It looks like the resolution has been to ignore all import type statements. Which concerned me at first, until I realized that flow itself will complain if you try to import a type that doesn't exist. Thanks all! 👍

@chadlwilson
Copy link

Thanks a lot for the work here all - this has been causing us some issues. Am I right in thinking this needs a new plugin release (not in 2.11.0)? If so, @benmosher could we plleeeeease get one, even if it's beta? :)

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

Successfully merging a pull request may close this issue.

6 participants