Skip to content

Commit

Permalink
test(parse/json): add test for bug where overrides erroneously overri…
Browse files Browse the repository at this point in the history
…de special parsing options (#3260)
  • Loading branch information
dyc3 authored Jun 24, 2024
1 parent 5fe2f68 commit 0ff8de4
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
61 changes: 61 additions & 0 deletions crates/biome_cli/tests/cases/overrides_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,3 +671,64 @@ fn takes_last_formatter_enabled_into_account() {
result,
));
}

#[test]
#[ignore = "Enable when we fix the behavior of how overrides are applied for json files"]
fn does_not_override_well_known_special_files_when_config_override_is_present() {
let mut console = BufferConsole::default();
let mut fs = MemoryFileSystem::default();
let file_path = Path::new("biome.json");
fs.insert(
file_path.into(),
r#"{
"overrides": [
{
"include": [
"**/*.json"
],
"formatter": { "enabled": false }
}
]
}"#
.as_bytes(),
);

let tsconfig = Path::new("tsconfig.json");
fs.insert(
tsconfig.into(),
r#"{
// This is a comment
"compilerOptions": {},
}"#,
);

let other_json = Path::new("other.json");
fs.insert(
other_json.into(),
r#"{
"asta": ["lorem", "ipsum", "first", "second"]
}"#,
);

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from(
[
"check",
other_json.as_os_str().to_str().unwrap(),
tsconfig.as_os_str().to_str().unwrap(),
]
.as_slice(),
),
);

assert!(result.is_ok(), "run_cli returned {result:?}");
assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"does_not_override_well_known_special_files_when_config_override_is_present",
fs,
console,
result,
));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `biome.json`

```json
{
"overrides": [
{
"include": ["**/*.json"],
"formatter": { "enabled": false }
}
]
}
```

## `other.json`

```json
{
"asta": ["lorem", "ipsum", "first", "second"]
}
```

## `tsconfig.json`

```json
{
// This is a comment
"compilerOptions": {},
}
```

# Emitted Messages

```block
Checked 2 files in <TIME>. No fixes applied.
```

0 comments on commit 0ff8de4

Please sign in to comment.