简体   繁体   中英

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

Currently, I'm getting these linting errors:

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. I'm trying to make it apply to both react/sort-comp and camelcase rules, any clues/help would be appreciated

You can add this to your eslint

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

This basically just allows all the renamed UNSAFE_ lifecycle methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM