Skip to content

Commit

Permalink
Add annotation to docs for props.children and alike
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKVal authored and yannickcr committed Apr 15, 2015
1 parent 80b51cb commit f9d141c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/rules/prop-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,20 @@ This rule can take one argument to ignore some specific props during validation.

* `enabled`: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.
* `ignore`: optional array of props name to ignore during validation.

### As for "exceptions"

It would seem that some common properties such as `props.children` or `props.className`
(and alike) need to be treated as exceptions.

As it aptly noticed in
[#7](https://github.com/yannickcr/eslint-plugin-react/issues/7)

> Why should children be an exception?
> Most components don't need `this.props.children`, so that makes it extra important
to document `children` in the propTypes.

> If `children` is difficult to figure out which type to use,
one can always use `React.PropTypes.any`

Since 2.0.0 children is no longer ignored for props validation.
3 changes: 3 additions & 0 deletions lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*/
'use strict';

// As for exceptions for props.children or props.className (and alike) look at
// https://github.com/yannickcr/eslint-plugin-react/issues/7

var componentUtil = require('../util/component');
var ComponentList = componentUtil.List;

Expand Down

0 comments on commit f9d141c

Please sign in to comment.