jsx-eslint/eslint-plugin-react

New rule: lifecycle param name

Open

#2,289 创建于 2019年5月25日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)JavaScript (2,797 fork)batch import
acceptedhelp wantednew rule

仓库指标

Star
 (8,630 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南