Skip to content

Commit

Permalink
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]
### Fixed
* Fix crash in [`boolean-prop-naming`] when encountering a required shape prop type ([#1791][] @pcorpet)

## [7.8.1] - 2018-05-12
### Fixed
* Fix crash in [`no-deprecated`][] when encountering a class constructor ([#1785][] @taddei)
5 changes: 4 additions & 1 deletion lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
@@ -76,7 +76,10 @@ module.exports = {
if (node.value.property) {
const name = node.value.property.name;
if (name === 'isRequired') {
return node.value.object.property.name;
if (node.value.object && node.value.object.property) {
return node.value.object.property.name;
}
return null;
}
return name;
}
11 changes: 11 additions & 0 deletions tests/lib/rules/boolean-prop-naming.js
Original file line number Diff line number Diff line change
@@ -348,6 +348,17 @@ ruleTester.run('boolean-prop-naming', rule, {
hasValue: PropTypes.bool.isRequired
}
`
}, {
// Ensure the rule does not throw when a shape prop isRequired.
code: `
var Hello = createReactClass({
propTypes: {something: PropTypes.shape({}).isRequired},
render: function() { return <div />; }
});
`,
options: [{
rule: '^is[A-Z]([A-Za-z0-9]?)+'
}]
}],

invalid: [{

0 comments on commit 7f3934a

Please sign in to comment.