Skip to content

Commit

Permalink
feat(config): add the includes field
Browse files Browse the repository at this point in the history
  • Loading branch information
Conaclos committed Jan 16, 2025
1 parent 4f07cc8 commit d4f8b93
Show file tree
Hide file tree
Showing 91 changed files with 573 additions and 393 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions crates/biome_cli/src/commands/rage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ impl Display for RageConfiguration<'_> {
.collect::<Vec<_>>()
.join(", ")
});
let includes = formatter_configuration.includes.map(|list| {
list.iter()
.map(|s| s.to_string())
.collect::<Vec<_>>()
.join(", ")
});
markup! (
{Section("Formatter")}
{KeyValuePair("Format with errors", markup!({DisplayOption(configuration.get_formatter_configuration().format_with_errors)}))}
Expand All @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions crates/biome_cli/src/execute/migrate/prettier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl TryFrom<PrettierConfiguration> 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
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_cli/tests/cases/config_extends.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn extends_config_merge_overrides() {
shared.into(),
r#"{
"overrides": [{
"include": ["**/*.js"],
"includes": ["**/*.js"],
"linter": { "rules": { "suspicious": { "noDebugger": "off" } } }
}]
}"#,
Expand All @@ -344,7 +344,7 @@ fn extends_config_merge_overrides() {
r#"{
"extends": ["shared.json"],
"overrides": [{
"include": ["**/*.js"],
"includes": ["**/*.js"],
"linter": { "rules": { "correctness": { "noUnusedVariables": "error" } } }
}]
}"#,
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/cases/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 5 additions & 5 deletions crates/biome_cli/tests/cases/included_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/cases/linter_domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fn enable_test_rules_via_overrides() {
}
},
"overrides": [{
"include": ["test1.js"],
"includes": ["test1.js"],
"linter": {
"domains": {
"test": "all"
Expand Down
54 changes: 27 additions & 27 deletions crates/biome_cli/tests/cases/overrides_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 } }]
}
"#
Expand Down Expand Up @@ -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 } }]
}
"#
Expand Down Expand Up @@ -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 } }
]
}
Expand Down Expand Up @@ -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" } }
]
}
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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" } } }
]
}
"#
Expand Down Expand Up @@ -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 } }
}
Expand Down Expand Up @@ -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 } }
]
}
Expand Down Expand Up @@ -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 } }
]
}
Expand Down Expand Up @@ -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 } }
]
}
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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 }
}
]
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -673,7 +673,7 @@ fn allow_trailing_commas_on_well_known_files() {
},
"overrides": [
{
"include": [
"includes": [
"**/*.json"
],
"json": { "parser": { "allowTrailingCommas": true } }
Expand Down Expand Up @@ -741,7 +741,7 @@ fn disallow_comments_on_well_known_files() {
},
"overrides": [
{
"include": [
"includes": [
"**/*.json"
],
"json": { "parser": { "allowComments": false } }
Expand Down Expand Up @@ -785,7 +785,7 @@ fn overrides_default_formatter_for_package_json() {
r#"{
"overrides": [
{
"include": ["package.json"],
"includes": ["package.json"],
"json": { "formatter": { "expand": "followSource" } }
}
]
Expand Down Expand Up @@ -825,7 +825,7 @@ fn overrides_grit_formatting_options() {
},
"overrides": [
{
"include": [
"includes": [
"file.grit"
],
"grit": { "formatter": { "indentStyle": "space", "indentWidth": 8 } }
Expand Down
Loading

0 comments on commit d4f8b93

Please sign in to comment.