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

Viewed 1212

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

1 Answers

You can add this to your eslint

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

This basically just allows all the renamed UNSAFE_ lifecycle methods.

Related