pub struct ConfigurationBuilder { /* private fields */ }
Expand description
Formatting configuration builder.
§Example
use dprint_plugin_json::configuration::*;
let config = ConfigurationBuilder::new()
.line_width(80)
.build();
Implementations§
source§impl ConfigurationBuilder
impl ConfigurationBuilder
sourcepub fn new() -> ConfigurationBuilder
pub fn new() -> ConfigurationBuilder
Constructs a new configuration builder.
sourcepub fn build(&self) -> Configuration
pub fn build(&self) -> Configuration
Gets the final configuration that can be used to format a file.
sourcepub fn global_config(&mut self, global_config: GlobalConfiguration) -> &mut Self
pub fn global_config(&mut self, global_config: GlobalConfiguration) -> &mut Self
Set the global configuration.
sourcepub fn line_width(&mut self, value: u32) -> &mut Self
pub fn line_width(&mut self, value: u32) -> &mut Self
The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases. Default: 120
sourcepub fn use_tabs(&mut self, value: bool) -> &mut Self
pub fn use_tabs(&mut self, value: bool) -> &mut Self
Whether to use tabs (true) or spaces (false).
Default: false
sourcepub fn indent_width(&mut self, value: u8) -> &mut Self
pub fn indent_width(&mut self, value: u8) -> &mut Self
The number of columns for an indent.
Default: 2
sourcepub fn new_line_kind(&mut self, value: NewLineKind) -> &mut Self
pub fn new_line_kind(&mut self, value: NewLineKind) -> &mut Self
The kind of newline to use.
Default: NewLineKind::LineFeed
sourcepub fn comment_line_force_space_after_slashes(
&mut self,
value: bool,
) -> &mut Self
pub fn comment_line_force_space_after_slashes( &mut self, value: bool, ) -> &mut Self
The kind of newline to use. Default: true
sourcepub fn ignore_node_comment_text(&mut self, value: &str) -> &mut Self
pub fn ignore_node_comment_text(&mut self, value: &str) -> &mut Self
The text to use for an ignore comment (ex. // dprint-ignore
).
Default: "dprint-ignore"
sourcepub fn prefer_single_line(&mut self, value: bool) -> &mut Self
pub fn prefer_single_line(&mut self, value: bool) -> &mut Self
Whether to make objects and arrays collapse to a single line when below the line width. Default: false
sourcepub fn array_prefer_single_line(&mut self, value: bool) -> &mut Self
pub fn array_prefer_single_line(&mut self, value: bool) -> &mut Self
Whether to make arrays collapse to a single line when below the line width. Default: false
sourcepub fn object_prefer_single_line(&mut self, value: bool) -> &mut Self
pub fn object_prefer_single_line(&mut self, value: bool) -> &mut Self
Whether to make ojects collapse to a single line when below the line width. Default: false
sourcepub fn trailing_commas(&mut self, value: TrailingCommaKind) -> &mut Self
pub fn trailing_commas(&mut self, value: TrailingCommaKind) -> &mut Self
Whether to use trailing commas.
Default: TrailingCommaKind::Jsonc
sourcepub fn json_trailing_comma_files(&mut self, value: Vec<String>) -> &mut Self
pub fn json_trailing_comma_files(&mut self, value: Vec<String>) -> &mut Self
When trailingCommas
is jsonc
, treat these files as JSONC and use trailing commas.
Ex. vec!["tsconfig.json".to_string(), ".vscode/settings.json".to_string()]