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
feat: invalidDefaults option to warn when defaults are ignored, fixes #957 #960
feat: invalidDefaults option to warn when defaults are ignored, fixes #957 #960
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. Not convinced they should be called “invalid” :) They are valid from JSON Schema point of view, it’s just that Ajv ignores them as there is no easy way to apply them. Will review and merge the code over weekend - ok?
Sure, no problem. Is there a name you would recommend instead? (Maybe something like |
I think ignoredDefaults was fine, there are two options that allow value “ignore”. I am guessing here - maybe you think it looks too similar to “ignoreDefaults” and can be confusing? We also could “simplify” the whole thing and cram it into useDefaults option - “warn” would log unused defaults and “strict” would throw? Not sure :) unusedDefaults is cool too - consistent with useDefaults |
unusedDefaults it is then :) |
I think my confusion with I'm certainly happy to change it to |
I see... so we need some option that would mean to throw if some defaults are not used. Maybe strictDefaults: true/'log'? The meaning is to only allow defaults that are used, and report other defaults? From reading the issue you want to throw:
If so, we could do useDefaults: true/'strict' and leave any possible further extension to the future. Logging is not that useful normally... Anyway, I am probably thinking too much about it :) Happy with either of the above: strictDefaults or useDefaults extension - your call. |
Going to merge it with strictDefaults - I want to release it today |
Thanks! |
What issue does this pull request resolve?
#957
What changes did you make?
This adds an
invalidDefaults
option to implement the suggestion from #957.(I chose the name
invalidDefaults
rather thanignoredDefaults
because the defaults are no longer actually ignored, depending on the value of the option.)Is there anything that requires more attention while reviewing?
I'm not very familiar with how the
dotjs
templates work, so it might be worth double-checking that I did that correctly.