-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Update: replace stacktrace by a clear message when invalid plugins are provided (fixes #10927) #10928
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
204f6f0
to
fe1c838
Compare
thanks for the PR! 😄 the config is here: Line 13 in 066f7e0
|
When an invalid config type for "plugins" is provided in eslintrc.json, like an array or an object, a stacktrace is dumped. The stacktrace has been replaced by a meaningful message using ajv.
I fix the stacktrace by using the validation with ajv. However, i duplicate a call to validator.validateConfigSchema into loadFromDisk (lib/config/config-file.js) validateConfigSchema must be called before plugins.loadAll. Actually, the call is made by the function validator.validate. I'm surprised by the fact that config is used before being validated. |
Any comment on this fix? |
@cotonne sorry, we lost track of this. Just to be clear: your concern here is if someone defines the I agree that it would be nice to give a more useful error message to the user, though there must be a way to do that without validating twice. |
After digging into this a bit, it looks like the best path forward might be to split up the validation steps in @not-an-aardvark @mysticatea thoughts on this? |
@nzakas Yes, i duplicate the call mainly because it will break a lot of tests. |
@cotonne it seems like the team liked my last comment, so here's what I would suggest:
Does that make sense? |
What is the purpose of this pull request? (put an "X" next to item)
[ ] Documentation update
[X ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
Please show your full configuration:
Configuration
File eslintrc.json ```js { ... "plugins": [ ["import"], [{ "node": "node"}], { "promise": "promise" }], ] } ```What did you do? Please include the actual source code causing the issue.
Provided an invalid json config file.
cf. configuration (generated with a fuzzer PyJFuzz)
What did you expect to happen?
A meaningful message should be displayed.
What actually happened? Please include the actual, raw output from ESLint.
Big exception:
What changes did you make? (Give an overview)
When a non-string parameter is provided to the configuration parameter "plugins",
an exception is thrown
Is there anything you'd like reviewers to focus on?