Eslint-plugin-import: [named] flow-typed definitions are not used unless node_modules are ignored

Created on 20 Sep 2017  路  6Comments  路  Source: benmosher/eslint-plugin-import

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.

flow help wanted

Most helpful comment

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

All 6 comments

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

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.

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.

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.

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! 馃憤

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? :)

Was this page helpful?
0 / 5 - 0 ratings