jsx-eslint/eslint-plugin-react

Object composition in propTypes causes 'default-props-match-prop-types' error

Aperta

#1674 aperta il 2 feb 2018

 (13 commenti) (15 reazioni) (0 assegnatari)JavaScript (2731 fork)batch import
bugenhancementhelp wanted

Metriche repository

Star
 (9293 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Consider the following functioning example:

elementEventCardBaseShape = {
  calendarLink: mediaFileShape,
  mapLink: PropTypes.string,
  startDate: PropTypes.string,
  locationName: PropTypes.string,
  street: PropTypes.string,
  city: PropTypes.string,
  region: PropTypes.string
};

ElementEventCard.propTypes = {
  ...elementEventCardBaseShape,
  lang: PropTypes.string
};

ElementEventCard.defaultProps = {
  lang: 'en',
  calendarLink: {},
  mapLink: '',
  startDate: '',
  locationName: '',
  street: '',
  city: '',
  region: ''
};

Where all but 'lang' throw an error for said prop supposedly having no matching propType. Am I missing something?

Guida contributor