Skip to content

Commit

Permalink
feat: allow $schema in JSON configuration file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AdamVig committed Dec 6, 2024
1 parent 94bcabf commit e057e11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions schemas/linter-config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"$schema": {
"type": "string"
},
"rules": {
"type": "object",
"propertyNames": {
Expand Down

0 comments on commit e057e11

Please sign in to comment.