Skip to content

Commit

Permalink
Add test for #1865
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzherdev committed Sep 27, 2018
1 parent 4d1b833 commit 5211a2b
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/lib/rules/require-default-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,19 @@ ruleTester.run('require-default-props', rule, {
].join('\n'),
parser: 'babel-eslint',
options: [{forbidDefaultForRequired: true}]
}, {
code: `
type Props = {
+name?: string,
};
function Hello(props: Props) {
return <div>Hello {props.name}</div>;
}
Hello.defaultProps = {
name: 'foo'
};
`,
parser: 'babel-eslint'
}
],

Expand Down Expand Up @@ -2174,6 +2187,20 @@ ruleTester.run('require-default-props', rule, {
}, {
message: 'propType "bar" is not required, but has no corresponding defaultProp declaration.'
}]
},
{
code: `
type Props = {
+name?: string,
};
function Hello(props: Props) {
return <div>Hello {props.name}</div>;
}
`,
parser: 'babel-eslint',
errors: [{
message: 'propType "name" is not required, but has no corresponding defaultProp declaration.'
}]
}
]
});

0 comments on commit 5211a2b

Please sign in to comment.