Require type for oneOf mutual exclusion by Namnamseo · Pull Request #5426 · golangci/golangci-lint (original) (raw)

Hello!

The following config:

linters-settings: custom: foo: path: "bin/linter/myplugin.so"

is considered broken under current JSON schema for config:

{ "custom": { "type": "object", "patternProperties": { "^.$": { "type": "object", "additionalProperties": false, "properties": { "type": { "enum": [ "module", "goplugin" ], "default": "goplugin" }, "path": { "type": "string", "examples": [ "/path/to/example.so" ] }, / ... */ }, "oneOf": [ { "properties": { "type": { "enum": [ "module" ] } } }, { "required": [ "path" ] } ] } } } }

for two reasons:

The given YAML:

I think the oneOf clause was there to do a mutual exclusion between "module" and "goplugin" type. Since the default is considered the latter, the "module" case should explicitly require for the property to be present.
This PR adds the requirement, and adds some test cases for that.


Since I'm new to the code base, I don't know which files among jsonschema/*.json needs to change; please point me if I'm wrong.