jsx-eslint/eslint-plugin-react

New rule: lifecycle param name

Open

#2,289 建立於 2019年5月25日

在 GitHub 查看
 (2 留言) (0 反應) (0 負責人)JavaScript (8,630 star) (2,797 fork)batch import
acceptedhelp wantednew rule

描述

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

貢獻者指南