Skip to content

Commit 9a2736b

Browse files
committed
feat(vscode): provide config's schema to oxlint config files
Updates the VSCode plugin client to automatically provide our auto-generated JSON schema to `\.?oxlint(rc)?(\.json)?` files.
1 parent 8862f06 commit 9a2736b

File tree

5 files changed

+30
-6
lines changed

5 files changed

+30
-6
lines changed

crates/oxc_linter/src/config/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use crate::{
2828
///
2929
/// ::: danger NOTE
3030
///
31-
/// Only the `.json` format is supported.
31+
/// Only the `.json` format is supported. You can use comments in configuration files.
3232
///
3333
/// :::
3434
///

crates/oxc_linter/src/snapshots/schema_json.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ expression: json
55
{
66
"$schema": "http://json-schema.org/draft-07/schema#",
77
"title": "OxlintConfig",
8-
"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\" } } ```",
8+
"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. You can use comments in configuration files.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json { \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
99
"type": "object",
1010
"properties": {
1111
"env": {

editors/vscode/package.json

+26-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,31 @@
101101
"description": "Path to ESlint configuration."
102102
}
103103
}
104-
}
104+
},
105+
"jsonValidation": [
106+
{
107+
"fileMatch": [
108+
"oxlintrc.json",
109+
"oxlint.json",
110+
".oxlintrc.json",
111+
".oxlint.json",
112+
".oxlintrc"
113+
],
114+
"url": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json"
115+
}
116+
],
117+
"languages": [
118+
{
119+
"id": "jsonc",
120+
"filenames": [
121+
"oxlintrc.json",
122+
"oxlint.json",
123+
".oxlintrc.json",
124+
".oxlint.json",
125+
".oxlintrc"
126+
]
127+
}
128+
]
105129
},
106130
"scripts": {
107131
"preinstall": "[ -f icon.png ] || curl https://cdn.jsdelivr.net/gh/oxc-project/oxc-assets/square.png --output icon.png",
@@ -130,4 +154,4 @@
130154
"vsce": {
131155
"dependencies": false
132156
}
133-
}
157+
}

npm/oxlint/configuration_schema.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "OxlintConfig",
4-
"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\" } } ```",
4+
"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. You can use comments in configuration files.\n\n:::\n\nExample\n\n`.oxlintrc.json`\n\n```json { \"env\": { \"browser\": true }, \"globals\": { \"foo\": \"readonly\" }, \"settings\": { }, \"rules\": { \"eqeqeq\": \"warn\" } } ```",
55
"type": "object",
66
"properties": {
77
"env": {

tasks/website/src/linter/snapshots/schema_markdown.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Usage: `oxlint -c oxlintrc.json`
1010

1111
::: danger NOTE
1212

13-
Only the `.json` format is supported.
13+
Only the `.json` format is supported. You can use comments in configuration files.
1414

1515
:::
1616

0 commit comments

Comments
 (0)