Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: flag to suppress existing diagnostics #4008

Merged
merged 67 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
62e46bc
WIP
anthonyshew Sep 20, 2024
9c50af1
WIP
anthonyshew Sep 20, 2024
a87006b
WIP
anthonyshew Sep 20, 2024
a39718d
WIP
anthonyshew Sep 20, 2024
cf0b9c0
WIP
anthonyshew Sep 22, 2024
02115cc
WIP
anthonyshew Sep 23, 2024
3b613f0
WIP
anthonyshew Sep 23, 2024
2eb7cdc
WIP
anthonyshew Sep 23, 2024
c378a77
WIP
anthonyshew Sep 26, 2024
dd05b07
WIP
anthonyshew Sep 26, 2024
c28db57
WIP
anthonyshew Sep 26, 2024
0cedb3e
WIP
anthonyshew Sep 26, 2024
a797a87
WIP
anthonyshew Sep 26, 2024
f1707a4
WIP
anthonyshew Sep 29, 2024
046e120
WIP
anthonyshew Sep 29, 2024
8bb572f
WIP
anthonyshew Sep 29, 2024
09889d0
WIP
anthonyshew Sep 29, 2024
25af91c
WIP
anthonyshew Sep 29, 2024
3611db0
WIP
anthonyshew Sep 29, 2024
6c6431b
WIP
anthonyshew Sep 29, 2024
8ddedf4
WIP
anthonyshew Sep 30, 2024
35e2145
WIP
anthonyshew Oct 2, 2024
86560e9
WIP
anthonyshew Oct 2, 2024
1b44843
WIP
anthonyshew Oct 2, 2024
88bfa71
WIP
anthonyshew Oct 2, 2024
f754916
WIP
anthonyshew Oct 2, 2024
0e1a789
WIP
anthonyshew Oct 2, 2024
e6b406d
WIP
anthonyshew Oct 2, 2024
cc81046
WIP
anthonyshew Oct 2, 2024
071d024
WIP
anthonyshew Oct 2, 2024
e43e9af
WIP
anthonyshew Oct 2, 2024
de33eab
Merge branch 'main' of https://github.com/anthonyshew/biome into shew…
anthonyshew Oct 2, 2024
3030687
WIP
anthonyshew Oct 2, 2024
f19cee6
Fix codegen.
anthonyshew Oct 2, 2024
2838190
WIP
anthonyshew Oct 2, 2024
82fd461
Update crates/biome_cli/src/commands/mod.rs
anthonyshew Oct 2, 2024
616b5da
WIP
anthonyshew Oct 2, 2024
1dfc0dc
Tests pass and behavior looks correct here. Write some more tests.
anthonyshew Oct 2, 2024
704cc59
Cleanup.
anthonyshew Oct 2, 2024
143db55
Wrote some tests.
anthonyshew Oct 2, 2024
063cb77
Fix codegen.
anthonyshew Oct 2, 2024
e5424b0
Reset codegen.
anthonyshew Oct 3, 2024
358bb87
codegen pls
anthonyshew Oct 3, 2024
66c9e9f
codegen pls
anthonyshew Oct 3, 2024
df889ec
WIP
anthonyshew Oct 3, 2024
497abd8
WIP
anthonyshew Oct 3, 2024
b870607
WIP
anthonyshew Oct 3, 2024
4ba4097
WIP
anthonyshew Oct 3, 2024
0aa9783
Fix JS API.
anthonyshew Oct 3, 2024
d5d8768
Merge branch 'main' into shew-d3bfe
anthonyshew Oct 3, 2024
23eaae2
Update crates/biome_cli/src/commands/mod.rs
anthonyshew Oct 5, 2024
f205f49
Update crates/biome_service/src/file_handlers/json.rs
anthonyshew Oct 5, 2024
50d5d17
Update crates/biome_service/src/file_handlers/graphql.rs
anthonyshew Oct 5, 2024
c143abd
Update crates/biome_service/src/file_handlers/css.rs
anthonyshew Oct 5, 2024
adeeb02
Fixes from review.
anthonyshew Oct 5, 2024
b497bd6
Merge branch 'shew-d3bfe' of https://github.com/anthonyshew/biome int…
anthonyshew Oct 5, 2024
6cd1584
Format.
anthonyshew Oct 5, 2024
9e8285f
Undo codegen since option is no longer there.
anthonyshew Oct 5, 2024
f6ce7b6
Merge branch 'main' into shew-d3bfe
anthonyshew Oct 5, 2024
5638e9a
Fix codegen?
anthonyshew Oct 5, 2024
e39b50a
Merge branch 'shew-d3bfe' of https://github.com/anthonyshew/biome int…
anthonyshew Oct 5, 2024
497a7e1
WIP
anthonyshew Oct 5, 2024
eaeebd4
WIP
anthonyshew Oct 5, 2024
aa121eb
WIP
anthonyshew Oct 5, 2024
45c26f4
WIP
anthonyshew Oct 5, 2024
b2a4ba3
Update snapshot.
anthonyshew Oct 5, 2024
0ccd3d0
Fix merge conflicts.
anthonyshew Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/biome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl CommandRunner for CheckCommandPayload {
apply: self.apply,
apply_unsafe: self.apply_unsafe,
write: self.write,
suppress: false,
fix: self.fix,
unsafe_: self.unsafe_,
},
Expand Down
3 changes: 3 additions & 0 deletions crates/biome_cli/src/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ pub(crate) struct LintCommandPayload {
pub(crate) write: bool,
pub(crate) fix: bool,
pub(crate) unsafe_: bool,
pub(crate) suppress: bool,
pub(crate) linter_configuration: Option<PartialLinterConfiguration>,
pub(crate) vcs_configuration: Option<PartialVcsConfiguration>,
pub(crate) files_configuration: Option<PartialFilesConfiguration>,
Expand Down Expand Up @@ -136,6 +137,7 @@ impl CommandRunner for LintCommandPayload {
write: self.write,
fix: self.fix,
unsafe_: self.unsafe_,
suppress: self.suppress,
},
console,
)?;
Expand All @@ -145,6 +147,7 @@ impl CommandRunner for LintCommandPayload {
only: self.only.clone(),
skip: self.skip.clone(),
vcs_targeted: (self.staged, self.changed).into(),
suppress: self.suppress,
})
.set_report(cli_options))
}
Expand Down
1 change: 1 addition & 0 deletions crates/biome_cli/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl CommandRunner for MigrateCommandPayload {
write: self.write,
fix: self.fix,
unsafe_: false,
suppress: false,
})
}

Expand Down
55 changes: 38 additions & 17 deletions crates/biome_cli/src/commands/mod.rs
anthonyshew marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ pub enum BiomeCommand {
#[bpaf(long("write"), switch)]
write: bool,

/// Fix diagnostics with suppression comments if the language supports it.
#[bpaf(long("suppress"))]
suppress: bool,

/// Allow to do unsafe fixes, should be used with `--write` or `--fix`
#[bpaf(long("unsafe"), switch)]
unsafe_: bool,
Expand Down Expand Up @@ -703,6 +707,7 @@ pub(crate) struct FixFileModeOptions {
apply: bool,
apply_unsafe: bool,
write: bool,
suppress: bool,
fix: bool,
unsafe_: bool,
}
Expand All @@ -719,6 +724,7 @@ pub(crate) fn determine_fix_file_mode(
apply_unsafe,
write,
fix,
suppress,
unsafe_,
} = options;

Expand All @@ -743,6 +749,8 @@ pub(crate) fn determine_fix_file_mode(
Ok(Some(FixFileMode::SafeAndUnsafeFixes))
} else if safe_fixes {
Ok(Some(FixFileMode::SafeFixes))
} else if suppress {
Ok(Some(FixFileMode::ApplySuppressions))
} else {
Ok(None)
}
Expand All @@ -754,6 +762,7 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C
apply,
apply_unsafe,
write,
suppress,
fix,
unsafe_,
} = options;
Expand All @@ -779,6 +788,13 @@ fn check_fix_incompatible_arguments(options: FixFileModeOptions) -> Result<(), C
));
} else if write && fix {
return Err(CliDiagnostic::incompatible_arguments("--write", "--fix"));
} else if suppress && write {
return Err(CliDiagnostic::incompatible_arguments(
"--suppress",
"--write",
));
} else if suppress && fix {
return Err(CliDiagnostic::incompatible_arguments("--suppress", "--fix"));
}
Ok(())
}
Expand Down Expand Up @@ -967,19 +983,20 @@ mod tests {

#[test]
fn incompatible_arguments() {
for (apply, apply_unsafe, write, fix, unsafe_) in [
(true, true, false, false, false), // --apply --apply-unsafe
(true, false, true, false, false), // --apply --write
(true, false, false, true, false), // --apply --fix
(false, true, false, false, true), // --apply-unsafe --unsafe
(false, true, true, false, false), // --apply-unsafe --write
(false, true, false, true, false), // --apply-unsafe --fix
(false, false, true, true, false), // --write --fix
for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [
(true, true, false, false, false, false), // --apply --apply-unsafe
(true, false, true, false, false, false), // --apply --write
(true, false, false, false, true, false), // --apply --fix
(false, true, false, false, false, true), // --apply-unsafe --unsafe
(false, true, true, false, false, false), // --apply-unsafe --write
(false, true, false, false, true, false), // --apply-unsafe --fix
(false, false, true, false, true, false), // --write --fix
] {
assert!(check_fix_incompatible_arguments(FixFileModeOptions {
apply,
apply_unsafe,
write,
suppress,
fix,
unsafe_
})
Expand All @@ -991,17 +1008,18 @@ mod tests {
fn safe_fixes() {
let mut console = BufferConsole::default();

for (apply, apply_unsafe, write, fix, unsafe_) in [
(true, false, false, false, false), // --apply
(false, false, true, false, false), // --write
(false, false, false, true, false), // --fix
for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [
(true, false, false, false, false, false), // --apply
(false, false, true, false, false, false), // --write
(false, false, false, false, true, false), // --fix
] {
assert_eq!(
determine_fix_file_mode(
FixFileModeOptions {
apply,
apply_unsafe,
write,
suppress,
fix,
unsafe_
},
Expand All @@ -1017,17 +1035,18 @@ mod tests {
fn safe_and_unsafe_fixes() {
let mut console = BufferConsole::default();

for (apply, apply_unsafe, write, fix, unsafe_) in [
(false, true, false, false, false), // --apply-unsafe
(false, false, true, false, true), // --write --unsafe
(false, false, false, true, true), // --fix --unsafe
for (apply, apply_unsafe, write, suppress, fix, unsafe_) in [
(false, true, false, false, false, false), // --apply-unsafe
(false, false, true, false, false, true), // --write --unsafe
(false, false, false, false, true, true), // --fix --unsafe
] {
assert_eq!(
determine_fix_file_mode(
FixFileModeOptions {
apply,
apply_unsafe,
write,
suppress,
fix,
unsafe_
},
Expand All @@ -1043,13 +1062,15 @@ mod tests {
fn no_fix() {
let mut console = BufferConsole::default();

let (apply, apply_unsafe, write, fix, unsafe_) = (false, false, false, false, false);
let (apply, apply_unsafe, write, suppress, fix, unsafe_) =
(false, false, false, false, false, false);
assert_eq!(
determine_fix_file_mode(
FixFileModeOptions {
apply,
apply_unsafe,
write,
suppress,
fix,
unsafe_
},
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_cli/src/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ pub enum TraversalMode {
skip: Vec<RuleSelector>,
/// A flag to know vcs integrated options such as `--staged` or `--changed` are enabled
vcs_targeted: VcsTargeted,
/// Supress existing diagnostics with a `// biome-ignore` comment
suppress: bool,
},
/// This mode is enabled when running the command `biome ci`
CI {
Expand Down
2 changes: 2 additions & 0 deletions crates/biome_cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl<'app> CliSession<'app> {
apply,
apply_unsafe,
write,
suppress,
fix,
unsafe_,
cli_options,
Expand All @@ -154,6 +155,7 @@ impl<'app> CliSession<'app> {
apply_unsafe,
apply,
write,
suppress,
fix,
unsafe_,
linter_configuration,
Expand Down
1 change: 1 addition & 0 deletions crates/biome_cli/tests/cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ mod reporter_github;
mod reporter_gitlab;
mod reporter_junit;
mod reporter_summary;
mod suppressions;
mod unknown_files;
Loading