mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
## Summary While working on a plugin that was just using the Kibana eslint config, I saw a stream of these messages: > Warning: React version specified in eslint-plugin-react-settings must be a string; got “object” Looking into our eslint config, I noticed we're using `semver.coerce` to get the version from the `package.json` file in Kibana. This looked right, except that method actually returns an object: ```js const ver = semver.coerce('^16.8.0'); console.log(ver); ``` That produces: ``` SemVer { options: { loose: false, includePrerelease: false }, loose: false, raw: '16.8.0', major: 16, minor: 8, patch: 0, prerelease: [], build: [], version: '16.8.0' } ``` The [semver package](https://www.npmjs.com/package/semver) includes some examples where they wrap that value in `semver.valid`, which produces a string and fixes the warning. ```js const ver = semver.valid(semver.coerce('^16.8.0')); console.log(ver); // outputs 16.8.0 ``` ### So why don't we see this warning in Kibana? I'm not sure, but I suspect it's because it's a console warning and our tooling prevents that output from showing up. This change stops the warning output when you run eslint in my plugin though. UPDATE: After some more digging, it looks like it's related to the version override in Kibana's eslintrc. Removing the override stops the linter from running, without the changes in this PR.
This commit is contained in:
parent
6e77320926
commit
000ae6b292
2 changed files with 1 additions and 5 deletions
|
@ -41,10 +41,6 @@ module.exports = {
|
|||
forceNode: true,
|
||||
},
|
||||
},
|
||||
|
||||
react: {
|
||||
version: '16.3',
|
||||
},
|
||||
},
|
||||
|
||||
rules: {
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
|
||||
settings: {
|
||||
react: {
|
||||
version: semver.coerce(PKG.dependencies.react),
|
||||
version: semver.valid(semver.coerce(PKG.dependencies.react)),
|
||||
},
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue