-
Notifications
You must be signed in to change notification settings - Fork 213
Set a more recent React version for eslint-plugin-react #1155
Comments
I'm leaning towards (1) and listing the version setting in the |
As mentioned in IRC, another option would be to read the version of |
A 6th option (hehe), would be to do what CRA does, and set a version of We could then update the use: [
['@neutrinojs/airbnb', {
eslint: {
settings: {
react: {
// Default to the enabling rules for the latest version of React
version: '999.999.999',
}
},
}
}]
] |
So far option 6 seems like the best choice, thoughts? |
Yeah I agree (6) seems best. However fixing this is blocked on fixing the issues mentioned in #382 (comment), since it's not currently possible to set |
I have the branch for this ready locally, but it's blocked on the review/merge of #1182. |
Several of the `eslint-plugin-react` rules use the specified React version to determine what warnings/errors to show (for example only showing deprecation warnings for certain features if using a newer version of React). Not setting a version, or setting one that's older than the version of React being used means that valid warnings/errors may not actually be shown. Whilst `eslint-plugin-react` helpfully outputs a warning if an explicit React version has not been specified, several popular presets (such as `eslint-config-airbnb` and `eslint-config-standard-react`) set a default version of `16.0`, which results in many rules being disabled. As such, we're using the trick used by CRA, of setting the version to `999.999.999`, which ends up being interpreted as "latest version" by `eslint-plugin-react`'s rules. Fixes #1155.
The eslint-plugin-react plugin takes a
version
option, which describes the React version used by a project, which helps rules decide which React features are available.By default, no
version
is specified, which results in a warning:https://github.com/yannickcr/eslint-plugin-react/blob/8f2663ed42860bb477d4720335674cf892ea65c5/lib/util/version.js#L16-L18
However when using via the AirBnB React config, then the version defaults to 16.0:
https://github.com/airbnb/javascript/blob/24da5bb540de12117bcdfa7b6d8ce3c0ff4b6504/packages/eslint-config-airbnb/rules/react.js#L462-L465
This suppresses the "no version set warning" and means that the rules are less strict than if set at a more recent version of React, such as
16.5
. eg:https://github.com/yannickcr/eslint-plugin-react/blob/7dce90a4f570847b33eaefddb8d9bb7d6eca9dc5/lib/rules/no-unsafe.js#L29-L32
https://github.com/yannickcr/eslint-plugin-react/blob/f27285f994291b450796303d461558ee91fffe47/lib/rules/no-deprecated.js#L80
I think that Neutrino's AirBnb preset should either:
16.5
) out of the box (and mention in the docs)16.5
16.0
default@eliperelman, thoughts?
The text was updated successfully, but these errors were encountered: