From f3cfa8a92d7e6ca1a5cc3036c60ca0194d250e3f Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Wed, 25 Sep 2024 16:42:59 +0200 Subject: [PATCH] fix(schema): make optional the `options` JSON schema field (#4080) --- .../@biomejs/biome/configuration_schema.json | 38 +++++++++---------- xtask/codegen/src/generate_schema.rs | 10 +++++ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index c2efd0fe4d50..b45098e9db28 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -2593,7 +2593,7 @@ }, "RuleWithAllowDomainOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2612,7 +2612,7 @@ }, "RuleWithComplexityOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2627,7 +2627,7 @@ }, "RuleWithConsistentArrayTypeOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2646,7 +2646,7 @@ }, "RuleWithConsistentMemberAccessibilityOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2663,7 +2663,7 @@ }, "RuleWithDeprecatedHooksOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2678,7 +2678,7 @@ }, "RuleWithFilenamingConventionOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2708,7 +2708,7 @@ }, "RuleWithHooksOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2723,7 +2723,7 @@ }, "RuleWithNamingConventionOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2742,7 +2742,7 @@ }, "RuleWithNoConsoleOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2761,7 +2761,7 @@ }, "RuleWithNoDoubleEqualsOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2780,7 +2780,7 @@ }, "RuleWithNoLabelWithoutControlOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2806,7 +2806,7 @@ }, "RuleWithNoRestrictedTypesOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2825,7 +2825,7 @@ }, "RuleWithRestrictedGlobalsOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2840,7 +2840,7 @@ }, "RuleWithRestrictedImportsOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2855,7 +2855,7 @@ }, "RuleWithUseComponentExportOnlyModulesOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2872,7 +2872,7 @@ }, "RuleWithUseImportExtensionsOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2891,7 +2891,7 @@ }, "RuleWithUseValidAutocompleteOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "level": { "description": "The severity of the emitted diagnostics by the rule", @@ -2906,7 +2906,7 @@ }, "RuleWithUtilityClassSortingOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", @@ -2925,7 +2925,7 @@ }, "RuleWithValidAriaRoleOptions": { "type": "object", - "required": ["level", "options"], + "required": ["level"], "properties": { "fix": { "description": "The kind of the code actions emitted by the rule", diff --git a/xtask/codegen/src/generate_schema.rs b/xtask/codegen/src/generate_schema.rs index 0c3eb8c985e2..aecfe297184e 100644 --- a/xtask/codegen/src/generate_schema.rs +++ b/xtask/codegen/src/generate_schema.rs @@ -86,8 +86,18 @@ fn rename_partial_references_in_schema(mut schema: RootSchema) -> RootSchema { key = "RuleFixConfiguration".to_string(); } else if let Some(stripped) = key.strip_prefix("RuleWithOptions_for_") { key = format!("RuleWith{stripped}"); + if let Schema::Object(schema_object) = &mut schema { + if let Some(object) = &mut schema_object.object { + object.required.remove("options"); + } + } } else if let Some(stripped) = key.strip_prefix("RuleWithFixOptions_for_") { key = format!("RuleWith{stripped}"); + if let Schema::Object(schema_object) = &mut schema { + if let Some(object) = &mut schema_object.object { + object.required.remove("options"); + } + } } else if let Some(stripped) = key .strip_prefix("RuleConfiguration_for_") .map(|x| x.strip_suffix("Options").unwrap_or(x))