Skip to content

Commit 48e8dc1

Browse files
authored
Merge pull request #1380 from brgibson/master
require-default-props - fixing an edge case where linting stops early
2 parents 02ed7d0 + f371368 commit 48e8dc1

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

lib/rules/require-default-props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ module.exports = {
578578

579579
// If no propTypes could be found, we don't report anything.
580580
if (!list[component].propTypes) {
581-
return;
581+
continue;
582582
}
583583

584584
reportPropTypesWithoutDefault(

tests/lib/rules/require-default-props.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,25 @@ ruleTester.run('require-default-props', rule, {
13071307
}]
13081308
},
13091309

1310+
// component with no declared props followed by a failing component
1311+
{
1312+
code: [
1313+
'var ComponentWithNoProps = ({ bar = "bar" }) => {',
1314+
' return <div>Hello {this.props.foo}</div>;',
1315+
'}',
1316+
'var Greetings = ({ foo = "foo" }) => {',
1317+
' return <div>Hello {this.props.foo}</div>;',
1318+
'}',
1319+
'Greetings.propTypes = {',
1320+
' foo: PropTypes.string',
1321+
'};'
1322+
].join('\n'),
1323+
errors: [{
1324+
message: 'propType "foo" is not required, but has no corresponding defaultProp declaration.',
1325+
line: 8,
1326+
column: 3
1327+
}]
1328+
},
13101329
//
13111330
// with Flow annotations
13121331
{

0 commit comments

Comments
 (0)