Skip to content

Conversation

yuri-sakharov
Copy link
Contributor

@yuri-sakharov yuri-sakharov commented Feb 3, 2018

We got PropType is defined but prop is never used react/no-unused-prop-types when used createReactClass.
Added fix, tests and removed 2 duplicated tests.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! For each of the tests you added (that use babel-eslint), could you add duplicate tests that use the default parser?

@yuri-sakharov
Copy link
Contributor Author

Yes, of course.

@yuri-sakharov
Copy link
Contributor Author

Added requested tests.

@yuri-sakharov
Copy link
Contributor Author

yuri-sakharov commented Feb 4, 2018

@ljharb what about this case:

class Hello extends Component { static propTypes = { something: PropTypes.bool } componentWillUpdate (nextProps, nextState) { const {something} = nextProps; } } 

does it should throw error or not?

@ljharb
Copy link
Member

ljharb commented Feb 4, 2018

That syntax requires babel-eslint; but we should have a test with the default parser that covers Hello.propTypes = { … } instead.

@yuri-sakharov
Copy link
Contributor Author

@ljharb is it the same

code: [ 'var Hello = createReactClass({', ' propTypes: {', ' something: PropTypes.bool,', ' },', ' componentWillReceiveProps (nextProps) {', ' const {something} = nextProps;', ' doSomething(something);', ' }', '})' ].join('\n'), parser: 'babel-eslint' 

and

code: [ 'var Hello = createReactClass({', ' propTypes: {', ' something: PropTypes.bool,', ' },', ' componentWillReceiveProps (nextProps) {', ' const {something} = nextProps;', ' doSomething(something);', ' }', '})' ].join('\n') 

?
will all use parser: 'babel-eslint'?

@ljharb
Copy link
Member

ljharb commented Feb 6, 2018

yep, those all look the same :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants