Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hank121314 committed Sep 24, 2020
2 parents e3d167e + 22cc878 commit 49e264a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 52 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
* [`prop-types`]: Detect JSX returned by sequential expression ([#2801][] @mikol)
* [`jsx-props-no-multi-spaces`]: "Expected no line gap between" false positive ([#2792][] @karolina-benitez)
* [`no-unknown-property`]: check attributes with any input case ([#2790][] @julienw)
* [`prop-types`]/[`no-unused-prop-types`]: handle CallExpression in ReturnType ([#2802][] @hank121314)

### Changed
* [Tests] [`jsx-one-expression-per-line`]: add passing tests ([#2799][] @TaLeaMonet)

[#2802]: https://github.com/yannickcr/eslint-plugin-react/pull/2802
[#2801]: https://github.com/yannickcr/eslint-plugin-react/pull/2801
[#2799]: https://github.com/yannickcr/eslint-plugin-react/pull/2799
[#2796]: https://github.com/yannickcr/eslint-plugin-react/pull/2796
Expand Down
104 changes: 52 additions & 52 deletions tests/lib/rules/no-unused-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -3645,7 +3645,7 @@ ruleTester.run('no-unused-prop-types', rule, {
type User = {
user: string;
}
type Props = User;
export default (props: Props) => {
Expand Down Expand Up @@ -3833,7 +3833,7 @@ ruleTester.run('no-unused-prop-types', rule, {
)
}
const mapDispatchToProps = (dispatch: ThunkDispatch<State, null, Action>) =>
const mapDispatchToProps = (dispatch: ThunkDispatch<State, null, Action>) =>
bindActionCreators(
{ prop1: importedAction, prop2: anotherImportedAction },
dispatch,
Expand Down Expand Up @@ -6391,11 +6391,11 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
z: string;
}
interface Bar extends Foo {
y: string;
}
const Baz = ({ x, y }: Bar) => (
<span>
{x}
Expand All @@ -6417,11 +6417,11 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
z: string;
}
interface Bar extends Foo {
y: string;
}
const Baz = ({ x, y }: Bar) => (
<span>
{x}
Expand All @@ -6439,11 +6439,11 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
x: number;
}
interface Bar extends Foo {
y: string;
}
const Baz = ({ x }: Bar) => (
<span>
{x}
Expand All @@ -6460,15 +6460,15 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
x: number;
}
interface Bar {
y: string;
}
interface Baz {
z:string;
}
const Baz = ({ x }: Bar & Foo & Baz) => (
<span>
{x}
Expand All @@ -6487,15 +6487,15 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
x: number;
}
interface Bar {
y: string;
}
interface Baz {
z:string;
}
const Baz = ({ x }: Bar & Foo & Baz) => (
<span>
{x}
Expand All @@ -6518,11 +6518,11 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
z: string;
}
interface Bar extends Foo {
y: string;
}
const Baz = ({ x }: Bar) => (
<span>
{x}
Expand All @@ -6543,11 +6543,11 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
z: string;
}
interface Bar extends Foo {
y: string;
}
const Baz = ({ x }: Bar) => (
<span>
{x}
Expand All @@ -6568,11 +6568,11 @@ ruleTester.run('no-unused-prop-types', rule, {
interface Foo {
z: string;
}
interface Foo {
y: string;
}
const Baz = ({ x }: Foo) => (
<span>
{x}
Expand All @@ -6596,22 +6596,22 @@ ruleTester.run('no-unused-prop-types', rule, {
type AgeProps = {
age: number;
}
type BirthdayProps = {
birthday: string;
}
type intersectionUserProps = AgeProps & BirthdayProps;
type Props = User & UserProps & intersectionUserProps;
export default (props: Props) => {
const { userId, user } = props;
if (userId === 0) {
return <p>userId is 0</p>;
}
return null;
};
`,
Expand All @@ -6635,22 +6635,22 @@ ruleTester.run('no-unused-prop-types', rule, {
type AgeProps = {
age: number;
}
type BirthdayProps = {
birthday: string;
}
type intersectionUserProps = AgeProps & BirthdayProps;
type Props = User & UserProps & intersectionUserProps;
export default (props: Props) => {
const { userId, user } = props;
if (userId === 0) {
return <p>userId is 0</p>;
}
return null;
};
`,
Expand All @@ -6666,10 +6666,10 @@ ruleTester.run('no-unused-prop-types', rule, {
const mapStateToProps = state => ({
books: state.books
});
interface InfoLibTableProps extends ReturnType<typeof mapStateToProps> {
}
const App = (props: InfoLibTableProps) => {
return <div></div>;
}
Expand All @@ -6684,10 +6684,10 @@ ruleTester.run('no-unused-prop-types', rule, {
const mapStateToProps = state => ({
books: state.books
});
interface InfoLibTableProps extends ReturnType<typeof mapStateToProps> {
}
const App = (props: InfoLibTableProps) => {
return <div></div>;
}
Expand All @@ -6702,11 +6702,11 @@ ruleTester.run('no-unused-prop-types', rule, {
const mapStateToProps = state => ({
books: state.books,
});
interface BooksTable extends ReturnType<typeof mapStateToProps> {
username: string;
username: string;
}
const App = (props: BooksTable) => {
return <div />;
}
Expand All @@ -6723,11 +6723,11 @@ ruleTester.run('no-unused-prop-types', rule, {
const mapStateToProps = state => ({
books: state.books,
});
interface BooksTable extends ReturnType<typeof mapStateToProps> {
username: string;
username: string;
}
const App = (props: BooksTable) => {
return <div />;
}
Expand All @@ -6742,9 +6742,9 @@ ruleTester.run('no-unused-prop-types', rule, {
{
code: `
interface BooksTable extends ReturnType<() => {books:Array<string>}> {
username: string;
username: string;
}
const App = (props: BooksTable) => {
return <div></div>;
}
Expand All @@ -6759,9 +6759,9 @@ ruleTester.run('no-unused-prop-types', rule, {
{
code: `
interface BooksTable extends ReturnType<() => {books:Array<string>}> {
username: string;
username: string;
}
const App = (props: BooksTable) => {
return <div></div>;
}
Expand All @@ -6776,9 +6776,9 @@ ruleTester.run('no-unused-prop-types', rule, {
{
code: `
type BooksTable = ReturnType<() => {books:Array<string>}> & {
username: string;
username: string;
}
const App = (props: BooksTable) => {
return <div></div>;
}
Expand All @@ -6793,9 +6793,9 @@ ruleTester.run('no-unused-prop-types', rule, {
{
code: `
type BooksTable = ReturnType<() => {books:Array<string>}> & {
username: string;
username: string;
}
const App = (props: BooksTable) => {
return <div></div>;
}
Expand All @@ -6812,11 +6812,11 @@ ruleTester.run('no-unused-prop-types', rule, {
type mapStateToProps = ReturnType<() => {books:Array<string>}>;
type Props = {
username: string;
username: string;
}
type BooksTable = mapStateToProps & Props;
const App = (props: BooksTable) => {
return <div></div>;
}
Expand All @@ -6833,11 +6833,11 @@ ruleTester.run('no-unused-prop-types', rule, {
type mapStateToProps = ReturnType<() => {books:Array<string>}>;
type Props = {
username: string;
username: string;
}
type BooksTable = mapStateToProps & Props;
const App = (props: BooksTable) => {
return <div></div>;
}
Expand All @@ -6848,7 +6848,7 @@ ruleTester.run('no-unused-prop-types', rule, {
}, {
message: '\'username\' PropType is defined but prop is never used'
}]
}]),
},
// Issue: #2795
{
code: `
Expand Down Expand Up @@ -6879,7 +6879,7 @@ ruleTester.run('no-unused-prop-types', rule, {
errors: [{
message: '\'prop1\' PropType is defined but prop is never used'
}]
}
}])

/* , {
// Enable this when the following issue is fixed
Expand Down

0 comments on commit 49e264a

Please sign in to comment.