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

Some rules for prop-types are false positive in switch/case component #2118

Closed
g4g1 opened this issue Jan 4, 2019 · 0 comments
Closed

Some rules for prop-types are false positive in switch/case component #2118

g4g1 opened this issue Jan 4, 2019 · 0 comments
Assignees

Comments

@g4g1
Copy link

g4g1 commented Jan 4, 2019

Example:

import PropTypes from 'prop-types';
import React from 'react';

const MyComponent= (props) => {
  switch (props.usedProp) {
    case 1:
      return (<div />);
    default:
      return <div />;
  }
};

MyComponent.propTypes = {
  unUsedProp: PropTypes.string,
};

MyComponent.defaultProps = {
};

export default MyComponent;

Code should throw 3 errors:
react/prop-types (usedProp missing in props)
react/required-default-props (for unUsedProp)
react/no-unused-prop-types (for unUsedProp)
but it seems ok for eslint

@yannickcr yannickcr self-assigned this Jan 6, 2019
This was referenced Jan 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants