Add a JSON Schema to improve developer experience in VS Code
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
The experience of maintaining large swiftlint configuration files can be tedious, it would be great to add a JSON Schema describing the configuration file allowing VS Code to lint and provide autocomplete.
The Schema could be contributed to https://www.schemastore.org/json/ or manually configured in VS Code settings.json like so:
"yaml.schemas": {
"./swiftlint.schema.json": [
"/.swiftlint.yml",
"/.swiftlint.yaml",
"/.swiftlint.*.yml",
"/.swiftlint.*.yaml"
]
},
I have manually written a partial Schema to test the idea (see below) but I think it would be better to generate it from the code and parameters itself.
Note that thanks to JSON Schema anyOf it is possible to document both implicit and explicit rule configuration (see exemple with rule accessibility_label_for_image below).
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://https://realm.github.io/SwiftLint/swiftlint.schema.json",
"title": "SwiftLint Configuration",
"type": "object",
"properties": {
"excluded": {
"type": "array",
"description": "Case-sensitive paths to ignore during linting. Takes precedence over `included`."
},
"included": {
"type": "array",
"description": "Case-sensitive paths to include during linting. `--path` is ignored if present."
},
"reporter": {
"enum": [
"csv",
"checkstyle",
"codeclimate",
"emoji",
"github-actions-logging",
"gitlab",
"html",
"json",
"junit",
"markdown",
"relative-path",
"sonarqube",
"summary",
"xcode"
],
"description": "Reporter type"
},
"strict": {
"type": "boolean",
"description": "If true, SwiftLint will treat all warnings as errors."
},
"disabled_rules": {
"type": "array",
"description": "Disable rules from the default enabled set."
},
"opt_in_rules": {
"type": "array",
"description": "Enable rules that are not part of the default set. The special `all` identifier will enable all opt in linter rules, except the ones listed in `disabled_rules`."
},
"only_rules": {
"type": "array",
"description": "Only the rules specified in this list will be enabled. Cannot be specified alongside `disabled_rules` or `opt_in_rules`."
},
"accessibility_label_for_image": {
"anyOf": [
{
"allOf": [
{
"$ref": "#/$defs/severity"
},
{
"default": false,
"description": "Images that provide context should have an accessibility label or should be explicitly hidden from accessibility.\nDocumentation: https://realm.github.io/SwiftLint/accessibility_label_for_image.html"
}
]
},
{
"default": false,
"description": "Images that provide context should have an accessibility label or should be explicitly hidden from accessibility.\nDocumentation: https://realm.github.io/SwiftLint/accessibility_label_for_image.html",
"properties": {
"severity": {
"$ref": "#/$defs/severity"
}
}
}
]
},
"file_length": {
"type": "object",
"description": "Files should not span too many lines.\nDocumentation: https://realm.github.io/SwiftLint/file_length.html",
"properties": {
"warning": {
"type": "integer",
"default": 400
},
"error": {
"type": "integer",
"default": 1000
},
"ignore_comment_only_lines": {
"type": "boolean",
"default": false
}
}
}
},
"$defs": {
"severity": {
"enum": [
"warning",
"error"
]
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Review SwiftLint's configuration definitions and the partial JSON Schema shown in the issue, then compare the proposed VS Code settings with the Schema Store option. Done means a schema describes the supported configuration and rules, including implicit and explicit rule forms, and provides useful validation and autocomplete in VS Code.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, swift, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100