eslint: Schema JSON validation fails with ESLint 4.2.0
Tell us about your environment
- ESLint Version: 4.2.0
- Node Version: 6.9.2
- npm Version: 3.10.2
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration: N/A
What did you do? Please include the actual source code causing the issue.
It seems that ESLint has upgraded its JSON validator for 4.2.0: eslint/eslint#8852
Note: It’s only a guess that the above change has caused the problems, but it’s not fully confirmed.
This is causing issues for a rule in eslint-plugin-react
:. It seems that the following schema validation is causing problems: https://github.com/yannickcr/eslint-plugin-react/blob/master/lib/rules/jsx-curly-spacing.js#L34
The produced error:
can't resolve reference #/definitions/basicConfig from id #
can't resolve reference #/definitions/basicConfigOrBoolean from id #
Warning: [object Object]:
Configuration for rule "react/jsx-curly-spacing" is invalid:
refVal[2] is not a function Use --force to continue.
at validateRuleOptions (node_modules\eslint\lib\config\config-validator.js:112:15)
at Object.keys.forEach.id (node_modules\eslint\lib\config\config-validator.js:152:9)
at Array.forEach (native)
at validateRules (node_modules\eslint\lib\config\config-validator.js:151:30)
at Object.validate (node_modules\eslint\lib\config\config-validator.js:206:5)
at runRuleForItem (node_modules\eslint\lib\testers\rule-tester.js:331:23)
at testValidTemplate (node_modules\eslint\lib\testers\rule-tester.js:413:28)
at Context.RuleTester.it (node_modules\eslint\lib\testers\rule-tester.js:546:25)
The issue can be reproduced by cloning the eslint-plugin-react
repo and running npm run test
.
What did you expect to happen?
No errors.
What actually happened? Please include the actual, raw output from ESLint.
See above.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 10
- Comments: 24 (7 by maintainers)
Commits related to this issue
- affixed-ids: correct schema for options Required for eslint 4.2+. See: https://github.com/eslint/eslint/issues/8908 — committed to pabigot/eslint-plugin-pabigot by pabigot 7 years ago
@mysticatea Ajv is supposed to ignore missing $ref, will release a fix.
I think this can be closed now, right?
https://github.com/yannickcr/eslint-plugin-react/pull/1292 Is merged but we are awaiting a release
Cool thanks guys for your help. Special thanks to @epoberezkin for his help.
It should have been unusable if the configuration was set in such a way that it crashes during schema validation (triggering the bug that has now been fixed in
ajv
).I’m guessing most users did not have such a “complicated configuration”? Although the issue on
eslint-plugin-react
has a few references to other Github repo issues.Also the bug would only occur when upgrading
eslint
. So anyone with locked dependency versions and a “broken configuration” wouldn’t have had the issue yet, right?I created PR for
eslint-plugin-react
to change the schema to full JSON object, just like you guys did with thecomma-dangle
rule foreslint
.@jseminck Was a PR created for eslint-plugin-react to address this issue? I can’t seem to find it.
I’ll make a PR to
eslint-plugin-react
as well to use full json schema object instead of an array. Thanks for the quick response and good explanations. TIL alot 😄The only thing I still fail to understand completely is why the
$ref
doesn’t work for theschema
when it is anarray
. As I understood from the PR comments, theschema array
is being transformed into:But why don’t the
definitions
insideobj
not work with this schema?