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

Add support for Flow TypedArgument in no-unsed-prop-types rule #1412

Merged
merged 3 commits into from Sep 5, 2017

Conversation

jseminck
Copy link
Contributor

@jseminck jseminck commented Sep 4, 2017

While working on #1393 I noticed that no-unused-prop-types rule supports way more cases than prop-types rule already supports.

Since we would release Flow 0.53 support in the next release for the prop-types rule, I felt it wouldn't be really complete if we supported the Flow TypedArgument syntax for this rule either.

Since #1393 will take a bit more time for me to complete, I figured that an additional extra small PR to add this support to this rule would be very useful.

The code is 100% copy-paste from the prop-types rule. The goal for #1393 is to actually eliminate that duplication.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems legit

@yannickcr
Copy link
Member

Does a release with #1376 and this one are enough to get a good Flow 53 support ? Or is it better to wait for #1393 ?

(I do not use Flow so I don't really know what is our current support status)

@jseminck
Copy link
Contributor Author

jseminck commented Sep 5, 2017

#1393 is this PR.

I created the issue because in addition we should merge the code for prop-types and no-unused-prop-types. The code is currently 80% the same, but some cases are supported in one rule and not the other.

I think this PR + #1377 cover the new Flow syntax for these two rules.

Edit: There's also another rule related to props checking: default-props-match-prop-types. That rule doesn't even support the <void, Props, void> (<= Flow 0.53) syntax at the moment. Ideally we should add support for the syntax for that rule as well, but no one has asked about it so far.

There's also some other Flow related bug fixes in the current open PR list. #1400 and #1390

I also don't use Flow so can't really be certain. What I could do is test out on a Flow open-source code base that I have contributed a few times to to test if everything is fine once everything has landed in master. It's not a big code-base but it's better than nothing. 😄

@yannickcr
Copy link
Member

Ok, then after merging theses PR I will publish a pre-release version for testing purpose.

@jseminck
Copy link
Contributor Author

jseminck commented Sep 5, 2017

Great. Perhaps @EvHaus can also test it? I think he's also working with a (big?) Flow code base.

I can try it on https://github.com/CompuIves/codesandbox-client/ (uses new Flow syntax) and https://github.com/bvaughn/babel-repl (uses normal Flow syntax, no TypedArguments)

@yannickcr yannickcr merged commit 9e090ed into jsx-eslint:master Sep 5, 2017
@EvHaus
Copy link
Collaborator

EvHaus commented Sep 5, 2017

Yeah, I'd love to test a pre-release of this. I'm sitting on hundreds of Flow-typed components :)

@yannickcr
Copy link
Member

I just published 7.4.0-rc.0 (release notes). You can install it with npm install eslint-plugin-react@next.

Feel free to report any issue 😃

@techieshark
Copy link

@yannickcr thanks, just ran into this problem (types in flow, not proptypes), googled it and found this issue, saw your comment and updated to eslint-plugin-react@next and that problem seemed to go away. By no means thorough testing but I appreciate not having that error anymore!

@EvHaus
Copy link
Collaborator

EvHaus commented Sep 6, 2017

Both no-unused-prop-types and prop-types working wonderfully on eslint-plugin-react@7.4.0-rc.0 using flow@0.54.0 for me across all my code bases. Didn't need to change a single thing. Nicely done everyone!

@jseminck ❤️

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

Successfully merging this pull request may close these issues.

None yet

5 participants