jsx-eslint/eslint-plugin-react

'no-unused-prop-types' breaks when using destructuring in jsx attributes

Open

#2.222 aberto em 29 de mar. de 2019

Ver no GitHub
 (6 comments) (5 reactions) (0 assignees)JavaScript (2.797 forks)batch import
bughelp wanted

Métricas do repositório

Stars
 (8.630 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

I was scratching my head over why no-unused-prop-types didn't trigger at all for some of my components, and after some experimentation it turns out it happens whenever I use destructuring in jsx attributes:

const DumbComponent = props => {
  const someObj = { value: 619 };
  return (
    <SomeOtherComp {...someObj} />
  );
};

DumbComponent.propTypes = {
  unused_prop: PropTypes.string // doesn't trigger
};

but

const DumbComponent = props => {
  const someObj = { value: 619 };
  return (
    <SomeOtherComp value={someObj.value} />
  );
};

DumbComponent.propTypes = {
  unused_prop: PropTypes.string // triggers
};

Guia do colaborador