-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[New] add prefer-exact-props
rule
#1547
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note the propWrapperFunctions
settings, with can be used to specify exact
or forbidPropTypes
.
Perhaps this warrants a new setting for "exact propType wrappers", that could also be checked everywhere the existing propWrappers are?
Do you think it should be a global setting instead of just an option for the rule? I'm unsure of the other use cases for it being a global setting. |
@jomasti if it were a global setting, then other rules could access it to "unwrap" propTypes for their own uses. |
@ljharb Wouldn't these particular "exact props" functions still be in |
@jomasti right; the idea is that i'd be able to move |
I guess an alternative schema for the existing setting could be: "propWrapperFunctions": [
"Object",
{ "property": "freeze", "object": "Object" },
{ "property": "forbidExtraProps", "exact": true }
] |
What exactly is missing before this can be merged? Can we maybe split this task and add support for libs like airbnb/prop-types in an other task? |
@maxammann that support already exists; see the "propWrapperFunctions" setting in the readme. This PR needs to be updated per the above comments. |
After doing some digging, it looks like the failures on ESLint 3 are due to versions 7.22+ of babel-eslint using |
We could modify the dep range, and for eslint 3 in Travis.yml manually downgrade it? |
Would you prefer for the |
Downgrading to a working version of |
Breaks other tests on eslint 3? |
Yes, using |
So what is it exactly about this pr that causes this breakage? |
It's looking for the TypeAlias variable in the scope. This works fine on |
ecbb05d
to
cb6aba0
Compare
This rule checks if non-exact objects are used for defining prop types when using Flow along with using normal objects for prop types instead of something like
prop-types-exact
to enforce only passing the exact props to a component.The exact prop wrapper functions for non-Flow usage are configurable by adding the
exact
property to an object setting in thepropWrapperFunctions
config option.Closes #1455