diff --git a/crates/biome_css_parser/src/lexer/mod.rs b/crates/biome_css_parser/src/lexer/mod.rs index f17c5c3e15ce..25ed5b2f63cf 100644 --- a/crates/biome_css_parser/src/lexer/mod.rs +++ b/crates/biome_css_parser/src/lexer/mod.rs @@ -1105,7 +1105,7 @@ impl<'src> CssLexer<'src> { COMMENT } } - Some(b'/') if self.options.allow_wrong_line_comments => { + Some(b'/') if self.options.allow_wrong_line_comments.unwrap_or_default() => { self.advance(2); while let Some(chr) = self.current_byte() { diff --git a/crates/biome_css_parser/src/parser.rs b/crates/biome_css_parser/src/parser.rs index 8ac7c9d81e61..d0b5633c5d6c 100644 --- a/crates/biome_css_parser/src/parser.rs +++ b/crates/biome_css_parser/src/parser.rs @@ -24,29 +24,29 @@ pub struct CssParserOptions { /// use `//` as a comment because it's javascript file. /// /// Defaults to `false`. - pub allow_wrong_line_comments: bool, + pub allow_wrong_line_comments: Option, /// Enables parsing of CSS Modules specific features. /// Defaults to `false`. - pub css_modules: bool, + pub css_modules: Option, } impl CssParserOptions { /// Allows the parser to parse wrong line comments. pub fn allow_wrong_line_comments(mut self) -> Self { - self.allow_wrong_line_comments = true; + self.allow_wrong_line_comments = Some(true); self } /// Enables parsing of css modules selectors. pub fn allow_css_modules(mut self) -> Self { - self.css_modules = true; + self.css_modules = Some(true); self } /// Checks if parsing of CSS Modules features is disabled. pub fn is_css_modules_disabled(&self) -> bool { - !self.css_modules + !self.css_modules.unwrap_or_default() } } diff --git a/crates/biome_css_parser/tests/spec_test.rs b/crates/biome_css_parser/tests/spec_test.rs index 65c60978beeb..e3864eb5ee8c 100644 --- a/crates/biome_css_parser/tests/spec_test.rs +++ b/crates/biome_css_parser/tests/spec_test.rs @@ -60,11 +60,11 @@ pub fn run(test_case: &str, _snapshot_name: &str, test_directory: &str, outcome_ let settings = settings.languages.css.parser; - if settings.css_modules { + if settings.css_modules.unwrap_or_default() { options = options.allow_css_modules(); } - if settings.allow_wrong_line_comments { + if settings.allow_wrong_line_comments.unwrap_or_default() { options = options.allow_wrong_line_comments(); } diff --git a/crates/biome_service/src/file_handlers/css.rs b/crates/biome_service/src/file_handlers/css.rs index be33cf500130..e5b38e909ef7 100644 --- a/crates/biome_service/src/file_handlers/css.rs +++ b/crates/biome_service/src/file_handlers/css.rs @@ -81,8 +81,8 @@ impl Default for CssLinterSettings { #[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] pub struct CssParserSettings { - pub allow_wrong_line_comments: bool, - pub css_modules: bool, + pub allow_wrong_line_comments: Option, + pub css_modules: Option, } impl ServiceLanguage for CssLanguage { diff --git a/crates/biome_service/src/settings.rs b/crates/biome_service/src/settings.rs index c1595369818b..daea776f1c72 100644 --- a/crates/biome_service/src/settings.rs +++ b/crates/biome_service/src/settings.rs @@ -5,8 +5,8 @@ use biome_configuration::diagnostics::InvalidIgnorePattern; use biome_configuration::javascript::JsxRuntime; use biome_configuration::organize_imports::OrganizeImports; use biome_configuration::{ - push_to_analyzer_rules, BiomeDiagnostic, CssConfiguration, FilesConfiguration, - FormatterConfiguration, JavascriptConfiguration, JsonConfiguration, LinterConfiguration, + push_to_analyzer_rules, BiomeDiagnostic, FilesConfiguration, FormatterConfiguration, + JavascriptConfiguration, JsonConfiguration, LinterConfiguration, OverrideFormatterConfiguration, OverrideLinterConfiguration, OverrideOrganizeImportsConfiguration, Overrides, PartialConfiguration, PartialCssConfiguration, PartialJavascriptConfiguration, PartialJsonConfiguration, PlainIndentStyle, Rules, @@ -216,7 +216,7 @@ impl Settings { } // css settings if let Some(css) = configuration.css { - self.languages.css = CssConfiguration::from(css).into(); + self.languages.css = css.into(); } // NOTE: keep this last. Computing the overrides require reading the settings computed by the parent settings. @@ -488,20 +488,25 @@ impl From for LanguageSettings { } } -impl From for LanguageSettings { - fn from(css: CssConfiguration) -> Self { +impl From for LanguageSettings { + fn from(css: PartialCssConfiguration) -> Self { let mut language_setting: LanguageSettings = LanguageSettings::default(); - language_setting.parser.allow_wrong_line_comments = css.parser.allow_wrong_line_comments; - language_setting.parser.css_modules = css.parser.css_modules; - - language_setting.formatter.enabled = Some(css.formatter.enabled); - language_setting.formatter.indent_width = css.formatter.indent_width; - language_setting.formatter.indent_style = css.formatter.indent_style.map(Into::into); - language_setting.formatter.line_width = css.formatter.line_width; - language_setting.formatter.line_ending = css.formatter.line_ending; - language_setting.formatter.quote_style = Some(css.formatter.quote_style); - language_setting.linter.enabled = Some(css.linter.enabled); + if let Some(parser) = css.parser { + language_setting.parser.allow_wrong_line_comments = parser.allow_wrong_line_comments; + language_setting.parser.css_modules = parser.css_modules; + } + if let Some(formatter) = css.formatter { + language_setting.formatter.enabled = formatter.enabled; + language_setting.formatter.indent_width = formatter.indent_width; + language_setting.formatter.indent_style = formatter.indent_style.map(Into::into); + language_setting.formatter.line_width = formatter.line_width; + language_setting.formatter.line_ending = formatter.line_ending; + language_setting.formatter.quote_style = formatter.quote_style; + } + if let Some(linter) = css.linter { + language_setting.linter.enabled = linter.enabled; + } language_setting } @@ -1357,8 +1362,8 @@ fn to_css_language_settings( let parent_parser = &parent_settings.parser; language_setting.parser.allow_wrong_line_comments = parser .allow_wrong_line_comments - .unwrap_or(parent_parser.allow_wrong_line_comments); - language_setting.parser.css_modules = parser.css_modules.unwrap_or(parent_parser.css_modules); + .or(parent_parser.allow_wrong_line_comments); + language_setting.parser.css_modules = parser.css_modules.or(parent_parser.css_modules); language_setting } diff --git a/crates/biome_unicode_table/src/tables.rs b/crates/biome_unicode_table/src/tables.rs index 7700038e9f9c..2521478eca81 100644 --- a/crates/biome_unicode_table/src/tables.rs +++ b/crates/biome_unicode_table/src/tables.rs @@ -782,7 +782,7 @@ pub mod derived_property { ('𫝀', '𫠝'), ('𫠠', '𬺡'), ('𬺰', '𮯠'), - ('\u{2ebf0}', '\u{2ee5d}'), + ('𮯰', '𮹝'), ('丽', '𪘀'), ('𰀀', '𱍊'), ('𱍐', '𲎯'), @@ -1448,7 +1448,7 @@ pub mod derived_property { ('𫝀', '𫠝'), ('𫠠', '𬺡'), ('𬺰', '𮯠'), - ('\u{2ebf0}', '\u{2ee5d}'), + ('𮯰', '𮹝'), ('丽', '𪘀'), ('𰀀', '𱍊'), ('𱍐', '𲎯'),