Skip to content

Commit

Permalink
feat(vscode): provide config's schema to oxlint config files
Browse files Browse the repository at this point in the history
Updates the VSCode plugin client to automatically provide our auto-generated
JSON schema to `\.?oxlint(rc)?(\.json)?` files.
  • Loading branch information
DonIsaac committed Aug 11, 2024
1 parent 8862f06 commit 8506d03
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
3 changes: 2 additions & 1 deletion crates/oxc_linter/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ use crate::{
///
/// `.oxlintrc.json`
///
/// ```json
/// ```jsonc
/// {
/// // You can use comments in config files
/// "env": {
/// "browser": true
/// },
Expand Down
2 changes: 1 addition & 1 deletion crates/oxc_linter/src/snapshots/schema_json.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: json
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "OxlintConfig",
"description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json { \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
"description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```jsonc { // You can use comments in config files \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
"type": "object",
"properties": {
"env": {
Expand Down
28 changes: 26 additions & 2 deletions editors/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,31 @@
"description": "Path to ESlint configuration."
}
}
}
},
"jsonValidation": [
{
"fileMatch": [
"oxlintrc.json",
"oxlint.json",
".oxlintrc.json",
".oxlint.json",
".oxlintrc"
],
"url": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json"
}
],
"languages": [
{
"id": "jsonc",
"filenames": [
"oxlintrc.json",
"oxlint.json",
".oxlintrc.json",
".oxlint.json",
".oxlintrc"
]
}
]
},
"scripts": {
"preinstall": "[ -f icon.png ] || curl https://cdn.jsdelivr.net/gh/oxc-project/oxc-assets/square.png --output icon.png",
Expand Down Expand Up @@ -130,4 +154,4 @@
"vsce": {
"dependencies": false
}
}
}
2 changes: 1 addition & 1 deletion npm/oxlint/configuration_schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "OxlintConfig",
"description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json { \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
"description": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\n::: danger NOTE\n\nOnly the `.json` format is supported.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```jsonc { // You can use comments in config files \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
"type": "object",
"properties": {
"env": {
Expand Down

0 comments on commit 8506d03

Please sign in to comment.