Skip to content

Commit

Permalink
[Tests] no-unused-prop-types: Added test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dozoisch authored and ljharb committed Nov 25, 2016
1 parent fd3cebb commit 8df4943
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Expand Up @@ -1094,6 +1094,30 @@ ruleTester.run('no-unused-prop-types', rule, {
'}'
].join('\n'),
parser: parsers.BABEL_ESLINT
}, {
code: [
'type Props = {notTarget: string};',
'class Hello extends React.Component {',
' props: Props;',
' onEvent({ target }: { target: Object }) {};',
' render () {',
' return <div>Hello {this.props.notTarget}</div>;',
' }',
'}'
].join('\n'),
parser: parsers.BABEL_ESLINT
}, {
code: [
'type Props = {notTarget: string};',
'class Hello extends React.Component {',
' props: Props;',
' onEvent(infos: { target: Object }) {};',
' render () {',
' return <div>Hello {this.props.notTarget}</div>;',
' }',
'}'
].join('\n'),
parser: parsers.BABEL_ESLINT
}, {
code: [
'class Hello extends React.Component {',
Expand Down Expand Up @@ -5081,6 +5105,21 @@ ruleTester.run('no-unused-prop-types', rule, {
errors: [{
message: '\'person.lastname\' PropType is defined but prop is never used'
}]
}, {
code: [
'type Props = {notTarget: string, unused: string};',
'class Hello extends React.Component {',
' props: Props;',
' onEvent = ({ target }: { target: Object }) => {};',
' render () {',
' return <div>Hello {this.props.notTarget}</div>;',
' }',
'}'
].join('\n'),
parser: parsers.BABEL_ESLINT,
errors: [
{message: '\'unused\' PropType is defined but prop is never used'}
]
}, {
code: `
import PropTypes from 'prop-types';
Expand Down

0 comments on commit 8df4943

Please sign in to comment.