Skip to content

New rule: no-invalid-default-props #1022

Closed
@ljharb

Description

@ljharb

I'd like a rule that errors if anything is in defaultProps that is not also in propTypes.

This came up with the following code:

Component.propTypes = {
  fooValue: PropTypes.string,
};
Component.defaultProps = {
  foo: '',
};

In other words, it was a partially completed prop rename.

This rule should also look up a propTypes variable (Component.propTypes = propTypes) defined elsewhere in the file.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions