Skip to content

Commit cbd4d74

Browse files
committed
[no-unused-prop-types] test cases
1 parent 95acd93 commit cbd4d74

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tests/lib/rules/no-unused-prop-types.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,63 @@ ruleTester.run('no-unused-prop-types', rule, {
20122012
'}'
20132013
].join('\n'),
20142014
parser: 'babel-eslint'
2015+
}, {
2016+
// issue #1002
2017+
code: [
2018+
' type User = {',
2019+
' country: string;',
2020+
' };',
2021+
2022+
' export default ({ user }: { user: User }) => (',
2023+
' <div>',
2024+
' { user.country }',
2025+
' </div>',
2026+
' );'
2027+
].join('\n'),
2028+
parser: 'babel-eslint'
2029+
}, {
2030+
// issue #1008
2031+
code: [
2032+
'type ObjectType = {',
2033+
' usedDirectly: string;',
2034+
' usedFromArray: string;',
2035+
'};',
2036+
2037+
'export class UseDirectly extends React.Component {',
2038+
' props: {',
2039+
' object: ObjectType;',
2040+
' }',
2041+
2042+
' render() {',
2043+
' console.log(this.props.object.usedDirectly);',
2044+
' return null;',
2045+
' }',
2046+
'}'
2047+
].join('\n'),
2048+
parser: 'babel-eslint'
2049+
}, {
2050+
// issue #1323
2051+
code: [
2052+
'type AProps = {',
2053+
' name: string;',
2054+
' age: number;',
2055+
'};',
2056+
2057+
'type BProps = {',
2058+
' greeting: string;',
2059+
'};',
2060+
2061+
'type Props = AProps & BProps;',
2062+
2063+
'class Hello extends React.Component {',
2064+
' props: Props;',
2065+
2066+
' render () {',
2067+
' return <div>{this.props.greeting}, {this.props.name}</div>;',
2068+
' }',
2069+
'}'
2070+
].join('\n'),
2071+
parser: 'babel-eslint'
20152072
}
20162073
],
20172074

0 commit comments

Comments
 (0)