This rule allows you to forbid some member expression usage and suggests some alternative. The good use case for this rule is for example when some library deprecates some of it's api methods and suggest you to use other.
Let's consider we have this configuration in .eslintrc
:
{
"plugins": ["deprecate"],
"rules": {
"deprecate/member-expression": ["error",
{"name": "React.createClass", "use": "native es6 classes"}
]
}
}
import React from 'react';
// React.createClass is deprecated
var Component = React.createClass({
mixins: [MixinA],
render() {
return <Child />;
}
});
You can just pass deprecated member expression strings as strings:
"deprecate/member-expression": [ 2, "<member expression str1>", "<member expression str1>"]
If you want more control over displayed errors (suggest alternative module import e.t.c) you can pass objects instead of just modules names:
"deprecate/member-expression": [ 2,
{"name": "<member expression str1>", "use": "<suggested alternative>"}, ... ]
name key is used for consistency with other deprecate functions
When you don't want to forbid some member expressions in your code.