Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Repro: Unused PropTypes detects flow destructuring #977

Merged
merged 1 commit into from Dec 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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