eslint-plugin-react icon indicating copy to clipboard operation
eslint-plugin-react copied to clipboard

Skip shape props in flow

Open Agontuk opened this issue 8 years ago • 4 comments

Fixes shape type props issue for flow.

Agontuk avatar Feb 09 '17 06:02 Agontuk

I forgot to run the unit test, I'll check and try to update as soon as possible.

Agontuk avatar Feb 09 '17 06:02 Agontuk

There's some test for flow which give error for unused shape prop types. Example:

class Hello extends React.Component {
    props: {
        name: {
            unused: string
        }
    }

    render () {
        return <div>Hello {this.props.name.lastname}</div>;
    }
}

But in my case, even if I use the prop it gives me error. Here's a example of my component:

type Props = {
    position: {
        x: number,
        y: number
    }
};

class Example extends Component {
    props: Props

    render() {
        const { position } = this.props;

        return (
            <div style={ { left: position.x, top: position.y } }>Hello World</div>
        );
    }
}

This gives me error position.x prop is defined but never used. Since currently there's a issue with detecting shape props, should I remove those test cases ? Or just use eslint-disable-line from my end ?

Agontuk avatar Feb 09 '17 07:02 Agontuk

@Agontuk hi! this PR still needs some tests; any interest in adding some?

ljharb avatar Dec 13 '19 23:12 ljharb

@ljharb sorry for the late response, unfortunately I'm not using flow for quite a while. So it's difficult for me to add the required test cases. I hope someone can pick it up and make the required changes.

Agontuk avatar Feb 03 '20 18:02 Agontuk