@@ -6,7 +6,7 @@ use biome_configuration::javascript::JsxRuntime;
66use biome_configuration:: json:: { JsonAssistConfiguration , JsonLinterConfiguration } ;
77use biome_configuration:: max_size:: MaxSize ;
88use biome_configuration:: {
9- Configuration , JsConfiguration , JsonConfiguration , LinterConfiguration ,
9+ Configuration , FormatterConfiguration , JsConfiguration , JsonConfiguration , LinterConfiguration ,
1010 OverrideFilesConfiguration , OverrideGlobs , OverrideLinterConfiguration , OverridePattern ,
1111 Overrides , RuleConfiguration , RulePlainConfiguration , Rules ,
1212} ;
@@ -174,3 +174,68 @@ fn json_to_settings_includes_linter_and_assist() {
174174 assert_eq ! ( settings. linter. enabled, Some ( true . into( ) ) ) ;
175175 assert_eq ! ( settings. assist. enabled, Some ( true . into( ) ) ) ;
176176}
177+
178+ #[ test]
179+ fn override_inherits_global_formatter_when_not_specified ( ) {
180+ // the formatter should inherit from global settings instead of being disabled
181+ let configuration = Configuration {
182+ formatter : Some ( FormatterConfiguration {
183+ enabled : Some ( true . into ( ) ) ,
184+ ..FormatterConfiguration :: default ( )
185+ } ) ,
186+ linter : Some ( LinterConfiguration {
187+ enabled : Some ( true . into ( ) ) ,
188+ ..LinterConfiguration :: default ( )
189+ } ) ,
190+ overrides : Some ( Overrides ( vec ! [ OverridePattern {
191+ includes: Some ( OverrideGlobs :: Globs ( Box :: new( [
192+ biome_glob:: NormalizedGlob :: from_str( "*.vue" ) . unwrap( ) ,
193+ ] ) ) ) ,
194+ // Override only specifies linter, not formatter
195+ linter: Some ( OverrideLinterConfiguration {
196+ enabled: Some ( false . into( ) ) ,
197+ ..OverrideLinterConfiguration :: default ( )
198+ } ) ,
199+ ..OverridePattern :: default ( )
200+ } ] ) ) ,
201+ ..Default :: default ( )
202+ } ;
203+
204+ let mut settings = Settings :: default ( ) ;
205+ settings
206+ . merge_with_configuration ( configuration, None )
207+ . expect ( "valid configuration" ) ;
208+
209+ // For .vue files, linter should be disabled (from override)
210+ let linter_enabled = JsLanguage :: linter_enabled_for_file_path (
211+ & settings,
212+ Utf8Path :: new ( "test.vue" ) ,
213+ ) ;
214+ assert ! ( !linter_enabled, "Linter should be disabled for .vue files" ) ;
215+
216+ // For .vue files, formatter should be enabled (inherited from global)
217+ let formatter_enabled = JsLanguage :: formatter_enabled_for_file_path (
218+ & settings,
219+ Utf8Path :: new ( "test.vue" ) ,
220+ ) ;
221+ assert ! (
222+ formatter_enabled,
223+ "Formatter should be enabled for .vue files (inherited from global)"
224+ ) ;
225+
226+ // For non .vue files, both should be enabled (from global)
227+ let linter_enabled_js = JsLanguage :: linter_enabled_for_file_path (
228+ & settings,
229+ Utf8Path :: new ( "test.js" ) ,
230+ ) ;
231+ assert ! ( linter_enabled_js, "Linter should be enabled for .js files" ) ;
232+
233+ let formatter_enabled_js = JsLanguage :: formatter_enabled_for_file_path (
234+ & settings,
235+ Utf8Path :: new ( "test.js" ) ,
236+ ) ;
237+ assert ! (
238+ formatter_enabled_js,
239+ "Formatter should be enabled for .js files"
240+ ) ;
241+ }
0 commit comments