Provide JSON schema for .lintstagedrc (that can be added to schemastore)
See original GitHub issueSince .lintstagedrc
is a JSON file, it can be validated if a schema is provided.
This schema could then be added to schemastore, which’d make it available on their public api for tools such as IntelliJ to download automatically.
I’m happy to attempt making such a schema if I get the time, but have created this issue for tracking, and in case someone who knows lint-staged
better wants to take a crack (I’ve not actually used it yet, but love things that have schemas).
First whack at it, mostly accurate:
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "lint-staged configuration.",
"description": "Run linters against staged git files and don't let 💩 slip into your code base!",
"type": "object",
"additionalProperties": true,
"definitions": {
"linter": {
"description": " keys (String) are glob patterns, values (Array<String> | String) are commands to execute.",
"type": [ "string", "array" ],
"items": {
"type": "string"
}
}
},
"properties": {
"$schema": {
"type": "string"
},
"linters": {
"description": " keys (String) are glob patterns, values (Array<String> | String) are commands to execute.",
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"concurrent": {
"description": "runs linters for each glob pattern simultaneously.",
"type": "boolean",
"default": true
},
"chunkSize ": {
"description": "Max allowed chunk size based on number of files for glob pattern. This option is only applicable on Windows based systems to avoid command length limitations.",
"type": "number"
},
"globOptions": {
"description": "micromatch options to customize how glob patterns match files.",
"type": "object",
"properties": {
"matchBase": {
"type": "boolean",
"default": true
},
"dot": {
"type": "boolean",
"default": true
}
},
"additionalProperties": true
},
"ignore": {
"description": "array of glob patterns to entirely ignore from any task.",
"type": "array",
"items": {
"type": "string"
},
"default": "['**/docs/**/*.js']"
},
"subTaskConcurrency": {
"description": "Controls concurrency for processing chunks generated for each linter. This option is only applicable on Windows. Execution is not concurrent by default.",
"type": "number",
"default": 1
},
"relative": {
"description": "If true it will give the relative path from your package.json directory to your linter arguments.",
"type": "boolean",
"default": false
}
}
}
This only supports the advanced type configuration, as I need to look into how to switch additionalProperties
based on if other properties are present 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
JSON Schema Store
JSON Schemas for common JSON file formats. ... Each schema file can be used in tooling such as command line validators, editor auto-completion...
Read more >JSON schema for the win - Gleb Bahmutov
There are a lot of schemas for widely used JSON files on schemastore.org/json/ and you can add your own by making a pull...
Read more >Frontend Handbook | Code Quality / Tools - Infinum
Lint-staged can be configured in many ways. We prefer configuration in .lintstagedrc file in JSON format. Lint-staged uses glob patterns which ...
Read more >How to create your own auto-completion for JSON and YAML ...
The JSON Schema Store provides a very good set of schemas. Still, with so many different file types, of course, it can´t have...
Read more >JSON Schema Store
JSON Schemas for common JSON file formats. ... In supported JSON editors like Visual Studio and Visual Studio Code, schema files can offer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I added
lint-staged
schema to schemastore.I’ll remove the advanced version in a few weeks, when I’ve cleared a few other things off my plate.
Q: would you be alright w/ supporting
the $schema
property? “support” in this case just means “ignore”.usecase:
I have actually put it in the schema file for the “advanced” config, as so long as it didn’t do anything to valid that only specific properties were there,
$schema
shouldn’t cause problems, but it needs explicit support in the simple config since it’s pattern matching.Finally done - took a lot of work, and most of my day, but it works:
I’ll look to make a PR “soon”, along w/ automation, & ideally a test suite; all once I get the time.