Skip to content

Commit

Permalink
Fix "ignore" option for prop-types rule (fixes #135)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickcr committed Jun 29, 2015
1 parent e577f76 commit 999e7c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,12 +500,11 @@ module.exports = function(context) {
* @param {Object} component The component to process
*/
function reportUndeclaredPropTypes(component) {
var allNames, name;
var allNames;
for (var i = 0, j = component.usedPropTypes.length; i < j; i++) {
name = component.usedPropTypes[i].name;
allNames = component.usedPropTypes[i].allNames;
if (
isIgnored(name) ||
isIgnored(allNames[0]) ||
isDeclaredInComponent(component, allNames)
) {
continue;
Expand Down
10 changes: 10 additions & 0 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ eslintTester.addRuleTest('lib/rules/prop-types', {
classes: true,
jsx: true
}
}, {
code: [
'class Hello extends React.Component {',
' render() {',
' return <div>{this.props.name.firstname}</div>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint',
args: [1, {ignore: ['name']}]
}
],

Expand Down

0 comments on commit 999e7c4

Please sign in to comment.