diff --git a/Cargo.lock b/Cargo.lock index 27d243e9e72e..44f311ebb3f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,6 +226,7 @@ dependencies = [ "biome_diagnostics", "biome_flags", "biome_formatter", + "biome_glob", "biome_graphql_analyze", "biome_graphql_syntax", "biome_html_formatter", @@ -1222,6 +1223,7 @@ dependencies = [ "biome_diagnostics", "biome_formatter", "biome_fs", + "biome_glob", "biome_graphql_analyze", "biome_graphql_formatter", "biome_graphql_parser", diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs index d21cdf730137..33b477a0dc36 100644 --- a/crates/biome_cli/src/commands/rage.rs +++ b/crates/biome_cli/src/commands/rage.rs @@ -254,6 +254,12 @@ impl Display for RageConfiguration<'_> { .collect::>() .join(", ") }); + let includes = formatter_configuration.includes.map(|list| { + list.iter() + .map(|s| s.to_string()) + .collect::>() + .join(", ") + }); markup! ( {Section("Formatter")} {KeyValuePair("Format with errors", markup!({DisplayOption(configuration.get_formatter_configuration().format_with_errors)}))} @@ -265,6 +271,7 @@ impl Display for RageConfiguration<'_> { {KeyValuePair("Bracket spacing", markup!({DisplayOption(formatter_configuration.bracket_spacing)}))} {KeyValuePair("Ignore", markup!({DisplayOption(ignore)}))} {KeyValuePair("Include", markup!({DisplayOption(include)}))} + {KeyValuePair("Includes", markup!({DisplayOption(includes)}))} ).fmt(fmt)?; let javascript_formatter_configuration = diff --git a/crates/biome_cli/src/execute/migrate/prettier.rs b/crates/biome_cli/src/execute/migrate/prettier.rs index 09e702786fd8..9507ac98aee3 100644 --- a/crates/biome_cli/src/execute/migrate/prettier.rs +++ b/crates/biome_cli/src/execute/migrate/prettier.rs @@ -208,6 +208,7 @@ impl TryFrom for biome_configuration::Configuration { format_with_errors: Some(false.into()), ignore: None, include: None, + includes: None, enabled: Some(true.into()), // editorconfig support is intentionally set to true, because prettier always reads the editorconfig file // see: https://github.com/prettier/prettier/issues/15255 diff --git a/crates/biome_cli/tests/cases/config_extends.rs b/crates/biome_cli/tests/cases/config_extends.rs index 5b0b3eb2bd46..09266feea2d8 100644 --- a/crates/biome_cli/tests/cases/config_extends.rs +++ b/crates/biome_cli/tests/cases/config_extends.rs @@ -332,7 +332,7 @@ fn extends_config_merge_overrides() { shared.into(), r#"{ "overrides": [{ - "include": ["**/*.js"], + "includes": ["**/*.js"], "linter": { "rules": { "suspicious": { "noDebugger": "off" } } } }] }"#, @@ -344,7 +344,7 @@ fn extends_config_merge_overrides() { r#"{ "extends": ["shared.json"], "overrides": [{ - "include": ["**/*.js"], + "includes": ["**/*.js"], "linter": { "rules": { "correctness": { "noUnusedVariables": "error" } } } }] }"#, diff --git a/crates/biome_cli/tests/cases/diagnostics.rs b/crates/biome_cli/tests/cases/diagnostics.rs index 1f8e9e746a10..f298a9dc10c8 100644 --- a/crates/biome_cli/tests/cases/diagnostics.rs +++ b/crates/biome_cli/tests/cases/diagnostics.rs @@ -16,7 +16,7 @@ fn logs_the_appropriate_messages_according_to_set_diagnostics_level() { file_path.into(), r#"{ "files": { - "include": ["test.js"] + "includes": ["test.js"] }, "linter": { "rules": { diff --git a/crates/biome_cli/tests/cases/included_files.rs b/crates/biome_cli/tests/cases/included_files.rs index 2d432cf7f7a9..36aea57e8f40 100644 --- a/crates/biome_cli/tests/cases/included_files.rs +++ b/crates/biome_cli/tests/cases/included_files.rs @@ -24,7 +24,7 @@ fn does_handle_only_included_files() { fs.insert( file_path.into(), r#"{ - "files": { "include": ["test.js"] } + "files": { "includes": ["test.js"] } } "# .as_bytes(), @@ -65,7 +65,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore() { fs.insert( file_path.into(), r#"{ - "files": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "files": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } "# .as_bytes(), @@ -106,7 +106,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore_formatter() { fs.insert( file_path.into(), r#"{ - "formatter": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "formatter": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } "# .as_bytes(), @@ -147,7 +147,7 @@ fn does_not_handle_included_files_if_overridden_by_ignore_linter() { fs.insert( file_path.into(), r#"{ - "linter": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "linter": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } "# .as_bytes(), @@ -190,7 +190,7 @@ fn does_not_handle_included_files_if_overridden_by_organize_imports() { r#"{ "formatter": { "enabled": false }, "linter": { "enabled": false }, - "assist": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "assist": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } "# .as_bytes(), diff --git a/crates/biome_cli/tests/cases/linter_domains.rs b/crates/biome_cli/tests/cases/linter_domains.rs index 5412862c529f..8ab6b1f9407c 100644 --- a/crates/biome_cli/tests/cases/linter_domains.rs +++ b/crates/biome_cli/tests/cases/linter_domains.rs @@ -129,7 +129,7 @@ fn enable_test_rules_via_overrides() { } }, "overrides": [{ - "include": ["test1.js"], + "includes": ["test1.js"], "linter": { "domains": { "test": "all" diff --git a/crates/biome_cli/tests/cases/overrides_formatter.rs b/crates/biome_cli/tests/cases/overrides_formatter.rs index 8e3b2f329ce8..83c497b5ecf8 100644 --- a/crates/biome_cli/tests/cases/overrides_formatter.rs +++ b/crates/biome_cli/tests/cases/overrides_formatter.rs @@ -37,9 +37,9 @@ fn does_handle_included_file_and_disable_formatter() { file_path.into(), r#"{ "files": { - "include": ["test.js", "special/**"] + "includes": ["test.js", "special/**"] }, - "overrides": [{ "include": ["special/**"], "formatter": { "enabled": false } }] + "overrides": [{ "includes": ["special/**"], "formatter": { "enabled": false } }] } "# @@ -80,7 +80,7 @@ fn does_include_file_with_different_formatting() { fs.insert( file_path.into(), r#"{ - "overrides": [{ "include": ["special/**"], "formatter": { "lineWidth": 20 } }] + "overrides": [{ "includes": ["special/**"], "formatter": { "lineWidth": 20 } }] } "# @@ -122,8 +122,8 @@ fn does_include_file_with_different_formatting_and_all_of_them() { file_path.into(), r#"{ "overrides": [ - { "include": ["special/**"], "formatter": { "lineWidth": 130 } }, - { "include": ["special/**"], "formatter": { "lineWidth": 20 } } + { "includes": ["special/**"], "formatter": { "lineWidth": 130 } }, + { "includes": ["special/**"], "formatter": { "lineWidth": 20 } } ] } @@ -166,8 +166,8 @@ fn does_include_file_with_different_overrides() { file_path.into(), r#"{ "overrides": [ - { "include": ["test.js"], "formatter": { "lineWidth": 20 } }, - { "include": ["test2.js"], "formatter": { "lineWidth": 20, "indentStyle": "space" } } + { "includes": ["test.js"], "formatter": { "lineWidth": 20 } }, + { "includes": ["test2.js"], "formatter": { "lineWidth": 20, "indentStyle": "space" } } ] } @@ -219,9 +219,9 @@ fn complex_enable_disable_overrides() { } }, "overrides": [ - { "include": ["formatted.js"], "formatter": { "enabled": true } }, + { "includes": ["formatted.js"], "formatter": { "enabled": true } }, { - "include": ["dirty.js"], + "includes": ["dirty.js"], "linter": { "rules": { "performance": { @@ -278,9 +278,9 @@ fn does_include_file_with_different_languages() { file_path.into(), r#"{ "overrides": [ - { "include": ["test.js"], "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } } }, - { "include": ["test2.js"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "javascript": { "formatter": { "semicolons": "asNeeded" } } }, - { "include": ["test.css"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "css": { "formatter": { "quoteStyle": "single" } } } + { "includes": ["test.js"], "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } } }, + { "includes": ["test2.js"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "javascript": { "formatter": { "semicolons": "asNeeded" } } }, + { "includes": ["test.css"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "css": { "formatter": { "quoteStyle": "single" } } } ] } "# @@ -335,15 +335,15 @@ fn does_include_file_with_different_languages_and_files() { file_path.into(), r#"{ "overrides": [ - { "include": ["test.js"], "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } } }, + { "includes": ["test.js"], "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } } }, { - "include": ["test2.js"], + "includes": ["test2.js"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "javascript": { "formatter": { "semicolons": "asNeeded" } }, "json": { "formatter": { "indentStyle": "space", "lineWidth": 20, "indentWidth": 4 } } }, { - "include": ["test3.json"], + "includes": ["test3.json"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "json": { "formatter": { "indentStyle": "space", "lineWidth": 20, "indentWidth": 4 } } } @@ -408,7 +408,7 @@ fn does_not_change_formatting_settings() { r#"{ "formatter": { "lineWidth": 20, "indentStyle": "space" }, "overrides": [ - { "include": ["test.js"], "linter": { "enabled": false } } + { "includes": ["test.js"], "linter": { "enabled": false } } ] } @@ -452,7 +452,7 @@ fn does_not_change_formatting_language_settings() { r#"{ "javascript": { "formatter": { "quoteStyle": "single" } }, "overrides": [ - { "include": ["test.js"], "linter": { "enabled": false } } + { "includes": ["test.js"], "linter": { "enabled": false } } ] } @@ -496,7 +496,7 @@ fn does_not_change_formatting_language_settings_2() { r#"{ "javascript": { "formatter": { "lineWidth": 20 } }, "overrides": [ - { "include": ["test.js"], "linter": { "enabled": false } } + { "includes": ["test.js"], "linter": { "enabled": false } } ] } @@ -540,8 +540,8 @@ fn does_not_conceal_previous_overrides() { r#"{ "javascript": { "formatter": { "quoteStyle": "single" } }, "overrides": [ - { "include": ["*.js"], "javascript": { "formatter": { "quoteStyle": "double" } } }, - { "include": ["test.js"], "javascript": { "formatter": { "indentWidth": 4 } } } + { "includes": ["*.js"], "javascript": { "formatter": { "quoteStyle": "double" } } }, + { "includes": ["test.js"], "javascript": { "formatter": { "indentWidth": 4 } } } ] }"# .as_bytes(), @@ -578,10 +578,10 @@ fn takes_last_formatter_enabled_into_account() { r#"{ "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "formatter": { "enabled": false } }, { - "include": ["*.js"], + "includes": ["*.js"], "formatter": { "enabled": true } } ] @@ -617,7 +617,7 @@ fn does_not_override_well_known_special_files_when_config_override_is_present() r#"{ "overrides": [ { - "include": [ + "includes": [ "**/*.json" ], "formatter": { "enabled": false } @@ -673,7 +673,7 @@ fn allow_trailing_commas_on_well_known_files() { }, "overrides": [ { - "include": [ + "includes": [ "**/*.json" ], "json": { "parser": { "allowTrailingCommas": true } } @@ -741,7 +741,7 @@ fn disallow_comments_on_well_known_files() { }, "overrides": [ { - "include": [ + "includes": [ "**/*.json" ], "json": { "parser": { "allowComments": false } } @@ -785,7 +785,7 @@ fn overrides_default_formatter_for_package_json() { r#"{ "overrides": [ { - "include": ["package.json"], + "includes": ["package.json"], "json": { "formatter": { "expand": "followSource" } } } ] @@ -825,7 +825,7 @@ fn overrides_grit_formatting_options() { }, "overrides": [ { - "include": [ + "includes": [ "file.grit" ], "grit": { "formatter": { "indentStyle": "space", "indentWidth": 8 } } diff --git a/crates/biome_cli/tests/cases/overrides_linter.rs b/crates/biome_cli/tests/cases/overrides_linter.rs index 0aafb8d2146b..16cff74d68f2 100644 --- a/crates/biome_cli/tests/cases/overrides_linter.rs +++ b/crates/biome_cli/tests/cases/overrides_linter.rs @@ -23,9 +23,9 @@ fn does_handle_included_file_and_disable_linter() { file_path.into(), r#"{ "files": { - "include": ["test.js", "special/**"] + "includes": ["test.js", "special/**"] }, - "overrides": [{ "include": ["special/**"], "linter": { "enabled": false } }] + "overrides": [{ "includes": ["special/**"], "linter": { "enabled": false } }] } "# @@ -66,7 +66,7 @@ fn does_include_file_with_different_rules() { fs.insert( file_path.into(), r#"{ - "overrides": [{ "include": ["special/**"], "linter": { "rules": { + "overrides": [{ "includes": ["special/**"], "linter": { "rules": { "suspicious": { "noDebugger": "off" } } } }] } @@ -111,7 +111,7 @@ fn does_include_file_with_different_linting_and_applies_all_of_them() { r#"{ "overrides": [ { - "include": [ + "includes": [ "special/**" ], "linter": { @@ -123,7 +123,7 @@ fn does_include_file_with_different_linting_and_applies_all_of_them() { } }, { - "include": [ + "includes": [ "special/**" ], "linter": { @@ -177,7 +177,7 @@ fn does_include_file_with_different_overrides() { r#"{ "overrides": [ { - "include": [ + "includes": [ "test.js" ], "linter": { @@ -189,7 +189,7 @@ fn does_include_file_with_different_overrides() { } }, { - "include": [ + "includes": [ "test2.js" ], "linter": { @@ -243,7 +243,7 @@ fn does_override_the_rules() { r#"{ "overrides": [ { - "include": [ + "includes": [ "test.js" ], "linter": { @@ -303,7 +303,7 @@ fn does_not_change_linting_settings() { } }, "overrides": [ - { "include": ["test.js"], "formatter": { "enabled": false } } + { "includes": ["test.js"], "formatter": { "enabled": false } } ] } @@ -352,7 +352,7 @@ fn does_override_recommended() { }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "recommended": false @@ -406,7 +406,7 @@ fn does_override_groupe_recommended() { }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": { @@ -462,7 +462,7 @@ fn does_preserve_group_recommended_when_override_global_recommened() { }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "recommended": true @@ -516,7 +516,7 @@ fn does_preserve_individually_diabled_rules_in_overrides() { }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": {} @@ -570,7 +570,7 @@ fn does_merge_all_overrides() { }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "linter": { "rules": { "suspicious": { @@ -579,7 +579,7 @@ fn does_merge_all_overrides() { } } }, { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": { @@ -588,7 +588,7 @@ fn does_merge_all_overrides() { } } }, { - "include": ["test3.js"] + "includes": ["test3.js"] } ] }"# @@ -631,10 +631,10 @@ fn does_not_conceal_overrides_globals() { }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "javascript": { "globals": ["GLOBAL_VAR"] } }, { - "include": ["*.js"] + "includes": ["*.js"] } ] }"# @@ -672,10 +672,10 @@ fn takes_last_linter_enabled_into_account() { }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "linter": { "enabled": false } }, { - "include": ["*.js"], + "includes": ["*.js"], "linter": { "enabled": true } } ] diff --git a/crates/biome_cli/tests/cases/overrides_organize_imports.rs b/crates/biome_cli/tests/cases/overrides_organize_imports.rs index 4db99c26475b..959aede0a308 100644 --- a/crates/biome_cli/tests/cases/overrides_organize_imports.rs +++ b/crates/biome_cli/tests/cases/overrides_organize_imports.rs @@ -19,9 +19,9 @@ fn does_handle_included_file_and_disable_organize_imports() { file_path.into(), r#"{ "files": { - "include": ["test.js", "special/**"] + "includes": ["test.js", "special/**"] }, - "overrides": [{ "include": ["special/**"], "assist": { "enabled": false } }] + "overrides": [{ "includes": ["special/**"], "assist": { "enabled": false } }] } "# diff --git a/crates/biome_cli/tests/commands/format.rs b/crates/biome_cli/tests/commands/format.rs index 93e1c7b6229e..9205e912e287 100644 --- a/crates/biome_cli/tests/commands/format.rs +++ b/crates/biome_cli/tests/commands/format.rs @@ -1421,7 +1421,7 @@ fn does_not_format_ignored_directories() { fn does_not_format_ignored_file_in_included_directory() { let config = r#"{ "formatter": { - "include": ["src"], + "includes": ["src/**"], "ignore": ["src/file2.js"] } }"#; @@ -1469,11 +1469,11 @@ fn include_ignore_cascade() { // - `file4.js` is not included at top-level let config = r#"{ "files": { - "include": ["file1.js", "file2.js", "file3.js"], + "includes": ["file1.js", "file2.js", "file3.js"], "ignore": ["file2.js"] }, "formatter": { - "include": ["file1.js", "file2.js"], + "includes": ["file1.js", "file2.js"], "ignore": ["file3.js"] } }"#; @@ -1939,7 +1939,7 @@ fn include_vcs_ignore_cascade() { "ignore": ["file2.js"] }, "formatter": { - "include": ["file1.js", "file2.js", "file4.js"], + "includes": ["file1.js", "file2.js", "file4.js"], "ignore": ["file3.js"] } }"#; @@ -2315,7 +2315,7 @@ fn format_json_trailing_commas_overrides_all() { "formatter": { "trailingCommas": "none" } }, "overrides": [{ - "include": ["file.json"], + "includes": ["file.json"], "json": { "formatter": { "trailingCommas": "all" } } @@ -2358,7 +2358,7 @@ fn format_json_trailing_commas_overrides_none() { "formatter": { "trailingCommas": "all" } }, "overrides": [{ - "include": ["file.json"], + "includes": ["file.json"], "json": { "formatter": { "trailingCommas": "none" } } diff --git a/crates/biome_cli/tests/commands/lint.rs b/crates/biome_cli/tests/commands/lint.rs index aa5d349a0e1b..2f7cbccd9421 100644 --- a/crates/biome_cli/tests/commands/lint.rs +++ b/crates/biome_cli/tests/commands/lint.rs @@ -1100,7 +1100,7 @@ fn include_files_in_subdir() { let mut console = BufferConsole::default(); let config = r#"{ "files": { - "include": ["./**/*.js"] + "includes": ["**/*.js"] } }"#; @@ -1143,7 +1143,7 @@ fn include_files_in_symlinked_subdir() { let mut console = BufferConsole::default(); let config = r#"{ "files": { - "include": ["./**/*.js"] + "includes": ["**/*.js"] } }"#; @@ -2548,7 +2548,7 @@ fn should_only_process_changed_file_if_its_included() { r#" { "files": { - "include": ["file.js"] + "includes": ["file.js"] }, "vcs": { "defaultBranch": "main" @@ -2763,7 +2763,7 @@ fn should_only_process_staged_file_if_its_included() { r#" { "files": { - "include": ["file.js"] + "includes": ["file.js"] }, "vcs": { "defaultBranch": "main" diff --git a/crates/biome_cli/tests/commands/rage.rs b/crates/biome_cli/tests/commands/rage.rs index bb1241af2a15..427e801595e0 100644 --- a/crates/biome_cli/tests/commands/rage.rs +++ b/crates/biome_cli/tests/commands/rage.rs @@ -202,7 +202,7 @@ fn with_formatter_configuration() { "attributePosition": "multiline", "enabled": true, "formatWithErrors": true, - "include": [ + "includes": [ "**/*.html", "**/*.css", "**/*.js", diff --git a/crates/biome_cli/tests/main.rs b/crates/biome_cli/tests/main.rs index c5477e4aac27..7f4397734c46 100644 --- a/crates/biome_cli/tests/main.rs +++ b/crates/biome_cli/tests/main.rs @@ -293,7 +293,7 @@ mod configuration { "globals": ["React"] }, "overrides": [{ - "include": ["tests"], + "includes": ["tests/**"], "javascript": { "globals": ["test", "it"] } diff --git a/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_merge_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_merge_overrides.snap index e99dfea4254d..ee99083339fd 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_merge_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_config_extends/extends_config_merge_overrides.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -9,7 +10,7 @@ expression: content "extends": ["shared.json"], "overrides": [ { - "include": ["**/*.js"], + "includes": ["**/*.js"], "linter": { "rules": { "correctness": { "noUnusedVariables": "error" } } } } ] @@ -21,7 +22,7 @@ expression: content ```json { "overrides": [{ - "include": ["**/*.js"], + "includes": ["**/*.js"], "linter": { "rules": { "suspicious": { "noDebugger": "off" } } } }] } diff --git a/crates/biome_cli/tests/snapshots/main_cases_diagnostics/logs_the_appropriate_messages_according_to_set_diagnostics_level.snap b/crates/biome_cli/tests/snapshots/main_cases_diagnostics/logs_the_appropriate_messages_according_to_set_diagnostics_level.snap index 199f3214a454..69e6e1770910 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_diagnostics/logs_the_appropriate_messages_according_to_set_diagnostics_level.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_diagnostics/logs_the_appropriate_messages_according_to_set_diagnostics_level.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "files": { - "include": ["test.js"] + "includes": ["test.js"] }, "linter": { "rules": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_handle_only_included_files.snap b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_handle_only_included_files.snap index 52be5e9ca353..25a5b6fa0d01 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_handle_only_included_files.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_handle_only_included_files.snap @@ -1,12 +1,13 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { - "files": { "include": ["test.js"] } + "files": { "includes": ["test.js"] } } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore.snap b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore.snap index 142b225c049f..7b36e072f27b 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore.snap @@ -1,12 +1,13 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { - "files": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "files": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_formatter.snap b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_formatter.snap index 602cf9c1ab1f..ee454d7d2efd 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_formatter.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_formatter.snap @@ -1,12 +1,13 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { - "formatter": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "formatter": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_linter.snap b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_linter.snap index 5283f072c195..23ce460a41d9 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_linter.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_ignore_linter.snap @@ -1,12 +1,13 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { - "linter": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "linter": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_organize_imports.snap b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_organize_imports.snap index 6236618990c9..c14765b5daa9 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_organize_imports.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_included_files/does_not_handle_included_files_if_overridden_by_organize_imports.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -9,7 +9,7 @@ snapshot_kind: text { "formatter": { "enabled": false }, "linter": { "enabled": false }, - "assist": { "include": ["test.js", "test2.js"], "ignore": ["test.js"] } + "assist": { "includes": ["test.js", "test2.js"], "ignore": ["test.js"] } } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_linter_domains/enable_test_rules_via_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_linter_domains/enable_test_rules_via_overrides.snap index 354e58d42d46..6afe4c5fd7d4 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_linter_domains/enable_test_rules_via_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_linter_domains/enable_test_rules_via_overrides.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -14,7 +14,7 @@ snapshot_kind: text }, "overrides": [ { - "include": ["test1.js"], + "includes": ["test1.js"], "linter": { "domains": { "test": "all" diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap index 83b93b28c684..21ca80ef7e05 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/allow_trailing_commas_on_well_known_files.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -13,7 +13,7 @@ snapshot_kind: text }, "overrides": [ { - "include": ["**/*.json"], + "includes": ["**/*.json"], "json": { "parser": { "allowTrailingCommas": true } } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/complex_enable_disable_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/complex_enable_disable_overrides.snap index bd9d4cfa4873..a43c758a45d9 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/complex_enable_disable_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/complex_enable_disable_overrides.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,9 +16,9 @@ expression: content } }, "overrides": [ - { "include": ["formatted.js"], "formatter": { "enabled": true } }, + { "includes": ["formatted.js"], "formatter": { "enabled": true } }, { - "include": ["dirty.js"], + "includes": ["dirty.js"], "linter": { "rules": { "performance": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/disallow_comments_on_well_known_files.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/disallow_comments_on_well_known_files.snap index d53d5abca5a5..ada59ee2eac5 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/disallow_comments_on_well_known_files.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/disallow_comments_on_well_known_files.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -12,7 +13,7 @@ expression: content }, "overrides": [ { - "include": ["**/*.json"], + "includes": ["**/*.json"], "json": { "parser": { "allowComments": false } } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_handle_included_file_and_disable_formatter.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_handle_included_file_and_disable_formatter.snap index ce9b430d9671..3404820bc95a 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_handle_included_file_and_disable_formatter.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_handle_included_file_and_disable_formatter.snap @@ -1,16 +1,17 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "files": { - "include": ["test.js", "special/**"] + "includes": ["test.js", "special/**"] }, "overrides": [ - { "include": ["special/**"], "formatter": { "enabled": false } } + { "includes": ["special/**"], "formatter": { "enabled": false } } ] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting.snap index 3f4076061238..af9295eb378b 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting.snap @@ -1,12 +1,15 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { - "overrides": [{ "include": ["special/**"], "formatter": { "lineWidth": 20 } }] + "overrides": [ + { "includes": ["special/**"], "formatter": { "lineWidth": 20 } } + ] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting_and_all_of_them.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting_and_all_of_them.snap index 39bbffcddb2a..1ff27390d719 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting_and_all_of_them.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_formatting_and_all_of_them.snap @@ -1,14 +1,15 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "overrides": [ - { "include": ["special/**"], "formatter": { "lineWidth": 130 } }, - { "include": ["special/**"], "formatter": { "lineWidth": 20 } } + { "includes": ["special/**"], "formatter": { "lineWidth": 130 } }, + { "includes": ["special/**"], "formatter": { "lineWidth": 20 } } ] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_languages.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_languages.snap index 2182f160cd0d..a69cb198a47a 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_languages.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_languages.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,17 +9,17 @@ expression: content { "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "formatter": { "lineWidth": 120 }, "javascript": { "formatter": { "quoteStyle": "single" } } }, { - "include": ["test2.js"], + "includes": ["test2.js"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "javascript": { "formatter": { "semicolons": "asNeeded" } } }, { - "include": ["test.css"], + "includes": ["test.css"], "formatter": { "lineWidth": 120, "indentStyle": "space" }, "css": { "formatter": { "quoteStyle": "single" } } } diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_overrides.snap index f3bbb3a0b678..0405595202b9 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_include_file_with_different_overrides.snap @@ -1,15 +1,16 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "overrides": [ - { "include": ["test.js"], "formatter": { "lineWidth": 20 } }, + { "includes": ["test.js"], "formatter": { "lineWidth": 20 } }, { - "include": ["test2.js"], + "includes": ["test2.js"], "formatter": { "lineWidth": 20, "indentStyle": "space" } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings.snap index 48e2c36d5870..674f6a7351de 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "javascript": { "formatter": { "quoteStyle": "single" } }, - "overrides": [{ "include": ["test.js"], "linter": { "enabled": false } }] + "overrides": [{ "includes": ["test.js"], "linter": { "enabled": false } }] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings_2.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings_2.snap index fcf15491134d..f20c9c7ca6bf 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings_2.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_language_settings_2.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "javascript": { "formatter": { "lineWidth": 20 } }, - "overrides": [{ "include": ["test.js"], "linter": { "enabled": false } }] + "overrides": [{ "includes": ["test.js"], "linter": { "enabled": false } }] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_settings.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_settings.snap index de3ffcb5d0b5..66c0733b8965 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_settings.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_change_formatting_settings.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "formatter": { "lineWidth": 20, "indentStyle": "space" }, - "overrides": [{ "include": ["test.js"], "linter": { "enabled": false } }] + "overrides": [{ "includes": ["test.js"], "linter": { "enabled": false } }] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_conceal_previous_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_conceal_previous_overrides.snap index 8d8a0e7a96c4..946389eb7861 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_conceal_previous_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_conceal_previous_overrides.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -9,11 +10,11 @@ expression: content "javascript": { "formatter": { "quoteStyle": "single" } }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "javascript": { "formatter": { "quoteStyle": "double" } } }, { - "include": ["test.js"], + "includes": ["test.js"], "javascript": { "formatter": { "indentWidth": 4 } } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_override_well_known_special_files_when_config_override_is_present.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_override_well_known_special_files_when_config_override_is_present.snap index 010822088545..6f1bf5ec8d08 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_override_well_known_special_files_when_config_override_is_present.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/does_not_override_well_known_special_files_when_config_override_is_present.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,7 +9,7 @@ expression: content { "overrides": [ { - "include": ["**/*.json"], + "includes": ["**/*.json"], "formatter": { "enabled": false } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_default_formatter_for_package_json.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_default_formatter_for_package_json.snap index c26fc15a6b4f..0e0dbc986760 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_default_formatter_for_package_json.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_default_formatter_for_package_json.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -9,7 +9,7 @@ snapshot_kind: text { "overrides": [ { - "include": ["package.json"], + "includes": ["package.json"], "json": { "formatter": { "expand": "followSource" } } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap index 2337721e0808..7a9edc5e4aec 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/overrides_grit_formatting_options.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -12,7 +12,7 @@ snapshot_kind: text }, "overrides": [ { - "include": ["file.grit"], + "includes": ["file.grit"], "grit": { "formatter": { "indentStyle": "space", "indentWidth": 8 } } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/takes_last_formatter_enabled_into_account.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/takes_last_formatter_enabled_into_account.snap index 2a2c1f345cc7..d04e90ad08f9 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/takes_last_formatter_enabled_into_account.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_formatter/takes_last_formatter_enabled_into_account.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,11 +9,11 @@ expression: content { "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "formatter": { "enabled": false } }, { - "include": ["*.js"], + "includes": ["*.js"], "formatter": { "enabled": true } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_handle_included_file_and_disable_linter.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_handle_included_file_and_disable_linter.snap index b2c4b720335c..cead69cd1638 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_handle_included_file_and_disable_linter.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_handle_included_file_and_disable_linter.snap @@ -1,15 +1,16 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "files": { - "include": ["test.js", "special/**"] + "includes": ["test.js", "special/**"] }, - "overrides": [{ "include": ["special/**"], "linter": { "enabled": false } }] + "overrides": [{ "includes": ["special/**"], "linter": { "enabled": false } }] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_linting_and_applies_all_of_them.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_linting_and_applies_all_of_them.snap index 3a60169a34f6..ace5f4e87c7c 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_linting_and_applies_all_of_them.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_linting_and_applies_all_of_them.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,7 +9,7 @@ expression: content { "overrides": [ { - "include": ["special/**"], + "includes": ["special/**"], "linter": { "rules": { "suspicious": { @@ -18,7 +19,7 @@ expression: content } }, { - "include": ["special/**"], + "includes": ["special/**"], "linter": { "rules": { "suspicious": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_overrides.snap index 1a6143f91d0a..aadbd5b423e1 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_overrides.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,7 +9,7 @@ expression: content { "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": { @@ -18,7 +19,7 @@ expression: content } }, { - "include": ["test2.js"], + "includes": ["test2.js"], "linter": { "rules": { "complexity": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_rules.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_rules.snap index 403b9385cf01..6e7f248114a2 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_rules.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_include_file_with_different_rules.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,7 +9,7 @@ expression: content { "overrides": [ { - "include": ["special/**"], + "includes": ["special/**"], "linter": { "rules": { "suspicious": { "noDebugger": "off" } diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_merge_all_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_merge_all_overrides.snap index dcf2bb913786..ecb249d7da00 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_merge_all_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_merge_all_overrides.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,7 +16,7 @@ expression: content }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "linter": { "rules": { "suspicious": { @@ -25,7 +26,7 @@ expression: content } }, { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": { @@ -35,7 +36,7 @@ expression: content } }, { - "include": ["test3.js"] + "includes": ["test3.js"] } ] } diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_change_linting_settings.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_change_linting_settings.snap index 5398177801df..9d99fc74fd79 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_change_linting_settings.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_change_linting_settings.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -13,7 +14,7 @@ expression: content } } }, - "overrides": [{ "include": ["test.js"], "formatter": { "enabled": false } }] + "overrides": [{ "includes": ["test.js"], "formatter": { "enabled": false } }] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_conceal_overrides_globals.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_conceal_overrides_globals.snap index bbc99aea195a..0f7d2c742d2b 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_conceal_overrides_globals.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_not_conceal_overrides_globals.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,11 +16,11 @@ expression: content }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "javascript": { "globals": ["GLOBAL_VAR"] } }, { - "include": ["*.js"] + "includes": ["*.js"] } ] } diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_groupe_recommended.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_groupe_recommended.snap index d3de7684ec41..c0bc7c8bfe9b 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_groupe_recommended.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_groupe_recommended.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,7 +16,7 @@ expression: content }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_recommended.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_recommended.snap index af7cbe3c7af3..2c73f9a2b03e 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_recommended.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_recommended.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -13,7 +14,7 @@ expression: content }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "recommended": false diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_the_rules.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_the_rules.snap index 4151505a49b4..38d80379d8aa 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_the_rules.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_override_the_rules.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -8,7 +9,7 @@ expression: content { "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": { diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_group_recommended_when_override_global_recommened.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_group_recommended_when_override_global_recommened.snap index 90ca9c99d6e5..772b1831afb1 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_group_recommended_when_override_global_recommened.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_group_recommended_when_override_global_recommened.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,7 +16,7 @@ expression: content }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "recommended": true diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_individually_diabled_rules_in_overrides.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_individually_diabled_rules_in_overrides.snap index 33dee09769b6..a85b0175affb 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_individually_diabled_rules_in_overrides.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/does_preserve_individually_diabled_rules_in_overrides.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,7 +16,7 @@ expression: content }, "overrides": [ { - "include": ["test.js"], + "includes": ["test.js"], "linter": { "rules": { "suspicious": {} diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/takes_last_linter_enabled_into_account.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/takes_last_linter_enabled_into_account.snap index 88cdc11e7694..2bc8f8390f8e 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/takes_last_linter_enabled_into_account.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_linter/takes_last_linter_enabled_into_account.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,11 +16,11 @@ expression: content }, "overrides": [ { - "include": ["*.js"], + "includes": ["*.js"], "linter": { "enabled": false } }, { - "include": ["*.js"], + "includes": ["*.js"], "linter": { "enabled": true } } ] diff --git a/crates/biome_cli/tests/snapshots/main_cases_overrides_organize_imports/does_handle_included_file_and_disable_organize_imports.snap b/crates/biome_cli/tests/snapshots/main_cases_overrides_organize_imports/does_handle_included_file_and_disable_organize_imports.snap index 813751dacbf9..f30d89624c9c 100644 --- a/crates/biome_cli/tests/snapshots/main_cases_overrides_organize_imports/does_handle_included_file_and_disable_organize_imports.snap +++ b/crates/biome_cli/tests/snapshots/main_cases_overrides_organize_imports/does_handle_included_file_and_disable_organize_imports.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -8,9 +8,9 @@ snapshot_kind: text ```json { "files": { - "include": ["test.js", "special/**"] + "includes": ["test.js", "special/**"] }, - "overrides": [{ "include": ["special/**"], "assist": { "enabled": false } }] + "overrides": [{ "includes": ["special/**"], "assist": { "enabled": false } }] } ``` diff --git a/crates/biome_cli/tests/snapshots/main_commands_format/does_not_format_ignored_file_in_included_directory.snap b/crates/biome_cli/tests/snapshots/main_commands_format/does_not_format_ignored_file_in_included_directory.snap index d1e1821b5e61..68b772fbc135 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_format/does_not_format_ignored_file_in_included_directory.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_format/does_not_format_ignored_file_in_included_directory.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "formatter": { - "include": ["src"], + "includes": ["src/**"], "ignore": ["src/file2.js"] } } diff --git a/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_all.snap b/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_all.snap index c1660c939454..1eaa0758d252 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_all.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_all.snap @@ -1,6 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) snapshot_kind: text --- ## `biome.json` @@ -13,7 +13,7 @@ snapshot_kind: text }, "overrides": [ { - "include": ["file.json"], + "includes": ["file.json"], "json": { "formatter": { "trailingCommas": "all" } } diff --git a/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_none.snap b/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_none.snap index c7d74a69f6b0..f36a4af52a52 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_none.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_format/format_json_trailing_commas_overrides_none.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -12,7 +13,7 @@ expression: content }, "overrides": [ { - "include": ["file.json"], + "includes": ["file.json"], "json": { "formatter": { "trailingCommas": "none" } } diff --git a/crates/biome_cli/tests/snapshots/main_commands_format/include_ignore_cascade.snap b/crates/biome_cli/tests/snapshots/main_commands_format/include_ignore_cascade.snap index 15ab07867204..366d6b021b1e 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_format/include_ignore_cascade.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_format/include_ignore_cascade.snap @@ -1,17 +1,18 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "files": { - "include": ["file1.js", "file2.js", "file3.js"], + "includes": ["file1.js", "file2.js", "file3.js"], "ignore": ["file2.js"] }, "formatter": { - "include": ["file1.js", "file2.js"], + "includes": ["file1.js", "file2.js"], "ignore": ["file3.js"] } } diff --git a/crates/biome_cli/tests/snapshots/main_commands_format/include_vcs_ignore_cascade.snap b/crates/biome_cli/tests/snapshots/main_commands_format/include_vcs_ignore_cascade.snap index af3163f1e532..9fb86dda18ba 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_format/include_vcs_ignore_cascade.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_format/include_vcs_ignore_cascade.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -15,7 +16,7 @@ expression: content "ignore": ["file2.js"] }, "formatter": { - "include": ["file1.js", "file2.js", "file4.js"], + "includes": ["file1.js", "file2.js", "file4.js"], "ignore": ["file3.js"] } } diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_changed_file_if_its_included.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_changed_file_if_its_included.snap index e0d47d3d6458..240f00d44a6c 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_changed_file_if_its_included.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_changed_file_if_its_included.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "files": { - "include": ["file.js"] + "includes": ["file.js"] }, "vcs": { "defaultBranch": "main" diff --git a/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_staged_file_if_its_included.snap b/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_staged_file_if_its_included.snap index e0d47d3d6458..240f00d44a6c 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_staged_file_if_its_included.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_lint/should_only_process_staged_file_if_its_included.snap @@ -1,13 +1,14 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` ```json { "files": { - "include": ["file.js"] + "includes": ["file.js"] }, "vcs": { "defaultBranch": "main" diff --git a/crates/biome_cli/tests/snapshots/main_commands_rage/with_formatter_configuration.snap b/crates/biome_cli/tests/snapshots/main_commands_rage/with_formatter_configuration.snap index edde299682dc..bb022eabb32b 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_rage/with_formatter_configuration.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_rage/with_formatter_configuration.snap @@ -11,7 +11,7 @@ snapshot_kind: text "attributePosition": "multiline", "enabled": true, "formatWithErrors": true, - "include": [ + "includes": [ "**/*.html", "**/*.css", "**/*.js", @@ -87,7 +87,8 @@ Formatter: Attribute position: Multiline Bracket spacing: unset Ignore: configuration-schema.json - Include: **/*.html, **/*.css, **/*.js, **/*.ts, **/*.tsx, **/*.jsx, **/*.json, **/*.md + Include: unset + Includes: **/*.html, **/*.css, **/*.js, **/*.ts, **/*.tsx, **/*.jsx, **/*.json, **/*.md JavaScript Formatter: Enabled: true diff --git a/crates/biome_cli/tests/snapshots/main_configuration/override_globals.snap b/crates/biome_cli/tests/snapshots/main_configuration/override_globals.snap index 736beaa703a2..6eb35ccb9ceb 100644 --- a/crates/biome_cli/tests/snapshots/main_configuration/override_globals.snap +++ b/crates/biome_cli/tests/snapshots/main_configuration/override_globals.snap @@ -1,6 +1,7 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content +expression: redactor(content) +snapshot_kind: text --- ## `biome.json` @@ -19,7 +20,7 @@ expression: content }, "overrides": [ { - "include": ["tests"], + "includes": ["tests/**"], "javascript": { "globals": ["test", "it"] } diff --git a/crates/biome_configuration/Cargo.toml b/crates/biome_configuration/Cargo.toml index bdac3e496f83..e8590ef8e756 100644 --- a/crates/biome_configuration/Cargo.toml +++ b/crates/biome_configuration/Cargo.toml @@ -22,6 +22,7 @@ biome_deserialize_macros = { workspace = true } biome_diagnostics = { workspace = true, features = ["serde_ini", "oxc_resolver"] } biome_flags = { workspace = true } biome_formatter = { workspace = true, features = ["serde"] } +biome_glob = { workspace = true } biome_graphql_analyze = { workspace = true } biome_graphql_syntax = { workspace = true } biome_html_formatter = { workspace = true, features = ["serde"] } diff --git a/crates/biome_configuration/src/analyzer/assist/mod.rs b/crates/biome_configuration/src/analyzer/assist/mod.rs index f521386d438e..1c2410240c40 100644 --- a/crates/biome_configuration/src/analyzer/assist/mod.rs +++ b/crates/biome_configuration/src/analyzer/assist/mod.rs @@ -22,17 +22,23 @@ pub struct AssistConfiguration { #[serde(skip_serializing_if = "Option::is_none")] pub actions: Option, - /// A list of Unix shell style patterns. The formatter will ignore files/folders that will + /// A list of Unix shell style patterns. Biome will ignore files/folders that will /// match these patterns. #[bpaf(hide, pure(Default::default()))] #[serde(skip_serializing_if = "Option::is_none")] pub ignore: Option>>, - /// A list of Unix shell style patterns. The formatter will include files/folders that will + /// A list of Unix shell style patterns. Biome will include files/folders that will /// match these patterns. #[bpaf(hide, pure(Default::default()))] #[serde(skip_serializing_if = "Option::is_none")] pub include: Option>>, + + /// A list of glob patterns. Biome will include files/folders that will + /// match these patterns. + #[bpaf(hide, pure(Default::default()))] + #[serde(skip_serializing_if = "Option::is_none")] + pub includes: Option>, } impl AssistConfiguration { diff --git a/crates/biome_configuration/src/analyzer/assists/mod.rs b/crates/biome_configuration/src/analyzer/assists/mod.rs new file mode 100644 index 000000000000..39a5205ecca8 --- /dev/null +++ b/crates/biome_configuration/src/analyzer/assists/mod.rs @@ -0,0 +1,48 @@ +mod actions; + +pub use crate::analyzer::assists::actions::*; +use biome_deserialize::StringSet; +use biome_deserialize_macros::{Deserializable, Merge, Partial}; +use bpaf::Bpaf; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Deserialize, Eq, Partial, PartialEq, Serialize)] +#[partial(derive(Bpaf, Clone, Deserializable, Eq, Merge, PartialEq))] +#[partial(cfg_attr(feature = "schema", derive(schemars::JsonSchema)))] +#[partial(serde(deny_unknown_fields, rename_all = "camelCase"))] +pub struct AssistsConfiguration { + /// Whether Biome should enable assists via LSP. + #[partial(bpaf(long("assists-enabled"), argument("true|false")))] + pub enabled: bool, + + /// Whether Biome should fail in CLI if the assists were not applied to the code. + #[partial(bpaf(pure(Default::default()), optional, hide))] + pub actions: Actions, + + /// A list of Unix shell style patterns. Biome will ignore files/folders that will + /// match these patterns. + #[partial(bpaf(hide))] + pub ignore: StringSet, + + /// A list of Unix shell style patterns. Biome will include files/folders that will + /// match these patterns. + #[partial(bpaf(hide))] + pub include: StringSet, + + /// A list of glob patterns. Biome will include files/folders that will + /// match these patterns. + #[partial(bpaf(pure(Default::default()), hide))] + pub includes: Vec, +} + +impl Default for AssistsConfiguration { + fn default() -> Self { + Self { + enabled: true, + actions: Actions::default(), + ignore: StringSet::default(), + include: StringSet::default(), + includes: Default::default(), + } + } +} diff --git a/crates/biome_configuration/src/analyzer/linter/mod.rs b/crates/biome_configuration/src/analyzer/linter/mod.rs index 53c791650eee..af27133c54b1 100644 --- a/crates/biome_configuration/src/analyzer/linter/mod.rs +++ b/crates/biome_configuration/src/analyzer/linter/mod.rs @@ -33,12 +33,18 @@ pub struct LinterConfiguration { #[serde(skip_serializing_if = "Option::is_none")] pub ignore: Option>>, - /// A list of Unix shell style patterns. The formatter will include files/folders that will + /// A list of Unix shell style patterns. The analyzer will include files/folders that will /// match these patterns. #[bpaf(hide, pure(Default::default()))] #[serde(skip_serializing_if = "Option::is_none")] pub include: Option>>, + /// A list of glob patterns. The analyzer will handle only those files/folders that will + /// match these patterns. + #[bpaf(pure(Default::default()), hide)] + #[serde(skip_serializing_if = "Option::is_none")] + pub includes: Option>, + /// An object where the keys are the names of the domains, and the values are boolean. `true` to turn-on the rules that /// belong to that domain, `false` to turn them off #[bpaf(hide, pure(Default::default()))] diff --git a/crates/biome_configuration/src/formatter.rs b/crates/biome_configuration/src/formatter.rs index 779c24b5df69..705108ca3387 100644 --- a/crates/biome_configuration/src/formatter.rs +++ b/crates/biome_configuration/src/formatter.rs @@ -83,6 +83,12 @@ pub struct FormatterConfiguration { #[bpaf(hide, pure(Default::default()))] #[serde(skip_serializing_if = "Option::is_none")] pub include: Option>>, + + /// A list of glob patterns. The formatter will include files/folders that will + /// match these patterns. + #[bpaf(pure(Default::default()), hide)] + #[serde(skip_serializing_if = "Option::is_none")] + pub includes: Option>, } impl FormatterConfiguration { @@ -121,12 +127,4 @@ impl FormatterConfiguration { pub fn use_editorconfig_resolved(&self) -> bool { self.use_editorconfig.unwrap_or_default().into() } - - pub fn ignore_resolved(&self) -> Vec> { - self.ignore.clone().unwrap_or_default() - } - - pub fn include_resolved(&self) -> Vec> { - self.include.clone().unwrap_or_default() - } } diff --git a/crates/biome_configuration/src/lib.rs b/crates/biome_configuration/src/lib.rs index 839c4ca7f8a9..ba82353aef2a 100644 --- a/crates/biome_configuration/src/lib.rs +++ b/crates/biome_configuration/src/lib.rs @@ -356,6 +356,12 @@ pub struct FilesConfiguration { #[bpaf(hide, pure(Default::default()))] #[serde(skip_serializing_if = "Option::is_none")] pub include: Option>>, + + /// A list of glob patterns. Biome will handle only those files/folders that will + /// match these patterns. + #[bpaf(hide, pure(Default::default()))] + #[serde(skip_serializing_if = "Option::is_none")] + pub includes: Option>, } pub struct ConfigurationPayload { diff --git a/crates/biome_configuration/src/organize_imports.rs b/crates/biome_configuration/src/organize_imports.rs new file mode 100644 index 000000000000..a03de8663ecc --- /dev/null +++ b/crates/biome_configuration/src/organize_imports.rs @@ -0,0 +1,50 @@ +use biome_deserialize::StringSet; +use biome_deserialize_macros::{Deserializable, Merge, Partial}; +use bpaf::Bpaf; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, Deserialize, Eq, Partial, PartialEq, Serialize)] +#[partial(derive(Bpaf, Clone, Deserializable, Eq, Merge, PartialEq))] +#[partial(cfg_attr(feature = "schema", derive(schemars::JsonSchema)))] +#[partial(serde(rename_all = "camelCase", default, deny_unknown_fields))] +pub struct OrganizeImports { + /// Enables the organization of imports + #[partial(bpaf(hide))] + pub enabled: bool, + + /// A list of Unix shell style patterns. The import organizer will ignore files/folders that will + /// match these patterns. + #[partial(bpaf(hide))] + pub ignore: StringSet, + + /// A list of Unix shell style patterns. The import organizer will include files/folders that will + /// match these patterns. + #[partial(bpaf(hide))] + pub include: StringSet, + + /// A list of glob patterns. The import organizer will include files/folders that will + /// match these patterns. + #[partial(bpaf(pure(Default::default()), hide))] + pub includes: Vec, +} + +impl Default for OrganizeImports { + fn default() -> Self { + Self { + enabled: true, + ignore: Default::default(), + include: Default::default(), + includes: Default::default(), + } + } +} + +impl PartialOrganizeImports { + pub const fn is_disabled(&self) -> bool { + matches!(self.enabled, Some(false)) + } + + pub const fn is_enabled(&self) -> bool { + !self.is_disabled() + } +} diff --git a/crates/biome_configuration/src/overrides.rs b/crates/biome_configuration/src/overrides.rs index c011018e7d5c..abc66c934e78 100644 --- a/crates/biome_configuration/src/overrides.rs +++ b/crates/biome_configuration/src/overrides.rs @@ -34,16 +34,21 @@ impl FromStr for Overrides { #[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] #[serde(rename_all = "camelCase", default, deny_unknown_fields)] pub struct OverridePattern { - /// A list of Unix shell style patterns. The formatter will ignore files/folders that will + /// A list of Unix shell style patterns. Biome will ignore files/folders that will /// match these patterns. #[serde(skip_serializing_if = "Option::is_none")] pub ignore: Option>>, - /// A list of Unix shell style patterns. The formatter will include files/folders that will + /// A list of Unix shell style patterns. Biome will include files/folders that will /// match these patterns. #[serde(skip_serializing_if = "Option::is_none")] pub include: Option>>, + /// A list of glob patterns. Biome will include files/folders that will + /// match these patterns. + #[serde(skip_serializing_if = "Option::is_none")] + pub includes: Option>, + /// Specific configuration for the JavaScript language #[serde(skip_serializing_if = "Option::is_none")] pub javascript: Option, diff --git a/crates/biome_configuration/tests/invalid/files_extraneous_field.json.snap b/crates/biome_configuration/tests/invalid/files_extraneous_field.json.snap index b144da9f9ff0..fc8eaf8c2411 100644 --- a/crates/biome_configuration/tests/invalid/files_extraneous_field.json.snap +++ b/crates/biome_configuration/tests/invalid/files_extraneous_field.json.snap @@ -1,6 +1,7 @@ --- source: crates/biome_service/tests/spec_tests.rs expression: files_extraneous_field.json +snapshot_kind: text --- files_extraneous_field.json:3:3 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -19,3 +20,4 @@ files_extraneous_field.json:3:3 deserialize ━━━━━━━━━━━━ - ignoreUnknown - ignore - include + - includes diff --git a/crates/biome_configuration/tests/invalid/formatter_extraneous_field.json.snap b/crates/biome_configuration/tests/invalid/formatter_extraneous_field.json.snap index 25e5faadae0b..27b8b57e2487 100644 --- a/crates/biome_configuration/tests/invalid/formatter_extraneous_field.json.snap +++ b/crates/biome_configuration/tests/invalid/formatter_extraneous_field.json.snap @@ -28,3 +28,4 @@ formatter_extraneous_field.json:3:3 deserialize ━━━━━━━━━━ - useEditorconfig - ignore - include + - includes diff --git a/crates/biome_configuration/tests/invalid/formatter_quote_style.json.snap b/crates/biome_configuration/tests/invalid/formatter_quote_style.json.snap index aaae7457feb9..34576e8a927e 100644 --- a/crates/biome_configuration/tests/invalid/formatter_quote_style.json.snap +++ b/crates/biome_configuration/tests/invalid/formatter_quote_style.json.snap @@ -28,3 +28,4 @@ formatter_quote_style.json:3:9 deserialize ━━━━━━━━━━━━ - useEditorconfig - ignore - include + - includes diff --git a/crates/biome_configuration/tests/invalid/overrides/incorrect_key.json.snap b/crates/biome_configuration/tests/invalid/overrides/incorrect_key.json.snap index ecc258318506..1444d0e4496d 100644 --- a/crates/biome_configuration/tests/invalid/overrides/incorrect_key.json.snap +++ b/crates/biome_configuration/tests/invalid/overrides/incorrect_key.json.snap @@ -18,6 +18,7 @@ incorrect_key.json:4:4 deserialize ━━━━━━━━━━━━━━━ - ignore - include + - includes - javascript - json - css diff --git a/crates/biome_configuration/tests/valid/overrides/top_level_keys.json b/crates/biome_configuration/tests/valid/overrides/top_level_keys.json index 5dfaed105db7..95add2114099 100644 --- a/crates/biome_configuration/tests/valid/overrides/top_level_keys.json +++ b/crates/biome_configuration/tests/valid/overrides/top_level_keys.json @@ -3,6 +3,7 @@ { "ignore": [], "include": [], + "includes": [], "javascript": {}, "json": {}, "css": {} diff --git a/crates/biome_glob/src/lib.rs b/crates/biome_glob/src/lib.rs index 2791a47d09d7..bd42efecb537 100644 --- a/crates/biome_glob/src/lib.rs +++ b/crates/biome_glob/src/lib.rs @@ -255,7 +255,7 @@ impl biome_deserialize::Deserializable for Glob { #[cfg(feature = "schema")] impl schemars::JsonSchema for Glob { fn schema_name() -> String { - "Regex".to_string() + "Glob".to_string() } fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema { diff --git a/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs b/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs index 6a7818503cad..0cd21989737e 100644 --- a/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs +++ b/crates/biome_js_analyze/src/lint/style/use_filenaming_convention.rs @@ -48,7 +48,7 @@ declare_lint_rule! { /// { /// "overrides": [ /// { - /// "include": ["test/**/*"], + /// "includes": ["test/**/*"], /// "linter": { /// "rules": { /// "style": { diff --git a/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs b/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs index 11112641192b..835bbbf447dc 100644 --- a/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs +++ b/crates/biome_js_analyze/src/lint/style/use_naming_convention.rs @@ -307,7 +307,7 @@ declare_lint_rule! { /// // ... /// "overrides": [ /// { - /// "include": ["typings/*.d.ts"], + /// "includes": ["typings/*.d.ts"], /// "linter": { /// "rules": { /// "style": { diff --git a/crates/biome_js_parser/tests/js_test_suite/ok/many_empty_strings.js.snap b/crates/biome_js_parser/tests/js_test_suite/ok/many_empty_strings.js.snap index 4fef657ca43c..bb065f491ed1 100644 --- a/crates/biome_js_parser/tests/js_test_suite/ok/many_empty_strings.js.snap +++ b/crates/biome_js_parser/tests/js_test_suite/ok/many_empty_strings.js.snap @@ -1,6 +1,7 @@ --- source: crates/biome_js_parser/tests/spec_test.rs expression: snapshot +snapshot_kind: text --- ## Input diff --git a/crates/biome_lsp/tests/server.rs b/crates/biome_lsp/tests/server.rs index fb42c6104c29..1c73b89c105a 100644 --- a/crates/biome_lsp/tests/server.rs +++ b/crates/biome_lsp/tests/server.rs @@ -1861,7 +1861,7 @@ async fn does_not_pull_action_for_disabled_rule_in_override_issue_2782() -> Resu }, "overrides": [ { - "include": ["*.ts", "*.tsx"], + "includes": ["**/*.ts", "**/*.tsx"], "linter": { "rules": { "style": { diff --git a/crates/biome_service/Cargo.toml b/crates/biome_service/Cargo.toml index e235dc6b8de9..38e43cef2d25 100644 --- a/crates/biome_service/Cargo.toml +++ b/crates/biome_service/Cargo.toml @@ -26,6 +26,7 @@ biome_deserialize = { workspace = true } biome_diagnostics = { workspace = true, features = ["camino"] } biome_formatter = { workspace = true, features = ["serde"] } biome_fs = { workspace = true, features = ["serde"] } +biome_glob = { workspace = true } biome_graphql_analyze = { workspace = true } biome_graphql_formatter = { workspace = true } biome_graphql_parser = { workspace = true } diff --git a/crates/biome_service/src/file_handlers/css.rs b/crates/biome_service/src/file_handlers/css.rs index 308652faa78a..295eb4ff4699 100644 --- a/crates/biome_service/src/file_handlers/css.rs +++ b/crates/biome_service/src/file_handlers/css.rs @@ -239,15 +239,9 @@ impl ServiceLanguage for CssLanguage { pattern.languages.css.formatter.enabled, pattern.formatter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -274,15 +268,9 @@ impl ServiceLanguage for CssLanguage { pattern.languages.css.assist.enabled, pattern.assist.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -309,15 +297,9 @@ impl ServiceLanguage for CssLanguage { pattern.languages.css.linter.enabled, pattern.linter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); diff --git a/crates/biome_service/src/file_handlers/graphql.rs b/crates/biome_service/src/file_handlers/graphql.rs index 66616269d189..ce818a8d7ff0 100644 --- a/crates/biome_service/src/file_handlers/graphql.rs +++ b/crates/biome_service/src/file_handlers/graphql.rs @@ -182,15 +182,9 @@ impl ServiceLanguage for GraphqlLanguage { pattern.languages.graphql.formatter.enabled, pattern.formatter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -217,15 +211,9 @@ impl ServiceLanguage for GraphqlLanguage { pattern.languages.graphql.assist.enabled, pattern.assist.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -252,15 +240,9 @@ impl ServiceLanguage for GraphqlLanguage { pattern.languages.graphql.linter.enabled, pattern.linter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); diff --git a/crates/biome_service/src/file_handlers/grit.rs b/crates/biome_service/src/file_handlers/grit.rs index fe9fbb073a14..8cc6dfadbd82 100644 --- a/crates/biome_service/src/file_handlers/grit.rs +++ b/crates/biome_service/src/file_handlers/grit.rs @@ -153,15 +153,9 @@ impl ServiceLanguage for GritLanguage { pattern.languages.grit.formatter.enabled, pattern.formatter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -188,15 +182,9 @@ impl ServiceLanguage for GritLanguage { pattern.languages.grit.assist.enabled, pattern.assist.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -223,15 +211,9 @@ impl ServiceLanguage for GritLanguage { pattern.languages.grit.linter.enabled, pattern.linter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); diff --git a/crates/biome_service/src/file_handlers/html.rs b/crates/biome_service/src/file_handlers/html.rs index 0a3aa1f15f54..bf68fc8f4d92 100644 --- a/crates/biome_service/src/file_handlers/html.rs +++ b/crates/biome_service/src/file_handlers/html.rs @@ -153,15 +153,9 @@ impl ServiceLanguage for HtmlLanguage { pattern.languages.html.formatter.enabled, pattern.formatter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); diff --git a/crates/biome_service/src/file_handlers/javascript.rs b/crates/biome_service/src/file_handlers/javascript.rs index 5fe8ab06ab08..a9c21c261b71 100644 --- a/crates/biome_service/src/file_handlers/javascript.rs +++ b/crates/biome_service/src/file_handlers/javascript.rs @@ -367,15 +367,9 @@ impl ServiceLanguage for JsLanguage { pattern.languages.javascript.formatter.enabled, pattern.formatter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -402,15 +396,9 @@ impl ServiceLanguage for JsLanguage { pattern.languages.javascript.assist.enabled, pattern.assist.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -437,15 +425,9 @@ impl ServiceLanguage for JsLanguage { pattern.languages.javascript.linter.enabled, pattern.linter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); diff --git a/crates/biome_service/src/file_handlers/json.rs b/crates/biome_service/src/file_handlers/json.rs index 7f09dd5392c9..84efbe730370 100644 --- a/crates/biome_service/src/file_handlers/json.rs +++ b/crates/biome_service/src/file_handlers/json.rs @@ -221,15 +221,9 @@ impl ServiceLanguage for JsonLanguage { pattern.languages.json.formatter.enabled, pattern.formatter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -256,15 +250,9 @@ impl ServiceLanguage for JsonLanguage { pattern.languages.json.assist.enabled, pattern.assist.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); @@ -291,15 +279,9 @@ impl ServiceLanguage for JsonLanguage { pattern.languages.json.linter.enabled, pattern.linter.enabled, ) - .and_then(|enabled| { + .filter(|_| { // Then check whether the path satisfies - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { - Some(enabled) - } else { - None - } + pattern.is_file_included(path) }) }); diff --git a/crates/biome_service/src/projects.rs b/crates/biome_service/src/projects.rs index da7f702773b4..49e8f4ca92dd 100644 --- a/crates/biome_service/src/projects.rs +++ b/crates/biome_service/src/projects.rs @@ -174,27 +174,52 @@ impl Projects { }; let settings = &project_data.settings; - let (feature_included_files, feature_ignored_files) = match feature { + let (feature_includes_files, feature_included_files, feature_ignored_files) = match feature + { FeatureKind::Format => { let formatter = &settings.formatter; - (&formatter.included_files, &formatter.ignored_files) + ( + &formatter.includes_files, + &formatter.included_files, + &formatter.ignored_files, + ) } FeatureKind::Lint => { let linter = &settings.linter; - (&linter.included_files, &linter.ignored_files) + ( + &linter.includes_files, + &linter.included_files, + &linter.ignored_files, + ) } FeatureKind::Assist => { let assists = &settings.assist; - (&assists.included_files, &assists.ignored_files) + ( + &assists.includes_files, + &assists.included_files, + &assists.ignored_files, + ) } // TODO: enable once the configuration is available FeatureKind::Search => return false, // There is no search-specific config. FeatureKind::Debug => return false, }; - let is_feature_included = feature_included_files.is_empty() - || is_dir(path) - || feature_included_files.matches_path(path); + + let mut is_feature_included = true; + if !feature_includes_files.is_empty() { + let candidate_path = biome_glob::CandidatePath::new(&path); + is_feature_included = if is_dir(path) { + candidate_path.matches_directory_with_exceptions(feature_includes_files) + } else { + candidate_path.matches_with_exceptions(feature_includes_files) + }; + } + if !feature_included_files.is_empty() { + is_feature_included = + is_feature_included && (is_dir(path) || feature_included_files.matches_path(path)); + }; + !is_feature_included || feature_ignored_files.matches_path(path) } } diff --git a/crates/biome_service/src/settings.rs b/crates/biome_service/src/settings.rs index 1f310ef8c2d5..d774a6934560 100644 --- a/crates/biome_service/src/settings.rs +++ b/crates/biome_service/src/settings.rs @@ -149,7 +149,7 @@ impl Settings { for pattern in overrides.patterns.iter() { let pattern_rules = pattern.linter.rules.as_ref(); if let Some(pattern_rules) = pattern_rules { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { result = if let Some(mut result) = result.take() { // Override rules result.to_mut().merge_with(pattern_rules.clone()); @@ -173,7 +173,7 @@ impl Settings { for pattern in overrides.patterns.iter() { let pattern_rules = pattern.linter.domains.as_ref(); if let Some(pattern_rules) = pattern_rules { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { result = if let Some(mut result) = result.take() { // Override rules result.to_mut().merge_with(pattern_rules.clone()); @@ -195,7 +195,7 @@ impl Settings { for pattern in overrides.patterns.iter() { let pattern_rules = pattern.assist.actions.as_ref(); if let Some(pattern_rules) = pattern_rules { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { result = if let Some(mut result) = result.take() { // Override rules result.to_mut().merge_with(pattern_rules.clone()); @@ -241,6 +241,8 @@ pub struct FormatSettings { pub ignored_files: Matcher, /// List of included paths/files pub included_files: Matcher, + /// List of included paths/files + pub includes_files: Box<[biome_glob::Glob]>, } impl FormatSettings { @@ -297,6 +299,9 @@ pub struct LinterSettings { /// List of included paths/files to match pub included_files: Matcher, + /// List of included paths/files + pub includes_files: Box<[biome_glob::Glob]>, + /// Rule domains pub domains: Option>, } @@ -334,6 +339,9 @@ pub struct AssistSettings { /// List of included paths/files to match pub included_files: Matcher, + + /// List of included paths/files + pub includes_files: Box<[biome_glob::Glob]>, } impl AssistSettings { @@ -591,6 +599,9 @@ pub struct FilesSettings { /// List of paths/files to matcher pub included_files: Matcher, + /// List of included paths/files + pub includes_files: Box<[biome_glob::Glob]>, + /// Files not recognized by Biome should not emit a diagnostic pub ignore_unknown: Option, } @@ -622,6 +633,7 @@ fn to_file_settings( config.ignore.as_deref(), )?, included_files: Matcher::from_globs(working_directory, config.include.as_deref())?, + includes_files: config.includes.unwrap_or_default().into(), ignore_unknown: config.ignore_unknown, }) } else { @@ -743,9 +755,7 @@ impl WorkspaceSettingsHandle { .rev() .find_map(|pattern| { if let Some(enabled) = pattern.formatter.format_with_errors { - if pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) - { + if pattern.is_file_included(path) { return Some(enabled); } } @@ -764,26 +774,6 @@ pub struct OverrideSettings { } impl OverrideSettings { - /// Checks whether at least one override excludes the provided `path` - pub fn is_path_excluded(&self, path: &Utf8Path) -> Option { - for pattern in &self.patterns { - if pattern.exclude.matches_path(path) { - return Some(true); - } - } - None - } - /// Checks whether at least one override include the provided `path` - pub fn is_path_included(&self, path: &Utf8Path) -> Option { - for pattern in &self.patterns { - if pattern.include.matches_path(path) { - return Some(true); - } - } - None - } - // #endregion - /// It scans the current override rules and return the formatting options that of the first override is matched pub fn override_js_format_options( &self, @@ -791,7 +781,7 @@ impl OverrideSettings { mut options: JsFormatOptions, ) -> JsFormatOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_js_format_options(&mut options); } } @@ -808,9 +798,7 @@ impl OverrideSettings { // Reverse the traversal as only the last override takes effect .rev() .find_map(|pattern| { - if pattern.languages.javascript.globals.is_some() - && pattern.include.matches_path(path) - && !pattern.exclude.matches_path(path) + if pattern.languages.javascript.globals.is_some() && pattern.is_file_included(path) { pattern.languages.javascript.globals.clone() } else { @@ -827,7 +815,7 @@ impl OverrideSettings { // Reverse the traversal as only the last override takes effect .rev() .find_map(|pattern| { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.languages.javascript.environment.jsx_runtime } else { None @@ -842,7 +830,7 @@ impl OverrideSettings { mut options: GritFormatOptions, ) -> GritFormatOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_grit_format_options(&mut options); } } @@ -855,7 +843,7 @@ impl OverrideSettings { mut options: HtmlFormatOptions, ) -> HtmlFormatOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_html_format_options(&mut options); } } @@ -868,7 +856,7 @@ impl OverrideSettings { mut options: JsParserOptions, ) -> JsParserOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_js_parser_options(&mut options); } } @@ -881,7 +869,7 @@ impl OverrideSettings { mut options: JsonParserOptions, ) -> JsonParserOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_json_parser_options(&mut options); } } @@ -895,7 +883,7 @@ impl OverrideSettings { mut options: CssParserOptions, ) -> CssParserOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_css_parser_options(&mut options); } } @@ -911,7 +899,7 @@ impl OverrideSettings { mut options: CssFormatOptions, ) -> CssFormatOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_css_format_options(&mut options); } } @@ -925,7 +913,7 @@ impl OverrideSettings { mut options: JsonParserOptions, ) -> JsonParserOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_json_parser_options(&mut options); } } @@ -939,7 +927,7 @@ impl OverrideSettings { mut options: JsonFormatOptions, ) -> JsonFormatOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_json_format_options(&mut options); } } @@ -957,12 +945,13 @@ impl OverrideSettings { mut options: GraphqlFormatOptions, ) -> GraphqlFormatOptions { for pattern in self.patterns.iter() { - if pattern.include.matches_path(path) && !pattern.exclude.matches_path(path) { + if pattern.is_file_included(path) { pattern.apply_overrides_to_graphql_format_options(&mut options); } } options } + // #endregion /// Retrieves the options of lint rules that have been overridden pub fn override_analyzer_rules( @@ -971,7 +960,7 @@ impl OverrideSettings { mut analyzer_rules: AnalyzerRules, ) -> AnalyzerRules { for pattern in self.patterns.iter() { - if !pattern.exclude.matches_path(path) && pattern.include.matches_path(path) { + if pattern.is_file_included(path) { if let Some(rules) = pattern.linter.rules.as_ref() { push_to_analyzer_rules( rules, @@ -1025,8 +1014,9 @@ impl OverrideSettings { #[derive(Clone, Debug, Default)] pub struct OverrideSettingPattern { - pub exclude: Matcher, - pub include: Matcher, + exclude: Matcher, + include: Matcher, + includes: Box<[biome_glob::Glob]>, /// Formatter settings applied to all files in the workspaces pub formatter: OverrideFormatSettings, /// Linter settings applied to all files in the workspace @@ -1038,6 +1028,23 @@ pub struct OverrideSettingPattern { } impl OverrideSettingPattern { + /// Returns `true` if this override settings concerns `file_path`. + /// + /// Note that only path to regular files should be passed. + /// This function doesn't take directories into account. + pub fn is_file_included(&self, file_path: &Utf8Path) -> bool { + if self.exclude.matches_path(file_path) { + return false; + } + self.include.matches_path(file_path) + || if !self.includes.is_empty() { + let candidate_path = biome_glob::CandidatePath::new(&file_path); + candidate_path.matches_with_exceptions(&self.includes) + } else { + false + } + } + fn apply_overrides_to_js_format_options(&self, options: &mut JsFormatOptions) { let js_formatter = &self.languages.javascript.formatter; let formatter = &self.formatter; @@ -1311,6 +1318,7 @@ pub fn to_override_settings( languages.html = to_html_language_settings(html, ¤t_settings.languages.html); let pattern_setting = OverrideSettingPattern { + includes: pattern.includes.unwrap_or_default().into(), include: Matcher::from_globs(working_directory.clone(), pattern.include.as_deref())?, exclude: Matcher::from_globs(working_directory.clone(), pattern.ignore.as_deref())?, formatter, @@ -1441,6 +1449,7 @@ pub fn to_format_settings( bracket_spacing: conf.bracket_spacing, ignored_files: Matcher::from_globs(working_directory.clone(), conf.ignore.as_deref())?, included_files: Matcher::from_globs(working_directory, conf.include.as_deref())?, + includes_files: conf.includes.unwrap_or_default().into(), }) } @@ -1467,6 +1476,7 @@ impl TryFrom for FormatSettings { format_with_errors: conf.format_with_errors, ignored_files: Matcher::empty(), included_files: Matcher::empty(), + includes_files: Default::default(), }) } } @@ -1480,6 +1490,7 @@ pub fn to_linter_settings( rules: conf.rules, ignored_files: Matcher::from_globs(working_directory.clone(), conf.ignore.as_deref())?, included_files: Matcher::from_globs(working_directory.clone(), conf.include.as_deref())?, + includes_files: conf.includes.unwrap_or_default().into(), domains: conf.domains, }) } @@ -1493,6 +1504,7 @@ impl TryFrom for LinterSettings { rules: conf.rules, ignored_files: Matcher::empty(), included_files: Matcher::empty(), + includes_files: Default::default(), domains: conf.domains, }) } @@ -1507,6 +1519,7 @@ pub fn to_assist_settings( actions: conf.actions, ignored_files: Matcher::from_globs(working_directory.clone(), conf.ignore.as_deref())?, included_files: Matcher::from_globs(working_directory.clone(), conf.include.as_deref())?, + includes_files: conf.includes.unwrap_or_default().into(), }) } @@ -1519,6 +1532,7 @@ impl TryFrom for AssistSettings { actions: conf.actions, ignored_files: Matcher::empty(), included_files: Matcher::empty(), + includes_files: Default::default(), }) } } diff --git a/crates/biome_service/src/workspace/server.rs b/crates/biome_service/src/workspace/server.rs index 9c01f2cbb4cd..f35eae5ad6cd 100644 --- a/crates/biome_service/src/workspace/server.rs +++ b/crates/biome_service/src/workspace/server.rs @@ -483,9 +483,19 @@ impl WorkspaceServer { return false; }; - let is_included = files_settings.included_files.is_empty() - || is_dir(path) - || files_settings.included_files.matches_path(path); + let mut is_included = true; + if !files_settings.includes_files.is_empty() { + let candidate_path = biome_glob::CandidatePath::new(&path); + is_included = if is_dir(path) { + candidate_path.matches_directory_with_exceptions(&files_settings.includes_files) + } else { + candidate_path.matches_with_exceptions(&files_settings.includes_files) + }; + } + if !files_settings.included_files.is_empty() { + is_included = + is_included && (is_dir(path) || files_settings.included_files.matches_path(path)) + }; !is_included || files_settings.ignored_files.matches_path(path) diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index b5a2605dbb27..b7bd679f86fa 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -98,13 +98,17 @@ export interface AssistConfiguration { */ enabled?: Bool; /** - * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. + * A list of Unix shell style patterns. Biome will ignore files/folders that will match these patterns. */ ignore?: string[]; /** - * A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns. + * A list of Unix shell style patterns. Biome will include files/folders that will match these patterns. */ include?: string[]; + /** + * A list of glob patterns. Biome will include files/folders that will match these patterns. + */ + includes?: Glob[]; } /** * Options applied to CSS files @@ -147,6 +151,10 @@ export interface FilesConfiguration { * A list of Unix shell style patterns. Biome will handle only those files/folders that will match these patterns. */ include?: string[]; + /** + * A list of glob patterns. Biome will handle only those files/folders that will match these patterns. + */ + includes?: Glob[]; /** * The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reasons. Defaults to 1 MiB */ @@ -181,6 +189,10 @@ export interface FormatterConfiguration { * A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns. */ include?: string[]; + /** + * A list of glob patterns. The formatter will include files/folders that will match these patterns. + */ + includes?: Glob[]; /** * The indent style. */ @@ -314,9 +326,13 @@ export interface LinterConfiguration { */ ignore?: string[]; /** - * A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns. + * A list of Unix shell style patterns. The analyzer will include files/folders that will match these patterns. */ include?: string[]; + /** + * A list of glob patterns. The analyzer will handle only those files/folders that will match these patterns. + */ + includes?: Glob[]; /** * List of rules */ @@ -359,6 +375,7 @@ export interface Actions { recommended?: boolean; source?: Source; } +export type Glob = string; /** * Options that changes how the CSS assist behaves */ @@ -768,13 +785,17 @@ export interface OverridePattern { */ html?: HtmlConfiguration; /** - * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. + * A list of Unix shell style patterns. Biome will ignore files/folders that will match these patterns. */ ignore?: string[]; /** - * A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns. + * A list of Unix shell style patterns. Biome will include files/folders that will match these patterns. */ include?: string[]; + /** + * A list of glob patterns. Biome will include files/folders that will match these patterns. + */ + includes?: Glob[]; /** * Specific configuration for the JavaScript language */ @@ -2611,7 +2632,7 @@ export interface RuleWithFixOptions_for_NoDoubleEqualsOptions { */ options: NoDoubleEqualsOptions; } -export type ImportGroup = PredefinedImportGroup | Regex; +export type ImportGroup = PredefinedImportGroup | Glob; /** * Used to identify the kind of code action emitted by a rule */ @@ -2834,7 +2855,6 @@ export type PredefinedImportGroup = | ":bun:" | ":node:" | ":types:"; -export type Regex = string; export type DependencyAvailability = boolean | string[]; export interface Hook { /** @@ -2865,6 +2885,7 @@ For example, for React's `useRef()` hook the value would be `true`, while for `u export type Accessibility = "noPublic" | "explicit" | "none"; export type ConsistentArrayType = "shorthand" | "generic"; export type FilenameCases = FilenameCase[]; +export type Regex = string; export interface Convention { /** * String cases to enforce diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index a69c7c7a30fe..7da573bac89e 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -398,14 +398,19 @@ "anyOf": [{ "$ref": "#/definitions/Bool" }, { "type": "null" }] }, "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "description": "A list of Unix shell style patterns. Biome will ignore files/folders that will match these patterns.", "type": ["array", "null"], "items": { "type": "string" } }, "include": { - "description": "A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns.", + "description": "A list of Unix shell style patterns. Biome will include files/folders that will match these patterns.", "type": ["array", "null"], "items": { "type": "string" } + }, + "includes": { + "description": "A list of glob patterns. Biome will include files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { "$ref": "#/definitions/Glob" } } }, "additionalProperties": false @@ -1390,6 +1395,11 @@ "type": ["array", "null"], "items": { "type": "string" } }, + "includes": { + "description": "A list of glob patterns. Biome will handle only those files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { "$ref": "#/definitions/Glob" } + }, "maxSize": { "description": "The maximum allowed size for source code files in bytes. Files above this limit will be ignored for performance reasons. Defaults to 1 MiB", "anyOf": [{ "$ref": "#/definitions/MaxSize" }, { "type": "null" }] @@ -1469,6 +1479,11 @@ "type": ["array", "null"], "items": { "type": "string" } }, + "includes": { + "description": "A list of glob patterns. The formatter will include files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { "$ref": "#/definitions/Glob" } + }, "indentStyle": { "description": "The indent style.", "anyOf": [{ "$ref": "#/definitions/IndentStyle" }, { "type": "null" }] @@ -1492,6 +1507,7 @@ }, "additionalProperties": false }, + "Glob": { "type": "string" }, "GraphqlAssistConfiguration": { "description": "Options that changes how the GraphQL linter behaves", "type": "object", @@ -1807,7 +1823,7 @@ "ImportGroup": { "anyOf": [ { "$ref": "#/definitions/PredefinedImportGroup" }, - { "$ref": "#/definitions/Regex" } + { "$ref": "#/definitions/Glob" } ] }, "IndentScriptAndStyle": { @@ -2258,10 +2274,15 @@ "items": { "type": "string" } }, "include": { - "description": "A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns.", + "description": "A list of Unix shell style patterns. The analyzer will include files/folders that will match these patterns.", "type": ["array", "null"], "items": { "type": "string" } }, + "includes": { + "description": "A list of glob patterns. The analyzer will handle only those files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { "$ref": "#/definitions/Glob" } + }, "rules": { "description": "List of rules", "anyOf": [{ "$ref": "#/definitions/Rules" }, { "type": "null" }] @@ -3018,15 +3039,20 @@ ] }, "ignore": { - "description": "A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns.", + "description": "A list of Unix shell style patterns. Biome will ignore files/folders that will match these patterns.", "type": ["array", "null"], "items": { "type": "string" } }, "include": { - "description": "A list of Unix shell style patterns. The formatter will include files/folders that will match these patterns.", + "description": "A list of Unix shell style patterns. Biome will include files/folders that will match these patterns.", "type": ["array", "null"], "items": { "type": "string" } }, + "includes": { + "description": "A list of glob patterns. Biome will include files/folders that will match these patterns.", + "type": ["array", "null"], + "items": { "$ref": "#/definitions/Glob" } + }, "javascript": { "description": "Specific configuration for the JavaScript language", "anyOf": [