mirror of
https://github.com/biomejs/biome.git
synced 2025-12-23 08:21:13 +00:00
feat(config): remove the ignore and include field (#5158)
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
parent
a7ebbf0db0
commit
ede663d886
35 changed files with 107 additions and 375 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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::<Vec<_>>()
|
||||
.join(", ")
|
||||
});
|
||||
let include = formatter_configuration.include.map(|list| {
|
||||
list.iter()
|
||||
.map(|s| s.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.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)?;
|
||||
|
||||
|
|
|
|||
|
|
@ -229,8 +229,6 @@ impl TryFrom<PrettierConfiguration> 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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -22,18 +22,6 @@ pub struct AssistConfiguration {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub actions: Option<Actions>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// A list of glob patterns. Biome will include files/folders that will
|
||||
/// match these patterns.
|
||||
#[bpaf(hide, pure(Default::default()))]
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,18 +27,6 @@ pub struct LinterConfiguration {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub rules: Option<Rules>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// A list of glob patterns. The analyzer will handle only those files/folders that will
|
||||
/// match these patterns.
|
||||
#[bpaf(pure(Default::default()), hide)]
|
||||
|
|
|
|||
|
|
@ -72,18 +72,6 @@ pub struct FormatterConfiguration {
|
|||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub use_editorconfig: Option<UseEditorconfigEnabled>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// A list of glob patterns. The formatter will include files/folders that will
|
||||
/// match these patterns.
|
||||
#[bpaf(pure(Default::default()), hide)]
|
||||
|
|
|
|||
|
|
@ -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<FilesIgnoreUnknownEnabled>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// 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<Vec<Box<str>>>,
|
||||
|
||||
/// A list of glob patterns. Biome will handle only those files/folders that will
|
||||
/// match these patterns.
|
||||
#[bpaf(hide, pure(Default::default()))]
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Vec<Box<str>>>,
|
||||
|
||||
/// A list of Unix shell style patterns. Biome will include files/folders that will
|
||||
/// match these patterns.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"files": {
|
||||
"ignore": "something"
|
||||
}
|
||||
}
|
||||
|
|
@ -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 │ }
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"files": {
|
||||
"ignore": ["correct", false]
|
||||
}
|
||||
}
|
||||
|
|
@ -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 │ }
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"files": {
|
||||
"include": "something"
|
||||
}
|
||||
}
|
||||
|
|
@ -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 │ }
|
||||
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"overrides": [
|
||||
{
|
||||
"ignore": [],
|
||||
"include": [],
|
||||
"includes": [],
|
||||
"javascript": {},
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"include": ["src/**/*.js"],
|
||||
"ignore": ["*.gen.js"]
|
||||
},
|
||||
"assists": {
|
||||
"assist": {
|
||||
"include": ["src/**/*.js"],
|
||||
"ignore": ["*.gen.js"]
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,10 +249,6 @@ pub struct FormatSettings {
|
|||
pub attribute_position: Option<AttributePosition>,
|
||||
pub bracket_same_line: Option<BracketSameLine>,
|
||||
pub bracket_spacing: Option<BracketSpacing>,
|
||||
/// 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<Rules>,
|
||||
|
||||
/// 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<Actions>,
|
||||
|
||||
/// 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<Gitignore>,
|
||||
|
||||
/// 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<OverrideFormatterConfiguration> 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<OverrideLinterConfiguration> 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<OverrideAssistConfiguration> for AssistSettings {
|
|||
Ok(Self {
|
||||
enabled: conf.enabled,
|
||||
actions: conf.actions,
|
||||
ignored_files: Matcher::empty(),
|
||||
included_files: Matcher::empty(),
|
||||
includes: Default::default(),
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
36
packages/@biomejs/backend-jsonrpc/src/workspace.ts
generated
36
packages/@biomejs/backend-jsonrpc/src/workspace.ts
generated
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
45
packages/@biomejs/biome/configuration_schema.json
generated
45
packages/@biomejs/biome/configuration_schema.json
generated
|
|
@ -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"],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue