Skip to content

Commit af7c6c0

Browse files
ematipicosiketyan
andauthored
fix(cli): apply --assist-enabled (#6912)
Co-authored-by: Naoki Ikeguchi <me@s6n.jp>
1 parent d77eaff commit af7c6c0

File tree

7 files changed

+237
-0
lines changed

7 files changed

+237
-0
lines changed

.changeset/nice-pugs-guess.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 [#6904](https://github.com/biomejs/biome/issues/6904). Now Biome correctly applies the argument `--assist-enabled=false` when running the command `ci` and the command `check`.

crates/biome_cli/src/commands/check.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ impl CommandRunner for CheckCommandPayload {
8686
// configuration.
8787
linter.rules = None;
8888
}
89+
if let Some(assist) = conf.assist.as_mut() {
90+
// Don't overwrite actions from the CLI configuration.
91+
// Otherwise, actions that are disabled in the config file might
92+
// become re-enabled due to the defaults included in the CLI
93+
// configuration.
94+
assist.actions = None
95+
}
8996
configuration.merge_with(conf);
9097
}
9198

crates/biome_cli/src/commands/ci.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ impl CommandRunner for CiCommandPayload {
8282
// configuration.
8383
linter.rules = None;
8484
}
85+
if let Some(assist) = conf.assist.as_mut() {
86+
// Don't overwrite actions from the CLI configuration.
87+
// Otherwise, actions that are disabled in the config file might
88+
// become re-enabled due to the defaults included in the CLI
89+
// configuration.
90+
assist.actions = None
91+
}
8592
configuration.merge_with(conf);
8693
}
8794

crates/biome_cli/tests/commands/check.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,3 +3222,32 @@ fn check_returns_error_for_css_sorting() {
32223222
result,
32233223
));
32243224
}
3225+
3226+
#[test]
3227+
fn check_does_not_enable_assist() {
3228+
let fs = MemoryFileSystem::default();
3229+
let mut console = BufferConsole::default();
3230+
3231+
let file = Utf8Path::new("file.js");
3232+
3233+
fs.insert(
3234+
file.into(),
3235+
"import z from \"zod\"; \n import foo from \"foo\";".as_bytes(),
3236+
);
3237+
3238+
let (fs, result) = run_cli(
3239+
fs,
3240+
&mut console,
3241+
Args::from(["check", "--assist-enabled=false", file.as_str()].as_slice()),
3242+
);
3243+
3244+
assert!(result.is_err(), "run_cli returned {result:?}");
3245+
3246+
assert_cli_snapshot(SnapshotPayload::new(
3247+
module_path!(),
3248+
"ci_does_not_enable_assist",
3249+
fs,
3250+
console,
3251+
result,
3252+
));
3253+
}

crates/biome_cli/tests/commands/ci.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,3 +937,32 @@ fn ci_skip_parse_errors() {
937937
result,
938938
));
939939
}
940+
941+
#[test]
942+
fn ci_does_not_enable_assist() {
943+
let fs = MemoryFileSystem::default();
944+
let mut console = BufferConsole::default();
945+
946+
let file = Utf8Path::new("file.js");
947+
948+
fs.insert(
949+
file.into(),
950+
"import z from \"zod\"; \n import foo from \"foo\";".as_bytes(),
951+
);
952+
953+
let (fs, result) = run_cli(
954+
fs,
955+
&mut console,
956+
Args::from(["ci", "--assist-enabled=false", file.as_str()].as_slice()),
957+
);
958+
959+
assert!(result.is_err(), "run_cli returned {result:?}");
960+
961+
assert_cli_snapshot(SnapshotPayload::new(
962+
module_path!(),
963+
"ci_does_not_enable_assist",
964+
fs,
965+
console,
966+
result,
967+
));
968+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
source: crates/biome_cli/tests/snap_test.rs
3+
expression: redactor(content)
4+
---
5+
## `file.js`
6+
7+
```js
8+
import z from "zod";
9+
import foo from "foo";
10+
```
11+
12+
# Termination Message
13+
14+
```block
15+
check ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
16+
17+
× Some errors were emitted while running checks.
18+
19+
20+
21+
```
22+
23+
# Emitted Messages
24+
25+
```block
26+
file.js:1:8 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
27+
28+
! This import is unused.
29+
30+
> 1 │ import z from "zod";·
31+
│ ^
32+
2 │ import foo from "foo";
33+
34+
i Unused imports might be the result of an incomplete refactoring.
35+
36+
i Unsafe fix: Remove the unused imports.
37+
38+
1 │ import·z·from·"zod";·
39+
│ ---------------------
40+
41+
```
42+
43+
```block
44+
file.js:2:9 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
45+
46+
! This import is unused.
47+
48+
1 │ import z from "zod";·
49+
> 2 │ import foo from "foo";
50+
│ ^^^
51+
52+
i Unused imports might be the result of an incomplete refactoring.
53+
54+
i Unsafe fix: Remove the unused imports.
55+
56+
1 1 │ import z from "zod";·
57+
2 │ - ·import·foo·from·"foo";
58+
59+
60+
```
61+
62+
```block
63+
file.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64+
65+
× Formatter would have printed the following content:
66+
67+
1 │ - import·z·from·"zod";·
68+
2 │ - ·import·foo·from·"foo";
69+
1 │ + import·z·from·"zod";
70+
2 │ + import·foo·from·"foo";
71+
3 │ +
72+
73+
74+
```
75+
76+
```block
77+
Checked 1 file in <TIME>. No fixes applied.
78+
Found 1 error.
79+
Found 2 warnings.
80+
```
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
source: crates/biome_cli/tests/snap_test.rs
3+
expression: redactor(content)
4+
---
5+
## `file.js`
6+
7+
```js
8+
import z from "zod";
9+
import foo from "foo";
10+
```
11+
12+
# Termination Message
13+
14+
```block
15+
ci ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
16+
17+
× Some errors were emitted while running checks.
18+
19+
20+
21+
```
22+
23+
# Emitted Messages
24+
25+
```block
26+
file.js:1:8 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
27+
28+
! This import is unused.
29+
30+
> 1 │ import z from "zod";·
31+
│ ^
32+
2 │ import foo from "foo";
33+
34+
i Unused imports might be the result of an incomplete refactoring.
35+
36+
i Unsafe fix: Remove the unused imports.
37+
38+
1 │ import·z·from·"zod";·
39+
│ ---------------------
40+
41+
```
42+
43+
```block
44+
file.js:2:9 lint/correctness/noUnusedImports FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
45+
46+
! This import is unused.
47+
48+
1 │ import z from "zod";·
49+
> 2 │ import foo from "foo";
50+
│ ^^^
51+
52+
i Unused imports might be the result of an incomplete refactoring.
53+
54+
i Unsafe fix: Remove the unused imports.
55+
56+
1 1 │ import z from "zod";·
57+
2 │ - ·import·foo·from·"foo";
58+
59+
60+
```
61+
62+
```block
63+
file.js format ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64+
65+
× File content differs from formatting output
66+
67+
1 │ - import·z·from·"zod";·
68+
2 │ - ·import·foo·from·"foo";
69+
1 │ + import·z·from·"zod";
70+
2 │ + import·foo·from·"foo";
71+
3 │ +
72+
73+
74+
```
75+
76+
```block
77+
Checked 1 file in <TIME>. No fixes applied.
78+
Found 1 error.
79+
Found 2 warnings.
80+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy