-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command for automatically generating JSON Schema for .ameba.yml
- Loading branch information
1 parent
e082eeb
commit 2c75cbc
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require "./cmd" | ||
|
||
schema = JSON.build(2) do |b| | ||
b.object do | ||
b.field("$schema", "http://json-schema.org/draft-07/schema#") | ||
b.field("title", ".ameba.yml") | ||
b.field("description", "Configuration rules for the Crystal lang ameba linter") | ||
b.field("type", "object") | ||
b.field("additionalProperties", false) | ||
|
||
b.string("properties") | ||
b.object do | ||
b.string("Excluded") | ||
b.object do | ||
b.field("type", "array") | ||
b.field("title", "excluded files and paths") | ||
b.field("description", "an array of wildcards (or paths) to exclude from the source list") | ||
|
||
b.string("items") | ||
b.object do | ||
b.field("type", "string") | ||
end | ||
end | ||
|
||
b.string("Globs") | ||
b.object do | ||
b.field("type", "array") | ||
b.field("title", "globbed files and paths") | ||
b.field("description", "an array of wildcards (or paths) to include to the inspection") | ||
|
||
b.string("items") | ||
b.object do | ||
b.field("type", "string") | ||
end | ||
end | ||
|
||
Ameba::Rule.rules.each do |rule| | ||
rule.to_json_schema(b) | ||
end | ||
end | ||
end | ||
end | ||
|
||
File.write(".ameba.yml.schema.json", schema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters