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

Add flow Union tests for no-unused-prop-types and prop-types with import #1570

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,17 @@ ruleTester.run('no-unused-prop-types', rule, {
'}'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'import type { FieldProps } from "redux-form"',
'',
'type Props = {',
'label: string,',
' type: string,',
' options: Array<SelectOption>',
'} & FieldProps'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'Card.propTypes = {',
Expand Down
37 changes: 24 additions & 13 deletions tests/lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,17 @@ ruleTester.run('prop-types', rule, {
'}'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'import type { FieldProps } from "redux-form"',
'',
'type Props = {',
'label: string,',
' type: string,',
' options: Array<SelectOption>',
'} & FieldProps'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'Card.propTypes = {',
Expand Down Expand Up @@ -1699,7 +1710,7 @@ ruleTester.run('prop-types', rule, {

class Bar extends React.Component {
props: Props;

render() {
return <div>{this.props.foo} - {this.props.bar}</div>
}
Expand All @@ -1715,7 +1726,7 @@ ruleTester.run('prop-types', rule, {

class Bar extends React.Component {
props: Props & PropsC;

render() {
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap}</div>
}
Expand All @@ -1731,7 +1742,7 @@ ruleTester.run('prop-types', rule, {

class Bar extends React.Component {
props: Props & PropsC;

render() {
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap}</div>
}
Expand All @@ -1743,12 +1754,12 @@ ruleTester.run('prop-types', rule, {
type PropsA = { bar: string };
type PropsB = { zap: string };
type Props = PropsA & {
baz: string
baz: string
};

class Bar extends React.Component {
props: Props & PropsB;

render() {
return <div>{this.props.bar} - {this.props.zap} - {this.props.baz}</div>
}
Expand All @@ -1760,12 +1771,12 @@ ruleTester.run('prop-types', rule, {
type PropsA = { bar: string };
type PropsB = { zap: string };
type Props = {
baz: string
baz: string
} & PropsA;

class Bar extends React.Component {
props: Props & PropsB;

render() {
return <div>{this.props.bar} - {this.props.zap} - {this.props.baz}</div>
}
Expand Down Expand Up @@ -3453,7 +3464,7 @@ ruleTester.run('prop-types', rule, {

class MyComponent extends React.Component {
props: Props;

render() {
return <div>{this.props.foo} - {this.props.bar} - {this.props.fooBar}</div>
}
Expand All @@ -3472,7 +3483,7 @@ ruleTester.run('prop-types', rule, {

class Bar extends React.Component {
props: Props & PropsC;

render() {
return <div>{this.props.foo} - {this.props.bar} - {this.props.zap} - {this.props.fooBar}</div>
}
Expand All @@ -3487,12 +3498,12 @@ ruleTester.run('prop-types', rule, {
type PropsB = { bar: string };
type PropsC = { zap: string };
type Props = PropsB & {
baz: string
baz: string
};

class Bar extends React.Component {
props: Props & PropsC;

render() {
return <div>{this.props.bar} - {this.props.baz} - {this.props.fooBar}</div>
}
Expand All @@ -3507,12 +3518,12 @@ ruleTester.run('prop-types', rule, {
type PropsB = { bar: string };
type PropsC = { zap: string };
type Props = {
baz: string
baz: string
} & PropsB;

class Bar extends React.Component {
props: Props & PropsC;

render() {
return <div>{this.props.bar} - {this.props.baz} - {this.props.fooBar}</div>
}
Expand Down