Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/oxlint/src-js/package/config.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export type LintPluginOptionsSchema =
| "node"
| "vue";
export type LintPlugins = LintPluginOptionsSchema[];
export type DummyRule = AllowWarnDeny | unknown[];
export type DummyRule = AllowWarnDeny | [AllowWarnDeny, ...unknown[]];
export type OxlintOverrides = OxlintOverride[];
export type TagNamePreference =
| string
Expand Down
39 changes: 37 additions & 2 deletions crates/oxc_linter/src/config/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ use std::{borrow::Cow, fmt};

use itertools::Itertools;
use rustc_hash::FxHashMap;
use schemars::{JsonSchema, r#gen::SchemaGenerator, schema::Schema};
use schemars::{
JsonSchema,
r#gen::SchemaGenerator,
schema::{ArrayValidation, InstanceType, Schema, SchemaObject},
};
use serde::{
Deserialize, Serialize, Serializer,
de::{self, Deserializer, Visitor},
Expand Down Expand Up @@ -243,7 +247,38 @@ impl JsonSchema for OxlintRules {
#[serde(untagged)]
enum DummyRule {
Toggle(AllowWarnDeny),
ToggleAndConfig(Vec<serde_json::Value>),
ToggleAndConfig(ToggleAndConfig),
}

#[derive(Debug, Clone)]
struct ToggleAndConfig;

impl JsonSchema for ToggleAndConfig {
fn is_referenceable() -> bool {
false
}

fn schema_name() -> String {
"ToggleAndConfig".to_string()
}

fn schema_id() -> Cow<'static, str> {
"ToggleAndConfig".into()
}

fn json_schema(r#gen: &mut SchemaGenerator) -> Schema {
SchemaObject {
instance_type: Some(InstanceType::Array.into()),
array: Some(Box::new(ArrayValidation {
items: Some(vec![r#gen.subschema_for::<AllowWarnDeny>()].into()),
min_items: Some(1),
additional_items: Some(Box::new(Schema::Bool(true))),
..Default::default()
})),
..Default::default()
}
.into()
}
}

#[expect(unused)]
Expand Down
10 changes: 8 additions & 2 deletions npm/oxlint/configuration_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,13 @@
},
{
"type": "array",
"items": true
"items": [
{
"$ref": "#/definitions/AllowWarnDeny"
}
],
"additionalItems": true,
"minItems": 1
}
]
},
Expand Down Expand Up @@ -761,4 +767,4 @@
}
},
"markdownDescription": "Oxlint Configuration File\n\nThis configuration is aligned with ESLint v8's configuration schema (`eslintrc.json`).\n\nUsage: `oxlint -c oxlintrc.json`\n\nExample\n\n`.oxlintrc.json`\n\n```json\n{\n\"$schema\": \"./node_modules/oxlint/configuration_schema.json\",\n\"plugins\": [\"import\", \"typescript\", \"unicorn\"],\n\"env\": {\n\"browser\": true\n},\n\"globals\": {\n\"foo\": \"readonly\"\n},\n\"settings\": {\n\"react\": {\n\"version\": \"18.2.0\"\n},\n\"custom\": { \"option\": true }\n},\n\"rules\": {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\n\"overrides\": [\n{\n\"files\": [\"*.test.ts\", \"*.spec.ts\"],\n\"rules\": {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n}\n```\n\n`oxlint.config.ts`\n\n```ts\nimport { defineConfig } from \"oxlint\";\n\nexport default defineConfig({\nplugins: [\"import\", \"typescript\", \"unicorn\"],\nenv: {\n\"browser\": true\n},\nglobals: {\n\"foo\": \"readonly\"\n},\nsettings: {\nreact: {\nversion: \"18.2.0\"\n},\ncustom: { option: true }\n},\nrules: {\n\"eqeqeq\": \"warn\",\n\"import/no-cycle\": \"error\",\n\"react/self-closing-comp\": [\"error\", { \"html\": false }]\n},\noverrides: [\n{\nfiles: [\"*.test.ts\", \"*.spec.ts\"],\nrules: {\n\"@typescript-eslint/no-explicit-any\": \"off\"\n}\n}\n]\n});\n```"
}
}
8 changes: 7 additions & 1 deletion tasks/website_linter/src/snapshots/schema_json.snap
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,13 @@ expression: json
},
{
"type": "array",
"items": true
"items": [
{
"$ref": "#/definitions/AllowWarnDeny"
}
],
"additionalItems": true,
"minItems": 1
}
]
},
Expand Down
Loading