Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
fix(rome_ci): apply import sorting (#4305)
Browse files Browse the repository at this point in the history
* fix(rome_ci): apply import sorting

* clippy

* better tests

* check feature inside LSP

* fix regression
  • Loading branch information
ematipico authored Mar 17, 2023
1 parent 3f6cff8 commit 6bd0a69
Show file tree
Hide file tree
Showing 36 changed files with 1,237 additions and 379 deletions.
2 changes: 1 addition & 1 deletion crates/rome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub(crate) fn check(mut session: CliSession) -> Result<(), CliDiagnostic> {
} else if apply && !apply_suggested {
Some(FixFileMode::SafeFixes)
} else {
Some(FixFileMode::SafeAndSuggestedFixes)
Some(FixFileMode::SafeAndUnsafeFixes)
};

execute_mode(
Expand Down
28 changes: 24 additions & 4 deletions crates/rome_cli/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,36 @@ impl Execution {
}

pub(crate) const fn is_check_apply(&self) -> bool {
match self.traversal_mode {
TraversalMode::Check { fix_file_mode } => fix_file_mode.is_some(),
_ => false,
}
matches!(
self.traversal_mode,
TraversalMode::Check {
fix_file_mode: Some(FixFileMode::SafeFixes)
}
)
}

pub(crate) const fn is_check_apply_unsafe(&self) -> bool {
matches!(
self.traversal_mode,
TraversalMode::Check {
fix_file_mode: Some(FixFileMode::SafeAndUnsafeFixes)
}
)
}

pub(crate) const fn is_format(&self) -> bool {
matches!(self.traversal_mode, TraversalMode::Format { .. })
}

/// Whether the traversal mode requires write access to files
pub(crate) const fn requires_write_access(&self) -> bool {
match self.traversal_mode {
TraversalMode::Check { fix_file_mode } => fix_file_mode.is_some(),
TraversalMode::CI => false,
TraversalMode::Format { write, .. } => write,
}
}

pub(crate) fn as_stdin_file(&self) -> Option<&(PathBuf, String)> {
match &self.traversal_mode {
TraversalMode::Format { stdin, .. } => stdin.as_ref(),
Expand Down
Loading

0 comments on commit 6bd0a69

Please sign in to comment.