Improve handling of schema properties having default values
Delapouite opened this issue · 1 comments
Hello
Summary
Many JSON schema have a handy default
value for properties. Currently it is used by the auto-completion feature which is nice!
I suggest that it could also be used for other situations:
- in the
doHover
. The tooltip appearing on hover of key currently displays the property description (in Markdown). It would be great to also display thedefault
value in this tooltip. - if a validated JSON has a key which happens to have the default value as its current value, in this case it could be consider a redundant info and a developer may be interested by removing this line from the JSON. I suggest this could potentially be surfaced as a
warning
or something similar.
Concrete example
Let me illustrate with a concrete situation, involving opening a .prettierrc.json
file. This is a config file used by the popular Prettier code formatter. When this kind of file is opened in VSCode, a dedicated extension correctly set https://json.schemastore.org/prettierrc as the schema.
If the content of this .prettierrc.json
is :
{
"endOfLine": "lf"
}
- When I hover
endOfLine
with my mouse, it displaysLine Feed only (\\n), common on Linux and macOS as well as inside git repos
in the tooltip, which is thedescription
of this enum. That's great. But it would be event better if this tooltip would additionally displays something like(default : "lf")
- In this scenario, as
"lf"
is the default value ofendOfLine
, it means that this config is "useless" because it only repeat the default behavior of this end of line option. As a developer I would find it valuable if I was able to have some kind of warning telling me just that : each case where I needlessly respecify a key, with no added benefit.
Thanks a lot
Having this information in the hover view would also be useful for context when I'm reviewing existing data - is the current value the default? What is the default for this property, if any?