[][src]Struct dprint_plugin_typescript::configuration::ConfigurationBuilder

pub struct ConfigurationBuilder { /* fields omitted */ }

TypeScript formatting configuration builder.

Example

use dprint_plugin_typescript::configuration::*;

let config = ConfigurationBuilder::new()
    .line_width(80)
    .prefer_hanging_parameters(true)
    .prefer_hanging_arguments(true)
    .quote_style(QuoteStyle::PreferSingle)
    .next_control_flow_position(NextControlFlowPosition::SameLine)
    .build();

Methods

impl ConfigurationBuilder[src]

pub fn new() -> ConfigurationBuilder[src]

Constructs a new configuration builder.

pub fn build(&self) -> Configuration[src]

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

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

Set the global configuration.

pub fn prettier(&mut self) -> &mut Self[src]

Helper method to more align Dprint with Prettier's defaults.

Note: This is just an alias for having the configuration to be more like Prettier's. It does not mean the code will format exactly like Prettier in all scenarios.

pub fn line_width(&mut self, value: u32) -> &mut Self[src]

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

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

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

Default: false

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

The number of columns for an indent.

Default: 4

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

The kind of newline to use.

Default: NewLineKind::Auto

pub fn quote_style(&mut self, value: QuoteStyle) -> &mut Self[src]

The quote style to use.

Default: QuoteStyle::PreferDouble

pub fn semi_colons(&mut self, value: SemiColons) -> &mut Self[src]

Whether statements should end in a semi-colon.

Default: SemiColons::Prefer

pub fn prefer_hanging(&mut self, value: bool) -> &mut Self[src]

Set to prefer hanging indentation when exceeding the line width.

Remarks: When set, this value propagtes down as the default value for other configuration such as preferHangingArguments and preferHangingParameters.

Default: false

pub fn prefer_hanging_arguments(&mut self, value: bool) -> &mut Self[src]

Prefers an argument list is hanging when it exceeds the line width. Note: It will be hanging when the first argument is on the same line as the open parenthesis and multi-line when on a different line.

Default: false

pub fn prefer_hanging_parameters(&mut self, value: bool) -> &mut Self[src]

Prefers a parameter list to be hanging when it exceeds the line width. Note: It will be hanging when the first parameter is on the same line as the open parenthesis and multi-line when on a different line.

Default: false

pub fn brace_position(&mut self, value: BracePosition) -> &mut Self[src]

Where to place the opening brace.

Default: BracePosition::NextLineIfHanging

pub fn next_control_flow_position(
    &mut self,
    value: NextControlFlowPosition
) -> &mut Self
[src]

Where to place the next control flow within a control flow statement.

Default: NextControlFlowPosition::NextLine

pub fn operator_position(&mut self, value: OperatorPosition) -> &mut Self[src]

Where to place the operator for expressions that span multiple lines.

Default: OperatorPosition::NextLine

pub fn single_body_position(&mut self, value: SingleBodyPosition) -> &mut Self[src]

Where to place the expression of a statement that could possibly be on one line (ex. if (true) console.log(5);).

Default: SingleBodyPosition::Maintain

pub fn trailing_commas(&mut self, value: TrailingCommas) -> &mut Self[src]

If trailing commas should be used.

Default: TrailingCommas::OnlyMultiLine

pub fn use_braces(&mut self, value: UseBraces) -> &mut Self[src]

If braces should be used or not.

Default: UseBraces::WhenNotSingleLine

pub fn binary_expression_space_surrounding_bitwise_and_arithmetic_operator(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to surround bitwise and arithmetic operators in a binary expression with spaces.

  • true (default) - Ex. 1 + 2
  • false - Ex. 1+2

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

Forces a space after the double slash in a comment line.

true (default) - Ex. //test -> // test false - Ex. //test -> //test

pub fn construct_signature_space_after_new_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the new keyword in a construct signature.

true - Ex. new (): MyClass; false (default) - Ex. new(): MyClass;

pub fn constructor_space_before_parentheses(&mut self, value: bool) -> &mut Self[src]

Whether to add a space before the parentheses of a constructor.

true - Ex. constructor () false (false) - Ex. constructor()

pub fn constructor_type_space_after_new_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the new keyword in a constructor type.

true - Ex. type MyClassCtor = new () => MyClass; false (default) - Ex. type MyClassCtor = new() => MyClass;

pub fn do_while_statement_space_after_while_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the while keyword in a do while statement.

true (true) - Ex. do {\n} while (condition); false - Ex. do {\n} while(condition);

pub fn export_declaration_space_surrounding_named_exports(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add spaces around named exports in an export declaration.

  • true (default) - Ex. export { SomeExport, OtherExport };
  • false - Ex. export {SomeExport, OtherExport};

pub fn for_statement_space_after_for_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the for keyword in a "for" statement.

  • true (default) - Ex. for (let i = 0; i < 5; i++)
  • false - Ex. for(let i = 0; i < 5; i++)

pub fn for_statement_space_after_semi_colons(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the semi-colons in a "for" statement.

  • true (default) - Ex. for (let i = 0; i < 5; i++)
  • false - Ex. for (let i = 0;i < 5;i++)

pub fn for_in_statement_space_after_for_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the for keyword in a "for in" statement.

  • true (default) - Ex. for (const prop in obj)
  • false - Ex. for(const prop in obj)

pub fn for_of_statement_space_after_for_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the for keyword in a "for of" statement.

  • true (default) - Ex. for (const value of myArray)
  • false - Ex. for(const value of myArray)

pub fn function_declaration_space_before_parentheses(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space before the parentheses of a function declaration.

  • true - Ex. function myFunction ()
  • false (default) - Ex. function myFunction()

pub fn function_expression_space_before_parentheses(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space before the parentheses of a function expression.

true - Ex. function<T> () false (default) - Ex. function<T> ()

pub fn function_expression_space_after_function_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the function keyword of a function expression.

true - Ex. function <T>(). false (default) - Ex. function<T>()

pub fn get_accessor_space_before_parentheses(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space before the parentheses of a get accessor.

true - Ex. get myProp () false (false) - Ex. get myProp()

pub fn if_statement_space_after_if_keyword(&mut self, value: bool) -> &mut Self[src]

Whether to add a space after the if keyword in an "if" statement.

true (default) - Ex. if (true) false - Ex. if(true)

pub fn import_declaration_space_surrounding_named_imports(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add spaces around named imports in an import declaration.

  • true (default) - Ex. import { SomeExport, OtherExport } from "my-module";
  • false - Ex. import {SomeExport, OtherExport} from "my-module";

pub fn jsx_expression_container_space_surrounding_expression(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space surrounding the expression of a JSX container.

  • true - Ex. { myValue }
  • false (default) - Ex. {myValue}

pub fn method_space_before_parentheses(&mut self, value: bool) -> &mut Self[src]

Whether to add a space before the parentheses of a method.

true - Ex. myMethod () false - Ex. myMethod()

pub fn set_accessor_space_before_parentheses(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space before the parentheses of a set accessor.

true - Ex. set myProp (value: string) false (default) - Ex. set myProp(value: string)

pub fn tagged_template_space_before_literal(&mut self, value: bool) -> &mut Self[src]

Whether to add a space before the literal in a tagged template.

true (default) - Ex. html \`false- Ex.html```

pub fn type_annotation_space_before_colon(&mut self, value: bool) -> &mut Self[src]

Whether to add a space before the colon of a type annotation.

  • true - Ex. function myFunction() : string
  • false (default) - Ex. function myFunction(): string

pub fn type_assertion_space_before_expression(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space before the expression in a type assertion.

  • true (default) - Ex. <string> myValue
  • false - Ex. <string>myValue

pub fn while_statement_space_after_while_keyword(
    &mut self,
    value: bool
) -> &mut Self
[src]

Whether to add a space after the while keyword in a while statement.

  • true (default) - Ex. while (true)
  • false - Ex. while(true)

pub fn arrow_function_use_parentheses(
    &mut self,
    value: UseParentheses
) -> &mut Self
[src]

pub fn arrow_function_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn class_declaration_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn class_expression_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn constructor_brace_position(&mut self, value: BracePosition) -> &mut Self[src]

pub fn do_while_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn enum_declaration_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn for_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn for_in_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn for_of_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn get_accessor_brace_position(&mut self, value: BracePosition) -> &mut Self[src]

pub fn if_statement_brace_position(&mut self, value: BracePosition) -> &mut Self[src]

pub fn interface_declaration_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn function_declaration_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn function_expression_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn method_brace_position(&mut self, value: BracePosition) -> &mut Self[src]

pub fn module_declaration_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn set_accessor_brace_position(&mut self, value: BracePosition) -> &mut Self[src]

pub fn switch_case_brace_position(&mut self, value: BracePosition) -> &mut Self[src]

pub fn switch_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn try_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn while_statement_brace_position(
    &mut self,
    value: BracePosition
) -> &mut Self
[src]

pub fn array_expression_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn array_pattern_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn do_while_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn export_declaration_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn extends_clause_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn for_in_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn for_of_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn for_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn if_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn implements_clause_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn import_declaration_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn object_expression_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn object_pattern_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn sequence_expression_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn switch_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn tuple_type_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn type_literal_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn type_parameter_declaration_prefer_hanging(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn union_and_intersection_type_prefer_hanging(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn variable_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn while_statement_prefer_hanging(&mut self, value: bool) -> &mut Self[src]

pub fn call_expression_prefer_hanging_arguments(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn new_expression_prefer_hanging_arguments(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn arrow_function_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn call_signature_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn construct_signature_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn constructor_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn constructor_type_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn function_declaration_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn function_expression_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn function_type_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn get_accessor_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn method_prefer_hanging_parameters(&mut self, value: bool) -> &mut Self[src]

pub fn method_signature_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn set_accessor_prefer_hanging_parameters(
    &mut self,
    value: bool
) -> &mut Self
[src]

pub fn enum_declaration_member_spacing(
    &mut self,
    value: MemberSpacing
) -> &mut Self
[src]

pub fn if_statement_next_control_flow_position(
    &mut self,
    value: NextControlFlowPosition
) -> &mut Self
[src]

pub fn try_statement_next_control_flow_position(
    &mut self,
    value: NextControlFlowPosition
) -> &mut Self
[src]

pub fn binary_expression_operator_position(
    &mut self,
    value: OperatorPosition
) -> &mut Self
[src]

pub fn conditional_expression_operator_position(
    &mut self,
    value: OperatorPosition
) -> &mut Self
[src]

pub fn if_statement_single_body_position(
    &mut self,
    value: SingleBodyPosition
) -> &mut Self
[src]

pub fn for_statement_single_body_position(
    &mut self,
    value: SingleBodyPosition
) -> &mut Self
[src]

pub fn for_in_statement_single_body_position(
    &mut self,
    value: SingleBodyPosition
) -> &mut Self
[src]

pub fn for_of_statement_single_body_position(
    &mut self,
    value: SingleBodyPosition
) -> &mut Self
[src]

pub fn while_statement_single_body_position(
    &mut self,
    value: SingleBodyPosition
) -> &mut Self
[src]

pub fn arguments_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self[src]

pub fn parameters_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self[src]

pub fn array_expression_trailing_commas(
    &mut self,
    value: TrailingCommas
) -> &mut Self
[src]

pub fn array_pattern_trailing_commas(
    &mut self,
    value: TrailingCommas
) -> &mut Self
[src]

pub fn enum_declaration_trailing_commas(
    &mut self,
    value: TrailingCommas
) -> &mut Self
[src]

pub fn object_expression_trailing_commas(
    &mut self,
    value: TrailingCommas
) -> &mut Self
[src]

pub fn object_pattern_trailing_commas(
    &mut self,
    value: TrailingCommas
) -> &mut Self
[src]

pub fn tuple_type_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self[src]

pub fn type_parameter_declaration_trailing_commas(
    &mut self,
    value: TrailingCommas
) -> &mut Self
[src]

pub fn if_statement_use_braces(&mut self, value: UseBraces) -> &mut Self[src]

pub fn for_statement_use_braces(&mut self, value: UseBraces) -> &mut Self[src]

pub fn for_in_statement_use_braces(&mut self, value: UseBraces) -> &mut Self[src]

pub fn for_of_statement_use_braces(&mut self, value: UseBraces) -> &mut Self[src]

pub fn while_statement_use_braces(&mut self, value: UseBraces) -> &mut Self[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.