Skip to content

no-unused-prop-types wrong detection #871

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

Closed
Kepro opened this issue Sep 29, 2016 · 2 comments
Closed

no-unused-prop-types wrong detection #871

Kepro opened this issue Sep 29, 2016 · 2 comments

Comments

@Kepro
Copy link

Kepro commented Sep 29, 2016

33:13 error 'config.type' PropType is defined but prop is never used react/no-unused-prop-types

my code is

  static propTypes = {
    config: PropTypes.shape({
      type: PropTypes.string.isRequired,
    }),
  };

and then I have a method

  getOptions(setValue, options = []) {
    const { config } = this.props;
   if (config.type === 'boolean') {
@dsernst
Copy link

dsernst commented Sep 30, 2016

I'm seeing this as well:

export default function AuthScreen({ auth }) {
  return (
    <Text style={s.bodyText}>
      Hello, {auth.full_name}
    </Text>
  )
}

AuthScreen.propTypes = {
  auth: React.PropTypes.shape({
    full_name: React.PropTypes.string.isRequired,
  }),
}

eslint error:

17:16  error  'auth.full_name' PropType is defined but prop is never used  react/no-unused-prop-types

@EvHaus
Copy link
Collaborator

EvHaus commented Sep 30, 2016

The no-unused-prop-types rule does not support shape props at the moment as such detection is very difficult. If you use shape props, I recommend setting the skipShapeProps option to true on the rule.

Duplicate of #819. Will track further discussion of shape props there.

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

No branches or pull requests

3 participants