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

Support propWrapperFunctions for boolean-prop-naming #1478

Merged
merged 3 commits into from Dec 4, 2017

Conversation

jomasti
Copy link
Contributor

@jomasti jomasti commented Oct 14, 2017

This adds support for checking prop types in boolean-prop-naming when using the propWrapperFunctions setting.

Closes #1452.

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.

We definitely don't want to just support any function call. Take a look at propWrapperFunctions for how this can be configured - we should probably add a new setting that defaults to ['Object.assign'], such that users could define _.assign or merge etc themselves. It could be named propObjectAssignFunctions perhaps?

@jomasti jomasti changed the title Support function call for setting propTypes Support Object.assign, et al, for bool-prop-naming Oct 18, 2017
@louisscruz
Copy link
Contributor

Any progress on this?

@jomasti
Copy link
Contributor Author

jomasti commented Nov 20, 2017

I think this is good based on the previous feedback, but @ljharb will have to review again.

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.

This LGTM; although it occurs to me that with object spread, there’s no need for a merge/assign function anyways - is there a reason you aren’t using object spread?

@jseminck
Copy link
Contributor

jseminck commented Nov 21, 2017

@ljharb last I remembered ESLint supports node 4 which does not support object spread. I've had the same problems in the past. We still have Travis running builds on node 4 so I suppose we still have to support it.

@ljharb
Copy link
Member

ljharb commented Nov 21, 2017

@jseminck I’m not asking about the rule implementation, I’m asking about users in their own codebase - also, object spread is trivially transpileable with Babel to Object.assign, or to any other package name via transform-replace-object-assign.

@jomasti
Copy link
Contributor Author

jomasti commented Nov 21, 2017

@ljharb Now that I think about it, this change should just use the current propWrapperFunctions setting instead of a new one since we would want to support the other functions that could be used like forbidExtraProps and whatnot.

@ljharb
Copy link
Member

ljharb commented Nov 22, 2017

@jomasti it could; but propWrapperFunctions is meant to convey "this function returns an object", which "exact" prop functions also do.

However, this rule deals only with "exact prop wrapper functions" - Object.freeze, for example, is a valid propWrapperFunction but not a valid exact prop wrapper function.

@jomasti
Copy link
Contributor Author

jomasti commented Nov 22, 2017

@ljharb You may be thinking about my other PR for prefer-exact-props, but for this one (boolean-prop-naming), any function that returns an object should be supported, right? That would be beyond the current implementation of adding a new property (and probably unnecessary currently) (propObjectAssignFunctions).

Also, avoiding adding this should make it easy to change the schema of propWrapperFunctions to support your suggested schema in #1547 without having to remove this new setting.

@ljharb
Copy link
Member

ljharb commented Nov 22, 2017

@jomasti oh lol i got confused, yes, i was thinking about the other one.

Yes, this rule should just use propWrapperFunctions, good call :-D

@jomasti jomasti changed the title Support Object.assign, et al, for bool-prop-naming Support propWrapperFunctions for boolean-prop-naming Nov 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants