Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed "PropType is defined but prop is never used react/no-unused-prop-types" #1675

Merged
merged 5 commits into from Feb 6, 2018
Merged

Fixed "PropType is defined but prop is never used react/no-unused-prop-types" #1675

merged 5 commits into from Feb 6, 2018

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
Development

Successfully merging this pull request may close these issues.

None yet

2 participants