Skip to content

Disabling prop-types on the function declaration line is no longer always sufficient #2325

Closed
@ThiefMaster

Description

@ThiefMaster

I have this function (which isn't even a component):

// eslint-disable-next-line 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>
    </>
  );
};

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:

  39:27  error  'equipment.length' is missing in props validation  react/prop-types
  39:45  error  'features.length' is missing in props validation   react/prop-types

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)...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions