Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Making every type optional via Option #4406

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions crates/rome_service/src/configuration/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@ use serde::{Deserialize, Serialize};
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct FormatterConfiguration {
// if `false`, it disables the feature. `true` by default
pub enabled: bool,
pub enabled: Option<bool>,
ematipico marked this conversation as resolved.
Show resolved Hide resolved

/// Stores whether formatting should be allowed to proceed if a given file
/// has syntax errors
pub format_with_errors: bool,
pub format_with_errors: Option<bool>,

/// The indent style.
pub indent_style: PlainIndentStyle,
pub indent_style: Option<PlainIndentStyle>,

/// The size of the indentation, 2 by default
pub indent_size: u8,
pub indent_size: Option<u8>,

/// What's the max width of a line. Defaults to 80.
#[serde(
deserialize_with = "deserialize_line_width",
serialize_with = "serialize_line_width"
)]
pub line_width: LineWidth,
pub line_width: Option<LineWidth>,

/// A list of Unix shell style patterns. The formatter will ignore files/folders that will
/// match these patterns.
Expand Down
10 changes: 5 additions & 5 deletions crates/rome_service/src/configuration/parse/json/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ impl VisitNode<JsonLanguage> for FormatterConfiguration {
let name_text = name.text();
match name_text {
"formatWithErrors" => {
self.format_with_errors = self.map_to_boolean(&value, name_text, diagnostics)?;
self.format_with_errors = self.map_to_boolean(&value, name_text, diagnostics);
}
"enabled" => {
self.enabled = self.map_to_boolean(&value, name_text, diagnostics)?;
self.enabled = self.map_to_boolean(&value, name_text, diagnostics);
}
"ignore" => {
self.ignore = self.map_to_index_set_string(&value, name_text, diagnostics);
}
"indentStyle" => {
let mut indent_style = PlainIndentStyle::default();
self.map_to_known_string(&value, name_text, &mut indent_style, diagnostics)?;
self.map_to_known_string(&value, name_text, &mut indent_style, diagnostics);
self.indent_style = indent_style;
}
"indentSize" => {
self.indent_size = self.map_to_u8(&value, name_text, u8::MAX, diagnostics)?;
self.indent_size = self.map_to_u8(&value, name_text, u8::MAX, diagnostics);
}
"lineWidth" => {
let line_width = self.map_to_u16(&value, name_text, LineWidth::MAX, diagnostics)?;
let line_width = self.map_to_u16(&value, name_text, LineWidth::MAX, diagnostics);

self.line_width = match LineWidth::try_from(line_width) {
ematipico marked this conversation as resolved.
Show resolved Hide resolved
Ok(result) => result,
Expand Down