Eslint-plugin-react: React 16 lifecycle errors appearing in a React 15 project

Created on 12 May 2018  路  6Comments  路  Source: yannickcr/eslint-plugin-react

I'm getting react/no-deprecated componentWillReceiveProps errors in a React 15 project 馃槩

enhancement help wanted react 16

Most helpful comment

Thanks @ljharb, I wasn't aware of the pragma setting!

From my perspective, having my linter (and therefore, my build) break due to a changing default in this plugin was not a fun thing to discover. I do see that the plugin documents its changing default React target version (React version, default to the latest React stable release).

Perhaps a warning if a pragma is not present would provide a better experience than finding out the hard way when something like this happens?

All 6 comments

https://github.com/swagger-api/swagger-ui/blob/d256ae87d310b40fb9fd5cc52ec2aa7db55b28ca/.eslintrc Doesn鈥檛 specify a react version pragma, so as far as eslint is concerned, it鈥檚 a React 16.3 project.

If you specify your react version, you鈥檒l get appropriate error messages.

Thanks @ljharb, I wasn't aware of the pragma setting!

From my perspective, having my linter (and therefore, my build) break due to a changing default in this plugin was not a fun thing to discover. I do see that the plugin documents its changing default React target version (React version, default to the latest React stable release).

Perhaps a warning if a pragma is not present would provide a better experience than finding out the hard way when something like this happens?

Adding a warning for that sounds like a great idea.

We have faced same error messages with react 16.2. Adding react version to .eslintrc file fixed the problem.

{
...
  "settings": {
    "react": {
      "version": "16.2.0"
    },
  }
...
}

Adding the react version is good to know, however like @shockey said, this isn't great behaviour. Ideally, any rules that are modified to break where they didn't before should be breaking changes rather than something that gets picked - usually automatically with a minor bump

@alasdairhurst there's always cases, however, where that constitutes a bugfix - ie, the bug was "it wasn't warning" and now it is.

Was this page helpful?
0 / 5 - 0 ratings