From e057e11ff2f482721033818c48a707f0482d27ff Mon Sep 17 00:00:00 2001 From: Adam Vigneaux Date: Tue, 3 Dec 2024 18:40:33 -0600 Subject: [PATCH] feat: allow `$schema` in JSON configuration file The `$schema` property can be used by editors to provide inline documentation and validation in JSON files (see [VS Code's documentation](https://code.visualstudio.com/Docs/languages/json#_json-schemas-and-settings) as an example). Currently, the JSON schema for the `dclint` configuration file does not allow `$schema`, so adding it causes a configuration validation error and prevents the tool from starting. This adds `$schema` to the configuration JSON schema and documents how to use it. --- README.md | 10 ++++++++++ schemas/linter-config.schema.json | 3 +++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index 96b9d8f..05cde5c 100644 --- a/README.md +++ b/README.md @@ -255,6 +255,16 @@ Here is an example of a configuration file using JSON format: - **debug**: Enables debug mode with additional output if set to `true`. - **exclude**: Specifies files or directories to exclude from linting. +To enable editor autocompletion in a JSON configuration file, add a `$schema` property. +If you have installed `dclint`: +``` +"$schema": "./node_modules/dclint/schemas/linter-config.schema.json", +``` +Otherwise: +``` +"$schema": "https://raw.githubusercontent.com/zavoloklom/docker-compose-linter/refs/heads/main/schemas/linter-config.schema.json", +``` + ### Configure Rules In addition to enabling or disabling rules, some rules may support custom parameters to tailor them to your specific diff --git a/schemas/linter-config.schema.json b/schemas/linter-config.schema.json index 2016b36..1b316c1 100644 --- a/schemas/linter-config.schema.json +++ b/schemas/linter-config.schema.json @@ -2,6 +2,9 @@ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { + "$schema": { + "type": "string" + }, "rules": { "type": "object", "propertyNames": {