dprint_plugin_typescript/configuration/
builder.rs

1use super::resolve_config::resolve_config;
2use super::types::*;
3use dprint_core::configuration::*;
4
5/// TypeScript formatting configuration builder.
6///
7/// # Example
8///
9/// ```
10/// use dprint_plugin_typescript::configuration::*;
11///
12/// let config = ConfigurationBuilder::new()
13///     .line_width(80)
14///     .prefer_hanging(true)
15///     .prefer_single_line(false)
16///     .quote_style(QuoteStyle::PreferSingle)
17///     .next_control_flow_position(NextControlFlowPosition::SameLine)
18///     .build();
19/// ```
20#[derive(Default)]
21pub struct ConfigurationBuilder {
22  pub(super) config: ConfigKeyMap,
23  global_config: Option<GlobalConfiguration>,
24}
25
26impl ConfigurationBuilder {
27  /// Constructs a new configuration builder.
28  pub fn new() -> ConfigurationBuilder {
29    ConfigurationBuilder::default()
30  }
31
32  /// Gets the final configuration that can be used to format a file.
33  pub fn build(&self) -> Configuration {
34    if let Some(global_config) = &self.global_config {
35      resolve_config(self.config.clone(), global_config).config
36    } else {
37      let global_config = GlobalConfiguration::default();
38      resolve_config(self.config.clone(), &global_config).config
39    }
40  }
41
42  /// Set the global configuration.
43  pub fn global_config(&mut self, global_config: GlobalConfiguration) -> &mut Self {
44    self.global_config = Some(global_config);
45    self
46  }
47
48  /// Helper method to set the configuration to what's used for Deno.
49  pub fn deno(&mut self) -> &mut Self {
50    self
51      .line_width(80)
52      .indent_width(2)
53      .next_control_flow_position(NextControlFlowPosition::SameLine)
54      .binary_expression_operator_position(OperatorPosition::SameLine)
55      .conditional_expression_operator_position(OperatorPosition::NextLine)
56      .conditional_type_operator_position(OperatorPosition::NextLine)
57      .brace_position(BracePosition::SameLine)
58      .comment_line_force_space_after_slashes(false)
59      .construct_signature_space_after_new_keyword(true)
60      .constructor_type_space_after_new_keyword(true)
61      .arrow_function_use_parentheses(UseParentheses::Force)
62      .new_line_kind(NewLineKind::LineFeed)
63      .function_expression_space_after_function_keyword(true)
64      .tagged_template_space_before_literal(false)
65      .conditional_expression_prefer_single_line(true)
66      .quote_style(QuoteStyle::PreferDouble)
67      .jsx_multi_line_parens(JsxMultiLineParens::Prefer)
68      .ignore_node_comment_text("deno-fmt-ignore")
69      .ignore_file_comment_text("deno-fmt-ignore-file")
70      .module_sort_import_declarations(SortOrder::Maintain)
71      .module_sort_export_declarations(SortOrder::Maintain)
72      .export_declaration_sort_type_only_exports(NamedTypeImportsExportsOrder::None)
73      .import_declaration_sort_type_only_imports(NamedTypeImportsExportsOrder::None)
74  }
75
76  /// The width of a line the printer will try to stay under. Note that the printer may exceed this width in certain cases.
77  ///
78  /// Default: `120`
79  pub fn line_width(&mut self, value: u32) -> &mut Self {
80    self.insert("lineWidth", (value as i32).into())
81  }
82
83  /// Whether to use tabs (true) or spaces (false).
84  ///
85  /// Default: `false`
86  pub fn use_tabs(&mut self, value: bool) -> &mut Self {
87    self.insert("useTabs", value.into())
88  }
89
90  /// The number of columns for an indent.
91  ///
92  /// Default: `4`
93  pub fn indent_width(&mut self, value: u8) -> &mut Self {
94    self.insert("indentWidth", (value as i32).into())
95  }
96
97  /// The kind of newline to use.
98  ///
99  /// Default: `NewLineKind::LineFeed`
100  pub fn new_line_kind(&mut self, value: NewLineKind) -> &mut Self {
101    self.insert("newLineKind", value.to_string().into())
102  }
103
104  /// The quote style to use.
105  ///
106  /// Default: `QuoteStyle::AlwaysDouble`
107  pub fn quote_style(&mut self, value: QuoteStyle) -> &mut Self {
108    self.insert("quoteStyle", value.to_string().into())
109  }
110
111  /// The JSX quote style to use for string literals in JSX attributes.
112  ///
113  /// Default: `JsxQuoteStyle::PreferDouble`
114  pub fn jsx_quote_style(&mut self, value: JsxQuoteStyle) -> &mut Self {
115    self.insert("jsx.quoteStyle", value.to_string().into())
116  }
117
118  /// Whether to surround a JSX element or fragment with parentheses
119  /// when it's the top JSX node and it spans multiple lines.
120  ///
121  /// Default: `JsxMultiLineParens::Prefer`
122  pub fn jsx_multi_line_parens(&mut self, value: JsxMultiLineParens) -> &mut Self {
123    self.insert("jsx.multiLineParens", value.to_string().into())
124  }
125
126  /// Forces newlines surrounding the content of JSX elements.
127  ///
128  /// Default: `false`
129  pub fn jsx_force_new_lines_surrounding_content(&mut self, value: bool) -> &mut Self {
130    self.insert("jsx.forceNewLinesSurroundingContent", value.into())
131  }
132
133  /// If the end angle bracket of a jsx opening element or self closing element
134  /// should be on the same or next line when the attributes span multiple lines.
135  ///
136  /// Default: `nextLine`
137  pub fn jsx_bracket_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
138    self.insert("jsx.bracketPosition", value.to_string().into())
139  }
140
141  /// If the end angle bracket of a jsx opening element should be on the same
142  /// or next line when the attributes span multiple lines.
143  ///
144  /// Default: `nextLine`
145  pub fn jsx_opening_element_bracket_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
146    self.insert("jsxOpeningElement.bracketPosition", value.to_string().into())
147  }
148
149  /// If the end angle bracket of a jsx self closing element should be on the same
150  /// or next line when the attributes span multiple lines.
151  ///
152  /// Default: `nextLine`
153  pub fn jsx_self_closing_element_bracket_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
154    self.insert("jsxSelfClosingElement.bracketPosition", value.to_string().into())
155  }
156
157  /// Whether statements should end in a semi-colon.
158  ///
159  /// Default: `SemiColons::Prefer`
160  pub fn semi_colons(&mut self, value: SemiColons) -> &mut Self {
161    self.insert("semiColons", value.to_string().into())
162  }
163
164  /// Set to prefer hanging indentation when exceeding the line width.
165  ///
166  /// Default: `false`
167  pub fn prefer_hanging(&mut self, value: bool) -> &mut Self {
168    self.insert("preferHanging", value.into())
169  }
170
171  /// Behaviour to use for quotes on property names.
172  ///
173  /// Default: `preserve`
174  pub fn quote_props(&mut self, value: QuoteProps) -> &mut Self {
175    self.insert("quoteProps", value.to_string().into())
176  }
177
178  /// Where to place the opening brace.
179  ///
180  /// Default: `BracePosition::SameLineUnlessHanging`
181  pub fn brace_position(&mut self, value: BracePosition) -> &mut Self {
182    self.insert("bracePosition", value.to_string().into())
183  }
184
185  /// Where to place the next control flow within a control flow statement.
186  ///
187  /// Default: `NextControlFlowPosition::NextLine`
188  pub fn next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
189    self.insert("nextControlFlowPosition", value.to_string().into())
190  }
191
192  /// Where to place the operator for expressions that span multiple lines.
193  ///
194  /// Default: `OperatorPosition::NextLine`
195  pub fn operator_position(&mut self, value: OperatorPosition) -> &mut Self {
196    self.insert("operatorPosition", value.to_string().into())
197  }
198
199  /// Where to place the expression of a statement that could possibly be on one line (ex. `if (true) console.log(5);`).
200  ///
201  /// Default: SingleBodyPosition::Maintain
202  pub fn single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
203    self.insert("singleBodyPosition", value.to_string().into())
204  }
205
206  /// Amount of indents to use for the whole file.
207  ///
208  /// This should only be set by tools that need to indent all the code in the file.
209  ///
210  /// Default: `0`
211  pub fn file_indent_level(&mut self, value: u16) -> &mut Self {
212    self.insert("fileIndentLevel", (value as i32).into())
213  }
214
215  /// If trailing commas should be used.
216  ///
217  /// Default: `TrailingCommas::OnlyMultiLine`
218  pub fn trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
219    self.insert("trailingCommas", value.to_string().into())
220  }
221
222  /// If braces should be used or not.
223  ///
224  /// Default: `UseBraces::WhenNotSingleLine`
225  pub fn use_braces(&mut self, value: UseBraces) -> &mut Self {
226    self.insert("useBraces", value.to_string().into())
227  }
228
229  /// If code should revert back from being on multiple lines to
230  /// being on a single line when able.
231  ///
232  /// Default: `false`
233  pub fn prefer_single_line(&mut self, value: bool) -> &mut Self {
234    self.insert("preferSingleLine", value.into())
235  }
236
237  /* space settings */
238
239  /// Whether to surround bitwise and arithmetic operators in a binary expression with spaces.
240  ///
241  /// * `true` (default) - Ex. `1 + 2`
242  /// * `false` - Ex. `1+2`
243  pub fn binary_expression_space_surrounding_bitwise_and_arithmetic_operator(&mut self, value: bool) -> &mut Self {
244    self.insert("binaryExpression.spaceSurroundingBitwiseAndArithmeticOperator", value.into())
245  }
246
247  /// Forces a space after the double slash in a comment line.
248  ///
249  /// `true` (default) - Ex. `//test` -> `// test`
250  /// `false` - Ex. `//test` -> `//test`
251  pub fn comment_line_force_space_after_slashes(&mut self, value: bool) -> &mut Self {
252    self.insert("commentLine.forceSpaceAfterSlashes", value.into())
253  }
254
255  /// Whether to add a space after the `new` keyword in a construct signature.
256  ///
257  /// `true` - Ex. `new (): MyClass;`
258  /// `false` (default) - Ex. `new(): MyClass;`
259  pub fn construct_signature_space_after_new_keyword(&mut self, value: bool) -> &mut Self {
260    self.insert("constructSignature.spaceAfterNewKeyword", value.into())
261  }
262
263  /// Whether to add a space before the parentheses of a constructor.
264  ///
265  /// `true` - Ex. `constructor ()`
266  /// `false` (false) - Ex. `constructor()`
267  pub fn constructor_space_before_parentheses(&mut self, value: bool) -> &mut Self {
268    self.insert("constructor.spaceBeforeParentheses", value.into())
269  }
270
271  /// Whether to add a space after the `new` keyword in a constructor type.
272  ///
273  /// `true` - Ex. `type MyClassCtor = new () => MyClass;`
274  /// `false` (default) - Ex. `type MyClassCtor = new() => MyClass;`
275  pub fn constructor_type_space_after_new_keyword(&mut self, value: bool) -> &mut Self {
276    self.insert("constructorType.spaceAfterNewKeyword", value.into())
277  }
278
279  /// Whether to add a space after the `while` keyword in a do while statement.
280  ///
281  /// `true` (true) - Ex. `do {\n} while (condition);`
282  /// `false` - Ex. `do {\n} while(condition);`
283  pub fn do_while_statement_space_after_while_keyword(&mut self, value: bool) -> &mut Self {
284    self.insert("doWhileStatement.spaceAfterWhileKeyword", value.into())
285  }
286
287  /// Whether to add spaces around named exports in an export declaration.
288  ///
289  /// * `true` (default) - Ex. `export { SomeExport, OtherExport };`
290  /// * `false` - Ex. `export {SomeExport, OtherExport};`
291  pub fn export_declaration_space_surrounding_named_exports(&mut self, value: bool) -> &mut Self {
292    self.insert("exportDeclaration.spaceSurroundingNamedExports", value.into())
293  }
294
295  /// Whether to add a space after the `for` keyword in a "for" statement.
296  ///
297  /// * `true` (default) - Ex. `for (let i = 0; i < 5; i++)`
298  /// * `false` - Ex. `for(let i = 0; i < 5; i++)`
299  pub fn for_statement_space_after_for_keyword(&mut self, value: bool) -> &mut Self {
300    self.insert("forStatement.spaceAfterForKeyword", value.into())
301  }
302
303  /// Whether to add a space after the semi-colons in a "for" statement.
304  ///
305  /// * `true` (default) - Ex. `for (let i = 0; i < 5; i++)`
306  /// * `false` - Ex. `for (let i = 0;i < 5;i++)`
307  pub fn for_statement_space_after_semi_colons(&mut self, value: bool) -> &mut Self {
308    self.insert("forStatement.spaceAfterSemiColons", value.into())
309  }
310
311  /// Whether to add a space after the `for` keyword in a "for in" statement.
312  ///
313  /// * `true` (default) - Ex. `for (const prop in obj)`
314  /// * `false` - Ex. `for(const prop in obj)`
315  pub fn for_in_statement_space_after_for_keyword(&mut self, value: bool) -> &mut Self {
316    self.insert("forInStatement.spaceAfterForKeyword", value.into())
317  }
318
319  /// Whether to add a space after the `for` keyword in a "for of" statement.
320  ///
321  /// * `true` (default) - Ex. `for (const value of myArray)`
322  /// * `false` - Ex. `for(const value of myArray)`
323  pub fn for_of_statement_space_after_for_keyword(&mut self, value: bool) -> &mut Self {
324    self.insert("forOfStatement.spaceAfterForKeyword", value.into())
325  }
326
327  /// Whether to add a space before the parentheses of a function declaration.
328  ///
329  /// * `true` - Ex. `function myFunction ()`
330  /// * `false` (default) - Ex. `function myFunction()`
331  pub fn function_declaration_space_before_parentheses(&mut self, value: bool) -> &mut Self {
332    self.insert("functionDeclaration.spaceBeforeParentheses", value.into())
333  }
334
335  /// Whether to add a space before the parentheses of a function expression.
336  ///
337  /// `true` - Ex. `function<T> ()`
338  /// `false` (default) - Ex. `function<T> ()`
339  pub fn function_expression_space_before_parentheses(&mut self, value: bool) -> &mut Self {
340    self.insert("functionExpression.spaceBeforeParentheses", value.into())
341  }
342
343  /// Whether to add a space after the function keyword of a function expression.
344  ///
345  /// `true` - Ex. `function <T>()`.
346  /// `false` (default) - Ex. `function<T>()`
347  pub fn function_expression_space_after_function_keyword(&mut self, value: bool) -> &mut Self {
348    self.insert("functionExpression.spaceAfterFunctionKeyword", value.into())
349  }
350
351  /// Whether to add a space before the parentheses of a get accessor.
352  ///
353  /// `true` - Ex. `get myProp ()`
354  /// `false` (false) - Ex. `get myProp()`
355  pub fn get_accessor_space_before_parentheses(&mut self, value: bool) -> &mut Self {
356    self.insert("getAccessor.spaceBeforeParentheses", value.into())
357  }
358
359  /// Whether to add a space after the `if` keyword in an "if" statement.
360  ///
361  /// `true` (default) - Ex. `if (true)`
362  /// `false` - Ex. `if(true)`
363  pub fn if_statement_space_after_if_keyword(&mut self, value: bool) -> &mut Self {
364    self.insert("ifStatement.spaceAfterIfKeyword", value.into())
365  }
366
367  /// Whether to add spaces around named imports in an import declaration.
368  ///
369  /// * `true` (default) - Ex. `import { SomeExport, OtherExport } from "my-module";`
370  /// * `false` - Ex. `import {SomeExport, OtherExport} from "my-module";`
371  pub fn import_declaration_space_surrounding_named_imports(&mut self, value: bool) -> &mut Self {
372    self.insert("importDeclaration.spaceSurroundingNamedImports", value.into())
373  }
374
375  /// Whether to add a space surrounding the expression of a JSX container.
376  ///
377  /// * `true` - Ex. `{ myValue }`
378  /// * `false` (default) - Ex. `{myValue}`
379  pub fn jsx_expression_container_space_surrounding_expression(&mut self, value: bool) -> &mut Self {
380    self.insert("jsxExpressionContainer.spaceSurroundingExpression", value.into())
381  }
382
383  /// Whether to add a space before the slash in a self closing tag for a JSX element.
384  ///
385  /// * `true` (default) - Ex. `<Test />`
386  /// * `false` - Ex. `<Test/>`
387  pub fn jsx_self_closing_element_space_before_slash(&mut self, value: bool) -> &mut Self {
388    self.insert("jsxSelfClosingElement.spaceBeforeSlash", value.into())
389  }
390
391  /// Whether to add a space surrounding the properties of an object expression.
392  ///
393  /// * `true` (default) - Ex. `{ key: value }`
394  /// * `false` - Ex. `{key: value}`
395  pub fn object_expression_space_surrounding_properties(&mut self, value: bool) -> &mut Self {
396    self.insert("objectExpression.spaceSurroundingProperties", value.into())
397  }
398
399  /// Whether to add a space surrounding the properties of an object pattern.
400  ///
401  /// * `true` (default) - Ex. `{ key: value } = obj`
402  /// * `false` - Ex. `{key: value} = obj`
403  pub fn object_pattern_space_surrounding_properties(&mut self, value: bool) -> &mut Self {
404    self.insert("objectPattern.spaceSurroundingProperties", value.into())
405  }
406
407  /// Whether to add a space before the parentheses of a method.
408  ///
409  /// `true` - Ex. `myMethod ()`
410  /// `false` - Ex. `myMethod()`
411  pub fn method_space_before_parentheses(&mut self, value: bool) -> &mut Self {
412    self.insert("method.spaceBeforeParentheses", value.into())
413  }
414
415  /// Whether to add a space before the parentheses of a set accessor.
416  ///
417  /// `true` - Ex. `set myProp (value: string)`
418  /// `false` (default) - Ex. `set myProp(value: string)`
419  pub fn set_accessor_space_before_parentheses(&mut self, value: bool) -> &mut Self {
420    self.insert("setAccessor.spaceBeforeParentheses", value.into())
421  }
422
423  /// Whether to add a space surrounding the properties of object-like nodes.
424  ///
425  /// * `true` (default) - Ex. `{ key: value }`
426  /// * `false` - Ex. `{key: value}`
427  pub fn space_surrounding_properties(&mut self, value: bool) -> &mut Self {
428    self.insert("spaceSurroundingProperties", value.into())
429  }
430
431  /// Whether to add a space before the literal in a tagged template.
432  ///
433  /// * `true` (default) - Ex. `html \`<element />\``
434  /// * `false` - Ex. `html\`<element />\``
435  pub fn tagged_template_space_before_literal(&mut self, value: bool) -> &mut Self {
436    self.insert("taggedTemplate.spaceBeforeLiteral", value.into())
437  }
438
439  /// Whether to add a space before the colon of a type annotation.
440  ///
441  /// * `true` - Ex. `function myFunction() : string`
442  /// * `false` (default) - Ex. `function myFunction(): string`
443  pub fn type_annotation_space_before_colon(&mut self, value: bool) -> &mut Self {
444    self.insert("typeAnnotation.spaceBeforeColon", value.into())
445  }
446
447  /// Whether to add a space before the expression in a type assertion.
448  ///
449  /// * `true` (default) - Ex. `<string> myValue`
450  /// * `false` - Ex. `<string>myValue`
451  pub fn type_assertion_space_before_expression(&mut self, value: bool) -> &mut Self {
452    self.insert("typeAssertion.spaceBeforeExpression", value.into())
453  }
454
455  /// Whether to add a space surrounding the properties of a type literal.
456  ///
457  /// * `true` (default) - Ex. `value: { key: Type }`
458  /// * `false` - Ex. `value: {key: Type}`
459  pub fn type_literal_space_surrounding_properties(&mut self, value: bool) -> &mut Self {
460    self.insert("typeLiteral.spaceSurroundingProperties", value.into())
461  }
462
463  /// Whether to add a space after the `while` keyword in a while statement.
464  ///
465  /// * `true` (default) - Ex. `while (true)`
466  /// * `false` - Ex. `while(true)`
467  pub fn while_statement_space_after_while_keyword(&mut self, value: bool) -> &mut Self {
468    self.insert("whileStatement.spaceAfterWhileKeyword", value.into())
469  }
470
471  /// Whether to place spaces around enclosed expressions.
472  ///
473  /// * `true` - Ex. `myFunction( true )`
474  /// * `false` (default) - Ex. `myFunction(true)`
475  pub fn space_around(&mut self, value: bool) -> &mut Self {
476    self.insert("spaceAround", value.into())
477  }
478
479  /* situational */
480
481  /// Whether to use parentheses for arrow functions.
482  ///
483  /// Default: `UseParentheses::Maintain`
484  pub fn arrow_function_use_parentheses(&mut self, value: UseParentheses) -> &mut Self {
485    self.insert("arrowFunction.useParentheses", value.to_string().into())
486  }
487
488  /// Whether to force a line per expression when spanning multiple lines.
489  ///
490  /// * `true` - Formats with each part on a new line.
491  /// * `false` (default) - Maintains the line breaks as written by the programmer.
492  pub fn binary_expression_line_per_expression(&mut self, value: bool) -> &mut Self {
493    self.insert("binaryExpression.linePerExpression", value.into())
494  }
495
496  /// Whether to force a line per expression when spanning multiple lines.
497  ///
498  /// * `true` - Formats with each part on a new line.
499  /// * `false` (default) - Maintains the line breaks as written by the programmer.
500  pub fn conditional_expression_line_per_expression(&mut self, value: bool) -> &mut Self {
501    self.insert("conditionalExpression.linePerExpression", value.into())
502  }
503
504  /// Whether to force a line per expression when spanning multiple lines.
505  ///
506  /// * `true` - Formats with each part on a new line.
507  /// * `false` (default) - Maintains the line breaks as written by the programmer.
508  pub fn member_expression_line_per_expression(&mut self, value: bool) -> &mut Self {
509    self.insert("memberExpression.linePerExpression", value.into())
510  }
511
512  /// The kind of separator to use in type literals.
513  pub fn type_literal_separator_kind(&mut self, value: SemiColonOrComma) -> &mut Self {
514    self.insert("typeLiteral.separatorKind", value.to_string().into())
515  }
516
517  /// The kind of separator to use in type literals when single line.
518  pub fn type_literal_separator_kind_single_line(&mut self, value: SemiColonOrComma) -> &mut Self {
519    self.insert("typeLiteral.separatorKind.singleLine", value.to_string().into())
520  }
521
522  /// The kind of separator to use in type literals when multi-line.
523  pub fn type_literal_separator_kind_multi_line(&mut self, value: SemiColonOrComma) -> &mut Self {
524    self.insert("typeLiteral.separatorKind.multiLine", value.to_string().into())
525  }
526
527  /* sorting */
528
529  /// Alphabetically sorts the import declarations based on their module specifiers.
530  ///
531  /// Default: Case insensitive
532  pub fn module_sort_import_declarations(&mut self, value: SortOrder) -> &mut Self {
533    self.insert("module.sortImportDeclarations", value.to_string().into())
534  }
535
536  /// Alphabetically sorts the export declarations based on their module specifiers.
537  ///
538  /// Default: Case insensitive
539  pub fn module_sort_export_declarations(&mut self, value: SortOrder) -> &mut Self {
540    self.insert("module.sortExportDeclarations", value.to_string().into())
541  }
542
543  /// Alphabetically sorts the import declaration's named imports.
544  ///
545  /// Default: Case insensitive
546  pub fn import_declaration_sort_named_imports(&mut self, value: SortOrder) -> &mut Self {
547    self.insert("importDeclaration.sortNamedImports", value.to_string().into())
548  }
549
550  /// Sorts type-only named imports first, last, or none (no sorting).
551  ///
552  /// Default: Last
553  pub fn import_declaration_sort_type_only_imports(&mut self, value: NamedTypeImportsExportsOrder) -> &mut Self {
554    self.insert("importDeclaration.sortTypeOnlyImports", value.to_string().into())
555  }
556
557  /// Alphabetically sorts the export declaration's named exports.
558  ///
559  /// Default: Case insensitive
560  pub fn export_declaration_sort_named_exports(&mut self, value: SortOrder) -> &mut Self {
561    self.insert("exportDeclaration.sortNamedExports", value.to_string().into())
562  }
563
564  /// Sorts type-only named exports first, last, or none (no sorting).
565  ///
566  /// Default: Last
567  pub fn export_declaration_sort_type_only_exports(&mut self, value: NamedTypeImportsExportsOrder) -> &mut Self {
568    self.insert("exportDeclaration.sortTypeOnlyExports", value.to_string().into())
569  }
570
571  /* ignore comments */
572
573  /// The text to use for an ignore comment (ex. `// dprint-ignore`).
574  ///
575  /// Default: `"dprint-ignore"`
576  pub fn ignore_node_comment_text(&mut self, value: &str) -> &mut Self {
577    self.insert("ignoreNodeCommentText", value.into())
578  }
579
580  /// The text to use for a file ignore comment (ex. `// dprint-ignore-file`).
581  ///
582  /// Default: `"dprint-ignore-file"`
583  pub fn ignore_file_comment_text(&mut self, value: &str) -> &mut Self {
584    self.insert("ignoreFileCommentText", value.into())
585  }
586
587  /* brace position */
588
589  pub fn arrow_function_brace_position(&mut self, value: BracePosition) -> &mut Self {
590    self.insert("arrowFunction.bracePosition", value.to_string().into())
591  }
592
593  pub fn class_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
594    self.insert("classDeclaration.bracePosition", value.to_string().into())
595  }
596
597  pub fn class_expression_brace_position(&mut self, value: BracePosition) -> &mut Self {
598    self.insert("classExpression.bracePosition", value.to_string().into())
599  }
600
601  pub fn constructor_brace_position(&mut self, value: BracePosition) -> &mut Self {
602    self.insert("constructor.bracePosition", value.to_string().into())
603  }
604
605  pub fn do_while_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
606    self.insert("doWhileStatement.bracePosition", value.to_string().into())
607  }
608
609  pub fn enum_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
610    self.insert("enumDeclaration.bracePosition", value.to_string().into())
611  }
612
613  pub fn for_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
614    self.insert("forStatement.bracePosition", value.to_string().into())
615  }
616
617  pub fn for_in_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
618    self.insert("forInStatement.bracePosition", value.to_string().into())
619  }
620
621  pub fn for_of_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
622    self.insert("forOfStatement.bracePosition", value.to_string().into())
623  }
624
625  pub fn get_accessor_brace_position(&mut self, value: BracePosition) -> &mut Self {
626    self.insert("getAccessor.bracePosition", value.to_string().into())
627  }
628
629  pub fn if_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
630    self.insert("ifStatement.bracePosition", value.to_string().into())
631  }
632
633  pub fn interface_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
634    self.insert("interfaceDeclaration.bracePosition", value.to_string().into())
635  }
636
637  pub fn function_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
638    self.insert("functionDeclaration.bracePosition", value.to_string().into())
639  }
640
641  pub fn function_expression_brace_position(&mut self, value: BracePosition) -> &mut Self {
642    self.insert("functionExpression.bracePosition", value.to_string().into())
643  }
644
645  pub fn method_brace_position(&mut self, value: BracePosition) -> &mut Self {
646    self.insert("method.bracePosition", value.to_string().into())
647  }
648
649  pub fn module_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
650    self.insert("moduleDeclaration.bracePosition", value.to_string().into())
651  }
652
653  pub fn set_accessor_brace_position(&mut self, value: BracePosition) -> &mut Self {
654    self.insert("setAccessor.bracePosition", value.to_string().into())
655  }
656
657  pub fn static_block_brace_position(&mut self, value: BracePosition) -> &mut Self {
658    self.insert("staticBlock.bracePosition", value.to_string().into())
659  }
660
661  pub fn switch_case_brace_position(&mut self, value: BracePosition) -> &mut Self {
662    self.insert("switchCase.bracePosition", value.to_string().into())
663  }
664
665  pub fn switch_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
666    self.insert("switchStatement.bracePosition", value.to_string().into())
667  }
668
669  pub fn try_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
670    self.insert("tryStatement.bracePosition", value.to_string().into())
671  }
672
673  pub fn while_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
674    self.insert("whileStatement.bracePosition", value.to_string().into())
675  }
676
677  /* prefer hanging */
678
679  pub fn arguments_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
680    self.insert("arguments.preferHanging", value.to_string().into())
681  }
682
683  pub fn array_expression_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
684    self.insert("arrayExpression.preferHanging", value.to_string().into())
685  }
686
687  pub fn array_pattern_prefer_hanging(&mut self, value: bool) -> &mut Self {
688    self.insert("arrayPattern.preferHanging", value.into())
689  }
690
691  pub fn do_while_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
692    self.insert("doWhileStatement.preferHanging", value.into())
693  }
694
695  pub fn export_declaration_prefer_hanging(&mut self, value: bool) -> &mut Self {
696    self.insert("exportDeclaration.preferHanging", value.into())
697  }
698
699  pub fn extends_clause_prefer_hanging(&mut self, value: bool) -> &mut Self {
700    self.insert("extendsClause.preferHanging", value.into())
701  }
702
703  pub fn for_in_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
704    self.insert("forInStatement.preferHanging", value.into())
705  }
706
707  pub fn for_of_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
708    self.insert("forOfStatement.preferHanging", value.into())
709  }
710
711  pub fn for_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
712    self.insert("forStatement.preferHanging", value.into())
713  }
714
715  pub fn if_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
716    self.insert("ifStatement.preferHanging", value.into())
717  }
718
719  pub fn implements_clause_prefer_hanging(&mut self, value: bool) -> &mut Self {
720    self.insert("implementsClause.preferHanging", value.into())
721  }
722
723  pub fn import_declaration_prefer_hanging(&mut self, value: bool) -> &mut Self {
724    self.insert("importDeclaration.preferHanging", value.into())
725  }
726
727  pub fn jsx_attributes_prefer_hanging(&mut self, value: bool) -> &mut Self {
728    self.insert("jsxAttributes.preferHanging", value.into())
729  }
730
731  pub fn object_expression_prefer_hanging(&mut self, value: bool) -> &mut Self {
732    self.insert("objectExpression.preferHanging", value.into())
733  }
734
735  pub fn object_pattern_prefer_hanging(&mut self, value: bool) -> &mut Self {
736    self.insert("objectPattern.preferHanging", value.into())
737  }
738
739  pub fn parameters_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
740    self.insert("parameters.preferHanging", value.to_string().into())
741  }
742
743  pub fn sequence_expression_prefer_hanging(&mut self, value: bool) -> &mut Self {
744    self.insert("sequenceExpression.preferHanging", value.into())
745  }
746
747  pub fn switch_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
748    self.insert("switchStatement.preferHanging", value.into())
749  }
750
751  pub fn tuple_type_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
752    self.insert("tupleType.preferHanging", value.to_string().into())
753  }
754
755  pub fn type_literal_prefer_hanging(&mut self, value: bool) -> &mut Self {
756    self.insert("typeLiteral.preferHanging", value.into())
757  }
758
759  pub fn type_parameters_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
760    self.insert("typeParameters.preferHanging", value.to_string().into())
761  }
762
763  pub fn union_and_intersection_type_prefer_hanging(&mut self, value: bool) -> &mut Self {
764    self.insert("unionAndIntersectionType.preferHanging", value.into())
765  }
766
767  pub fn variable_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
768    self.insert("variableStatement.preferHanging", value.into())
769  }
770
771  pub fn while_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
772    self.insert("whileStatement.preferHanging", value.into())
773  }
774
775  /* force single line */
776
777  pub fn export_declaration_force_single_line(&mut self, value: bool) -> &mut Self {
778    self.insert("exportDeclaration.forceSingleLine", value.into())
779  }
780
781  pub fn import_declaration_force_single_line(&mut self, value: bool) -> &mut Self {
782    self.insert("importDeclaration.forceSingleLine", value.into())
783  }
784
785  /* force multi line specifiers */
786
787  pub fn export_declaration_force_multi_line(&mut self, value: ForceMultiLine) -> &mut Self {
788    self.insert("exportDeclaration.forceMultiLine", value.to_string().into())
789  }
790
791  pub fn import_declaration_force_multi_line(&mut self, value: ForceMultiLine) -> &mut Self {
792    self.insert("importDeclaration.forceMultiLine", value.to_string().into())
793  }
794
795  /* member spacing */
796
797  pub fn enum_declaration_member_spacing(&mut self, value: MemberSpacing) -> &mut Self {
798    self.insert("enumDeclaration.memberSpacing", value.to_string().into())
799  }
800
801  /* next control flow position */
802
803  pub fn if_statement_next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
804    self.insert("ifStatement.nextControlFlowPosition", value.to_string().into())
805  }
806
807  pub fn try_statement_next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
808    self.insert("tryStatement.nextControlFlowPosition", value.to_string().into())
809  }
810
811  pub fn do_while_statement_next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
812    self.insert("doWhileStatement.nextControlFlowPosition", value.to_string().into())
813  }
814
815  /* operator position */
816
817  pub fn binary_expression_operator_position(&mut self, value: OperatorPosition) -> &mut Self {
818    self.insert("binaryExpression.operatorPosition", value.to_string().into())
819  }
820
821  pub fn conditional_expression_operator_position(&mut self, value: OperatorPosition) -> &mut Self {
822    self.insert("conditionalExpression.operatorPosition", value.to_string().into())
823  }
824
825  pub fn conditional_type_operator_position(&mut self, value: OperatorPosition) -> &mut Self {
826    self.insert("conditionalType.operatorPosition", value.to_string().into())
827  }
828
829  /* single body position */
830
831  pub fn if_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
832    self.insert("ifStatement.singleBodyPosition", value.to_string().into())
833  }
834
835  pub fn for_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
836    self.insert("forStatement.singleBodyPosition", value.to_string().into())
837  }
838
839  pub fn for_in_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
840    self.insert("forInStatement.singleBodyPosition", value.to_string().into())
841  }
842
843  pub fn for_of_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
844    self.insert("forOfStatement.singleBodyPosition", value.to_string().into())
845  }
846
847  pub fn while_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
848    self.insert("whileStatement.singleBodyPosition", value.to_string().into())
849  }
850
851  /* trailing commas */
852
853  pub fn arguments_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
854    self.insert("arguments.trailingCommas", value.to_string().into())
855  }
856
857  pub fn parameters_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
858    self.insert("parameters.trailingCommas", value.to_string().into())
859  }
860
861  pub fn array_expression_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
862    self.insert("arrayExpression.trailingCommas", value.to_string().into())
863  }
864
865  pub fn array_pattern_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
866    self.insert("arrayPattern.trailingCommas", value.to_string().into())
867  }
868
869  pub fn enum_declaration_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
870    self.insert("enumDeclaration.trailingCommas", value.to_string().into())
871  }
872
873  pub fn export_declaration_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
874    self.insert("exportDeclaration.trailingCommas", value.to_string().into())
875  }
876
877  pub fn import_declaration_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
878    self.insert("importDeclaration.trailingCommas", value.to_string().into())
879  }
880
881  pub fn object_expression_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
882    self.insert("objectExpression.trailingCommas", value.to_string().into())
883  }
884
885  pub fn object_pattern_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
886    self.insert("objectPattern.trailingCommas", value.to_string().into())
887  }
888
889  pub fn tuple_type_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
890    self.insert("tupleType.trailingCommas", value.to_string().into())
891  }
892
893  /// Only applies when using commas on type literals.
894  pub fn type_literal_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
895    self.insert("typeLiteral.trailingCommas", value.to_string().into())
896  }
897
898  pub fn type_parameters_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
899    self.insert("typeParameters.trailingCommas", value.to_string().into())
900  }
901
902  /* use braces */
903
904  pub fn if_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
905    self.insert("ifStatement.useBraces", value.to_string().into())
906  }
907
908  pub fn for_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
909    self.insert("forStatement.useBraces", value.to_string().into())
910  }
911
912  pub fn for_in_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
913    self.insert("forInStatement.useBraces", value.to_string().into())
914  }
915
916  pub fn for_of_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
917    self.insert("forOfStatement.useBraces", value.to_string().into())
918  }
919
920  pub fn while_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
921    self.insert("whileStatement.useBraces", value.to_string().into())
922  }
923
924  /* prefer single line */
925
926  pub fn array_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
927    self.insert("arrayExpression.preferSingleLine", value.into())
928  }
929
930  pub fn array_pattern_prefer_single_line(&mut self, value: bool) -> &mut Self {
931    self.insert("arrayPattern.preferSingleLine", value.into())
932  }
933
934  pub fn arguments_prefer_single_line(&mut self, value: bool) -> &mut Self {
935    self.insert("arguments.preferSingleLine", value.into())
936  }
937
938  pub fn binary_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
939    self.insert("binaryExpression.preferSingleLine", value.into())
940  }
941
942  pub fn computed_prefer_single_line(&mut self, value: bool) -> &mut Self {
943    self.insert("computed.preferSingleLine", value.into())
944  }
945
946  pub fn conditional_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
947    self.insert("conditionalExpression.preferSingleLine", value.into())
948  }
949
950  pub fn conditional_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
951    self.insert("conditionalType.preferSingleLine", value.into())
952  }
953
954  pub fn decorators_prefer_single_line(&mut self, value: bool) -> &mut Self {
955    self.insert("decorators.preferSingleLine", value.into())
956  }
957
958  pub fn export_declaration_prefer_single_line(&mut self, value: bool) -> &mut Self {
959    self.insert("exportDeclaration.preferSingleLine", value.into())
960  }
961
962  pub fn for_statement_prefer_single_line(&mut self, value: bool) -> &mut Self {
963    self.insert("forStatement.preferSingleLine", value.into())
964  }
965
966  pub fn import_declaration_prefer_single_line(&mut self, value: bool) -> &mut Self {
967    self.insert("importDeclaration.preferSingleLine", value.into())
968  }
969
970  pub fn jsx_attributes_prefer_single_line(&mut self, value: bool) -> &mut Self {
971    self.insert("jsxAttributes.preferSingleLine", value.into())
972  }
973
974  pub fn jsx_element_prefer_single_line(&mut self, value: bool) -> &mut Self {
975    self.insert("jsxElement.preferSingleLine", value.into())
976  }
977
978  pub fn mapped_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
979    self.insert("mappedType.preferSingleLine", value.into())
980  }
981
982  pub fn member_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
983    self.insert("memberExpression.preferSingleLine", value.into())
984  }
985
986  pub fn object_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
987    self.insert("objectExpression.preferSingleLine", value.into())
988  }
989
990  pub fn object_pattern_prefer_single_line(&mut self, value: bool) -> &mut Self {
991    self.insert("objectPattern.preferSingleLine", value.into())
992  }
993
994  pub fn parameters_prefer_single_line(&mut self, value: bool) -> &mut Self {
995    self.insert("parameters.preferSingleLine", value.into())
996  }
997
998  pub fn parentheses_prefer_single_line(&mut self, value: bool) -> &mut Self {
999    self.insert("parentheses.preferSingleLine", value.into())
1000  }
1001
1002  pub fn tuple_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
1003    self.insert("tupleType.preferSingleLine", value.into())
1004  }
1005
1006  pub fn type_literal_prefer_single_line(&mut self, value: bool) -> &mut Self {
1007    self.insert("typeLiteral.preferSingleLine", value.into())
1008  }
1009
1010  pub fn type_parameters_prefer_single_line(&mut self, value: bool) -> &mut Self {
1011    self.insert("typeParameters.preferSingleLine", value.into())
1012  }
1013
1014  pub fn union_and_intersection_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
1015    self.insert("unionAndIntersectionType.preferSingleLine", value.into())
1016  }
1017
1018  pub fn variable_statement_prefer_single_line(&mut self, value: bool) -> &mut Self {
1019    self.insert("variableStatement.preferSingleLine", value.into())
1020  }
1021
1022  /* space around */
1023
1024  pub fn arguments_space_around(&mut self, value: bool) -> &mut Self {
1025    self.insert("arguments.spaceAround", value.into())
1026  }
1027
1028  pub fn array_expression_space_around(&mut self, value: bool) -> &mut Self {
1029    self.insert("arrayExpression.spaceAround", value.into())
1030  }
1031
1032  pub fn array_pattern_space_around(&mut self, value: bool) -> &mut Self {
1033    self.insert("arrayPattern.spaceAround", value.into())
1034  }
1035
1036  pub fn catch_clause_space_around(&mut self, value: bool) -> &mut Self {
1037    self.insert("catchClause.spaceAround", value.into())
1038  }
1039
1040  pub fn do_while_statement_space_around(&mut self, value: bool) -> &mut Self {
1041    self.insert("doWhileStatement.spaceAround", value.into())
1042  }
1043
1044  pub fn for_in_statement_space_around(&mut self, value: bool) -> &mut Self {
1045    self.insert("forInStatement.spaceAround", value.into())
1046  }
1047
1048  pub fn for_of_statement_space_around(&mut self, value: bool) -> &mut Self {
1049    self.insert("forOfStatement.spaceAround", value.into())
1050  }
1051
1052  pub fn for_statement_space_around(&mut self, value: bool) -> &mut Self {
1053    self.insert("forStatement.spaceAround", value.into())
1054  }
1055
1056  pub fn if_statement_space_around(&mut self, value: bool) -> &mut Self {
1057    self.insert("ifStatement.spaceAround", value.into())
1058  }
1059
1060  pub fn parameters_space_around(&mut self, value: bool) -> &mut Self {
1061    self.insert("parameters.spaceAround", value.into())
1062  }
1063
1064  pub fn paren_expression_space_around(&mut self, value: bool) -> &mut Self {
1065    self.insert("parenExpression.spaceAround", value.into())
1066  }
1067
1068  pub fn switch_statement_space_around(&mut self, value: bool) -> &mut Self {
1069    self.insert("switchStatement.spaceAround", value.into())
1070  }
1071
1072  pub fn tuple_type_space_around(&mut self, value: bool) -> &mut Self {
1073    self.insert("tupleType.spaceAround", value.into())
1074  }
1075
1076  pub fn while_statement_space_around(&mut self, value: bool) -> &mut Self {
1077    self.insert("whileStatement.spaceAround", value.into())
1078  }
1079
1080  #[cfg(test)]
1081  pub(super) fn get_inner_config(&self) -> ConfigKeyMap {
1082    self.config.clone()
1083  }
1084
1085  fn insert(&mut self, name: &str, value: ConfigKeyValue) -> &mut Self {
1086    self.config.insert(String::from(name), value);
1087    self
1088  }
1089}
1090
1091#[cfg(test)]
1092mod tests {
1093  use super::*;
1094
1095  #[test]
1096  fn check_all_values_set() {
1097    let mut config = ConfigurationBuilder::new();
1098    config
1099      .new_line_kind(NewLineKind::Auto)
1100      .line_width(80)
1101      .use_tabs(false)
1102      .indent_width(4)
1103      /* common */
1104      .quote_style(QuoteStyle::AlwaysDouble)
1105      .jsx_quote_style(JsxQuoteStyle::PreferSingle)
1106      .jsx_multi_line_parens(JsxMultiLineParens::Never)
1107      .jsx_force_new_lines_surrounding_content(true)
1108      .jsx_bracket_position(SameOrNextLinePosition::Maintain)
1109      .jsx_opening_element_bracket_position(SameOrNextLinePosition::Maintain)
1110      .jsx_self_closing_element_bracket_position(SameOrNextLinePosition::Maintain)
1111      .semi_colons(SemiColons::Prefer)
1112      .brace_position(BracePosition::NextLine)
1113      .next_control_flow_position(NextControlFlowPosition::SameLine)
1114      .operator_position(OperatorPosition::SameLine)
1115      .single_body_position(SameOrNextLinePosition::SameLine)
1116      .trailing_commas(TrailingCommas::Never)
1117      .file_indent_level(1)
1118      .use_braces(UseBraces::WhenNotSingleLine)
1119      .quote_props(QuoteProps::AsNeeded)
1120      .prefer_hanging(false)
1121      /* situational */
1122      .arrow_function_use_parentheses(UseParentheses::Maintain)
1123      .binary_expression_line_per_expression(false)
1124      .conditional_expression_line_per_expression(true)
1125      .member_expression_line_per_expression(false)
1126      .type_literal_separator_kind(SemiColonOrComma::Comma)
1127      .type_literal_separator_kind_single_line(SemiColonOrComma::Comma)
1128      .type_literal_separator_kind_multi_line(SemiColonOrComma::Comma)
1129      /* sorting */
1130      .module_sort_import_declarations(SortOrder::Maintain)
1131      .module_sort_export_declarations(SortOrder::Maintain)
1132      .import_declaration_sort_named_imports(SortOrder::Maintain)
1133      .export_declaration_sort_named_exports(SortOrder::Maintain)
1134      .import_declaration_sort_type_only_imports(NamedTypeImportsExportsOrder::First)
1135      .export_declaration_sort_type_only_exports(NamedTypeImportsExportsOrder::None)
1136      /* ignore comments */
1137      .ignore_node_comment_text("ignore")
1138      .ignore_file_comment_text("ignore-file")
1139      /* brace position*/
1140      .arrow_function_brace_position(BracePosition::NextLine)
1141      .class_declaration_brace_position(BracePosition::NextLine)
1142      .class_expression_brace_position(BracePosition::NextLine)
1143      .constructor_brace_position(BracePosition::NextLine)
1144      .do_while_statement_brace_position(BracePosition::NextLine)
1145      .enum_declaration_brace_position(BracePosition::NextLine)
1146      .for_statement_brace_position(BracePosition::NextLine)
1147      .for_in_statement_brace_position(BracePosition::NextLine)
1148      .for_of_statement_brace_position(BracePosition::NextLine)
1149      .get_accessor_brace_position(BracePosition::NextLine)
1150      .if_statement_brace_position(BracePosition::NextLine)
1151      .interface_declaration_brace_position(BracePosition::NextLine)
1152      .function_declaration_brace_position(BracePosition::NextLine)
1153      .function_expression_brace_position(BracePosition::NextLine)
1154      .method_brace_position(BracePosition::NextLine)
1155      .module_declaration_brace_position(BracePosition::NextLine)
1156      .set_accessor_brace_position(BracePosition::NextLine)
1157      .static_block_brace_position(BracePosition::NextLine)
1158      .switch_case_brace_position(BracePosition::NextLine)
1159      .switch_statement_brace_position(BracePosition::NextLine)
1160      .try_statement_brace_position(BracePosition::NextLine)
1161      .while_statement_brace_position(BracePosition::NextLine)
1162      /* prefer hanging */
1163      .arguments_prefer_hanging(PreferHanging::OnlySingleItem)
1164      .array_expression_prefer_hanging(PreferHanging::OnlySingleItem)
1165      .array_pattern_prefer_hanging(true)
1166      .do_while_statement_prefer_hanging(true)
1167      .export_declaration_prefer_hanging(true)
1168      .extends_clause_prefer_hanging(true)
1169      .for_in_statement_prefer_hanging(true)
1170      .for_of_statement_prefer_hanging(true)
1171      .for_statement_prefer_hanging(true)
1172      .if_statement_prefer_hanging(true)
1173      .implements_clause_prefer_hanging(true)
1174      .import_declaration_prefer_hanging(true)
1175      .jsx_attributes_prefer_hanging(true)
1176      .object_expression_prefer_hanging(true)
1177      .object_pattern_prefer_hanging(true)
1178      .parameters_prefer_hanging(PreferHanging::OnlySingleItem)
1179      .sequence_expression_prefer_hanging(true)
1180      .switch_statement_prefer_hanging(true)
1181      .tuple_type_prefer_hanging(PreferHanging::OnlySingleItem)
1182      .type_literal_prefer_hanging(true)
1183      .type_parameters_prefer_hanging(PreferHanging::OnlySingleItem)
1184      .union_and_intersection_type_prefer_hanging(true)
1185      .variable_statement_prefer_hanging(true)
1186      .while_statement_prefer_hanging(true)
1187      /* member spacing */
1188      .enum_declaration_member_spacing(MemberSpacing::Maintain)
1189      /* next control flow position */
1190      .if_statement_next_control_flow_position(NextControlFlowPosition::SameLine)
1191      .try_statement_next_control_flow_position(NextControlFlowPosition::SameLine)
1192      .do_while_statement_next_control_flow_position(NextControlFlowPosition::SameLine)
1193      /* operator position */
1194      .binary_expression_operator_position(OperatorPosition::SameLine)
1195      .conditional_expression_operator_position(OperatorPosition::SameLine)
1196      .conditional_type_operator_position(OperatorPosition::SameLine)
1197      /* single body position */
1198      .if_statement_single_body_position(SameOrNextLinePosition::SameLine)
1199      .for_statement_single_body_position(SameOrNextLinePosition::SameLine)
1200      .for_in_statement_single_body_position(SameOrNextLinePosition::SameLine)
1201      .for_of_statement_single_body_position(SameOrNextLinePosition::SameLine)
1202      .while_statement_single_body_position(SameOrNextLinePosition::SameLine)
1203      /* trailing commas */
1204      .arguments_trailing_commas(TrailingCommas::Never)
1205      .parameters_trailing_commas(TrailingCommas::Never)
1206      .array_expression_trailing_commas(TrailingCommas::Never)
1207      .array_pattern_trailing_commas(TrailingCommas::Never)
1208      .enum_declaration_trailing_commas(TrailingCommas::Never)
1209      .import_declaration_trailing_commas(TrailingCommas::Never)
1210      .export_declaration_trailing_commas(TrailingCommas::Never)
1211      .object_expression_trailing_commas(TrailingCommas::Never)
1212      .object_pattern_trailing_commas(TrailingCommas::Never)
1213      .type_parameters_trailing_commas(TrailingCommas::Never)
1214      .tuple_type_trailing_commas(TrailingCommas::Never)
1215      .type_literal_trailing_commas(TrailingCommas::Never)
1216      /* use braces */
1217      .if_statement_use_braces(UseBraces::Always)
1218      .for_statement_use_braces(UseBraces::Always)
1219      .for_in_statement_use_braces(UseBraces::Always)
1220      .for_of_statement_use_braces(UseBraces::Always)
1221      .while_statement_use_braces(UseBraces::Always)
1222      /* prefer single line */
1223      .array_expression_prefer_single_line(false)
1224      .array_pattern_prefer_single_line(false)
1225      .arguments_prefer_single_line(false)
1226      .binary_expression_prefer_single_line(false)
1227      .computed_prefer_single_line(false)
1228      .conditional_expression_prefer_single_line(false)
1229      .conditional_type_prefer_single_line(false)
1230      .decorators_prefer_single_line(false)
1231      .export_declaration_prefer_single_line(false)
1232      .for_statement_prefer_single_line(false)
1233      .import_declaration_prefer_single_line(false)
1234      .jsx_attributes_prefer_single_line(false)
1235      .jsx_element_prefer_single_line(false)
1236      .mapped_type_prefer_single_line(false)
1237      .member_expression_prefer_single_line(false)
1238      .object_expression_prefer_single_line(false)
1239      .object_pattern_prefer_single_line(false)
1240      .parameters_prefer_single_line(false)
1241      .parentheses_prefer_single_line(false)
1242      .tuple_type_prefer_single_line(false)
1243      .type_literal_prefer_single_line(false)
1244      .type_parameters_prefer_single_line(false)
1245      .union_and_intersection_type_prefer_single_line(false)
1246      .variable_statement_prefer_single_line(false)
1247      /* force single line */
1248      .export_declaration_force_single_line(true)
1249      .import_declaration_force_single_line(true)
1250      /* force multi line specifiers */
1251      .export_declaration_force_multi_line(ForceMultiLine::Always)
1252      .import_declaration_force_multi_line(ForceMultiLine::Always)
1253      /* space settings */
1254      .binary_expression_space_surrounding_bitwise_and_arithmetic_operator(true)
1255      .comment_line_force_space_after_slashes(false)
1256      .construct_signature_space_after_new_keyword(true)
1257      .constructor_space_before_parentheses(true)
1258      .constructor_type_space_after_new_keyword(true)
1259      .do_while_statement_space_after_while_keyword(true)
1260      .export_declaration_space_surrounding_named_exports(true)
1261      .for_statement_space_after_for_keyword(true)
1262      .for_statement_space_after_semi_colons(true)
1263      .for_in_statement_space_after_for_keyword(true)
1264      .for_of_statement_space_after_for_keyword(true)
1265      .function_declaration_space_before_parentheses(true)
1266      .function_expression_space_before_parentheses(true)
1267      .function_expression_space_after_function_keyword(true)
1268      .get_accessor_space_before_parentheses(true)
1269      .if_statement_space_after_if_keyword(true)
1270      .import_declaration_space_surrounding_named_imports(true)
1271      .jsx_expression_container_space_surrounding_expression(true)
1272      .jsx_self_closing_element_space_before_slash(true)
1273      .method_space_before_parentheses(true)
1274      .object_expression_space_surrounding_properties(false)
1275      .object_pattern_space_surrounding_properties(false)
1276      .set_accessor_space_before_parentheses(true)
1277      .space_surrounding_properties(false)
1278      .tagged_template_space_before_literal(false)
1279      .type_annotation_space_before_colon(true)
1280      .type_assertion_space_before_expression(true)
1281      .type_literal_space_surrounding_properties(false)
1282      .while_statement_space_after_while_keyword(true)
1283      /* space around */
1284      .arguments_space_around(true)
1285      .array_expression_space_around(true)
1286      .array_pattern_space_around(true)
1287      .catch_clause_space_around(true)
1288      .do_while_statement_space_around(true)
1289      .for_in_statement_space_around(true)
1290      .for_of_statement_space_around(true)
1291      .for_statement_space_around(true)
1292      .if_statement_space_around(true)
1293      .parameters_space_around(true)
1294      .paren_expression_space_around(true)
1295      .switch_statement_space_around(true)
1296      .tuple_type_space_around(true)
1297      .while_statement_space_around(true);
1298
1299    let inner_config = config.get_inner_config();
1300    assert_eq!(inner_config.len(), 182);
1301    let diagnostics = resolve_config(inner_config, &Default::default()).diagnostics;
1302    assert_eq!(diagnostics.len(), 0);
1303  }
1304}