jsx-eslint/eslint-plugin-react

New rule: lifecycle param name

Open

#2289 aperta il 25 mag 2019

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)JavaScript (2797 fork)batch import
acceptedhelp wantednew rule

Metriche repository

Star
 (8630 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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`.
}

Guida contributor