简体   繁体   English

React JS - ESLint - 使用 UNSAFE_componentWillMount、UNSAFE_componentWillUpdate 和 UNSAFE_componentWillReceiveProps 忽略组件的规则

[英]React JS - ESLint - Rules for ignoring components with UNSAFE_componentWillMount, UNSAFE_componentWillUpdate, and UNSAFE_componentWillReceiveProps

Currently, I'm getting these linting errors:目前,我收到这些 linting 错误:

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

and

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

Currently, I'm not able to find the correct rules to add to .eslintrc to apply to the prepended UNSAFE_ component lifecycles.目前,我无法找到正确的规则来添加到.eslintrc以应用于前置的UNSAFE_组件生命周期。 I'm trying to make it apply to both react/sort-comp and camelcase rules, any clues/help would be appreciated我正在尝试使其同时适用于react/sort-compcamelcase规则,任何线索/帮助将不胜感激

You can add this to your eslint您可以将此添加到您的 eslint

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

This basically just allows all the renamed UNSAFE_ lifecycle methods.这基本上只允许所有重命名的UNSAFE_生命周期方法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用React 16.3.2时未调用UNSAFE_componentWillReceiveProps - UNSAFE_componentWillReceiveProps not called when using React 16.3.2 在严格模式下使用 UNSAFE_componentWillReceiveProps 的反应警告 - React warning for Using UNSAFE_componentWillReceiveProps in strict mode 修复 'index.js:1 警告:不建议在严格模式下使用 UNSAFE_componentWillReceiveProps,这可能表明您的代码中存在错误' - Fixing 'index.js:1 Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code' in react @typescript-eslint/no-unsafe-* 规则的新 eslint 错误 - New eslint errors with the @typescript-eslint/no-unsafe-* rules @typescript-eslint/no-unsafe-assignment:任何值的不安全赋值 - @typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value ESLint:“any”的不安全分配和“any”类型值的不安全调用 - ESLint: Unsafe assignment of an `any` and Unsafe call of an `any` typed value 如何找出哪个 package 正在使用 UNSAFE componentWillMount 方法? - How to find out which package is using the UNSAFE componentWillMount method? 为什么内联JS块不安全? - Why are inline JS blocks unsafe? 什么使不安全的脚本“不安全”? - What makes an unsafe script “unsafe”? Typescript:ESLint:任何类型值的不安全返回 @typescript-eslint/no-unsafe-return - Typescript : ESLint : Unsafe return of an any typed value @typescript-eslint/no-unsafe-return
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM