Repository: biomejs/biome (Rust)

Issue:
📎 Accept `biome.json` as config file
### Description

Currently, Biome uses `rome.json` as configuration file.

We should also accept `biome.json`.
We should continue to support `rome.json` and emit a deprecation diagnostic when it is used in place of `biome.json`.

Question: Should we adopt `biome.jsonc` instead of `biome.json` in order to allow comments in the config file?



Fix (patch):
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6cb1ece38211..dc88a52a7750 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,8 @@ New entries must be placed in a section entitled `Unreleased`.
 
   This aligns with semantic and behaviour meant for the command `biome check`.
 
+- `init` command emits a `biome.json` file;
+
 #### Other changes
 
 - Fix [#4670](https://github.com/rome/tools/issues/4670), don't crash at empty default export.
@@ -95,7 +97,7 @@ New entries must be placed in a section entitled `Unreleased`.
   - `.swcrc`;
   - `.hintrc`;
   - `.babelrc`;
-
+- Add support for `biome.json`;
 ### Configuration
 
 #### Other changes
diff --git a/crates/rome_deserialize/src/lib.rs b/crates/rome_deserialize/src/lib.rs
index 296203d68b43..521ee95f7bb2 100644
--- a/crates/rome_deserialize/src/lib.rs
+++ b/crates/rome_deserialize/src/lib.rs
@@ -6,11 +6,12 @@ pub mod string_set;
 
 pub use diagnostics::{DeserializationAdvice, DeserializationDiagnostic};
 use rome_diagnostics::Error;
+use std::fmt::Debug;
 pub use string_set::{deserialize_string_set, serialize_string_set, StringSet};
 pub use visitor::VisitNode;
 
 /// A small type to interrogate the result of a JSON deserialization
-#[derive(Default)]
+#[derive(Debug, Default)]
 pub struct Deserialized<P> {
     diagnostics: Vec<Error>,
     deserialized: P,
diff --git a/crates/rome_diagnostics/CHANGELOG.md b/crates/rome_diagnostics/CHANGELOG.md
deleted file mode 100644
index 71d31024418c..000000000000
--- a/crates/rome_diagnostics/CHANGELOG.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# Changelog
-
-All notable changes to this crate will be documented in this file.
-
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
-
-## [Unreleased]
-
-## [0.2.0] - 2021-09-16
-
-### Fixed
-
-- Fixed lsp diagnostic conversion not working correctly
-
-### Added
-
-- Added the `Formatter` trait for describing structs which can emit diagnostics in a certain way
-- Added the `ShortFormatter` which emits diagnostics in an eslint-like style
-
-### Changed
-
-- Changed codespan backend to render notes with severity correctly
-- Improved note rendering to account for severity length and indent correctly, as well as add a border
-  between lines if the note spans multiple lines
-
-## [0.1.1]
-
-### Added
-
-- Added multiple utility methods to `Span`
diff --git a/crates/rome_fs/src/fs.rs b/crates/rome_fs/src/fs.rs
index a7543254fd0e..aed9edf2fe04 100644
--- a/crates/rome_fs/src/fs.rs
+++ b/crates/rome_fs/src/fs.rs
@@ -13,7 +13,10 @@ use tracing::{error, info};
 mod memory;
 mod os;
 
-pub const CONFIG_NAME: &str = "rome.json";
+pub const CONFIG_NAMES: [&str; 2] = [ROME_JSON, BIOME_JSON];
+
+pub const ROME_JSON: &str = "rome.json";
+pub const BIOME_JSON: &str = "biome.json";
 
 pub trait FileSystem: Send + Sync + RefUnwindSafe {
     /// It opens a file with the given set of options
@@ -25,9 +28,14 @@ pub trait FileSystem: Send + Sync + RefUnwindSafe {
     /// efficiently batch many filesystem read operations
     fn traversal<'scope>(&'scope self, func: BoxedTraversal<'_, 'scope>);
 
+    /// Returns the temporary configuration files that are supported
+    fn config_names(&self) -> [&str; 2] {
+        CONFIG_NAMES
+    }
+
     /// Returns the name of the main configuration file
     fn config_name(&self) -> &str {
-        CONFIG_NAME
+        BIOME_JSON
     }
 
     /// Return the path to the working directory
diff --git a/crates/rome_fs/src/lib.rs b/crates/rome_fs/src/lib.rs
index 51cbcc843d6a..12d9f2149fc1 100644
--- a/crates/rome_fs/src/lib.rs
+++ b/crates/rome_fs/src/lib.rs
@@ -4,7 +4,8 @@ mod path;
 
 pub use fs::{
     AutoSearchResult, ErrorEntry, File, FileSystem, FileSystemDiagnostic, FileSystemExt,
-    MemoryFileSystem, OpenOptions, OsFileSystem, TraversalContext, TraversalScope, CONFIG_NAME,
+    MemoryFileSystem, OpenOptions, OsFileSystem, TraversalContext, TraversalScope, BIOME_JSON,
+    CONFIG_NAMES, ROME_JSON,
 };
 pub use interner::PathInterner;
 pub use path::RomePath;
diff --git a/crates/rome_lsp/src/server.rs b/crates/rome_lsp/src/server.rs
index 1c5d8636d95e..14ea226e67e1 100644
--- a/crates/rome_lsp/src/server.rs
+++ b/crates/rome_lsp/src/server.rs
@@ -10,7 +10,7 @@ use futures::future::ready;
 use futures::FutureExt;
 use rome_console::markup;
 use rome_diagnostics::panic::PanicError;
-use rome_fs::CONFIG_NAME;
+use rome_fs::{BIOME_JSON, ROME_JSON};
 use rome_service::workspace::{RageEntry, RageParams, RageResult};
 use rome_service::{workspace, Workspace};
 use serde_json::json;
@@ -308,7 +308,9 @@ impl LanguageServer for LSPServer {
                     if let Some(base_path) = base_path {
                         let possible_rome_json = file_path.strip_prefix(&base_path);
                         if let Ok(possible_rome_json) = possible_rome_json {
-                            if possible_rome_json.display().to_string() == CONFIG_NAME {
+                            if possible_rome_json.display().to_string() == ROME_JSON
+                                || possible_rome_json.display().to_string() == BIOME_JSON
+                            {
                                 self.session.load_workspace_settings().await;
                                 self.setup_capabilities().await;
                                 self.session.update_all_diagnostics().await;
diff --git a/crates/rome_service/src/configuration/mod.rs b/crates/rome_service/src/configuration/mod.rs
index 9c7cadd7d167..badec6e4bf4c 100644
--- a/crates/rome_service/src/configuration/mod.rs
+++ b/crates/rome_service/src/configuration/mod.rs
@@ -327,7 +327,7 @@ pub fn load_config(
     file_system: &DynRef<dyn FileSystem>,
     base_path: ConfigurationBasePath,
 ) -> LoadConfig {
-    let config_name = file_system.config_name();
+    let config_names = file_system.config_names();
     let working_directory = file_system.working_directory();
     let configuration_directory = match base_path {
         ConfigurationBasePath::Lsp(ref path) | ConfigurationBasePath::FromUser(ref path) => {
@@ -340,9 +340,17 @@ pub fn load_config(
     };
     let should_error = base_path.is_from_user();
 
-    let result = file_system.auto_search(configuration_directory, config_name, should_error)?;
+    let mut auto_search_result = None;
+    for config_name in config_names {
+        let result =
+            file_system.auto_search(configuration_directory.clone(), config_name, should_error)?;
+        if result.is_some() {
+            auto_search_result = result;
+            break;
+        }
+    }
 
-    if let Some(auto_search_result) = result {
+    if let Some(auto_search_result) = auto_search_result {
         let AutoSearchResult {
             content,
             directory_path,
diff --git a/crates/rome_service/src/file_handlers/json.rs b/crates/rome_service/src/file_handlers/json.rs
index 0f0b3e4bf1c4..ddd6fea2175f 100644
--- a/crates/rome_service/src/file_handlers/json.rs
+++ b/crates/rome_service/src/file_handlers/json.rs
@@ -17,7 +17,7 @@ use rome_analyze::{AnalyzerOptions, ControlFlow, Never, RuleCategories};
 use rome_deserialize::json::deserialize_from_json_ast;
 use rome_diagnostics::{category, Diagnostic, DiagnosticExt, Severity};
 use rome_formatter::{FormatError, Printed};
-use rome_fs::{RomePath, CONFIG_NAME};
+use rome_fs::{RomePath, BIOME_JSON, ROME_JSON};
 use rome_json_analyze::analyze;
 use rome_json_formatter::context::JsonFormatOptions;
 use rome_json_formatter::format_node;
@@ -224,7 +224,7 @@ fn lint(params: LintParams) -> LintResults {
 
         // if we're parsing the `rome.json` file, we deserialize it, so we can emit diagnostics for
         // malformed configuration
-        if params.path.ends_with(CONFIG_NAME) {
+        if params.path.ends_with(ROME_JSON) || params.path.ends_with(BIOME_JSON) {
             let deserialized = deserialize_from_json_ast::<Configuration>(&root);
             diagnostics.extend(
                 deserialized