My eslint config:
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"linebreak-style": [
"error",
"unix"
],
"no-console": "warn"
}
}
eslint: v5.0.1
eslint-plugin-react: 7.10.0
You don鈥檛 seem to be setting a React version number in settings - in what way is the rule not working for you? If you鈥檙e asking about React 16 deprecations, you鈥檇 have to be using v16.3+.
I am using react: v16.3.0.
For example when I am using these lifecycle methods it should give me error right?
componentWillMount() { }
componentWillReceiveProps() { }
componentWillUpdate() { }
The eslint plugin can鈥檛 know which version you鈥檙e using unless you explicitly tell it in your eslint config. See https://github.com/yannickcr/eslint-plugin-react#configuration
Now my config is looks like, but this not working too:
{
"env": {
"browser": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"rules": {
"linebreak-style": [
"error",
"unix"
],
"no-console": "warn"
},
"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "16.3.0",
"flowVersion": "0.53"
},
"propWrapperFunctions": [
"forbidExtraProps"
]
}
}
ahhh - so no those methods aren't warned by this plugin yet, mainly because there's not yet a complete replacement for all of their use cases.
They'll continue to work in React 17, so there's no hurry to move away from them.
Someone is getting warnings because of this #1833 ? What about #1864? Can i use it in my project?
React itself might be giving these warnings, but I don't think we've enabled them here yet.
In this case why it is mentioned in README (recommended settings)?

There are many deprecated things beyond those three new lifecycle methods.
What about this ?

ha, ok, then in that case it should be warning. What if you set your version to 16.4?
I mean, changing the eslint config. The version of React you鈥檙e actually using is irrelevant; the plugin only knows about what鈥檚 in your settings.
Sure.
"settings": {
"react": {
"createClass": "createReactClass",
"pragma": "React",
"version": "16.4.1",
"flowVersion": "0.53"
},
"propWrapperFunctions": [
"forbidExtraProps"
]
}
same result here.
Can you share the entire component code that鈥檚 not warning, but should be?
What happens if you extend React.Component, instead of the destructured Component?
@ljharb Nothing changed. Still the same.
This is very confusing, given the tests: https://github.com/yannickcr/eslint-plugin-react/blob/master/tests/lib/rules/no-deprecated.js
Thanks. I managed to solve this problem. Now it works. I think my (old) global eslint was conflicting with local eslint.
Definitely you want to uninstall any global eslint stuff; almost everything should only be installed locally. Glad you figured it out!
Most helpful comment
Thanks. I managed to solve this problem. Now it works. I think my (old) global eslint was conflicting with local eslint.