-
-
Notifications
You must be signed in to change notification settings - Fork 154
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
Combine define & use-flowType rules #44
Comments
The reason for keeping them separate was because If babel-eslint 7.x isn't going to update the scope anymore, then it makes total sense to merge the rules, since, yeah, you'll always want them together. I like that babel-eslint is slimming down, but there's a very real need for scope information on flow types. I can see how a plugin could easily either update the scope, or maintain its own scope information. @danez do you know if the eslint team has any opposition against exposing estraverse on the context object? |
I'm not part of eslint so I'm not sure what the think about exposing estraverse, maybe @hzoo knows. |
So I can do my own traversal before the rule visitors are called and augment the scope. I can install my own, but it'd be nice to use the same machinery that eslint already has. |
Would it be possible to expand Maybe a better option would be to make an ESLint env that includes all Flow built-ins as globals and then a way to define directories or files that contain type declarations (similar to how |
Closing as stale. |
I'm currently trying to figure out what is the best solution to go forward with babel-eslint 7.x and this plugin.
We want to make the next babel-eslint version not to define or use any flow type anymore. When I pull in the dev version of babel-eslint into this plugin the whole test-suite collapses for the define & use rule. It is pretty straight forward to fix most of the cases, but I stumbled upon cases where it is now hard to test, because the two plugins are split.
Assume this example:
Previously this was always failing (
A is defined but never used
) without any rule. Now babel-eslint is not doing anything toA
so this does not trigger any error by default.What the tests should cover now is
define-flow-type
is enabled then it should faildefine-flow-type
anduse-flow-type
is enabled it should still failNow the first is easy, but for the second assertion there is currently no location to test that.
This could be solved by either adding a new testfile that tests both rules together, includes the
define-rule
in the use-test or by combining both rules into one.The two rules were usually always used together afaik, but at least with the new babel-eslint version it will be nearly always necessary to use both of them when using flowtype in your code and especially when linting of flowtype is desired. So that brought up the question in my head if it makes sense to have two rules at all. Although both rules have a single responsibility right now, I think it would maybe still make sense to combine them and the underlying code could still be split into use/define.
But before I start creating a PR I wanted to get feedback and hear what you think about it @gajus
?
The text was updated successfully, but these errors were encountered: