Skip to content

Commit

Permalink
feat: add config JSON schema
Browse files Browse the repository at this point in the history
  • Loading branch information
theoludwig committed Feb 2, 2024
1 parent 09731d4 commit 8934ac1
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ npm install --save-dev html-w3c-validator start-server-and-test

```json
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/main/schema/html-w3c-validatorrc-schema.json",

// URLs to validate.
"urls": ["http://127.0.0.1:3000/", "http://127.0.0.1:3000/about"],

// You can also specify HTML files instead of URLs
// Files to validate.
"files": ["./index.html", "./about.html"],

// Specify the severities of the validator (default: ["warning", "error"])
// Specify the severities of the validator messages to report. (default: ["warning", "error"])
"severities": ["info", "warning", "error"]
}
```
Expand Down
1 change: 1 addition & 0 deletions example/.html-w3c-validatorrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"urls": ["http://127.0.0.1:3000/", "http://127.0.0.1:3000/about"],
"files": ["./build/index.html", "./build/about.html"]
}
47 changes: 47 additions & 0 deletions schema/html-w3c-validatorrc-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/main/schema/html-w3c-validatorrc-schema.json",
"title": "html-w3c-validator configuration schema",
"type": "object",
"properties": {
"$schema": {
"description": "JSON Schema URI",
"type": "string",
"default": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/main/schema/html-w3c-validatorrc-schema.json"
},
"urls": {
"description": "URLs to validate.",
"type": "array",
"default": [],
"minItems": 1,
"items": {
"description": "URL to validate.",
"type": "string",
"minLength": 1
}
},
"files": {
"description": "Files to validate.",
"type": "array",
"minItems": 1,
"default": [],
"items": {
"description": "File to validate.",
"type": "string",
"minLength": 1
}
},
"severities": {
"description": "Specify the severities of the validator messages to report.",
"type": "array",
"minItems": 1,
"default": ["warning", "error"],
"items": {
"description": "Severity to report.",
"type": "string",
"enum": ["error", "warning", "info"]
}
}
},
"additionalProperties": false
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"urls": [],
"files": []
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"files": "Invalid"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"files": ["./index.html"],
"severities": []
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"files": ["./index.html"],
"severities": ["errors-invalid"]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"urls": "Invalid"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"files": ["./index.html"]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"files": ["./build/index.html", "./build/about.html"]
}
1 change: 1 addition & 0 deletions src/__test__/fixtures/success/.html-w3c-validatorrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/theoludwig/html-w3c-validator/develop/schema/html-w3c-validatorrc-schema.json",
"files": ["./build/index.html", "./build/about.html"]
}

0 comments on commit 8934ac1

Please sign in to comment.