From 78ec577ca61ef657f67efcab751ee80c47d80965 Mon Sep 17 00:00:00 2001 From: Justin Anastos Date: Fri, 24 Nov 2017 08:18:41 -0500 Subject: [PATCH 1/2] test(no-unused-prop-types): Add `import` test with `Union` --- tests/lib/rules/no-unused-prop-types.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/lib/rules/no-unused-prop-types.js b/tests/lib/rules/no-unused-prop-types.js index 97ce57bebd..5eaf90de0d 100644 --- a/tests/lib/rules/no-unused-prop-types.js +++ b/tests/lib/rules/no-unused-prop-types.js @@ -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', + '} & FieldProps' + ].join('\n'), + parser: 'babel-eslint' }, { code: [ 'Card.propTypes = {', From 6323015242428a2f7e9b490b6e9ca07078a428a0 Mon Sep 17 00:00:00 2001 From: Justin Anastos Date: Fri, 24 Nov 2017 08:19:37 -0500 Subject: [PATCH 2/2] test(prop-types): Add `import` test with `Union` --- tests/lib/rules/prop-types.js | 37 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/tests/lib/rules/prop-types.js b/tests/lib/rules/prop-types.js index c16b7065f5..08153a711a 100644 --- a/tests/lib/rules/prop-types.js +++ b/tests/lib/rules/prop-types.js @@ -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', + '} & FieldProps' + ].join('\n'), + parser: 'babel-eslint' }, { code: [ 'Card.propTypes = {', @@ -1699,7 +1710,7 @@ ruleTester.run('prop-types', rule, { class Bar extends React.Component { props: Props; - + render() { return
{this.props.foo} - {this.props.bar}
} @@ -1715,7 +1726,7 @@ ruleTester.run('prop-types', rule, { class Bar extends React.Component { props: Props & PropsC; - + render() { return
{this.props.foo} - {this.props.bar} - {this.props.zap}
} @@ -1731,7 +1742,7 @@ ruleTester.run('prop-types', rule, { class Bar extends React.Component { props: Props & PropsC; - + render() { return
{this.props.foo} - {this.props.bar} - {this.props.zap}
} @@ -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
{this.props.bar} - {this.props.zap} - {this.props.baz}
} @@ -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
{this.props.bar} - {this.props.zap} - {this.props.baz}
} @@ -3453,7 +3464,7 @@ ruleTester.run('prop-types', rule, { class MyComponent extends React.Component { props: Props; - + render() { return
{this.props.foo} - {this.props.bar} - {this.props.fooBar}
} @@ -3472,7 +3483,7 @@ ruleTester.run('prop-types', rule, { class Bar extends React.Component { props: Props & PropsC; - + render() { return
{this.props.foo} - {this.props.bar} - {this.props.zap} - {this.props.fooBar}
} @@ -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
{this.props.bar} - {this.props.baz} - {this.props.fooBar}
} @@ -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
{this.props.bar} - {this.props.baz} - {this.props.fooBar}
}