Skip to content

Commit

Permalink
refactor: remove organizeImports (#4788)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored Dec 26, 2024
1 parent 4f4cafb commit 93d1e23
Show file tree
Hide file tree
Showing 113 changed files with 807 additions and 945 deletions.
5 changes: 5 additions & 0 deletions .changeset/the_organizeimports_is_now_part_of_biome_assist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cli: major
---

# The `organizeImports` is now part of Biome Assist
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ things you would need to run and check:
- `just f` (alias for `just format`), formats Rust and TOML files.
- `just l` (alias for `just lint`), run the linter for the whole project.
- Code generation. The code generation of the repository is spread in the different parts of the code base. Sometimes is needed and sometime it isn't:
- run `just gen-lint` when you're working on the **linter**;
- run `just gen-analyzer` when you're working on the **linter**;
- run `just gen-bindings` in case you worked around the **workspace**.

> [!NOTE]
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/biome_analyze/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ declare_lint_rule! {
For simplicity, use `just` to run all the commands with:

```shell
just gen-lint
just gen-analyzer
```

### Commiting your work
Expand Down
12 changes: 1 addition & 11 deletions crates/biome_cli/src/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use crate::commands::{get_files_to_process_with_cli_options, CommandRunner};
use crate::{CliDiagnostic, Execution, TraversalMode};
use biome_configuration::analyzer::assist::PartialAssistConfiguration;
use biome_configuration::{
organize_imports::PartialOrganizeImports, PartialConfiguration, PartialFormatterConfiguration,
PartialLinterConfiguration,
PartialConfiguration, PartialFormatterConfiguration, PartialLinterConfiguration,
};
use biome_console::Console;
use biome_deserialize::Merge;
Expand All @@ -22,7 +21,6 @@ pub(crate) struct CheckCommandPayload {
pub(crate) stdin_file_path: Option<String>,
pub(crate) formatter_enabled: Option<bool>,
pub(crate) linter_enabled: Option<bool>,
pub(crate) organize_imports_enabled: Option<bool>,
pub(crate) assist_enabled: Option<bool>,
pub(crate) staged: bool,
pub(crate) changed: bool,
Expand Down Expand Up @@ -73,14 +71,6 @@ impl CommandRunner for CheckCommandPayload {
linter.enabled = self.linter_enabled;
}

let organize_imports = fs_configuration
.organize_imports
.get_or_insert_with(PartialOrganizeImports::default);

if self.organize_imports_enabled.is_some() {
organize_imports.enabled = self.organize_imports_enabled;
}

let assist = fs_configuration
.assist
.get_or_insert_with(PartialAssistConfiguration::default);
Expand Down
15 changes: 3 additions & 12 deletions crates/biome_cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::cli_options::CliOptions;
use crate::commands::{CommandRunner, LoadEditorConfig};
use crate::{CliDiagnostic, Execution};
use biome_configuration::analyzer::assist::PartialAssistConfiguration;
use biome_configuration::{organize_imports::PartialOrganizeImports, PartialConfiguration};
use biome_configuration::PartialConfiguration;
use biome_configuration::{PartialFormatterConfiguration, PartialLinterConfiguration};
use biome_console::Console;
use biome_deserialize::Merge;
Expand All @@ -15,7 +15,6 @@ use std::ffi::OsString;
pub(crate) struct CiCommandPayload {
pub(crate) formatter_enabled: Option<bool>,
pub(crate) linter_enabled: Option<bool>,
pub(crate) organize_imports_enabled: Option<bool>,
pub(crate) assist_enabled: Option<bool>,
pub(crate) paths: Vec<OsString>,
pub(crate) configuration: Option<PartialConfiguration>,
Expand Down Expand Up @@ -68,14 +67,6 @@ impl CommandRunner for CiCommandPayload {
linter.enabled = self.linter_enabled;
}

let organize_imports = fs_configuration
.organize_imports
.get_or_insert_with(PartialOrganizeImports::default);

if self.organize_imports_enabled.is_some() {
organize_imports.enabled = self.organize_imports_enabled;
}

let assist = fs_configuration
.assist
.get_or_insert_with(PartialAssistConfiguration::default);
Expand Down Expand Up @@ -130,9 +121,9 @@ impl CommandRunner for CiCommandPayload {
fn check_incompatible_arguments(&self) -> Result<(), CliDiagnostic> {
if matches!(self.formatter_enabled, Some(false))
&& matches!(self.linter_enabled, Some(false))
&& matches!(self.organize_imports_enabled, Some(false))
&& matches!(self.assist_enabled, Some(false))
{
return Err(CliDiagnostic::incompatible_end_configuration("Formatter, linter and organize imports are disabled, can't perform the command. At least one feature needs to be enabled. This is probably and error."));
return Err(CliDiagnostic::incompatible_end_configuration("Formatter, linter and assist are disabled, can't perform the command. At least one feature needs to be enabled. This is probably and error."));
}
if self.since.is_some() && !self.changed {
return Err(CliDiagnostic::incompatible_arguments("since", "changed"));
Expand Down
11 changes: 0 additions & 11 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,6 @@ pub enum BiomeCommand {
/// Allow to enable or disable the linter check.
#[bpaf(long("linter-enabled"), argument("true|false"), optional, hide_usage)]
linter_enabled: Option<bool>,
/// Allow to enable or disable the organize imports.
#[bpaf(
long("organize-imports-enabled"),
argument("true|false"),
optional,
hide_usage
)]
organize_imports_enabled: Option<bool>,

/// Allow to enable or disable the assist.
#[bpaf(long("assist-enabled"), argument("true|false"), optional)]
Expand Down Expand Up @@ -329,9 +321,6 @@ pub enum BiomeCommand {
/// Allow to enable or disable the linter check.
#[bpaf(long("linter-enabled"), argument("true|false"), optional)]
linter_enabled: Option<bool>,
/// Allow to enable or disable the organize imports.
#[bpaf(long("organize-imports-enabled"), argument("true|false"), optional)]
organize_imports_enabled: Option<bool>,

/// Allow to enable or disable the assist.
#[bpaf(long("assist-enabled"), argument("true|false"), optional)]
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/src/commands/rage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl Display for RageConfiguration<'_> {
{KeyValuePair("Status", status)}
{KeyValuePair("Formatter disabled", markup!({DebugDisplay(configuration.is_formatter_disabled())}))}
{KeyValuePair("Linter disabled", markup!({DebugDisplay(configuration.is_linter_disabled())}))}
{KeyValuePair("Organize imports disabled", markup!({DebugDisplay(configuration.is_organize_imports_disabled())}))}
{KeyValuePair("Assist disabled", markup!({DebugDisplay(configuration.is_assist_disabled())}))}
{KeyValuePair("VCS disabled", markup!({DebugDisplay(configuration.is_vcs_disabled())}))}
).fmt(fmt)?;

Expand Down Expand Up @@ -294,13 +294,13 @@ impl Display for RageConfiguration<'_> {
let javascript_linter = configuration.get_javascript_linter_configuration();
let json_linter = configuration.get_json_linter_configuration();
let css_linter = configuration.get_css_linter_configuration();
let graphq_linter = configuration.get_graphql_linter_configuration();
let graphql_linter = configuration.get_graphql_linter_configuration();
markup! (
{Section("Linter")}
{KeyValuePair("JavaScript enabled", markup!({DebugDisplay(javascript_linter.enabled)}))}
{KeyValuePair("JSON enabled", markup!({DebugDisplay(json_linter.enabled)}))}
{KeyValuePair("CSS enabled", markup!({DebugDisplay(css_linter.enabled)}))}
{KeyValuePair("GraphQL enabled", markup!({DebugDisplay(graphq_linter.enabled)}))}
{KeyValuePair("GraphQL enabled", markup!({DebugDisplay(graphql_linter.enabled)}))}
{KeyValuePair("Recommended", markup!({DebugDisplay(linter_configuration.recommended.unwrap_or_default())}))}
{RageConfigurationLintRules("Enabled rules", linter_configuration)}
).fmt(fmt)?;
Expand Down
24 changes: 0 additions & 24 deletions crates/biome_cli/src/execute/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@ pub(crate) struct CIFormatDiffDiagnostic {
pub(crate) diff: ContentDiffAdvice,
}

#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "organizeImports",
message = "Import statements differs from the output"
)]
pub(crate) struct CIOrganizeImportsDiffDiagnostic {
#[location(resource)]
pub(crate) file_name: String,
#[advice]
pub(crate) diff: ContentDiffAdvice,
}
#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "assist",
Expand All @@ -54,19 +43,6 @@ pub(crate) struct FormatDiffDiagnostic {
pub(crate) diff: ContentDiffAdvice,
}

#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "organizeImports",
severity = Error,
message = "Import statements could be sorted:"
)]
pub(crate) struct OrganizeImportsDiffDiagnostic {
#[location(resource)]
pub(crate) file_name: String,
#[advice]
pub(crate) diff: ContentDiffAdvice,
}

#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "assist",
Expand Down
4 changes: 2 additions & 2 deletions crates/biome_cli/src/execute/migrate/eslint_to_biome.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ mod tests {
assert!(biome_config.files.is_none());
assert!(biome_config.overrides.is_none());
assert!(biome_config.formatter.is_none());
assert!(biome_config.organize_imports.is_none());
assert!(biome_config.assist.is_none());
let linter = biome_config.linter.unwrap();
assert_eq!(linter.include.unwrap(), ["*.js".into()],);
assert_eq!(linter.ignore.unwrap(), ["*.test.js".into()],);
Expand Down Expand Up @@ -393,7 +393,7 @@ mod tests {

assert!(biome_config.files.is_none());
assert!(biome_config.formatter.is_none());
assert!(biome_config.organize_imports.is_none());
assert!(biome_config.assist.is_none());
let linter = biome_config.linter.unwrap();
assert!(linter.include.is_none());
assert_eq!(
Expand Down
1 change: 0 additions & 1 deletion crates/biome_cli/src/execute/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ impl Execution {
TraversalMode::Format { .. } => FeaturesBuilder::new().with_formatter().build(),
TraversalMode::Lint { .. } => FeaturesBuilder::new().with_linter().build(),
TraversalMode::Check { .. } | TraversalMode::CI { .. } => FeaturesBuilder::new()
.with_organize_imports()
.with_formatter()
.with_linter()
.with_assist()
Expand Down
4 changes: 1 addition & 3 deletions crates/biome_cli/src/execute/process_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ mod assist;
mod check;
mod format;
mod lint;
mod organize_imports;
mod search;
pub(crate) mod workspace_file;

Expand Down Expand Up @@ -73,7 +72,6 @@ impl Message {
#[derive(Debug)]
pub(crate) enum DiffKind {
Format,
OrganizeImports,
Assist,
}

Expand Down Expand Up @@ -174,7 +172,7 @@ pub(crate) fn process_file(ctx: &TraversalOptions, biome_path: &BiomePath) -> Fi
)
.and(
file_features
.support_kind_for(&FeatureKind::OrganizeImports)
.support_kind_for(&FeatureKind::Assist)
.and_then(|support_kind| {
if support_kind.is_not_enabled() {
Some(support_kind)
Expand Down
22 changes: 0 additions & 22 deletions crates/biome_cli/src/execute/process_file/check.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::execute::process_file::assist::assist_with_guard;
use crate::execute::process_file::format::format_with_guard;
use crate::execute::process_file::lint::lint_with_guard;
use crate::execute::process_file::organize_imports::organize_imports_with_guard;
use crate::execute::process_file::workspace_file::WorkspaceFile;
use crate::execute::process_file::{FileResult, FileStatus, Message, SharedTraversalOptions};
use biome_diagnostics::{category, DiagnosticExt};
Expand Down Expand Up @@ -49,27 +48,6 @@ pub(crate) fn check_file<'ctx>(
}
}

if file_features.supports_organize_imports() {
let organize_imports_result = organize_imports_with_guard(ctx, &mut workspace_file);
match organize_imports_result {
Ok(status) => {
if status.is_changed() {
changed = true
}
if let FileStatus::Message(msg) = status {
if msg.is_failure() {
has_failures = true;
}
ctx.push_message(msg);
}
}
Err(err) => {
ctx.push_message(err);
has_failures = true;
}
}
}

if file_features.supports_assist() {
let assist_result = assist_with_guard(ctx, &mut workspace_file);
match assist_result {
Expand Down
67 changes: 0 additions & 67 deletions crates/biome_cli/src/execute/process_file/organize_imports.rs

This file was deleted.

Loading

0 comments on commit 93d1e23

Please sign in to comment.