【问题标题】:React JS - ESLint - Rules for ignoring components with UNSAFE_componentWillMount, UNSAFE_componentWillUpdate, and UNSAFE_componentWillReceivePropsReact JS - ESLint - 使用 UNSAFE_componentWillMount、UNSAFE_componentWillUpdate 和 UNSAFE_componentWillReceiveProps 忽略组件的规则
【发布时间】:2019-05-19 12:50:46
【问题描述】:

目前,我遇到了这些 linting 错误:

ESLint: UNSAFE_componentWillUpdate should be placed after someFunction (react/sort-comp)

ESLint: Identifier 'UNSAFE_componentWillUpdate' is not in camel case. (camelcase)

目前,我找不到要添加到 .eslintrc 以应用于前置 UNSAFE_ 组件生命周期的正确规则。我正在尝试使其适用于 react/sort-compcamelcase 规则,任何线索/帮助将不胜感激

【问题讨论】:

    标签: javascript html reactjs frontend eslint


    【解决方案1】:

    你可以把它添加到你的 eslint

    "camelcase": [
      "error", {
        "ignoreDestructuring": true,
        "allow": [ "^UNSAFE_" ]
      }
    ],
    

    这基本上只允许所有重命名的UNSAFE_ 生命周期方法。

    【讨论】:

    • eslint 配置文件在哪里?编辑:在项目根文件夹:/.eslintrc 规则下需要添加代码:part
    猜你喜欢
    • 1970-01-01
    • 2021-01-15
    • 1970-01-01
    • 2018-01-08
    • 2018-05-27
    • 1970-01-01
    • 2020-05-10
    • 2017-05-10
    • 2019-02-10
    相关资源
    最近更新 更多