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

refactor(core): configuration, settings and capabilities #4845

Merged
merged 22 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix merge
  • Loading branch information
ematipico committed Jan 6, 2025
commit e508d94e70593c699efdaa4694f44eb24527e66e
6 changes: 3 additions & 3 deletions crates/biome_cli/src/commands/ci.rs
Original file line number Diff line number Diff line change
@@ -122,9 +122,9 @@ impl CommandRunner for CiCommandPayload {
}

fn check_incompatible_arguments(&self) -> Result<(), CliDiagnostic> {
if self.formatter_enabled.is_some_and(|v| v.value() == false)
&& self.linter_enabled.is_some_and(|v| v.value() == false)
&& self.assist_enabled.is_some_and(|v| v.value() == false)
if self.formatter_enabled.is_some_and(|v| !v.value())
&& self.linter_enabled.is_some_and(|v| !v.value())
&& self.assist_enabled.is_some_and(|v| !v.value())
{
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."));
}
14 changes: 13 additions & 1 deletion crates/biome_configuration/src/bool.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use biome_console::fmt::Formatter;
use biome_deserialize::{Deserializable, DeserializableValue, DeserializationContext, Merge};
use schemars::gen::SchemaGenerator;
use schemars::schema::Schema;
use std::{
fmt,
str::{FromStr, ParseBoolError},
@@ -9,7 +11,6 @@ use std::{
///
/// The const generic indicates the default bool value of this wrapper type
#[derive(Clone, Copy, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
pub struct Bool<const D: bool>(pub bool);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this new type! The AssistEnabled, LinterEnabled types are so descriptive ❤️


impl<const D: bool> Merge for Bool<D> {
@@ -100,3 +101,14 @@ impl From<Bool<true>> for Bool<false> {
Self(value.value())
}
}

#[cfg(feature = "schema")]
impl<const D: bool> schemars::JsonSchema for Bool<D> {
fn schema_name() -> String {
"boolean".to_string()
}

fn json_schema(gen: &mut SchemaGenerator) -> Schema {
bool::json_schema(gen)
}
}
3 changes: 0 additions & 3 deletions crates/biome_service/src/file_handlers/javascript.rs
Original file line number Diff line number Diff line change
@@ -178,7 +178,6 @@ impl ServiceLanguage for JsLanguage {
path: &BiomePath,
document_file_source: &DocumentFileSource,
) -> JsFormatOptions {
dbg!(&language);
let options = JsFormatOptions::new(
document_file_source
.to_js_file_source()
@@ -242,7 +241,6 @@ impl ServiceLanguage for JsLanguage {
.unwrap_or_default(),
);

dbg!("resolve_format_options: options = {:#?}", &options);
if let Some(overrides) = overrides {
overrides.override_js_format_options(path, options)
} else {
@@ -920,7 +918,6 @@ pub(crate) fn format(
let options = settings.format_options::<JsLanguage>(biome_path, document_file_source);

debug!("Options used for format: \n{}", options);
dbg!("here");

let tree = parse.syntax();
info!("Format file {}", biome_path.as_str());
2 changes: 1 addition & 1 deletion crates/biome_service/src/projects.rs
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ impl Projects {
.and_then(|data| data.settings.files.max_size)
.unwrap_or_default();

usize::try_from(limit).unwrap_or(usize::MAX)
usize::from(limit)
}

/// Checks whether a file is ignored through the feature's
1 change: 0 additions & 1 deletion crates/biome_service/src/settings.rs
Original file line number Diff line number Diff line change
@@ -631,7 +631,6 @@ impl WorkspaceSettingsHandle {
where
L: ServiceLanguage,
{
dbg!("format_options:");
let settings = self.settings();
let formatter = settings.map(|s| &s.formatter);
let overrides = settings.map(|s| &s.override_settings);
1 change: 0 additions & 1 deletion crates/biome_service/src/workspace/server.rs
Original file line number Diff line number Diff line change
@@ -488,7 +488,6 @@ impl WorkspaceServer {
!is_included
|| files_settings.ignored_files.matches_path(path)
|| files_settings.git_ignore.as_ref().is_some_and(|ignore| {
dbg!("check this");
// `matched_path_or_any_parents` panics if `source` is not under the gitignore root.
// This checks excludes absolute paths that are not a prefix of the base root.
if !path.has_root() || path.starts_with(ignore.path()) {
Loading
Loading