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

Update no-typos rule to check static lifecycle methods #2006

Merged
merged 2 commits into from Dec 28, 2019
Merged

Update no-typos rule to check static lifecycle methods #2006

merged 2 commits into from Dec 28, 2019

Conversation

bsonntag
Copy link
Contributor

@bsonntag bsonntag commented Oct 5, 2018

This updates the "no-typos" rule so that it checks for lifecycle methods that should be static, like getDerivedStateFromProps.

Closes #1999

lib/rules/no-typos.js Outdated Show resolved Hide resolved
}, {
code: `
class Hello extends React.Component {
getDerivedStateFromProps() { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's please add a "valid" rule for static getDerivedStateFromProps, and also an invalid one for static getDERIVEDStateFromProps :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test to check that static getDerivedStateFromProps is valid.

Regarding the second, there is already a test that checks static GetDerivedStateFromProps is invalid. Is it necessary to check static getDERIVEDStateFromProps too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as the checks cover a) the proper spelling and capitalization, b) any miscapitalization, c) any misspelling, and then those three with 1) static and 2) instance, then we should be good.

@bsonntag bsonntag closed this Oct 16, 2019
@ljharb ljharb reopened this Oct 16, 2019
@ljharb
Copy link
Member

ljharb commented Dec 13, 2019

@bsonntag i've rebased this; the tests are still failing. are you still interested in completing this PR?

@bsonntag
Copy link
Contributor Author

@ljharb not really, sorry.

ljharb and others added 2 commits December 27, 2019 15:38
This updates the `no-typos` rule so that it checks for lifecycle methods that should be static, like `getDerivedStateFromProps`.
@ljharb ljharb merged commit c1ed90e into jsx-eslint:master Dec 28, 2019
@bsonntag bsonntag deleted the enhancement/static-get-derived-state-from-props branch June 13, 2020 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Add new rule for getDerivedStateFromProps
2 participants