-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Disabling prop-types on the function declaration line is no longer always sufficient #2325
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
Comments
Props detection became more powerful in last release, hence these new errors. Disabling component detection on lowercase functions was discussed in #512 but no decision was made yet. Right now the easiest way to disable /* eslint-disable react/prop-types */
const renderEquipment = ({equipment, features}) => {
const count = equipment.length + features.length;
if (!count) {
return null;
}
return (
<>
<Translate>Equipment</Translate>
<Label circular horizontal className="white" size="tiny" styleName="filter-bar-button-label">
{count}
</Label>
</>
);
};
/* eslint-enable react/prop-types */ |
Yes, that's what I went for in the end. |
This seems like a breaking change, in a minor version release. Can it be rolled back and pushed in a major version release? |
Also, this is going to be very confusing for developers. Where was this change discussed? |
the issue here isn’t the change; its that that render function is a component by our heuristic (I’d argue it is one conceptually and thus should be defined as one, but that’s a separate topic). If you define a propType for both of those props as an array, you won’t get a warning. |
Digging a little more, I'm ok with the change, just not rolling it out as a minor version bump. |
We try to follow the same Semantic Versioning Policy as ESLint, this case being covered by:
So AFAIK it is ok to release it in a minor. |
I have this function (which isn't even a component):
As you can see, I disabled the prop-types validation on it. However, after updating from 7.13 to 7.14.1, I'm now getting additional errors on the line where I'm accessing the length of the arrays:
I guess this happened because now accessing nested props also trigger a prop-type validation - but of course this makes it very ugly to disable prop-type validation for a whole (non-)component...
Maybe the component detection should never consider functions whose name starts with a lowercase character components, since they can't be components (when used in JSX)...
The text was updated successfully, but these errors were encountered: