Skip to content

Commit

Permalink
feat: remove --indent-size (#4270)
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Oct 31, 2024
1 parent 7f4f0a8 commit a2eafcb
Show file tree
Hide file tree
Showing 35 changed files with 51 additions and 627 deletions.
15 changes: 15 additions & 0 deletions .changeset/remove_indentsize_option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
cli: major
---

# Remove `indentSize` deprecated option

The deprecated option `indentSize`, and its relative CLI options, has been removed:
- Configuration file: `formatter.indentSize`
- Configuration file: `javascript.formatter.indentSize`
- Configuration file: `json.formatter.indentSize`
- CLI option `--indent-size`
- CLI option `--javascript-formatter-indent-size`
- CLI option `--json-formatter-indent-size`

Use `indentWidth` and its relative CLI options instead.
50 changes: 1 addition & 49 deletions crates/biome_cli/src/commands/format.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
use crate::cli_options::CliOptions;
use crate::commands::{get_files_to_process_with_cli_options, CommandRunner, LoadEditorConfig};
use crate::diagnostics::DeprecatedArgument;
use crate::{CliDiagnostic, Execution, TraversalMode};
use biome_configuration::vcs::PartialVcsConfiguration;
use biome_configuration::{
PartialConfiguration, PartialCssFormatter, PartialFilesConfiguration,
PartialFormatterConfiguration, PartialGraphqlFormatter, PartialJavascriptFormatter,
PartialJsonFormatter,
};
use biome_console::{markup, Console, ConsoleExt};
use biome_console::Console;
use biome_deserialize::Merge;
use biome_diagnostics::PrintDiagnostic;
use biome_fs::FileSystem;
use biome_service::configuration::LoadedConfiguration;
use biome_service::{DynRef, Workspace, WorkspaceError};
Expand Down Expand Up @@ -63,52 +61,6 @@ impl CommandRunner for FormatCommandPayload {
fs_configuration.merge_with(biome_configuration);
let mut configuration = fs_configuration;

// TODO: remove in biome 2.0
if let Some(config) = self.formatter_configuration.as_mut() {
if let Some(indent_size) = config.indent_size {
let diagnostic = DeprecatedArgument::new(markup! {
"The argument "<Emphasis>"--indent-size"</Emphasis>" is deprecated, it will be removed in the next major release. Use "<Emphasis>"--indent-width"</Emphasis>" instead."
});
console.error(markup! {
{PrintDiagnostic::simple(&diagnostic)}
});

if config.indent_width.is_none() {
config.indent_width = Some(indent_size);
}
}
}
// TODO: remove in biome 2.0
if let Some(js_formatter) = self.javascript_formatter.as_mut() {
if let Some(indent_size) = js_formatter.indent_size {
let diagnostic = DeprecatedArgument::new(markup! {
"The argument "<Emphasis>"--javascript-formatter-indent-size"</Emphasis>" is deprecated, it will be removed in the next major release. Use "<Emphasis>"--javascript-formatter-indent-width"</Emphasis>" instead."
});
console.error(markup! {
{PrintDiagnostic::simple(&diagnostic)}
});

if js_formatter.indent_width.is_none() {
js_formatter.indent_width = Some(indent_size);
}
}
}
// TODO: remove in biome 2.0
if let Some(json_formatter) = self.json_formatter.as_mut() {
if let Some(indent_size) = json_formatter.indent_size {
let diagnostic = DeprecatedArgument::new(markup! {
"The argument "<Emphasis>"--json-formatter-indent-size"</Emphasis>" is deprecated, it will be removed in the next major release. Use "<Emphasis>"--json-formatter-indent-width"</Emphasis>" instead."
});
console.error(markup! {
{PrintDiagnostic::simple(&diagnostic)}
});

if json_formatter.indent_width.is_none() {
json_formatter.indent_width = Some(indent_size);
}
}
}

// merge formatter options
if !configuration
.formatter
Expand Down
9 changes: 0 additions & 9 deletions crates/biome_cli/src/diagnostics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use biome_console::fmt::Display;
use biome_console::markup;
use biome_diagnostics::adapters::{BpafError, IoError, SerdeJsonError};
use biome_diagnostics::{
Expand Down Expand Up @@ -258,14 +257,6 @@ pub struct DeprecatedArgument {
pub message: MessageAndDescription,
}

impl DeprecatedArgument {
pub fn new(message: impl Display) -> Self {
Self {
message: MessageAndDescription::from(markup! {{message}}.to_owned()),
}
}
}

#[derive(Debug, Diagnostic)]
pub enum ReportDiagnostic {
/// Emitted when trying to serialise the report
Expand Down
5 changes: 0 additions & 5 deletions crates/biome_cli/src/execute/migrate/prettier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ impl TryFrom<PrettierConfiguration> for biome_configuration::PartialConfiguratio
// editorconfig support is intentionally set to true, because prettier always reads the editorconfig file
// see: https://github.com/prettier/prettier/issues/15255
use_editorconfig: Some(true),
// deprecated
indent_size: None,
bracket_spacing: Some(BracketSpacing::default()),
};
result.formatter = Some(formatter);
Expand All @@ -239,9 +237,6 @@ impl TryFrom<PrettierConfiguration> for biome_configuration::PartialConfiguratio
indent_style: None,
line_ending: None,
enabled: None,
// deprecated
indent_size: None,

// js ones
bracket_same_line: Some(value.bracket_line),
arrow_parentheses: Some(value.arrow_parens.into()),
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/cases/biome_json_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn formatter_biome_json() {
("10"),
("--indent-style"),
("space"),
("--indent-size"),
("--indent-width"),
("8"),
("--write"),
file_path.as_os_str().to_str().unwrap(),
Expand Down
26 changes: 13 additions & 13 deletions crates/biome_cli/tests/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ fn applies_custom_configuration() {
("10"),
("--indent-style"),
("space"),
("--indent-size"),
("--indent-width"),
("8"),
("--write"),
file_path.as_os_str().to_str().unwrap(),
Expand Down Expand Up @@ -534,7 +534,7 @@ fn applies_custom_configuration_over_config_file() {
("10"),
("--indent-style"),
("space"),
("--indent-size"),
("--indent-width"),
("8"),
("--write"),
file_path.as_os_str().to_str().unwrap(),
Expand Down Expand Up @@ -1042,7 +1042,7 @@ fn indent_size_parse_errors_negative() {
let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("format"), ("--indent-size=-1"), ("file.js")].as_slice()),
Args::from([("format"), ("--indent-width=-1"), ("file.js")].as_slice()),
);

assert!(result.is_err(), "run_cli returned {result:?}");
Expand All @@ -1064,7 +1064,7 @@ fn indent_size_parse_errors_overflow() {
let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("format"), ("--indent-size=257"), ("file.js")].as_slice()),
Args::from([("format"), ("--indent-width=257"), ("file.js")].as_slice()),
);

assert!(result.is_err(), "run_cli returned {result:?}");
Expand Down Expand Up @@ -2557,13 +2557,13 @@ fn should_apply_different_formatting() {
"javascript": {
"formatter": {
"lineWidth": 320,
"indentSize": 8
"indentWidth": 8
}
},
"json": {
"formatter": {
"lineWidth": 80,
"indentSize": 2
"indentWidth": 2
}
},
"css": {
Expand Down Expand Up @@ -2663,9 +2663,9 @@ const a = {
("format"),
"--write",
"--javascript-formatter-line-width=320",
"--javascript-formatter-indent-size=8",
"--javascript-formatter-indent-width=8",
"--json-formatter-line-width=20",
"--json-formatter-indent-size=2",
"--json-formatter-indent-width=2",
"--css-formatter-line-width=40",
"--css-formatter-indent-width=6",
"--css-formatter-enabled=true",
Expand Down Expand Up @@ -2703,7 +2703,7 @@ fn should_not_format_json_files_if_disabled() {
"javascript": {
"formatter": {
"lineWidth": 80,
"indentSize": 4
"indentWidth": 4
}
},
"json": {
Expand Down Expand Up @@ -2777,7 +2777,7 @@ fn should_not_format_js_files_if_disabled() {
"json": {
"formatter": {
"lineWidth": 80,
"indentSize": 2
"indentWidth": 2
}
}
}"#,
Expand Down Expand Up @@ -2841,7 +2841,7 @@ fn should_not_format_css_files_if_disabled() {
"javascript": {
"formatter": {
"lineWidth": 80,
"indentSize": 4
"indentWidth": 4
}
},
"css": {
Expand Down Expand Up @@ -2909,14 +2909,14 @@ fn should_apply_different_indent_style() {
"javascript": {
"formatter": {
"lineWidth": 320,
"indentSize": 8,
"indentWidth": 8,
"indentStyle": "tab"
}
},
"json": {
"formatter": {
"lineWidth": 80,
"indentSize": 2,
"indentWidth": 2,
"indentStyle": "tab"
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/biome_cli/tests/configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub const CONFIG_FORMAT: &str = r#"{
"enabled": true,
"lineWidth": 160,
"indentStyle": "space",
"indentSize": 6
"indentWidth": 6
}
}
"#;
Expand Down Expand Up @@ -38,7 +38,7 @@ pub const CONFIG_ALL_FIELDS: &str = r#"{
"enabled": true,
"formatWithErrors": true,
"indentStyle": "tab",
"indentSize": 2,
"indentWidth": 2,
"lineWidth": 80
},
"linter": {
Expand Down Expand Up @@ -192,7 +192,7 @@ pub const CONFIG_INCORRECT_GLOBALS_V2: &str = r#"{
pub const CONFIG_ISSUE_3175_1: &str = r#"{
"formatter": {
"indentStyle": "space",
"indentSize": 2,
"indentWidth": 2,
"lineWidth": 120
}
}"#;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ expression: content
"enabled": true,
"lineWidth": 160,
"indentStyle": "space",
"indentSize": 6
"indentWidth": 6
}
}
```
Expand All @@ -29,29 +29,6 @@ function f() {

# Emitted Messages

```block
biome.json:6:5 deserialize DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! The property indentSize is deprecated. Use formatter.indentWidth instead.
4 │ "lineWidth": 160,
5 │ "indentStyle": "space",
> 6 │ "indentSize": 6
│ ^^^^^^^^^^^^
7 │ }
8 │ }
```

```block
internalError/fs DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! The argument --indent-size is deprecated, it will be removed in the next major release. Use --indent-width instead.
```

```block
Formatted 1 file in <TIME>. Fixed 1 file.
```
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ The configuration that is contained inside the file `biome.json`
Configuration in `biome.json` will override `.editorconfig`
configuration. Default: false.
--indent-style=<tab|space> The indent style.
--indent-size=NUMBER The size of the indentation, 2 by default (deprecated, use
`indent-width`)
--indent-width=NUMBER The size of the indentation, 2 by default
--line-ending=<lf|crlf|cr> The type of line ending.
--line-width=NUMBER What's the max width of a line. Defaults to 80.
Expand All @@ -56,8 +54,6 @@ The configuration that is contained inside the file `biome.json`
super languages) files.
--javascript-formatter-indent-style=<tab|space> The indent style applied to JavaScript (and
its super languages) files.
--javascript-formatter-indent-size=NUMBER The size of the indentation applied to JavaScript
(and its super languages) files. Default to 2.
--javascript-formatter-indent-width=NUMBER The size of the indentation applied to
JavaScript (and its super languages) files. Default to 2.
--javascript-formatter-line-ending=<lf|crlf|cr> The type of line ending applied to
Expand All @@ -78,8 +74,6 @@ The configuration that is contained inside the file `biome.json`
languages) files.
--json-formatter-indent-width=NUMBER The size of the indentation applied to JSON (and its
super languages) files. Default to 2.
--json-formatter-indent-size=NUMBER The size of the indentation applied to JSON (and its
super languages) files. Default to 2.
--json-formatter-line-ending=<lf|crlf|cr> The type of line ending applied to JSON (and its
super languages) files.
--json-formatter-line-width=NUMBER What's the max width of a line applied to JSON (and its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ The configuration that is contained inside the file `biome.json`
Configuration in `biome.json` will override `.editorconfig`
configuration. Default: false.
--indent-style=<tab|space> The indent style.
--indent-size=NUMBER The size of the indentation, 2 by default (deprecated, use
`indent-width`)
--indent-width=NUMBER The size of the indentation, 2 by default
--line-ending=<lf|crlf|cr> The type of line ending.
--line-width=NUMBER What's the max width of a line. Defaults to 80.
Expand All @@ -58,8 +56,6 @@ The configuration that is contained inside the file `biome.json`
super languages) files.
--javascript-formatter-indent-style=<tab|space> The indent style applied to JavaScript (and
its super languages) files.
--javascript-formatter-indent-size=NUMBER The size of the indentation applied to JavaScript
(and its super languages) files. Default to 2.
--javascript-formatter-indent-width=NUMBER The size of the indentation applied to
JavaScript (and its super languages) files. Default to 2.
--javascript-formatter-line-ending=<lf|crlf|cr> The type of line ending applied to
Expand All @@ -80,8 +76,6 @@ The configuration that is contained inside the file `biome.json`
languages) files.
--json-formatter-indent-width=NUMBER The size of the indentation applied to JSON (and its
super languages) files. Default to 2.
--json-formatter-indent-size=NUMBER The size of the indentation applied to JSON (and its
super languages) files. Default to 2.
--json-formatter-line-ending=<lf|crlf|cr> The type of line ending applied to JSON (and its
super languages) files.
--json-formatter-line-width=NUMBER What's the max width of a line applied to JSON (and its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ function f() {

# Emitted Messages

```block
internalError/fs DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
! The argument --indent-size is deprecated, it will be removed in the next major release. Use --indent-width instead.
```

```block
Formatted 1 file in <TIME>. Fixed 1 file.
```
Loading

0 comments on commit a2eafcb

Please sign in to comment.