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: remove support for rome.json #4244

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/remove_support_for_romejson.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
cli: major
---

# Remove support for `rome.json`
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.

19 changes: 2 additions & 17 deletions crates/biome_cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::changed::{get_changed_files, get_staged_files};
use crate::cli_options::{cli_options, CliOptions, CliReporter, ColorsArg};
use crate::diagnostics::{DeprecatedArgument, DeprecatedConfigurationFile};
use crate::diagnostics::DeprecatedArgument;
use crate::execute::Stdin;
use crate::logging::LoggingKind;
use crate::{
Expand All @@ -22,7 +22,7 @@ use biome_configuration::{
};
use biome_configuration::{BiomeDiagnostic, PartialConfiguration};
use biome_console::{markup, Console, ConsoleExt};
use biome_diagnostics::{Diagnostic, PrintDiagnostic};
use biome_diagnostics::PrintDiagnostic;
use biome_fs::{BiomePath, FileSystem};
use biome_service::configuration::{
load_configuration, load_editorconfig, LoadedConfiguration, PartialConfigurationExt,
Expand Down Expand Up @@ -618,21 +618,6 @@ pub(crate) fn validate_configuration_diagnostics(
console: &mut dyn Console,
verbose: bool,
) -> Result<(), CliDiagnostic> {
if let Some(file_path) = loaded_configuration
.file_path
.as_ref()
.and_then(|f| f.file_name())
.and_then(|f| f.to_str())
{
if file_path == "rome.json" {
let diagnostic = DeprecatedConfigurationFile::new(file_path);
if diagnostic.tags().is_verbose() && verbose {
console.error(markup! {{PrintDiagnostic::verbose(&diagnostic)}})
} else {
console.error(markup! {{PrintDiagnostic::simple(&diagnostic)}})
}
}
}
let diagnostics = loaded_configuration.as_diagnostics_iter();
for diagnostic in diagnostics {
if diagnostic.tags().is_verbose() && verbose {
Expand Down
20 changes: 0 additions & 20 deletions crates/biome_cli/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,26 +475,6 @@ impl Termination for CliDiagnostic {
}
}

#[derive(Debug, Diagnostic)]
#[diagnostic(
category = "internalError/fs",
severity = Warning,
message(
description = "The configuration file {path} is deprecated. Use biome.json instead.",
message("The configuration file "<Emphasis>{self.path}</Emphasis>" is deprecated. Use "<Emphasis>"biome.json"</Emphasis>" instead."),
)
)]
pub struct DeprecatedConfigurationFile {
#[location(resource)]
pub path: String,
}

impl DeprecatedConfigurationFile {
pub fn new(path: impl Into<String>) -> Self {
Self { path: path.into() }
}
}

#[derive(Debug, Default, Diagnostic)]
#[diagnostic(
severity = Error,
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/commands/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ fn fs_files_ignore_symlink() {
check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path));
}

let config_path = root_path.join("rome.json");
let config_path = root_path.join("biome.json");
let mut config_file = File::create(config_path).unwrap();
config_file
.write_all(CONFIG_IGNORE_SYMLINK.as_bytes())
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/commands/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ fn custom_config_file_path() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let config_path = Path::new("/test/rome.json");
let config_path = Path::new("/test/biome.json");
fs.insert(config_path.into(), CONFIG_FORMAT.as_bytes());

let file_path = Path::new("file.js");
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_cli/tests/commands/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ fn fs_files_ignore_symlink() {
check_windows_symlink!(symlink_dir(&testcase2_path, symlink_testcase2_path));
}

let config_path = root_path.join("rome.json");
let config_path = root_path.join("biome.json");
let mut config_file = File::create(config_path).unwrap();
config_file
.write_all(CONFIG_IGNORE_SYMLINK.as_bytes())
Expand Down
54 changes: 0 additions & 54 deletions crates/biome_cli/tests/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,60 +79,6 @@ fn missing_configuration_file() {
));
}

#[test]
fn emit_diagnostic_for_rome_json() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#"{ "linter": { "enabled": true } }"#;

let configuration_path = Path::new("rome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("migrate")].as_slice()),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"emit_diagnostic_for_rome_json",
fs,
console,
result,
));
}

#[test]
fn should_create_biome_json_file() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let configuration = r#"{ "linter": { "enabled": true } }"#;

let configuration_path = Path::new("rome.json");
fs.insert(configuration_path.into(), configuration.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
&mut console,
Args::from([("migrate"), "--write"].as_slice()),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

assert_cli_snapshot(SnapshotPayload::new(
module_path!(),
"should_create_biome_json_file",
fs,
console,
result,
));
}

#[test]
fn should_emit_incompatible_arguments_error() {
let mut fs = MemoryFileSystem::default();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ expression: content
---
# Emitted Messages

```block
rome.json internalError/fs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! The configuration file rome.json is deprecated. Use biome.json instead.


```

```block
internalError/fs DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source: crates/biome_cli/tests/snap_test.rs
expression: content
---
## `/test/rome.json`
## `/test/biome.json`

```json
{
Expand All @@ -28,15 +28,7 @@ function f() {
# Emitted Messages

```block
rome.json internalError/fs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! The configuration file rome.json is deprecated. Use biome.json instead.


```

```block
/test/rome.json:6:5 deserialize DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
/test/biome.json:6:5 deserialize DEPRECATED ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! The property indentSize is deprecated. Use formatter.indentWidth instead.

Expand Down

This file was deleted.

This file was deleted.

8 changes: 0 additions & 8 deletions crates/biome_fs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use tracing::{error, info};
mod memory;
mod os;

pub const ROME_JSON: &str = "rome.json";

pub struct ConfigName;

impl ConfigName {
Expand Down Expand Up @@ -48,12 +46,6 @@ pub trait FileSystem: Send + Sync + RefUnwindSafe {
/// efficiently batch many filesystem read operations
fn traversal<'scope>(&'scope self, func: BoxedTraversal<'_, 'scope>);

// TODO: remove once we remove `rome.json` support [2.0]
/// Returns the temporary configuration files that are supported
fn deprecated_config_name(&self) -> &str {
ROME_JSON
}

/// Return the path to the working directory
fn working_directory(&self) -> Option<PathBuf>;

Expand Down
1 change: 0 additions & 1 deletion crates/biome_fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub use dir::ensure_cache_dir;
pub use fs::{
AutoSearchResult, ConfigName, ErrorEntry, File, FileSystem, FileSystemDiagnostic,
FileSystemExt, MemoryFileSystem, OpenOptions, OsFileSystem, TraversalContext, TraversalScope,
ROME_JSON,
};
pub use interner::PathInterner;
pub use path::BiomePath;
15 changes: 3 additions & 12 deletions crates/biome_lsp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::utils::{into_lsp_error, panic_to_lsp_error};
use crate::{handlers, requests};
use biome_console::markup;
use biome_diagnostics::panic::PanicError;
use biome_fs::{ConfigName, FileSystem, OsFileSystem, ROME_JSON};
use biome_fs::{ConfigName, FileSystem, OsFileSystem};
use biome_service::workspace::{
RageEntry, RageParams, RageResult, RegisterProjectFolderParams, UnregisterProjectFolderParams,
};
Expand Down Expand Up @@ -156,14 +156,6 @@ impl LSPServer {
base_path.display()
)),
kind: Some(WatchKind::all()),
},
// TODO: Biome 2.0 remove it
FileSystemWatcher {
glob_pattern: GlobPattern::String(format!(
"{}/rome.json",
base_path.display()
)),
kind: Some(WatchKind::all()),
}
],
})))
Expand Down Expand Up @@ -333,9 +325,8 @@ impl LanguageServer for LSPServer {
if let Some(base_path) = base_path {
let possible_rome_json = file_path.strip_prefix(&base_path);
if let Ok(watched_file) = possible_rome_json {
if watched_file.display().to_string() == ROME_JSON
|| ConfigName::file_names()
.contains(&&*watched_file.display().to_string())
if ConfigName::file_names()
.contains(&&*watched_file.display().to_string())
|| watched_file.ends_with(".editorconfig")
{
self.session.load_workspace_settings().await;
Expand Down
23 changes: 2 additions & 21 deletions crates/biome_service/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,30 +217,11 @@ fn load_config(
};

// We first search for `biome.json` or `biome.jsonc` files
if let Some(auto_search_result) = match file_system.auto_search(
if let Some(auto_search_result) = file_system.auto_search(
&configuration_directory,
ConfigName::file_names().as_slice(),
should_error,
) {
Ok(Some(auto_search_result)) => Some(auto_search_result),
// We then search for the deprecated `rome.json` file
// if neither `biome.json` nor `biome.jsonc` is found
// TODO: The following arms should be removed in v2.0.0
Ok(None) => file_system.auto_search(
&configuration_directory,
[file_system.deprecated_config_name()].as_slice(),
should_error,
)?,
Err(error) => file_system
.auto_search(
&configuration_directory,
[file_system.deprecated_config_name()].as_slice(),
should_error,
)
// Map the error so users won't see error messages
// that contains `rome.json`
.map_err(|_| error)?,
} {
)? {
let AutoSearchResult { content, file_path } = auto_search_result;

let parser_options = match file_path.extension().map(OsStr::as_encoded_bytes) {
Expand Down
5 changes: 2 additions & 3 deletions crates/biome_service/src/file_handlers/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use biome_configuration::PartialConfiguration;
use biome_deserialize::json::deserialize_from_json_ast;
use biome_diagnostics::{category, Applicability, Diagnostic, DiagnosticExt, Severity};
use biome_formatter::{FormatError, IndentStyle, IndentWidth, LineEnding, LineWidth, Printed};
use biome_fs::{BiomePath, ConfigName, ROME_JSON};
use biome_fs::{BiomePath, ConfigName};
use biome_json_analyze::analyze;
use biome_json_formatter::context::{JsonFormatOptions, TrailingCommas};
use biome_json_formatter::format_node;
Expand Down Expand Up @@ -348,8 +348,7 @@ fn lint(params: LintParams) -> LintResults {
let mut diagnostics = params.parse.into_diagnostics();
// if we're parsing the `biome.json` file, we deserialize it, so we can emit diagnostics for
// malformed configuration
if params.path.ends_with(ROME_JSON)
|| params.path.ends_with(ConfigName::biome_json())
if params.path.ends_with(ConfigName::biome_json())
|| params.path.ends_with(ConfigName::biome_jsonc())
{
let deserialized = deserialize_from_json_ast::<PartialConfiguration>(&root, "");
Expand Down
2 changes: 1 addition & 1 deletion crates/biome_wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
name = "biome_wasm"
publish = false
repository = "https://github.com/biomejs/biome"
version = "1.7.3"
version = "1.9.3"


[lib]
Expand Down
2 changes: 1 addition & 1 deletion packages/@biomejs/cli-darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@biomejs/cli-darwin-arm64",
"version": "1.8.3",
"version": "1.9.3",
"license": "MIT OR Apache-2.0",
"repository": {
"type": "git",
Expand Down
Loading