Skip to content

Commit 098f1ff

Browse files
authored
fix(core): file size diagnostic severity (#9980)
1 parent 3f89810 commit 098f1ff

18 files changed

Lines changed: 122 additions & 29 deletions

.changeset/every-poets-throw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#9941](https://github.com/biomejs/biome/issues/9941): Biome now emits a `warning` diagnostic when a file exceed the `files.maxSize` limit.

crates/biome_cli/tests/commands/check.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3665,3 +3665,37 @@ fn check_tab_alignment_in_diff_output() {
36653665
result,
36663666
));
36673667
}
3668+
3669+
#[test]
3670+
fn file_too_large_error_on_warnings() {
3671+
let fs = MemoryFileSystem::default();
3672+
let mut console = BufferConsole::default();
3673+
fs.insert(Utf8PathBuf::from("biome.json"), CONFIG_FILE_SIZE_LIMIT);
3674+
// This file exceeds the limit
3675+
let large_file = Utf8Path::new("large.js");
3676+
fs.insert(large_file.into(), "statement1();\nstatement2();");
3677+
// This file is within the limit
3678+
let small_file = Utf8Path::new("small.js");
3679+
fs.insert(small_file.into(), "a;\n");
3680+
let (fs, result) = run_cli(
3681+
fs,
3682+
&mut console,
3683+
Args::from(
3684+
[
3685+
"check",
3686+
"--error-on-warnings",
3687+
large_file.as_str(),
3688+
small_file.as_str(),
3689+
]
3690+
.as_slice(),
3691+
),
3692+
);
3693+
assert!(result.is_err(), "run_cli returned {result:?}");
3694+
assert_cli_snapshot(SnapshotPayload::new(
3695+
module_path!(),
3696+
"file_too_large_error_on_warnings",
3697+
fs,
3698+
console,
3699+
result,
3700+
));
3701+
}

crates/biome_cli/tests/snapshots/main_cases_overrides_max_file_size/overrides_files_max_size_too_large_limit_check.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
4747
```block
4848
test.js check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4949
50-
i The size of the file is 13 B, which exceeds the configured maximum of 1 B for this project.
50+
! The size of the file is 13 B, which exceeds the configured maximum of 1 B for this project.
5151
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
5252
5353
5454
```
5555

5656
```block
5757
Checked 0 files in <TIME>. No fixes applied.
58-
Found 1 info.
58+
Found 1 warning.
5959
```

crates/biome_cli/tests/snapshots/main_cases_overrides_max_file_size/overrides_files_max_size_too_large_limit_format.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ format ━━━━━━━━━━━━━━━━━━━━━━━━
4747
```block
4848
test.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4949
50-
i The size of the file is 13 B, which exceeds the configured maximum of 1 B for this project.
50+
! The size of the file is 13 B, which exceeds the configured maximum of 1 B for this project.
5151
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
5252
5353
5454
```
5555

5656
```block
5757
Checked 0 files in <TIME>. No fixes applied.
58-
Found 1 info.
58+
Found 1 warning.
5959
```

crates/biome_cli/tests/snapshots/main_commands_check/file_too_large.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
2424
```block
2525
check.js check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2626
27-
i The size of the file is 1.0 MiB, which exceeds the configured maximum of 1.0 MiB for this project.
27+
! The size of the file is 1.0 MiB, which exceeds the configured maximum of 1.0 MiB for this project.
2828
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
2929
3030
3131
```
3232

3333
```block
3434
Checked 0 files in <TIME>. No fixes applied.
35-
Found 1 info.
35+
Found 1 warning.
3636
```

crates/biome_cli/tests/snapshots/main_commands_check/file_too_large_cli_limit.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
3131
```block
3232
check.js check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3333
34-
i The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
34+
! The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
3535
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
3636
3737
3838
```
3939

4040
```block
4141
Checked 0 files in <TIME>. No fixes applied.
42-
Found 1 info.
42+
Found 1 warning.
4343
```

crates/biome_cli/tests/snapshots/main_commands_check/file_too_large_config_limit.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
4141
```block
4242
check.js check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
4343
44-
i The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
44+
! The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
4545
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
4646
4747
4848
```
4949

5050
```block
5151
Checked 0 files in <TIME>. No fixes applied.
52-
Found 1 info.
52+
Found 1 warning.
5353
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
source: crates/biome_cli/tests/snap_test.rs
3+
expression: redactor(content)
4+
---
5+
## `biome.json`
6+
7+
```json
8+
{
9+
"files": {
10+
"maxSize": 16
11+
}
12+
}
13+
```
14+
15+
## `large.js`
16+
17+
```js
18+
statement1();
19+
statement2();
20+
```
21+
22+
## `small.js`
23+
24+
```js
25+
a;
26+
27+
```
28+
29+
# Termination Message
30+
31+
```block
32+
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
33+
34+
× Some warnings were emitted while running checks.
35+
36+
37+
38+
```
39+
40+
# Emitted Messages
41+
42+
```block
43+
large.js check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44+
45+
! The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
46+
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
47+
48+
49+
```
50+
51+
```block
52+
Checked 1 file in <TIME>. No fixes applied.
53+
Found 1 warning.
54+
```

crates/biome_cli/tests/snapshots/main_commands_ci/file_too_large.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ ci ━━━━━━━━━━━━━━━━━━━━━━━━━
2424
```block
2525
ci.js ci ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
2626
27-
i The size of the file is 1.0 MiB, which exceeds the configured maximum of 1.0 MiB for this project.
27+
! The size of the file is 1.0 MiB, which exceeds the configured maximum of 1.0 MiB for this project.
2828
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
2929
3030
3131
```
3232

3333
```block
3434
Checked 0 files in <TIME>. No fixes applied.
35-
Found 1 info.
35+
Found 1 warning.
3636
```

crates/biome_cli/tests/snapshots/main_commands_ci/file_too_large_cli_limit.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ ci ━━━━━━━━━━━━━━━━━━━━━━━━━
3131
```block
3232
ci.js ci ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3333
34-
i The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
34+
! The size of the file is 27 B, which exceeds the configured maximum of 16 B for this project.
3535
Use the `files.maxSize` configuration to change the maximum size of files processed, or `files.includes` to ignore the file.
3636
3737
3838
```
3939

4040
```block
4141
Checked 0 files in <TIME>. No fixes applied.
42-
Found 1 info.
42+
Found 1 warning.
4343
```

0 commit comments

Comments
 (0)