Skip to content

Commit 6a7018e

Browse files
committed
feat(linter): generate stricter json schema for lint plugins (oxc-project#11219)
e.g: ![Screenshot 2025-05-21 at 16.22.41.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/8ASanJZ3iQ7b9iVhlds7/8cb1875b-782e-4325-bb86-ae31be2092c5.png)
1 parent e8470d9 commit 6a7018e

File tree

3 files changed

+60
-3
lines changed

3 files changed

+60
-3
lines changed

crates/oxc_linter/src/config/plugins.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,26 @@ impl JsonSchema for LintPlugins {
219219
}
220220

221221
fn json_schema(r#gen: &mut SchemaGenerator) -> Schema {
222-
r#gen.subschema_for::<Vec<&str>>()
222+
#[derive(JsonSchema)]
223+
#[serde(rename_all = "kebab-case")]
224+
#[expect(dead_code)]
225+
enum LintPluginOptionsSchema {
226+
Eslint,
227+
React,
228+
Unicorn,
229+
Typescript,
230+
Oxc,
231+
Import,
232+
Jsdoc,
233+
Jest,
234+
Vitest,
235+
JsxA11y,
236+
Nextjs,
237+
ReactPerf,
238+
Promise,
239+
Node,
240+
}
241+
r#gen.subschema_for::<Vec<LintPluginOptionsSchema>>()
223242
}
224243
}
225244

crates/oxc_linter/src/snapshots/schema_json.snap

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,29 @@ expression: json
273273
}
274274
}
275275
},
276+
"LintPluginOptionsSchema": {
277+
"type": "string",
278+
"enum": [
279+
"eslint",
280+
"react",
281+
"unicorn",
282+
"typescript",
283+
"oxc",
284+
"import",
285+
"jsdoc",
286+
"jest",
287+
"vitest",
288+
"jsx-a11y",
289+
"nextjs",
290+
"react-perf",
291+
"promise",
292+
"node"
293+
]
294+
},
276295
"LintPlugins": {
277296
"type": "array",
278297
"items": {
279-
"type": "string"
298+
"$ref": "#/definitions/LintPluginOptionsSchema"
280299
}
281300
},
282301
"NextPluginSettings": {

npm/oxlint/configuration_schema.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,29 @@
269269
}
270270
}
271271
},
272+
"LintPluginOptionsSchema": {
273+
"type": "string",
274+
"enum": [
275+
"eslint",
276+
"react",
277+
"unicorn",
278+
"typescript",
279+
"oxc",
280+
"import",
281+
"jsdoc",
282+
"jest",
283+
"vitest",
284+
"jsx-a11y",
285+
"nextjs",
286+
"react-perf",
287+
"promise",
288+
"node"
289+
]
290+
},
272291
"LintPlugins": {
273292
"type": "array",
274293
"items": {
275-
"type": "string"
294+
"$ref": "#/definitions/LintPluginOptionsSchema"
276295
}
277296
},
278297
"NextPluginSettings": {

0 commit comments

Comments
 (0)