javascript - React JS - ESLint - 使用 UNSAFE_componentWillMount、UNSAFE_componentWillUpdate 和 UNSAFE_componentWillReceiveProps 忽略组件的规则
问题描述
目前,我收到这些 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-comp
规则camelcase
,任何线索/帮助将不胜感激
解决方案
您可以将其添加到您的 eslint
"camelcase": [
"error", {
"ignoreDestructuring": true,
"allow": [ "^UNSAFE_" ]
}
],
这基本上只允许所有重命名的UNSAFE_
生命周期方法。
推荐阅读
- c - 查找最大数的索引
- javascript - 如何修复 MongoDB 连接上的“MongoParseError: Multiple text records not allowed at ...”
- r - 如何用 igraph 计算最大瓶颈路径?
- r - Why manual autocorrelation does not match acf() results?
- c# - 启用将警告视为每个文件的错误
- xpath - Scrapy:以字符串和/或整数形式获取 HTML 类?
- bash - 如何使用目录中的文件前缀动态定义路径?
- java - 出现错误 - 没有符合条件的 bean 类型
- javascript - 如何在 Puppeteer 中找到 document.activeElement
- java - 偶尔而不是强制验证 Json(Entity)