jsx-eslint/eslint-plugin-react

New rule: lifecycle param name

Open

#2,289 opened on May 25, 2019

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (2,797 forks)batch import
acceptedhelp wantednew rule

Repository metrics

Stars
 (8,630 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

The rule enforces that lifecycle parameter names exactly matches the well known names. For example, a prevProps should not be named as props, because people might confuse it with this.props.

This are considered warnings:

class Foo extends Component {
  componentDidUpdate(props) {}
//                   ~~~~~ Error: should be `prevProps`.
  shouldComponentUpdate(prevProps, nextState) {}
//                      ~~~~~~~~~ Error: should be `nextProps`.
}

Contributor guide