Struct ConfigurationBuilder

Source
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

Source

pub fn new() -> ConfigurationBuilder

Constructs a new configuration builder.

Source

pub fn build(&self) -> Configuration

Gets the final configuration that can be used to format a file.

Source

pub fn global_config(&mut self, global_config: GlobalConfiguration) -> &mut Self

Set the global configuration.

Source

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

Source

pub fn use_tabs(&mut self, value: bool) -> &mut Self

Whether to use tabs (true) or spaces (false).

Default: false

Source

pub fn indent_width(&mut self, value: u8) -> &mut Self

The number of columns for an indent.

Default: 2

Source

pub fn new_line_kind(&mut self, value: NewLineKind) -> &mut Self

The kind of newline to use. Default: NewLineKind::LineFeed

Source

pub fn comment_line_force_space_after_slashes( &mut self, value: bool, ) -> &mut Self

The kind of newline to use. Default: true

Source

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"

Source

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

Source

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

Source

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

Source

pub fn trailing_commas(&mut self, value: TrailingCommaKind) -> &mut Self

Whether to use trailing commas.

Default: TrailingCommaKind::Jsonc

Source

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()]

Source

pub fn deno(&mut self) -> &mut Self

Sets the configuration to what is used in Deno.

Trait Implementations§

Source§

impl Default for ConfigurationBuilder

Source§

fn default() -> ConfigurationBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.