Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react/boolean-prop-naming error with isRequired on a shape #1791

Closed
pcorpet opened this issue May 12, 2018 · 0 comments
Closed

react/boolean-prop-naming error with isRequired on a shape #1791

pcorpet opened this issue May 12, 2018 · 0 comments

Comments

@pcorpet
Copy link
Contributor

pcorpet commented May 12, 2018

When upgrading to 7.8 from 7.7.0 eslint trigger the following error:

Cannot read property 'name' of undefined
TypeError: Cannot read property 'name' of undefined
    at getPropKey (/usr/app/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:79:45)
    at forEach.prop (/usr/app/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:114:25)
    at Array.forEach (<anonymous>)
    at validatePropNaming (/usr/app/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:113:25)
    at Object.ClassProperty (/usr/app/node_modules/eslint-plugin-react/lib/rules/boolean-prop-naming.js:175:11)
    at updatedRuleInstructions.(anonymous function) (/usr/app/node_modules/eslint-plugin-react/lib/util/Components.js:698:75)
    at listeners.(anonymous function).forEach.listener (/usr/app/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/usr/app/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/usr/app/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/usr/app/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/usr/app/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/usr/app/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at Traverser.enter [as _enter] (/usr/app/node_modules/eslint/lib/linter.js:865:28)
    at Traverser._traverse (/usr/app/node_modules/eslint/lib/util/traverser.js:132:14)
    at Traverser._traverse (/usr/app/node_modules/eslint/lib/util/traverser.js:144:34)

I was able to reproduce with this simple code:

import PropTypes from 'prop-types'
import React from 'react'


class MyComponent extends React.Component {
  static propTypes = {
    requiredObject: PropTypes.shape({}).isRequired,
  }

  render() {
    return null
  }
}

I believe this is due to f980c38 introducing a check for simple PropTypes.bool.isRequired but not handling the case where isRequired is added after a function.

pcorpet added a commit to pcorpet/eslint-plugin-react that referenced this issue May 12, 2018
pcorpet added a commit to pcorpet/eslint-plugin-react that referenced this issue May 13, 2018
This was referenced Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant