jsx-eslint/eslint-plugin-react

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

Open

#1,674 建立於 2018年2月2日

在 GitHub 查看
 (13 留言) (15 反應) (0 負責人)JavaScript (8,630 star) (2,797 fork)batch import
bugenhancementhelp wanted

描述

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?

貢獻者指南