Skip to content

Commit

Permalink
Merge pull request #1570 from justinanastos/fix/prop-types-union-flow…
Browse files Browse the repository at this point in the history
…type-1468

[Tests] Add flow `Union` tests for `no-unused-prop-types` and `prop-types` with `import`
  • Loading branch information
ljharb committed Nov 24, 2017
2 parents 115e4b9 + 6323015 commit e5e4536
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
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

0 comments on commit e5e4536

Please sign in to comment.