Eslint-plugin-react: 7.14.0: no-unused-prop-types throws exception on intermediate destructuring props

Created on 24 Jun 2019  路  3Comments  路  Source: yannickcr/eslint-plugin-react

Version 7.14.0

Using intermediate destructuring of props in a class render method throws an exception. This seems to have been introduced in the v7.14.0 release

The following fails with VariableDeclarator ASTNodes are not handled by markPropTypesAsUsed:

  render() {
    const { chartData, chartTitle, loading, className } = this.props;
    const { legendData, title, tooltip } = chartTitle;
  ...

Whereas the following passes:

  render() {
    const {
      chartData,
      chartTitle: { legendData, title, tooltip },
      loading,
      className
    } = this.props;
  ...

Relevant propTypes are:

chartData: PropTypes.array.isRequired,
chartTitle: PropTypes.object.isRequired,
loading: PropTypes.bool.isRequired,
className: PropTypes.string

I didn't expect the intermediate destructuring to fail, but if it is invalid then it should fail cleanly rather than throw.

Most helpful comment

Duplicate of #2319. Fix is merged in master but waiting for release.

All 3 comments

Duplicate of #2319. Fix is merged in master but waiting for release.

Just released v7.14.1 with the fix :slightly_smiling_face:

Great! thanks.

Was this page helpful?
0 / 5 - 0 ratings