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>,

§

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>,

§

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.