Please describe the origin of the rule here.
By default, this rule aims to limit the use of React un-prefixed deprecated lifecycle methods including in componentWillMount
, componentWillReceiveProps
, componentWillUpdate
. Check out React Post at here
Examples of incorrect code for this rule:
class Hello extends React.Component {
componentWillMount() { ... } // deprecated lifecycle
componentWillReceiveProps() { ... } // deprecated lifecycle
componentWillUpdate() { ... } // deprecated lifecycle
}
Examples of correct code for this rule:
class Hello extends React.Component {
UNSAFE_componentWillMount() { ... }
UNSAFE_componentWillReceiveProps() { ... }
UNSAFE_componentWillUpdate() { ... }
}
This rule can take one argument to customize the components organization.
...
"jam3/forbid-methods": <enabled>
...
or
...
"jam3/forbid-methods": [<enabled>, { forbiddenMethods: <forbiddenMethods>}]
...
enabled
: for enabling the rule. 0=off, 1=warn, 2=error. Defaults to 0.forbiddenMethods
: optional array of forbidden method(s).
The default configuration is:
{
forbiddenMethods: [
]
}
You can override this configuration to match your needs.
For example, if you want to block additional methods:
"jam3/forbid-methods": [2, {
forbiddenMethods: [
'additionalForbiddenMethods1',
'additionalForbiddenMethods2'
]
}]