From ede663d88643b99e4193d25051bdc27d024ed4d4 Mon Sep 17 00:00:00 2001 From: Victorien Elvinger Date: Thu, 20 Feb 2025 17:20:55 +0100 Subject: [PATCH] feat(config): remove the `ignore` and `include` field (#5158) Co-authored-by: Emanuele Stoppa --- .changeset/introduce_includes.md | 102 ++++++++++++++---- benchmark/biome.json | 4 +- biome.json | 5 +- crates/biome_cli/src/commands/rage.rs | 14 --- .../biome_cli/src/execute/migrate/prettier.rs | 2 - .../creates_config_file.snap | 6 +- ...n_biome_installed_via_package_manager.snap | 6 +- .../creates_config_jsonc_file.snap | 6 +- .../with_formatter_configuration.snap | 3 - .../src/analyzer/assist/mod.rs | 12 --- .../src/analyzer/assists/mod.rs | 12 --- .../src/analyzer/linter/mod.rs | 12 --- crates/biome_configuration/src/formatter.rs | 12 --- crates/biome_configuration/src/lib.rs | 13 --- .../src/organize_imports.rs | 11 -- crates/biome_configuration/src/overrides.rs | 5 - .../invalid/files_extraneous_field.json.snap | 6 +- .../invalid/files_ignore_incorrect_type.json | 5 - .../files_ignore_incorrect_type.json.snap | 17 --- .../invalid/files_ignore_incorrect_value.json | 5 - .../files_ignore_incorrect_value.json.snap | 17 --- .../invalid/files_include_incorrect_type.json | 5 - .../files_include_incorrect_type.json.snap | 17 --- .../formatter_extraneous_field.json.snap | 4 +- .../invalid/formatter_quote_style.json.snap | 4 +- .../invalid/overrides/incorrect_key.json.snap | 3 +- .../tests/valid/overrides/top_level_keys.json | 1 - .../biome_migrate/src/analyzers/includes.rs | 2 +- .../includes/invalid_include_ignore.json | 2 +- .../includes/invalid_include_ignore.json.snap | 8 +- crates/biome_service/src/projects.rs | 28 +---- crates/biome_service/src/settings.rs | 47 -------- crates/biome_service/src/workspace/server.rs | 5 - .../@biomejs/backend-jsonrpc/src/workspace.ts | 36 ------- .../@biomejs/biome/configuration_schema.json | 45 -------- 35 files changed, 107 insertions(+), 375 deletions(-) delete mode 100644 crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json delete mode 100644 crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json.snap delete mode 100644 crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json delete mode 100644 crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json.snap delete mode 100644 crates/biome_configuration/tests/invalid/files_include_incorrect_type.json delete mode 100644 crates/biome_configuration/tests/invalid/files_include_incorrect_type.json.snap diff --git a/.changeset/introduce_includes.md b/.changeset/introduce_includes.md index 753136395f..c7f96ef769 100644 --- a/.changeset/introduce_includes.md +++ b/.changeset/introduce_includes.md @@ -1,44 +1,102 @@ --- -"@biomejs/biome": minor +"@biomejs/biome": major --- -Introduce `includes`. +Removed `include` and `ignore` fields in favor of the new filed `includes`. -Biome allows users to `include` and `ignore` files in its configuration using glob patterns. +The Biome configuration file allows users to specify which files should be processed using [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)). +Prior to Biome 2.0, this was done using the `include` and `ignore` fields. +In Biome 2.0, `include` and `ignore` are removed and replaced by `includes`. +You can run `biome migrate` to convert `include` and `ignore` into `includes` automatically. -For example, in the following configuration, all files of the `src/` directory are checked except the ones ending with the extension `.test.js`. +`includes` uses a different glob pattern format that fixes [many](https://github.com/biomejs/biome/issues/2421) [issues](https://github.com/biomejs/biome/issues/3345) and many other limitations that Biome users reported. + +`includes` accepts an array of glob patterns. +A glob pattern starting with a `!` is a negated pattern also called exception. +This replaces `ignore` patterns and allows users to create chains of include and ignore patterns. +Thus, it is now possible to include again a file previously ignored. +This was not possible with `include` and `ignore`, because `ignore` has priority over `include`. + +The semantics of `*` and `**/*` have changed too. +Before, with `include` and `ignore`, the glob `*` was interpreted as `**/*`. +Now, with `includes`, the globs `*` and `**/*` are interpreted differently. +The first pattern matches all files that are inside a folder. +The second pattern recursively matches all files **and sub-folders** inside a folder. + +Let's take an example. +Given the following file hierarchy of a project... + +``` +├── biome.json +├── src +│   ├── file.js +│   ├── file.ts +│   ├── out.gen.js +│   ├── file.test.js +│ └── test +│ └── special.test.js +└── test ... +``` + +...we want: + +1. Ignore all files ending with `.test.js`, except `special.test.ts`. +2. Ignore all files of the `test` directory. + The `test` directory is located at the root of the project. +3. Execute the linter on files in the `src` directory, that don't end with `.gen.js`. + The `src` directory is located at the root of the project. +4. Enable the `noDefaultExport` lint rule on files ending with `.ts`. + +Prior to Biome 2.0, the configuration might look like: ```json { "files": { + "ignore": ["*.test.js", "test"] + }, + "linter": { "include": ["src/**"], - "ignore": ["**/*.test.js"] - } + "ignore": ["*.gen.js"], + "enabled": true + }, + "overrides": [{ + "include": ["*.ts"], + "linter": { "rules": { "style": { "noDefaultExport": "on" } } } + }] } ``` -Some Biome users have requested the ability to ignore a set of files except some of the files. -With the current system, this is not possible because `include` is always applied before `ignore`. +Unfortunately, the configuration doesn't quite fit what we want: -Also, many Biome users [reported](https://github.com/biomejs/biome/issues/2421) [issues](https://github.com/biomejs/biome/issues/3345) with the behavior of the glob patterns. -Notably: +1. There is no way to ignore files and unignore one of them. + Thus, we ignore all files ending with `.test.js`, including `special.test.ts`. +2. The configuration ignores all directories named `test`, including `src/test`. +3. The linter is executed on all files of all directories named `src` -- `src/**` is interpreted as `**/src/**` -- `*.js` is interpreted as `**/*.js` - -To solve all these issues, we introduce a new field `includes`, which replaces both `include` and `ignore`. -`includes` accepts an array of glob patterns with a stricter and more intuitive behavior than the previous glob pattern format. -A glob starting with a `!` is an exception. -This replaces `ignore` patterns. - -The previous configuration must be updated as follows: +All these issues and limitations are fixed with `includes`. +Here the migrated configuration: ```json { "files": { - "includes": ["src/**", "!**/*.test.js"] - } + "includes": ["**", "!**/*.test.js", "**/special.test.ts", "!test"] + }, + "linter": { + "includes": ["src/**", "!**/*.gen.js"], + "enabled": true + }, + "overrides": [{ + "includes": ["**/*.ts"], + "linter": { "rules": { "style": { "noDefaultExport": "on" } } } + }] } ``` -You can run `biome migrate` to automatically convert from `include` and `ignore` to `includes`. +1. All files named `special.test.ts` are unignored because the pattern appear after the pattern that ignore files ending with `.test.js`. +2. Only the `test` directory at the project's root is ignored because the pattern doesn't start with `**/`. +3. The linter is executed on the `src` directory at the project's root only. + +Because `includes` pattern have a different pattern format than `include` and `ignore` we made some adjustments: + +- We added the pattern `**` in `files.includes` to ensure that all files are included before ignoring some of them. +- We added the prefix `**/` for patterns that must match at any level of the file hierarchy. diff --git a/benchmark/biome.json b/benchmark/biome.json index 77e7210b2b..40f620534a 100644 --- a/benchmark/biome.json +++ b/benchmark/biome.json @@ -1,7 +1,7 @@ { "$schema": "../packages/@biomejs/biome/configuration_schema.json", "formatter": { - "include": [ + "includes": [ "**/*.js", "**/*.jsx", "**/*.cjs", @@ -11,7 +11,7 @@ "indentStyle": "space" }, "linter": { - "include": [ + "includes": [ "**/*.js" ], "rules": { diff --git a/biome.json b/biome.json index 98fb7eae05..4c6e8a0212 100644 --- a/biome.json +++ b/biome.json @@ -2,8 +2,9 @@ "$schema": "./packages/@biomejs/biome/configuration_schema.json", "assist": { "enabled": true, - "ignore": [ - "./packages/@biomejs/biome/configuration_schema.json" + "includes": [ + "**", + "!./packages/@biomejs/biome/configuration_schema.json" ], "actions": { "source": { diff --git a/crates/biome_cli/src/commands/rage.rs b/crates/biome_cli/src/commands/rage.rs index 33b477a0dc..f52ad0a4a7 100644 --- a/crates/biome_cli/src/commands/rage.rs +++ b/crates/biome_cli/src/commands/rage.rs @@ -242,18 +242,6 @@ impl Display for RageConfiguration<'_> { // Print formatter configuration if --formatter option is true if self.formatter { let formatter_configuration = configuration.get_formatter_configuration(); - let ignore = formatter_configuration.ignore.map(|list| { - list.iter() - .map(|s| s.to_string()) - .collect::>() - .join(", ") - }); - let include = formatter_configuration.include.map(|list| { - list.iter() - .map(|s| s.to_string()) - .collect::>() - .join(", ") - }); let includes = formatter_configuration.includes.map(|list| { list.iter() .map(|s| s.to_string()) @@ -269,8 +257,6 @@ impl Display for RageConfiguration<'_> { {KeyValuePair("Line width", markup!({DisplayOption(formatter_configuration.line_width)}))} {KeyValuePair("Attribute position", markup!({DisplayOption(formatter_configuration.attribute_position)}))} {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)?; diff --git a/crates/biome_cli/src/execute/migrate/prettier.rs b/crates/biome_cli/src/execute/migrate/prettier.rs index 9f649ff331..772bfc2958 100644 --- a/crates/biome_cli/src/execute/migrate/prettier.rs +++ b/crates/biome_cli/src/execute/migrate/prettier.rs @@ -229,8 +229,6 @@ impl TryFrom for biome_configuration::Configuration { bracket_same_line: Some(value.bracket_line.into()), attribute_position: Some(AttributePosition::default()), 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 diff --git a/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file.snap b/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file.snap index d96e802d4e..b94aa2287c 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file.snap @@ -1,7 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content -snapshot_kind: text +expression: redactor(content) --- ## `biome.json` @@ -14,8 +13,7 @@ snapshot_kind: text "useIgnoreFile": false }, "files": { - "ignoreUnknown": false, - "ignore": [] + "ignoreUnknown": false }, "formatter": { "enabled": true, diff --git a/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file_when_biome_installed_via_package_manager.snap b/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file_when_biome_installed_via_package_manager.snap index 9ba402f654..3c05856ac5 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file_when_biome_installed_via_package_manager.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_file_when_biome_installed_via_package_manager.snap @@ -1,7 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content -snapshot_kind: text +expression: redactor(content) --- ## `biome.json` @@ -14,8 +13,7 @@ snapshot_kind: text "useIgnoreFile": false }, "files": { - "ignoreUnknown": false, - "ignore": [] + "ignoreUnknown": false }, "formatter": { "enabled": true, diff --git a/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_jsonc_file.snap b/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_jsonc_file.snap index fc44c9e4be..2044721226 100644 --- a/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_jsonc_file.snap +++ b/crates/biome_cli/tests/snapshots/main_commands_init/creates_config_jsonc_file.snap @@ -1,7 +1,6 @@ --- source: crates/biome_cli/tests/snap_test.rs -expression: content -snapshot_kind: text +expression: redactor(content) --- ## `biome.jsonc` @@ -14,8 +13,7 @@ snapshot_kind: text "useIgnoreFile": false }, "files": { - "ignoreUnknown": false, - "ignore": [] + "ignoreUnknown": false }, "formatter": { "enabled": true, 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 02149940d3..ac9f475d94 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 @@ -1,7 +1,6 @@ --- source: crates/biome_cli/tests/commands/rage.rs expression: content -snapshot_kind: text --- ## `biome.json` @@ -86,8 +85,6 @@ Formatter: Line width: 120 Attribute position: Multiline Bracket spacing: unset - Ignore: unset - Include: unset Includes: **/*.html, **/*.css, **/*.js, **/*.ts, **/*.tsx, **/*.jsx, **/*.json, **/*.md, !configuration-schema.json JavaScript Formatter: diff --git a/crates/biome_configuration/src/analyzer/assist/mod.rs b/crates/biome_configuration/src/analyzer/assist/mod.rs index 1c2410240c..e15e531b26 100644 --- a/crates/biome_configuration/src/analyzer/assist/mod.rs +++ b/crates/biome_configuration/src/analyzer/assist/mod.rs @@ -22,18 +22,6 @@ pub struct AssistConfiguration { #[serde(skip_serializing_if = "Option::is_none")] pub actions: Option, - /// 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. 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()))] diff --git a/crates/biome_configuration/src/analyzer/assists/mod.rs b/crates/biome_configuration/src/analyzer/assists/mod.rs index 39a5205ecc..7246c707c0 100644 --- a/crates/biome_configuration/src/analyzer/assists/mod.rs +++ b/crates/biome_configuration/src/analyzer/assists/mod.rs @@ -19,16 +19,6 @@ pub struct AssistsConfiguration { #[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))] @@ -40,8 +30,6 @@ impl Default for AssistsConfiguration { 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 2f9a67af05..5bb9c0be1d 100644 --- a/crates/biome_configuration/src/analyzer/linter/mod.rs +++ b/crates/biome_configuration/src/analyzer/linter/mod.rs @@ -27,18 +27,6 @@ pub struct LinterConfiguration { #[serde(skip_serializing_if = "Option::is_none")] pub rules: Option, - /// A list of Unix shell style patterns. The formatter 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 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)] diff --git a/crates/biome_configuration/src/formatter.rs b/crates/biome_configuration/src/formatter.rs index 705108ca33..fe2e7013e3 100644 --- a/crates/biome_configuration/src/formatter.rs +++ b/crates/biome_configuration/src/formatter.rs @@ -72,18 +72,6 @@ pub struct FormatterConfiguration { #[serde(skip_serializing_if = "Option::is_none")] pub use_editorconfig: Option, - /// A list of Unix shell style patterns. The formatter 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 - /// match these patterns. - #[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)] diff --git a/crates/biome_configuration/src/lib.rs b/crates/biome_configuration/src/lib.rs index d41811d19e..3da5407eda 100644 --- a/crates/biome_configuration/src/lib.rs +++ b/crates/biome_configuration/src/lib.rs @@ -171,7 +171,6 @@ impl Configuration { }), files: Some(FilesConfiguration { ignore_unknown: Some(false.into()), - ignore: Some(Default::default()), ..Default::default() }), formatter: Some(FormatterConfiguration { @@ -345,18 +344,6 @@ pub struct FilesConfiguration { #[serde(skip_serializing_if = "Option::is_none")] pub ignore_unknown: Option, - /// 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. 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 include: Option>>, - /// A list of glob patterns. Biome will handle only those files/folders that will /// match these patterns. #[bpaf(hide, pure(Default::default()))] diff --git a/crates/biome_configuration/src/organize_imports.rs b/crates/biome_configuration/src/organize_imports.rs index a03de8663e..51934a13cd 100644 --- a/crates/biome_configuration/src/organize_imports.rs +++ b/crates/biome_configuration/src/organize_imports.rs @@ -12,16 +12,6 @@ pub struct OrganizeImports { #[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))] @@ -33,7 +23,6 @@ impl Default for OrganizeImports { Self { enabled: true, ignore: Default::default(), - include: Default::default(), includes: Default::default(), } } diff --git a/crates/biome_configuration/src/overrides.rs b/crates/biome_configuration/src/overrides.rs index 21f2825b4b..13c08cd68c 100644 --- a/crates/biome_configuration/src/overrides.rs +++ b/crates/biome_configuration/src/overrides.rs @@ -34,11 +34,6 @@ 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. 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. Biome will include files/folders that will /// match these patterns. #[serde(skip_serializing_if = "Option::is_none")] 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 fc8eaf8c24..9e66781eb5 100644 --- a/crates/biome_configuration/tests/invalid/files_extraneous_field.json.snap +++ b/crates/biome_configuration/tests/invalid/files_extraneous_field.json.snap @@ -1,7 +1,7 @@ --- -source: crates/biome_service/tests/spec_tests.rs +source: crates/biome_configuration/tests/spec_tests.rs +assertion_line: 58 expression: files_extraneous_field.json -snapshot_kind: text --- files_extraneous_field.json:3:3 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -18,6 +18,4 @@ files_extraneous_field.json:3:3 deserialize ━━━━━━━━━━━━ - maxSize - ignoreUnknown - - ignore - - include - includes diff --git a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json b/crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json deleted file mode 100644 index f11d344365..0000000000 --- a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files": { - "ignore": "something" - } -} diff --git a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json.snap b/crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json.snap deleted file mode 100644 index 34e20a98ee..0000000000 --- a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_type.json.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/biome_service/tests/spec_tests.rs -expression: files_ignore_incorrect_type.json ---- -files_ignore_incorrect_type.json:3:13 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × ignore has an incorrect type, expected an array, but received a string. - - 1 │ { - 2 │ "files": { - > 3 │ "ignore": "something" - │ ^^^^^^^^^^^ - 4 │ } - 5 │ } - - - diff --git a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json b/crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json deleted file mode 100644 index 0853b725d2..0000000000 --- a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files": { - "ignore": ["correct", false] - } -} diff --git a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json.snap b/crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json.snap deleted file mode 100644 index be4f34ad2d..0000000000 --- a/crates/biome_configuration/tests/invalid/files_ignore_incorrect_value.json.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/biome_service/tests/spec_tests.rs -expression: files_ignore_incorrect_value.json ---- -files_ignore_incorrect_value.json:3:25 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × Incorrect type, expected a string, but received a boolean. - - 1 │ { - 2 │ "files": { - > 3 │ "ignore": ["correct", false] - │ ^^^^^ - 4 │ } - 5 │ } - - - diff --git a/crates/biome_configuration/tests/invalid/files_include_incorrect_type.json b/crates/biome_configuration/tests/invalid/files_include_incorrect_type.json deleted file mode 100644 index 20085eafc2..0000000000 --- a/crates/biome_configuration/tests/invalid/files_include_incorrect_type.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files": { - "include": "something" - } -} diff --git a/crates/biome_configuration/tests/invalid/files_include_incorrect_type.json.snap b/crates/biome_configuration/tests/invalid/files_include_incorrect_type.json.snap deleted file mode 100644 index 6aa2bcc64f..0000000000 --- a/crates/biome_configuration/tests/invalid/files_include_incorrect_type.json.snap +++ /dev/null @@ -1,17 +0,0 @@ ---- -source: crates/biome_service/tests/spec_tests.rs -expression: files_include_incorrect_type.json ---- -files_include_incorrect_type.json:3:14 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ - - × include has an incorrect type, expected an array, but received a string. - - 1 │ { - 2 │ "files": { - > 3 │ "include": "something" - │ ^^^^^^^^^^^ - 4 │ } - 5 │ } - - - 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 27b8b57e24..a7f256049b 100644 --- a/crates/biome_configuration/tests/invalid/formatter_extraneous_field.json.snap +++ b/crates/biome_configuration/tests/invalid/formatter_extraneous_field.json.snap @@ -1,7 +1,7 @@ --- source: crates/biome_configuration/tests/spec_tests.rs +assertion_line: 58 expression: formatter_extraneous_field.json -snapshot_kind: text --- formatter_extraneous_field.json:3:3 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -26,6 +26,4 @@ formatter_extraneous_field.json:3:3 deserialize ━━━━━━━━━━ - bracketSameLine - bracketSpacing - 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 34576e8a92..683aa7a14a 100644 --- a/crates/biome_configuration/tests/invalid/formatter_quote_style.json.snap +++ b/crates/biome_configuration/tests/invalid/formatter_quote_style.json.snap @@ -1,7 +1,7 @@ --- source: crates/biome_configuration/tests/spec_tests.rs +assertion_line: 58 expression: formatter_quote_style.json -snapshot_kind: text --- formatter_quote_style.json:3:9 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -26,6 +26,4 @@ formatter_quote_style.json:3:9 deserialize ━━━━━━━━━━━━ - bracketSameLine - bracketSpacing - 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 1444d0e449..b1787223a3 100644 --- a/crates/biome_configuration/tests/invalid/overrides/incorrect_key.json.snap +++ b/crates/biome_configuration/tests/invalid/overrides/incorrect_key.json.snap @@ -1,7 +1,7 @@ --- source: crates/biome_configuration/tests/spec_tests.rs +assertion_line: 58 expression: incorrect_key.json -snapshot_kind: text --- incorrect_key.json:4:4 deserialize ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ @@ -16,7 +16,6 @@ incorrect_key.json:4:4 deserialize ━━━━━━━━━━━━━━━ i Known keys: - - ignore - include - includes - javascript 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 95add21140..fb4f83ce3b 100644 --- a/crates/biome_configuration/tests/valid/overrides/top_level_keys.json +++ b/crates/biome_configuration/tests/valid/overrides/top_level_keys.json @@ -1,7 +1,6 @@ { "overrides": [ { - "ignore": [], "include": [], "includes": [], "javascript": {}, diff --git a/crates/biome_migrate/src/analyzers/includes.rs b/crates/biome_migrate/src/analyzers/includes.rs index ff7b80adc2..317d0dfb31 100644 --- a/crates/biome_migrate/src/analyzers/includes.rs +++ b/crates/biome_migrate/src/analyzers/includes.rs @@ -33,7 +33,7 @@ impl Rule for Includes { continue; }; match name.text() { - "files" | "formatter" | "linter" | "assists" => { + "files" | "formatter" | "linter" | "assist" => { let Ok(AnyJsonValue::JsonObjectValue(object)) = root_member.value() else { continue; }; diff --git a/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json b/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json index f31ca57e93..902aea9111 100644 --- a/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json +++ b/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json @@ -7,7 +7,7 @@ "include": ["src/**/*.js"], "ignore": ["*.gen.js"] }, - "assists": { + "assist": { "include": ["src/**/*.js"], "ignore": ["*.gen.js"] }, diff --git a/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json.snap b/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json.snap index 1c92459c2d..e32fb3056b 100644 --- a/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json.snap +++ b/crates/biome_migrate/tests/specs/migrations/includes/invalid_include_ignore.json.snap @@ -13,7 +13,7 @@ expression: invalid_include_ignore.json "include": ["src/**/*.js"], "ignore": ["*.gen.js"] }, - "assists": { + "assist": { "include": ["src/**/*.js"], "ignore": ["*.gen.js"] }, @@ -80,7 +80,7 @@ invalid_include_ignore.json:7:5 migrate FIXABLE ━━━━━━━━━━ 8 │ - ····"ignore":·["*.gen.js"] 7 │ + ····"includes":·["**/src/**/*.js",·"!**/*.gen.js"] 9 8 │ }, - 10 9 │ "assists": { + 10 9 │ "assist": { ``` @@ -91,7 +91,7 @@ invalid_include_ignore.json:11:5 migrate FIXABLE ━━━━━━━━━ ! include and ignore configurations have been replaced by the includes configuration. 9 │ }, - 10 │ "assists": { + 10 │ "assist": { > 11 │ "include": ["src/**/*.js"], │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ 12 │ "ignore": ["*.gen.js"] @@ -100,7 +100,7 @@ invalid_include_ignore.json:11:5 migrate FIXABLE ━━━━━━━━━ i Safe fix: Use includes instead. 9 9 │ }, - 10 10 │ "assists": { + 10 10 │ "assist": { 11 │ - ····"include":·["src/**/*.js"], 12 │ - ····"ignore":·["*.gen.js"] 11 │ + ····"includes":·["**/src/**/*.js",·"!**/*.gen.js"] diff --git a/crates/biome_service/src/projects.rs b/crates/biome_service/src/projects.rs index 2cc1f123d3..a6dc8e8c80 100644 --- a/crates/biome_service/src/projects.rs +++ b/crates/biome_service/src/projects.rs @@ -174,32 +174,19 @@ impl Projects { }; let settings = &project_data.settings; - let (feature_includes_files, feature_included_files, feature_ignored_files) = match feature - { + let feature_includes_files = match feature { FeatureKind::Format => { let formatter = &settings.formatter; - ( - &formatter.includes, - &formatter.included_files, - &formatter.ignored_files, - ) + &formatter.includes } FeatureKind::Lint => { let linter = &settings.linter; - ( - &linter.includes, - &linter.included_files, - &linter.ignored_files, - ) + &linter.includes } FeatureKind::Assist => { let assists = &settings.assist; - ( - &assists.includes, - &assists.included_files, - &assists.ignored_files, - ) + &assists.includes } // TODO: enable once the configuration is available FeatureKind::Search => return false, // There is no search-specific config. @@ -214,11 +201,6 @@ impl Projects { feature_includes_files.matches_with_exceptions(path) }; } - 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) + !is_feature_included } } diff --git a/crates/biome_service/src/settings.rs b/crates/biome_service/src/settings.rs index 49add7a355..6bfc57be62 100644 --- a/crates/biome_service/src/settings.rs +++ b/crates/biome_service/src/settings.rs @@ -249,10 +249,6 @@ pub struct FormatSettings { pub attribute_position: Option, pub bracket_same_line: Option, pub bracket_spacing: Option, - /// List of ignore paths/files - pub ignored_files: Matcher, - /// List of included paths/files - pub included_files: Matcher, /// List of included paths/files pub includes: Includes, } @@ -305,12 +301,6 @@ pub struct LinterSettings { /// List of rules pub rules: Option, - /// List of ignored paths/files to match - pub ignored_files: Matcher, - - /// List of included paths/files to match - pub included_files: Matcher, - /// List of included paths/files pub includes: Includes, @@ -346,12 +336,6 @@ pub struct AssistSettings { /// List of rules pub actions: Option, - /// List of ignored paths/files to match - pub ignored_files: Matcher, - - /// List of included paths/files to match - pub included_files: Matcher, - /// List of included paths/files pub includes: Includes, } @@ -605,12 +589,6 @@ pub struct FilesSettings { /// gitignore file patterns pub git_ignore: Option, - /// List of paths/files to matcher - pub ignored_files: Matcher, - - /// List of paths/files to matcher - pub included_files: Matcher, - /// List of included paths/files pub includes: Includes, @@ -695,14 +673,6 @@ fn to_file_settings( Some(FilesSettings { max_size: config.max_size, git_ignore, - ignored_files: Matcher::from_globs( - working_directory.clone(), - config.ignore.as_deref(), - )?, - included_files: Matcher::from_globs( - working_directory.clone(), - config.include.as_deref(), - )?, includes: Includes::new(working_directory, config.includes), ignore_unknown: config.ignore_unknown, }) @@ -1084,7 +1054,6 @@ impl OverrideSettings { #[derive(Clone, Debug, Default)] pub struct OverrideSettingPattern { - exclude: Matcher, include: Matcher, includes: Includes, /// Formatter settings applied to all files in the workspaces @@ -1103,9 +1072,6 @@ impl OverrideSettingPattern { /// 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_unset() { self.includes.matches_with_exceptions(file_path) @@ -1389,7 +1355,6 @@ pub fn to_override_settings( let pattern_setting = OverrideSettingPattern { includes: Includes::new(working_directory.clone(), pattern.includes), include: Matcher::from_globs(working_directory.clone(), pattern.include.as_deref())?, - exclude: Matcher::from_globs(working_directory.clone(), pattern.ignore.as_deref())?, formatter, linter, assist, @@ -1516,8 +1481,6 @@ pub fn to_format_settings( attribute_position: conf.attribute_position, bracket_same_line: conf.bracket_same_line, bracket_spacing: conf.bracket_spacing, - 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: Includes::new(working_directory, conf.includes), }) } @@ -1543,8 +1506,6 @@ impl TryFrom for FormatSettings { bracket_same_line: conf.bracket_same_line, bracket_spacing: Some(BracketSpacing::default()), format_with_errors: conf.format_with_errors, - ignored_files: Matcher::empty(), - included_files: Matcher::empty(), includes: Default::default(), }) } @@ -1557,8 +1518,6 @@ pub fn to_linter_settings( Ok(LinterSettings { enabled: conf.enabled, 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: Includes::new(working_directory, conf.includes), domains: conf.domains, }) @@ -1571,8 +1530,6 @@ impl TryFrom for LinterSettings { Ok(Self { enabled: conf.enabled, rules: conf.rules, - ignored_files: Matcher::empty(), - included_files: Matcher::empty(), includes: Default::default(), domains: conf.domains, }) @@ -1586,8 +1543,6 @@ pub fn to_assist_settings( Ok(AssistSettings { enabled: conf.enabled, 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: Includes::new(working_directory, conf.includes), }) } @@ -1599,8 +1554,6 @@ impl TryFrom for AssistSettings { Ok(Self { enabled: conf.enabled, actions: conf.actions, - ignored_files: Matcher::empty(), - included_files: Matcher::empty(), includes: Default::default(), }) } diff --git a/crates/biome_service/src/workspace/server.rs b/crates/biome_service/src/workspace/server.rs index bb1d9d13d3..321d2a8688 100644 --- a/crates/biome_service/src/workspace/server.rs +++ b/crates/biome_service/src/workspace/server.rs @@ -504,13 +504,8 @@ impl WorkspaceServer { files_settings.includes.matches_with_exceptions(path) }; } - 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) || files_settings.git_ignore.as_ref().is_some_and(|ignore| { // `matched_path_or_any_parents` panics if `source` is not under the gitignore root. // This checks excludes absolute paths that are not a prefix of the base root. diff --git a/packages/@biomejs/backend-jsonrpc/src/workspace.ts b/packages/@biomejs/backend-jsonrpc/src/workspace.ts index 0340c217d3..e8e1fb9c4f 100644 --- a/packages/@biomejs/backend-jsonrpc/src/workspace.ts +++ b/packages/@biomejs/backend-jsonrpc/src/workspace.ts @@ -97,14 +97,6 @@ export interface AssistConfiguration { * Whether Biome should enable assist via LSP. */ enabled?: Bool; - /** - * 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. 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. */ @@ -139,18 +131,10 @@ export interface CssConfiguration { * The configuration of the filesystem */ export interface FilesConfiguration { - /** - * A list of Unix shell style patterns. Biome will ignore files/folders that will match these patterns. - */ - ignore?: string[]; /** * Tells Biome to not emit diagnostics when handling files that doesn't know */ ignoreUnknown?: Bool; - /** - * 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. */ @@ -181,14 +165,6 @@ export interface FormatterConfiguration { * Stores whether formatting should be allowed to proceed if a given file has syntax errors */ formatWithErrors?: Bool; - /** - * A list of Unix shell style patterns. The formatter 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. - */ - include?: string[]; /** * A list of glob patterns. The formatter will include files/folders that will match these patterns. */ @@ -321,14 +297,6 @@ export interface LinterConfiguration { * if `false`, it disables the feature and the linter won't be executed. `true` by default */ enabled?: Bool; - /** - * A list of Unix shell style patterns. The formatter will ignore files/folders that will match these patterns. - */ - ignore?: string[]; - /** - * 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. */ @@ -792,10 +760,6 @@ export interface OverridePattern { * Specific configuration for the GritQL language */ html?: HtmlConfiguration; - /** - * 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. Biome will include files/folders that will match these patterns. */ diff --git a/packages/@biomejs/biome/configuration_schema.json b/packages/@biomejs/biome/configuration_schema.json index 177497adc6..4e01f374f9 100644 --- a/packages/@biomejs/biome/configuration_schema.json +++ b/packages/@biomejs/biome/configuration_schema.json @@ -397,16 +397,6 @@ "description": "Whether Biome should enable assist via LSP.", "anyOf": [{ "$ref": "#/definitions/Bool" }, { "type": "null" }] }, - "ignore": { - "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. 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"], @@ -1381,20 +1371,10 @@ "description": "The configuration of the filesystem", "type": "object", "properties": { - "ignore": { - "description": "A list of Unix shell style patterns. Biome will ignore files/folders that will match these patterns.", - "type": ["array", "null"], - "items": { "type": "string" } - }, "ignoreUnknown": { "description": "Tells Biome to not emit diagnostics when handling files that doesn't know", "anyOf": [{ "$ref": "#/definitions/Bool" }, { "type": "null" }] }, - "include": { - "description": "A list of Unix shell style patterns. Biome will handle only those files/folders that will match these patterns.", - "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"], @@ -1469,16 +1449,6 @@ "description": "Stores whether formatting should be allowed to proceed if a given file has syntax errors", "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.", - "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.", - "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"], @@ -2279,16 +2249,6 @@ "description": "if `false`, it disables the feature and the linter won't be executed. `true` by default", "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.", - "type": ["array", "null"], - "items": { "type": "string" } - }, - "include": { - "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"], @@ -3085,11 +3045,6 @@ { "type": "null" } ] }, - "ignore": { - "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. Biome will include files/folders that will match these patterns.", "type": ["array", "null"],