Skip to content

Commit d39a6cc

Browse files
committed
Fix allowed methods on arrayOf in prop-types (fixes jsx-eslint#146)
1 parent 675ab31 commit d39a6cc

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).
55

6+
## [Unreleased]
7+
### Fixed
8+
* Fix allowed methods on arrayOf in `prop-types` ([#146][])
9+
10+
[Unreleased]: https://github.com/yannickcr/eslint-plugin-react/compare/v3.3.1...HEAD
11+
[#146]: https://github.com/yannickcr/eslint-plugin-react/issues/146
12+
613
## [3.3.1] - 2015-09-01
714
### Changed
815
* Update dependencies

lib/rules/prop-types.js

-10
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,6 @@ module.exports = function(context) {
257257
});
258258
return shapeTypeDefinition;
259259
case 'arrayOf':
260-
return {
261-
type: 'array',
262-
children: {
263-
// Accept only array prototype and computed properties
264-
__ANY_KEY__: {
265-
acceptedProperties: Array.prototype
266-
},
267-
__COMPUTED_PROP__: buildReactDeclarationTypes(argument)
268-
}
269-
};
270260
case 'objectOf':
271261
return {
272262
type: 'object',

tests/lib/rules/prop-types.js

+19
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,25 @@ ruleTester.run('prop-types', rule, {
737737
ecmaFeatures: {
738738
jsx: true
739739
}
740+
}, {
741+
code: [
742+
'class Hello extends React.Component {',
743+
' static get propTypes() {}',
744+
' render() {',
745+
' var users = this.props.users.find(user => user.name === \'John\');',
746+
' return <div>Hello you {users.length}</div>;',
747+
' }',
748+
'}',
749+
'Hello.propTypes = {',
750+
' users: React.PropTypes.arrayOf(React.PropTypes.object)',
751+
'};'
752+
].join('\n'),
753+
env: {
754+
es6: true
755+
},
756+
ecmaFeatures: {
757+
jsx: true
758+
}
740759
}
741760
],
742761

0 commit comments

Comments
 (0)