-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[new] Add jsx-props-no-spreading rule #2191
Conversation
also hopefully like this: function MyComponent({ one_prop, two_prop }) {
return <MySubComponent one_prop={one_prop} two_prop={two_prop} />
} |
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.
I think this will need an exceptions
array option as well, since spreading props is actually necessary for HOCs.
Additionally, I think it would be ideal to provide another option that controls whether this rule applies to custom component elements, or HTML elements, or both.
Added option |
hmm. Thanks for adding that! We probably should have discussed the schema a bit more :-) Let's do something like this: {
html: 'enforce'/'ignore',
custom: 'enforce'/'ignore',
exceptions: ['ComponentName', 'OtherComponentName'],
} and make sure it errors if |
Sure, made the respective changes. |
That's a good question :-) it'll probably have to be something like:
|
I think the
@ljharb what do you think? |
ah true, that's a good point. I'd like the schema to be as explicit as possible. If both are "ignore", then |
@ljharb made the requested changes. |
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.
Looks pretty good, thanks!
a835a3f
to
752de70
Compare
This adds a rule to disallow JSX props spreading as it reduces both the readability and maintainability of the code. Fixes #1094.
So, instead of passing props like this:
This rule will enforce passing props like this: