Struct dprint_plugin_typescript::configuration::ConfigurationBuilder [−][src]
pub struct ConfigurationBuilder { /* fields omitted */ }
Expand description
TypeScript formatting configuration builder.
Example
use dprint_plugin_typescript::configuration::*; let config = ConfigurationBuilder::new() .line_width(80) .prefer_hanging(true) .prefer_single_line(false) .quote_style(QuoteStyle::PreferSingle) .next_control_flow_position(NextControlFlowPosition::SameLine) .build();
Implementations
Constructs a new configuration builder.
Gets the final configuration that can be used to format a file.
Set the global configuration.
Helper method to set the configuration to what’s used for Deno.
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
Whether to use tabs (true) or spaces (false).
Default: false
The number of columns for an indent.
Default: 4
The kind of newline to use.
Default: NewLineKind::LineFeed
The quote style to use.
Default: QuoteStyle::AlwaysDouble
The JSX quote style to use for string literals in JSX attributes.
Default: JsxQuoteStyle::PreferDouble
Whether to surround a JSX element or fragment with parentheses when it’s the top JSX node and it spans multiple lines.
Default: true
Whether statements should end in a semi-colon.
Default: SemiColons::Prefer
Set to prefer hanging indentation when exceeding the line width.
Default: false
Where to place the opening brace.
Default: BracePosition::SameLineUnlessHanging
Where to place the next control flow within a control flow statement.
Default: NextControlFlowPosition::NextLine
Where to place the operator for expressions that span multiple lines.
Default: OperatorPosition::NextLine
Where to place the expression of a statement that could possibly be on one line (ex. if (true) console.log(5);
).
Default: SingleBodyPosition::Maintain
If trailing commas should be used.
Default: TrailingCommas::OnlyMultiLine
If braces should be used or not.
Default: UseBraces::WhenNotSingleLine
If code should revert back from being on multiple lines to being on a single line when able.
Default: false
pub fn binary_expression_space_surrounding_bitwise_and_arithmetic_operator(
&mut self,
value: bool
) -> &mut Self
pub fn binary_expression_space_surrounding_bitwise_and_arithmetic_operator(
&mut self,
value: bool
) -> &mut Self
Whether to surround bitwise and arithmetic operators in a binary expression with spaces.
true
(default) - Ex.1 + 2
false
- Ex.1+2
Forces a space after the double slash in a comment line.
true
(default) - Ex. //test
-> // test
false
- Ex. //test
-> //test
Whether to add a space after the new
keyword in a construct signature.
true
- Ex. new (): MyClass;
false
(default) - Ex. new(): MyClass;
Whether to add a space before the parentheses of a constructor.
true
- Ex. constructor ()
false
(false) - Ex. constructor()
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;
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
pub fn export_declaration_space_surrounding_named_exports(
&mut self,
value: bool
) -> &mut Self
Whether to add spaces around named exports in an export declaration.
true
(default) - Ex.export { SomeExport, OtherExport };
false
- Ex.export {SomeExport, OtherExport};
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++)
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++)
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)
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)
Whether to add a space before the parentheses of a function declaration.
true
- Ex.function myFunction ()
false
(default) - Ex.function myFunction()
Whether to add a space before the parentheses of a function expression.
true
- Ex. function<T> ()
false
(default) - Ex. function<T> ()
Whether to add a space after the function keyword of a function expression.
true
- Ex. function <T>()
.
false
(default) - Ex. function<T>()
Whether to add a space before the parentheses of a get accessor.
true
- Ex. get myProp ()
false
(false) - Ex. get myProp()
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
pub fn import_declaration_space_surrounding_named_imports(
&mut self,
value: bool
) -> &mut Self
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
pub fn jsx_expression_container_space_surrounding_expression(
&mut self,
value: bool
) -> &mut Self
Whether to add a space surrounding the expression of a JSX container.
true
- Ex.{ myValue }
false
(default) - Ex.{myValue}
Whether to add a space surrounding the properties of an object expression.
true
(default) - Ex.{ key: value }
false
- Ex.{key: value}
Whether to add a space surrounding the properties of an object pattern.
true
(default) - Ex.{ key: value } = obj
false
- Ex.{key: value} = obj
Whether to add a space before the parentheses of a method.
true
- Ex. myMethod ()
false
- Ex. myMethod()
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)
Whether to add a space surrounding the properties of object-like nodes.
true
(default) - Ex.{ key: value }
false
- Ex.{key: value}
Whether to add a space before the literal in a tagged template.
true
(default) - Ex.html \
`` false
- Ex.html\
``
Whether to add a space before the colon of a type annotation.
true
- Ex.function myFunction() : string
false
(default) - Ex.function myFunction(): string
Whether to add a space before the expression in a type assertion.
true
(default) - Ex.<string> myValue
false
- Ex.<string>myValue
Whether to add a space surrounding the properties of a type literal.
true
(default) - Ex.value: { key: Type }
false
- Ex.value: {key: Type}
Whether to add a space after the while
keyword in a while statement.
true
(default) - Ex.while (true)
false
- Ex.while(true)
Whether to use parentheses for arrow functions.
Default: UseParentheses::Maintain
Whether to force a line per expression when spanning multiple lines.
true
- Formats with each part on a new line.false
(default) - Maintains the line breaks as written by the programmer.
Whether to force a line per expression when spanning multiple lines.
true
- Formats with each part on a new line.false
(default) - Maintains the line breaks as written by the programmer.
The kind of separator to use in type literals.
pub fn type_literal_separator_kind_single_line(
&mut self,
value: SemiColonOrComma
) -> &mut Self
pub fn type_literal_separator_kind_single_line(
&mut self,
value: SemiColonOrComma
) -> &mut Self
The kind of separator to use in type literals when single line.
pub fn type_literal_separator_kind_multi_line(
&mut self,
value: SemiColonOrComma
) -> &mut Self
pub fn type_literal_separator_kind_multi_line(
&mut self,
value: SemiColonOrComma
) -> &mut Self
The kind of separator to use in type literals when multi-line.
Alphabetically sorts the import declarations based on their module specifiers.
Default: Case insensitive
Alphabetically sorts the export declarations based on their module specifiers.
Default: Case insensitive
Alphabetically sorts the import declaration’s named imports.
Default: Case insensitive
Alphabetically sorts the export declaration’s named exports.
Default: Case insensitive
The text to use for an ignore comment (ex. // dprint-ignore
).
Default: "dprint-ignore"
The text to use for a file ignore comment (ex. // dprint-ignore-file
).
Default: "dprint-ignore-file"
pub fn if_statement_next_control_flow_position(
&mut self,
value: NextControlFlowPosition
) -> &mut Self
pub fn try_statement_next_control_flow_position(
&mut self,
value: NextControlFlowPosition
) -> &mut Self
pub fn conditional_expression_operator_position(
&mut self,
value: OperatorPosition
) -> &mut Self
pub fn for_in_statement_single_body_position(
&mut self,
value: SingleBodyPosition
) -> &mut Self
pub fn for_of_statement_single_body_position(
&mut self,
value: SingleBodyPosition
) -> &mut Self
pub fn while_statement_single_body_position(
&mut self,
value: SingleBodyPosition
) -> &mut Self
Only applies when using commas on type literals.