Skip to content

Commit f9d141c

Browse files
AlexKValyannickcr
authored andcommitted
Add annotation to docs for props.children and alike
1 parent 80b51cb commit f9d141c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

docs/rules/prop-types.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,20 @@ This rule can take one argument to ignore some specific props during validation.
6464

6565
* `enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
6666
* `ignore`: optional array of props name to ignore during validation.
67+
68+
### As for "exceptions"
69+
70+
It would seem that some common properties such as `props.children` or `props.className`
71+
(and alike) need to be treated as exceptions.
72+
73+
As it aptly noticed in
74+
[#7](https://github.com/yannickcr/eslint-plugin-react/issues/7)
75+
76+
> Why should children be an exception?
77+
> Most components don't need `this.props.children`, so that makes it extra important
78+
to document `children` in the propTypes.
79+
80+
> If `children` is difficult to figure out which type to use,
81+
one can always use `React.PropTypes.any`
82+
83+
Since 2.0.0 children is no longer ignored for props validation.

lib/rules/prop-types.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*/
55
'use strict';
66

7+
// As for exceptions for props.children or props.className (and alike) look at
8+
// https://github.com/yannickcr/eslint-plugin-react/issues/7
9+
710
var componentUtil = require('../util/component');
811
var ComponentList = componentUtil.List;
912

0 commit comments

Comments
 (0)