Skip to content

PropType validation errors when using custom validators #145

Closed
@HurricaneJames

Description

This just started happening when I updated recently, I think I was on v2.2 or 2.3 previously. I believe the issue is related to #134.

var React = require('react')
  , ImmutablePropTypes = require('react-immutable-proptypes');

var MyComponent = React.createClass({
  displayName: 'MyComponent',
  propTypes: {
    immutableObject: ImmutablePropTypes.shape({
      xyz: React.PropTypes.string
    })
  },
  render: function() {
    return <div className={this.props.immutableObject.get('xyz')} />;
  }
});

module.exports = MyComponent;

eslint-react-plugin will complain that 'immutableObject.get' is missing in props validation (react/prop-types).

As you can see, I'm using a custom validator for immutable.js classes, where the default React.PropTypes.shape does not work. I know a lot of people use the react-immutable-proptypes library, so this is going to affect quite a few people if they are also trying to lint with the latest eslint.

I like where object shape validation is going, but it should probably have a separate flag to enable/disable that feature or limit it to props defined with React.PropTypes.shape. I do not wish to turn off validator linting completely, but at the same time it is completely broken when using a custom validator.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions