Skip to content

Commit 0ff8de4

Browse files
authored
test(parse/json): add test for bug where overrides erroneously override special parsing options (#3260)
1 parent 5fe2f68 commit 0ff8de4

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

crates/biome_cli/tests/cases/overrides_formatter.rs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,3 +671,64 @@ fn takes_last_formatter_enabled_into_account() {
671671
result,
672672
));
673673
}
674+
675+
#[test]
676+
#[ignore = "Enable when we fix the behavior of how overrides are applied for json files"]
677+
fn does_not_override_well_known_special_files_when_config_override_is_present() {
678+
let mut console = BufferConsole::default();
679+
let mut fs = MemoryFileSystem::default();
680+
let file_path = Path::new("biome.json");
681+
fs.insert(
682+
file_path.into(),
683+
r#"{
684+
"overrides": [
685+
{
686+
"include": [
687+
"**/*.json"
688+
],
689+
"formatter": { "enabled": false }
690+
}
691+
]
692+
}"#
693+
.as_bytes(),
694+
);
695+
696+
let tsconfig = Path::new("tsconfig.json");
697+
fs.insert(
698+
tsconfig.into(),
699+
r#"{
700+
// This is a comment
701+
"compilerOptions": {},
702+
}"#,
703+
);
704+
705+
let other_json = Path::new("other.json");
706+
fs.insert(
707+
other_json.into(),
708+
r#"{
709+
"asta": ["lorem", "ipsum", "first", "second"]
710+
}"#,
711+
);
712+
713+
let result = run_cli(
714+
DynRef::Borrowed(&mut fs),
715+
&mut console,
716+
Args::from(
717+
[
718+
"check",
719+
other_json.as_os_str().to_str().unwrap(),
720+
tsconfig.as_os_str().to_str().unwrap(),
721+
]
722+
.as_slice(),
723+
),
724+
);
725+
726+
assert!(result.is_ok(), "run_cli returned {result:?}");
727+
assert_cli_snapshot(SnapshotPayload::new(
728+
module_path!(),
729+
"does_not_override_well_known_special_files_when_config_override_is_present",
730+
fs,
731+
console,
732+
result,
733+
));
734+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
source: crates/biome_cli/tests/snap_test.rs
3+
expression: content
4+
---
5+
## `biome.json`
6+
7+
```json
8+
{
9+
"overrides": [
10+
{
11+
"include": ["**/*.json"],
12+
"formatter": { "enabled": false }
13+
}
14+
]
15+
}
16+
```
17+
18+
## `other.json`
19+
20+
```json
21+
{
22+
"asta": ["lorem", "ipsum", "first", "second"]
23+
}
24+
```
25+
26+
## `tsconfig.json`
27+
28+
```json
29+
{
30+
// This is a comment
31+
"compilerOptions": {},
32+
}
33+
```
34+
35+
# Emitted Messages
36+
37+
```block
38+
Checked 2 files in <TIME>. No fixes applied.
39+
```

0 commit comments

Comments
 (0)