Eslint-plugin-react: Unexpected errors if Flow types were defined

Created on 21 Feb 2019  路  6Comments  路  Source: yannickcr/eslint-plugin-react

Hello!
I've updated from [email protected] to [email protected] and I got some new specific errors. I got unexpected react/no-unused-prop-types error on 5 and 6 lines in the next code listing.

// @flow
import React from 'react';

export type ChildComponentProps = {
    value: string,
    name: string
};

export const ParentComponent = ({arrayOfSmth}: Object) => {
    return (
        <div>
            {arrayOfSmth.map(({value, name}: ChildComponentProps) => {
                return (
                    <span>
                        {name ? value : <Text>{name}</Text>}
                    </span>
                );
            })}
        </div>
    );
};
5:12  error    'value' PropType is defined but prop is never used  react/no-unused-prop-types
6:11  error    'name' PropType is defined but prop is never used   react/no-unused-prop-types

Is it expected behavior for my case?

bug flow help wanted

Most helpful comment

I have a very similar issue:

class SomeComponent extends PureComponent<Props> {
    method({ param }: { param: boolean }) {

    }

    render() {
        return null;
    }
}
'param' PropType is defined but prop is never used  react/no-unused-prop-types

Workaround: the issue disappears if I don't destructure the parameters method(dontDestructure: { param: boolean }) {

All 6 comments

That鈥檚 very strange indeed, seems like a bug.

Also, have the same issue.

I have a very similar issue:

class SomeComponent extends PureComponent<Props> {
    method({ param }: { param: boolean }) {

    }

    render() {
        return null;
    }
}
'param' PropType is defined but prop is never used  react/no-unused-prop-types

Workaround: the issue disappears if I don't destructure the parameters method(dontDestructure: { param: boolean }) {

I think you mean destructure; spread is three dots.

You're right, I totally meant destructure. I've edited my message.

Have the same issue here:

const Wrapper = featureToggle
? ({ children }: { children: Node }) => (
  <FeatureToggledComponent
      featureToggle={featureToggle}
      defaultValue
  >
      {children}
  </FeatureToggledComponent>
)
: React.Fragment;

75:54 error 'children' PropType is defined but prop is never used react/no-unused-prop-types

Was this page helpful?
0 / 5 - 0 ratings