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

[New Rule] Check propTypes are static #1896

Closed
pke opened this issue Jul 23, 2018 · 2 comments
Closed

[New Rule] Check propTypes are static #1896

pke opened this issue Jul 23, 2018 · 2 comments

Comments

@pke
Copy link

pke commented Jul 23, 2018

You get this runtime warning:

warning: propTypes was defined as an instance property on MyComponent. Use a static property to define propTypes instead.

when you forget to make the propTypes static like this:

class MyComponent extends React.PureComponent {
  propTypes = {
    text: PropTypes.string,
  }
}

The new rule could detect non-static propTypes inside class definitions and report them by default as warning.

@ljharb
Copy link
Member

ljharb commented Jul 23, 2018

This seems like something no-typos should be handling.

@ljharb
Copy link
Member

ljharb commented Feb 6, 2022

Indeed, no-typos already handled this over a year before this was filed (see #1209)

@ljharb ljharb closed this as completed Feb 6, 2022
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

2 participants