jsx-eslint/eslint-plugin-react

New rule: lifecycle param name

Offen

#2.289 geöffnet am 25.05.2019

 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)JavaScript (2.731 Forks)batch import
acceptedhelp wantednew rule

Repository-Metriken

Stars
 (9.293 Sterne)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

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