Skip to main content

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 skip indenting the body of a function expression used in an IIFE.
352  ///
353  /// `true` - Does not indent the body of the function in `(function() { ... })();`.
354  /// `false` (default) - Indents the body as normal.
355  pub fn function_expression_flat_iife(&mut self, value: bool) -> &mut Self {
356    self.insert("functionExpression.flatIife", value.into())
357  }
358
359  /// Whether to add a space before the parentheses of a get accessor.
360  ///
361  /// `true` - Ex. `get myProp ()`
362  /// `false` (false) - Ex. `get myProp()`
363  pub fn get_accessor_space_before_parentheses(&mut self, value: bool) -> &mut Self {
364    self.insert("getAccessor.spaceBeforeParentheses", value.into())
365  }
366
367  /// Whether to add a space after the `if` keyword in an "if" statement.
368  ///
369  /// `true` (default) - Ex. `if (true)`
370  /// `false` - Ex. `if(true)`
371  pub fn if_statement_space_after_if_keyword(&mut self, value: bool) -> &mut Self {
372    self.insert("ifStatement.spaceAfterIfKeyword", value.into())
373  }
374
375  /// Whether to add spaces around named imports in an import declaration.
376  ///
377  /// * `true` (default) - Ex. `import { SomeExport, OtherExport } from "my-module";`
378  /// * `false` - Ex. `import {SomeExport, OtherExport} from "my-module";`
379  pub fn import_declaration_space_surrounding_named_imports(&mut self, value: bool) -> &mut Self {
380    self.insert("importDeclaration.spaceSurroundingNamedImports", value.into())
381  }
382
383  /// Whether to add a space surrounding the expression of a JSX container.
384  ///
385  /// * `true` - Ex. `{ myValue }`
386  /// * `false` (default) - Ex. `{myValue}`
387  pub fn jsx_expression_container_space_surrounding_expression(&mut self, value: bool) -> &mut Self {
388    self.insert("jsxExpressionContainer.spaceSurroundingExpression", value.into())
389  }
390
391  /// Whether to add a space before the slash in a self closing tag for a JSX element.
392  ///
393  /// * `true` (default) - Ex. `<Test />`
394  /// * `false` - Ex. `<Test/>`
395  pub fn jsx_self_closing_element_space_before_slash(&mut self, value: bool) -> &mut Self {
396    self.insert("jsxSelfClosingElement.spaceBeforeSlash", value.into())
397  }
398
399  /// Whether to add a space surrounding the properties of an object expression.
400  ///
401  /// * `true` (default) - Ex. `{ key: value }`
402  /// * `false` - Ex. `{key: value}`
403  pub fn object_expression_space_surrounding_properties(&mut self, value: bool) -> &mut Self {
404    self.insert("objectExpression.spaceSurroundingProperties", value.into())
405  }
406
407  /// Whether to add a space surrounding the properties of an object pattern.
408  ///
409  /// * `true` (default) - Ex. `{ key: value } = obj`
410  /// * `false` - Ex. `{key: value} = obj`
411  pub fn object_pattern_space_surrounding_properties(&mut self, value: bool) -> &mut Self {
412    self.insert("objectPattern.spaceSurroundingProperties", value.into())
413  }
414
415  /// Whether to add a space before the parentheses of a method.
416  ///
417  /// `true` - Ex. `myMethod ()`
418  /// `false` - Ex. `myMethod()`
419  pub fn method_space_before_parentheses(&mut self, value: bool) -> &mut Self {
420    self.insert("method.spaceBeforeParentheses", value.into())
421  }
422
423  /// Whether to add a space before the parentheses of a set accessor.
424  ///
425  /// `true` - Ex. `set myProp (value: string)`
426  /// `false` (default) - Ex. `set myProp(value: string)`
427  pub fn set_accessor_space_before_parentheses(&mut self, value: bool) -> &mut Self {
428    self.insert("setAccessor.spaceBeforeParentheses", value.into())
429  }
430
431  /// Whether to add a space surrounding the properties of object-like nodes.
432  ///
433  /// * `true` (default) - Ex. `{ key: value }`
434  /// * `false` - Ex. `{key: value}`
435  pub fn space_surrounding_properties(&mut self, value: bool) -> &mut Self {
436    self.insert("spaceSurroundingProperties", value.into())
437  }
438
439  /// Whether to add a space before the literal in a tagged template.
440  ///
441  /// * `true` (default) - Ex. `html \`<element />\``
442  /// * `false` - Ex. `html\`<element />\``
443  pub fn tagged_template_space_before_literal(&mut self, value: bool) -> &mut Self {
444    self.insert("taggedTemplate.spaceBeforeLiteral", value.into())
445  }
446
447  /// Whether to add a space before the colon of a type annotation.
448  ///
449  /// * `true` - Ex. `function myFunction() : string`
450  /// * `false` (default) - Ex. `function myFunction(): string`
451  pub fn type_annotation_space_before_colon(&mut self, value: bool) -> &mut Self {
452    self.insert("typeAnnotation.spaceBeforeColon", value.into())
453  }
454
455  /// Whether to add a space before the expression in a type assertion.
456  ///
457  /// * `true` (default) - Ex. `<string> myValue`
458  /// * `false` - Ex. `<string>myValue`
459  pub fn type_assertion_space_before_expression(&mut self, value: bool) -> &mut Self {
460    self.insert("typeAssertion.spaceBeforeExpression", value.into())
461  }
462
463  /// Whether to add a space surrounding the properties of a type literal.
464  ///
465  /// * `true` (default) - Ex. `value: { key: Type }`
466  /// * `false` - Ex. `value: {key: Type}`
467  pub fn type_literal_space_surrounding_properties(&mut self, value: bool) -> &mut Self {
468    self.insert("typeLiteral.spaceSurroundingProperties", value.into())
469  }
470
471  /// Whether to add a space after the `while` keyword in a while statement.
472  ///
473  /// * `true` (default) - Ex. `while (true)`
474  /// * `false` - Ex. `while(true)`
475  pub fn while_statement_space_after_while_keyword(&mut self, value: bool) -> &mut Self {
476    self.insert("whileStatement.spaceAfterWhileKeyword", value.into())
477  }
478
479  /// Whether to place spaces around enclosed expressions.
480  ///
481  /// * `true` - Ex. `myFunction( true )`
482  /// * `false` (default) - Ex. `myFunction(true)`
483  pub fn space_around(&mut self, value: bool) -> &mut Self {
484    self.insert("spaceAround", value.into())
485  }
486
487  /* situational */
488
489  /// Whether to use parentheses for arrow functions.
490  ///
491  /// Default: `UseParentheses::Maintain`
492  pub fn arrow_function_use_parentheses(&mut self, value: UseParentheses) -> &mut Self {
493    self.insert("arrowFunction.useParentheses", value.to_string().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 binary_expression_line_per_expression(&mut self, value: bool) -> &mut Self {
501    self.insert("binaryExpression.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 conditional_expression_line_per_expression(&mut self, value: bool) -> &mut Self {
509    self.insert("conditionalExpression.linePerExpression", value.into())
510  }
511
512  /// Whether to force a line per expression when spanning multiple lines.
513  ///
514  /// * `true` - Formats with each part on a new line.
515  /// * `false` (default) - Maintains the line breaks as written by the programmer.
516  pub fn member_expression_line_per_expression(&mut self, value: bool) -> &mut Self {
517    self.insert("memberExpression.linePerExpression", value.into())
518  }
519
520  /// The kind of separator to use in type literals.
521  pub fn type_literal_separator_kind(&mut self, value: SemiColonOrComma) -> &mut Self {
522    self.insert("typeLiteral.separatorKind", value.to_string().into())
523  }
524
525  /// The kind of separator to use in type literals when single line.
526  pub fn type_literal_separator_kind_single_line(&mut self, value: SemiColonOrComma) -> &mut Self {
527    self.insert("typeLiteral.separatorKind.singleLine", value.to_string().into())
528  }
529
530  /// The kind of separator to use in type literals when multi-line.
531  pub fn type_literal_separator_kind_multi_line(&mut self, value: SemiColonOrComma) -> &mut Self {
532    self.insert("typeLiteral.separatorKind.multiLine", value.to_string().into())
533  }
534
535  /* sorting */
536
537  /// Alphabetically sorts the import declarations based on their module specifiers.
538  ///
539  /// Default: Case insensitive
540  pub fn module_sort_import_declarations(&mut self, value: SortOrder) -> &mut Self {
541    self.insert("module.sortImportDeclarations", value.to_string().into())
542  }
543
544  /// Alphabetically sorts the export declarations based on their module specifiers.
545  ///
546  /// Default: Case insensitive
547  pub fn module_sort_export_declarations(&mut self, value: SortOrder) -> &mut Self {
548    self.insert("module.sortExportDeclarations", value.to_string().into())
549  }
550
551  /// Alphabetically sorts the import declaration's named imports.
552  ///
553  /// Default: Case insensitive
554  pub fn import_declaration_sort_named_imports(&mut self, value: SortOrder) -> &mut Self {
555    self.insert("importDeclaration.sortNamedImports", value.to_string().into())
556  }
557
558  /// Sorts type-only named imports first, last, or none (no sorting).
559  ///
560  /// Default: Last
561  pub fn import_declaration_sort_type_only_imports(&mut self, value: NamedTypeImportsExportsOrder) -> &mut Self {
562    self.insert("importDeclaration.sortTypeOnlyImports", value.to_string().into())
563  }
564
565  /// Alphabetically sorts the export declaration's named exports.
566  ///
567  /// Default: Case insensitive
568  pub fn export_declaration_sort_named_exports(&mut self, value: SortOrder) -> &mut Self {
569    self.insert("exportDeclaration.sortNamedExports", value.to_string().into())
570  }
571
572  /// Sorts type-only named exports first, last, or none (no sorting).
573  ///
574  /// Default: Last
575  pub fn export_declaration_sort_type_only_exports(&mut self, value: NamedTypeImportsExportsOrder) -> &mut Self {
576    self.insert("exportDeclaration.sortTypeOnlyExports", value.to_string().into())
577  }
578
579  /* ignore comments */
580
581  /// The text to use for an ignore comment (ex. `// dprint-ignore`).
582  ///
583  /// Default: `"dprint-ignore"`
584  pub fn ignore_node_comment_text(&mut self, value: &str) -> &mut Self {
585    self.insert("ignoreNodeCommentText", value.into())
586  }
587
588  /// The text to use for a file ignore comment (ex. `// dprint-ignore-file`).
589  ///
590  /// Default: `"dprint-ignore-file"`
591  pub fn ignore_file_comment_text(&mut self, value: &str) -> &mut Self {
592    self.insert("ignoreFileCommentText", value.into())
593  }
594
595  /* brace position */
596
597  pub fn arrow_function_brace_position(&mut self, value: BracePosition) -> &mut Self {
598    self.insert("arrowFunction.bracePosition", value.to_string().into())
599  }
600
601  pub fn class_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
602    self.insert("classDeclaration.bracePosition", value.to_string().into())
603  }
604
605  pub fn class_expression_brace_position(&mut self, value: BracePosition) -> &mut Self {
606    self.insert("classExpression.bracePosition", value.to_string().into())
607  }
608
609  pub fn constructor_brace_position(&mut self, value: BracePosition) -> &mut Self {
610    self.insert("constructor.bracePosition", value.to_string().into())
611  }
612
613  pub fn do_while_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
614    self.insert("doWhileStatement.bracePosition", value.to_string().into())
615  }
616
617  pub fn enum_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
618    self.insert("enumDeclaration.bracePosition", value.to_string().into())
619  }
620
621  pub fn for_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
622    self.insert("forStatement.bracePosition", value.to_string().into())
623  }
624
625  pub fn for_in_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
626    self.insert("forInStatement.bracePosition", value.to_string().into())
627  }
628
629  pub fn for_of_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
630    self.insert("forOfStatement.bracePosition", value.to_string().into())
631  }
632
633  pub fn get_accessor_brace_position(&mut self, value: BracePosition) -> &mut Self {
634    self.insert("getAccessor.bracePosition", value.to_string().into())
635  }
636
637  pub fn if_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
638    self.insert("ifStatement.bracePosition", value.to_string().into())
639  }
640
641  pub fn interface_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
642    self.insert("interfaceDeclaration.bracePosition", value.to_string().into())
643  }
644
645  pub fn function_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
646    self.insert("functionDeclaration.bracePosition", value.to_string().into())
647  }
648
649  pub fn function_expression_brace_position(&mut self, value: BracePosition) -> &mut Self {
650    self.insert("functionExpression.bracePosition", value.to_string().into())
651  }
652
653  pub fn method_brace_position(&mut self, value: BracePosition) -> &mut Self {
654    self.insert("method.bracePosition", value.to_string().into())
655  }
656
657  pub fn module_declaration_brace_position(&mut self, value: BracePosition) -> &mut Self {
658    self.insert("moduleDeclaration.bracePosition", value.to_string().into())
659  }
660
661  pub fn set_accessor_brace_position(&mut self, value: BracePosition) -> &mut Self {
662    self.insert("setAccessor.bracePosition", value.to_string().into())
663  }
664
665  pub fn static_block_brace_position(&mut self, value: BracePosition) -> &mut Self {
666    self.insert("staticBlock.bracePosition", value.to_string().into())
667  }
668
669  pub fn switch_case_brace_position(&mut self, value: BracePosition) -> &mut Self {
670    self.insert("switchCase.bracePosition", value.to_string().into())
671  }
672
673  pub fn switch_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
674    self.insert("switchStatement.bracePosition", value.to_string().into())
675  }
676
677  pub fn try_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
678    self.insert("tryStatement.bracePosition", value.to_string().into())
679  }
680
681  pub fn while_statement_brace_position(&mut self, value: BracePosition) -> &mut Self {
682    self.insert("whileStatement.bracePosition", value.to_string().into())
683  }
684
685  /* prefer hanging */
686
687  pub fn arguments_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
688    self.insert("arguments.preferHanging", value.to_string().into())
689  }
690
691  pub fn array_expression_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
692    self.insert("arrayExpression.preferHanging", value.to_string().into())
693  }
694
695  pub fn array_pattern_prefer_hanging(&mut self, value: bool) -> &mut Self {
696    self.insert("arrayPattern.preferHanging", value.into())
697  }
698
699  pub fn do_while_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
700    self.insert("doWhileStatement.preferHanging", value.into())
701  }
702
703  pub fn export_declaration_prefer_hanging(&mut self, value: bool) -> &mut Self {
704    self.insert("exportDeclaration.preferHanging", value.into())
705  }
706
707  pub fn extends_clause_prefer_hanging(&mut self, value: bool) -> &mut Self {
708    self.insert("extendsClause.preferHanging", value.into())
709  }
710
711  pub fn for_in_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
712    self.insert("forInStatement.preferHanging", value.into())
713  }
714
715  pub fn for_of_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
716    self.insert("forOfStatement.preferHanging", value.into())
717  }
718
719  pub fn for_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
720    self.insert("forStatement.preferHanging", value.into())
721  }
722
723  pub fn if_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
724    self.insert("ifStatement.preferHanging", value.into())
725  }
726
727  pub fn implements_clause_prefer_hanging(&mut self, value: bool) -> &mut Self {
728    self.insert("implementsClause.preferHanging", value.into())
729  }
730
731  pub fn import_declaration_prefer_hanging(&mut self, value: bool) -> &mut Self {
732    self.insert("importDeclaration.preferHanging", value.into())
733  }
734
735  pub fn jsx_attributes_prefer_hanging(&mut self, value: bool) -> &mut Self {
736    self.insert("jsxAttributes.preferHanging", value.into())
737  }
738
739  pub fn object_expression_prefer_hanging(&mut self, value: bool) -> &mut Self {
740    self.insert("objectExpression.preferHanging", value.into())
741  }
742
743  pub fn object_pattern_prefer_hanging(&mut self, value: bool) -> &mut Self {
744    self.insert("objectPattern.preferHanging", value.into())
745  }
746
747  pub fn parameters_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
748    self.insert("parameters.preferHanging", value.to_string().into())
749  }
750
751  pub fn sequence_expression_prefer_hanging(&mut self, value: bool) -> &mut Self {
752    self.insert("sequenceExpression.preferHanging", value.into())
753  }
754
755  pub fn switch_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
756    self.insert("switchStatement.preferHanging", value.into())
757  }
758
759  pub fn tuple_type_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
760    self.insert("tupleType.preferHanging", value.to_string().into())
761  }
762
763  pub fn type_literal_prefer_hanging(&mut self, value: bool) -> &mut Self {
764    self.insert("typeLiteral.preferHanging", value.into())
765  }
766
767  pub fn type_parameters_prefer_hanging(&mut self, value: PreferHanging) -> &mut Self {
768    self.insert("typeParameters.preferHanging", value.to_string().into())
769  }
770
771  pub fn union_and_intersection_type_prefer_hanging(&mut self, value: bool) -> &mut Self {
772    self.insert("unionAndIntersectionType.preferHanging", value.into())
773  }
774
775  pub fn variable_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
776    self.insert("variableStatement.preferHanging", value.into())
777  }
778
779  pub fn while_statement_prefer_hanging(&mut self, value: bool) -> &mut Self {
780    self.insert("whileStatement.preferHanging", value.into())
781  }
782
783  /* force single line */
784
785  pub fn export_declaration_force_single_line(&mut self, value: bool) -> &mut Self {
786    self.insert("exportDeclaration.forceSingleLine", value.into())
787  }
788
789  pub fn import_declaration_force_single_line(&mut self, value: bool) -> &mut Self {
790    self.insert("importDeclaration.forceSingleLine", value.into())
791  }
792
793  /* force multi line specifiers */
794
795  pub fn export_declaration_force_multi_line(&mut self, value: ForceMultiLine) -> &mut Self {
796    self.insert("exportDeclaration.forceMultiLine", value.to_string().into())
797  }
798
799  pub fn import_declaration_force_multi_line(&mut self, value: ForceMultiLine) -> &mut Self {
800    self.insert("importDeclaration.forceMultiLine", value.to_string().into())
801  }
802
803  /* member spacing */
804
805  pub fn enum_declaration_member_spacing(&mut self, value: MemberSpacing) -> &mut Self {
806    self.insert("enumDeclaration.memberSpacing", value.to_string().into())
807  }
808
809  /* next control flow position */
810
811  pub fn if_statement_next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
812    self.insert("ifStatement.nextControlFlowPosition", value.to_string().into())
813  }
814
815  pub fn try_statement_next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
816    self.insert("tryStatement.nextControlFlowPosition", value.to_string().into())
817  }
818
819  pub fn do_while_statement_next_control_flow_position(&mut self, value: NextControlFlowPosition) -> &mut Self {
820    self.insert("doWhileStatement.nextControlFlowPosition", value.to_string().into())
821  }
822
823  /* operator position */
824
825  pub fn binary_expression_operator_position(&mut self, value: OperatorPosition) -> &mut Self {
826    self.insert("binaryExpression.operatorPosition", value.to_string().into())
827  }
828
829  pub fn conditional_expression_operator_position(&mut self, value: OperatorPosition) -> &mut Self {
830    self.insert("conditionalExpression.operatorPosition", value.to_string().into())
831  }
832
833  pub fn conditional_type_operator_position(&mut self, value: OperatorPosition) -> &mut Self {
834    self.insert("conditionalType.operatorPosition", value.to_string().into())
835  }
836
837  /* single body position */
838
839  pub fn if_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
840    self.insert("ifStatement.singleBodyPosition", value.to_string().into())
841  }
842
843  pub fn for_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
844    self.insert("forStatement.singleBodyPosition", value.to_string().into())
845  }
846
847  pub fn for_in_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
848    self.insert("forInStatement.singleBodyPosition", value.to_string().into())
849  }
850
851  pub fn for_of_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
852    self.insert("forOfStatement.singleBodyPosition", value.to_string().into())
853  }
854
855  pub fn while_statement_single_body_position(&mut self, value: SameOrNextLinePosition) -> &mut Self {
856    self.insert("whileStatement.singleBodyPosition", value.to_string().into())
857  }
858
859  /* trailing commas */
860
861  pub fn arguments_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
862    self.insert("arguments.trailingCommas", value.to_string().into())
863  }
864
865  pub fn parameters_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
866    self.insert("parameters.trailingCommas", value.to_string().into())
867  }
868
869  pub fn array_expression_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
870    self.insert("arrayExpression.trailingCommas", value.to_string().into())
871  }
872
873  pub fn array_pattern_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
874    self.insert("arrayPattern.trailingCommas", value.to_string().into())
875  }
876
877  pub fn enum_declaration_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
878    self.insert("enumDeclaration.trailingCommas", value.to_string().into())
879  }
880
881  pub fn export_declaration_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
882    self.insert("exportDeclaration.trailingCommas", value.to_string().into())
883  }
884
885  pub fn import_declaration_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
886    self.insert("importDeclaration.trailingCommas", value.to_string().into())
887  }
888
889  pub fn object_expression_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
890    self.insert("objectExpression.trailingCommas", value.to_string().into())
891  }
892
893  pub fn object_pattern_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
894    self.insert("objectPattern.trailingCommas", value.to_string().into())
895  }
896
897  pub fn tuple_type_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
898    self.insert("tupleType.trailingCommas", value.to_string().into())
899  }
900
901  /// Only applies when using commas on type literals.
902  pub fn type_literal_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
903    self.insert("typeLiteral.trailingCommas", value.to_string().into())
904  }
905
906  pub fn type_parameters_trailing_commas(&mut self, value: TrailingCommas) -> &mut Self {
907    self.insert("typeParameters.trailingCommas", value.to_string().into())
908  }
909
910  /* use braces */
911
912  pub fn if_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
913    self.insert("ifStatement.useBraces", value.to_string().into())
914  }
915
916  pub fn for_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
917    self.insert("forStatement.useBraces", value.to_string().into())
918  }
919
920  pub fn for_in_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
921    self.insert("forInStatement.useBraces", value.to_string().into())
922  }
923
924  pub fn for_of_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
925    self.insert("forOfStatement.useBraces", value.to_string().into())
926  }
927
928  pub fn while_statement_use_braces(&mut self, value: UseBraces) -> &mut Self {
929    self.insert("whileStatement.useBraces", value.to_string().into())
930  }
931
932  /* prefer single line */
933
934  pub fn array_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
935    self.insert("arrayExpression.preferSingleLine", value.into())
936  }
937
938  pub fn array_pattern_prefer_single_line(&mut self, value: bool) -> &mut Self {
939    self.insert("arrayPattern.preferSingleLine", value.into())
940  }
941
942  pub fn arguments_prefer_single_line(&mut self, value: bool) -> &mut Self {
943    self.insert("arguments.preferSingleLine", value.into())
944  }
945
946  pub fn binary_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
947    self.insert("binaryExpression.preferSingleLine", value.into())
948  }
949
950  pub fn computed_prefer_single_line(&mut self, value: bool) -> &mut Self {
951    self.insert("computed.preferSingleLine", value.into())
952  }
953
954  pub fn conditional_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
955    self.insert("conditionalExpression.preferSingleLine", value.into())
956  }
957
958  pub fn conditional_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
959    self.insert("conditionalType.preferSingleLine", value.into())
960  }
961
962  pub fn decorators_prefer_single_line(&mut self, value: bool) -> &mut Self {
963    self.insert("decorators.preferSingleLine", value.into())
964  }
965
966  pub fn export_declaration_prefer_single_line(&mut self, value: bool) -> &mut Self {
967    self.insert("exportDeclaration.preferSingleLine", value.into())
968  }
969
970  pub fn for_statement_prefer_single_line(&mut self, value: bool) -> &mut Self {
971    self.insert("forStatement.preferSingleLine", value.into())
972  }
973
974  pub fn import_declaration_prefer_single_line(&mut self, value: bool) -> &mut Self {
975    self.insert("importDeclaration.preferSingleLine", value.into())
976  }
977
978  pub fn jsx_attributes_prefer_single_line(&mut self, value: bool) -> &mut Self {
979    self.insert("jsxAttributes.preferSingleLine", value.into())
980  }
981
982  pub fn jsx_element_prefer_single_line(&mut self, value: bool) -> &mut Self {
983    self.insert("jsxElement.preferSingleLine", value.into())
984  }
985
986  pub fn mapped_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
987    self.insert("mappedType.preferSingleLine", value.into())
988  }
989
990  pub fn member_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
991    self.insert("memberExpression.preferSingleLine", value.into())
992  }
993
994  pub fn object_expression_prefer_single_line(&mut self, value: bool) -> &mut Self {
995    self.insert("objectExpression.preferSingleLine", value.into())
996  }
997
998  pub fn object_pattern_prefer_single_line(&mut self, value: bool) -> &mut Self {
999    self.insert("objectPattern.preferSingleLine", value.into())
1000  }
1001
1002  pub fn parameters_prefer_single_line(&mut self, value: bool) -> &mut Self {
1003    self.insert("parameters.preferSingleLine", value.into())
1004  }
1005
1006  pub fn parentheses_prefer_single_line(&mut self, value: bool) -> &mut Self {
1007    self.insert("parentheses.preferSingleLine", value.into())
1008  }
1009
1010  pub fn tuple_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
1011    self.insert("tupleType.preferSingleLine", value.into())
1012  }
1013
1014  pub fn type_literal_prefer_single_line(&mut self, value: bool) -> &mut Self {
1015    self.insert("typeLiteral.preferSingleLine", value.into())
1016  }
1017
1018  pub fn type_parameters_prefer_single_line(&mut self, value: bool) -> &mut Self {
1019    self.insert("typeParameters.preferSingleLine", value.into())
1020  }
1021
1022  pub fn union_and_intersection_type_prefer_single_line(&mut self, value: bool) -> &mut Self {
1023    self.insert("unionAndIntersectionType.preferSingleLine", value.into())
1024  }
1025
1026  pub fn variable_statement_prefer_single_line(&mut self, value: bool) -> &mut Self {
1027    self.insert("variableStatement.preferSingleLine", value.into())
1028  }
1029
1030  /* space around */
1031
1032  pub fn arguments_space_around(&mut self, value: bool) -> &mut Self {
1033    self.insert("arguments.spaceAround", value.into())
1034  }
1035
1036  pub fn array_expression_space_around(&mut self, value: bool) -> &mut Self {
1037    self.insert("arrayExpression.spaceAround", value.into())
1038  }
1039
1040  pub fn array_pattern_space_around(&mut self, value: bool) -> &mut Self {
1041    self.insert("arrayPattern.spaceAround", value.into())
1042  }
1043
1044  pub fn catch_clause_space_around(&mut self, value: bool) -> &mut Self {
1045    self.insert("catchClause.spaceAround", value.into())
1046  }
1047
1048  pub fn do_while_statement_space_around(&mut self, value: bool) -> &mut Self {
1049    self.insert("doWhileStatement.spaceAround", value.into())
1050  }
1051
1052  pub fn for_in_statement_space_around(&mut self, value: bool) -> &mut Self {
1053    self.insert("forInStatement.spaceAround", value.into())
1054  }
1055
1056  pub fn for_of_statement_space_around(&mut self, value: bool) -> &mut Self {
1057    self.insert("forOfStatement.spaceAround", value.into())
1058  }
1059
1060  pub fn for_statement_space_around(&mut self, value: bool) -> &mut Self {
1061    self.insert("forStatement.spaceAround", value.into())
1062  }
1063
1064  pub fn if_statement_space_around(&mut self, value: bool) -> &mut Self {
1065    self.insert("ifStatement.spaceAround", value.into())
1066  }
1067
1068  pub fn parameters_space_around(&mut self, value: bool) -> &mut Self {
1069    self.insert("parameters.spaceAround", value.into())
1070  }
1071
1072  pub fn paren_expression_space_around(&mut self, value: bool) -> &mut Self {
1073    self.insert("parenExpression.spaceAround", value.into())
1074  }
1075
1076  pub fn switch_statement_space_around(&mut self, value: bool) -> &mut Self {
1077    self.insert("switchStatement.spaceAround", value.into())
1078  }
1079
1080  pub fn tuple_type_space_around(&mut self, value: bool) -> &mut Self {
1081    self.insert("tupleType.spaceAround", value.into())
1082  }
1083
1084  pub fn while_statement_space_around(&mut self, value: bool) -> &mut Self {
1085    self.insert("whileStatement.spaceAround", value.into())
1086  }
1087
1088  #[cfg(test)]
1089  pub(super) fn get_inner_config(&self) -> ConfigKeyMap {
1090    self.config.clone()
1091  }
1092
1093  fn insert(&mut self, name: &str, value: ConfigKeyValue) -> &mut Self {
1094    self.config.insert(String::from(name), value);
1095    self
1096  }
1097}
1098
1099#[cfg(test)]
1100mod tests {
1101  use super::*;
1102
1103  #[test]
1104  fn check_all_values_set() {
1105    let mut config = ConfigurationBuilder::new();
1106    config
1107      .new_line_kind(NewLineKind::Auto)
1108      .line_width(80)
1109      .use_tabs(false)
1110      .indent_width(4)
1111      /* common */
1112      .quote_style(QuoteStyle::AlwaysDouble)
1113      .jsx_quote_style(JsxQuoteStyle::PreferSingle)
1114      .jsx_multi_line_parens(JsxMultiLineParens::Never)
1115      .jsx_force_new_lines_surrounding_content(true)
1116      .jsx_bracket_position(SameOrNextLinePosition::Maintain)
1117      .jsx_opening_element_bracket_position(SameOrNextLinePosition::Maintain)
1118      .jsx_self_closing_element_bracket_position(SameOrNextLinePosition::Maintain)
1119      .semi_colons(SemiColons::Prefer)
1120      .brace_position(BracePosition::NextLine)
1121      .next_control_flow_position(NextControlFlowPosition::SameLine)
1122      .operator_position(OperatorPosition::SameLine)
1123      .single_body_position(SameOrNextLinePosition::SameLine)
1124      .trailing_commas(TrailingCommas::Never)
1125      .file_indent_level(1)
1126      .use_braces(UseBraces::WhenNotSingleLine)
1127      .quote_props(QuoteProps::AsNeeded)
1128      .prefer_hanging(false)
1129      /* situational */
1130      .arrow_function_use_parentheses(UseParentheses::Maintain)
1131      .binary_expression_line_per_expression(false)
1132      .conditional_expression_line_per_expression(true)
1133      .member_expression_line_per_expression(false)
1134      .type_literal_separator_kind(SemiColonOrComma::Comma)
1135      .type_literal_separator_kind_single_line(SemiColonOrComma::Comma)
1136      .type_literal_separator_kind_multi_line(SemiColonOrComma::Comma)
1137      /* sorting */
1138      .module_sort_import_declarations(SortOrder::Maintain)
1139      .module_sort_export_declarations(SortOrder::Maintain)
1140      .import_declaration_sort_named_imports(SortOrder::Maintain)
1141      .export_declaration_sort_named_exports(SortOrder::Maintain)
1142      .import_declaration_sort_type_only_imports(NamedTypeImportsExportsOrder::First)
1143      .export_declaration_sort_type_only_exports(NamedTypeImportsExportsOrder::None)
1144      /* ignore comments */
1145      .ignore_node_comment_text("ignore")
1146      .ignore_file_comment_text("ignore-file")
1147      /* brace position*/
1148      .arrow_function_brace_position(BracePosition::NextLine)
1149      .class_declaration_brace_position(BracePosition::NextLine)
1150      .class_expression_brace_position(BracePosition::NextLine)
1151      .constructor_brace_position(BracePosition::NextLine)
1152      .do_while_statement_brace_position(BracePosition::NextLine)
1153      .enum_declaration_brace_position(BracePosition::NextLine)
1154      .for_statement_brace_position(BracePosition::NextLine)
1155      .for_in_statement_brace_position(BracePosition::NextLine)
1156      .for_of_statement_brace_position(BracePosition::NextLine)
1157      .get_accessor_brace_position(BracePosition::NextLine)
1158      .if_statement_brace_position(BracePosition::NextLine)
1159      .interface_declaration_brace_position(BracePosition::NextLine)
1160      .function_declaration_brace_position(BracePosition::NextLine)
1161      .function_expression_brace_position(BracePosition::NextLine)
1162      .method_brace_position(BracePosition::NextLine)
1163      .module_declaration_brace_position(BracePosition::NextLine)
1164      .set_accessor_brace_position(BracePosition::NextLine)
1165      .static_block_brace_position(BracePosition::NextLine)
1166      .switch_case_brace_position(BracePosition::NextLine)
1167      .switch_statement_brace_position(BracePosition::NextLine)
1168      .try_statement_brace_position(BracePosition::NextLine)
1169      .while_statement_brace_position(BracePosition::NextLine)
1170      /* prefer hanging */
1171      .arguments_prefer_hanging(PreferHanging::OnlySingleItem)
1172      .array_expression_prefer_hanging(PreferHanging::OnlySingleItem)
1173      .array_pattern_prefer_hanging(true)
1174      .do_while_statement_prefer_hanging(true)
1175      .export_declaration_prefer_hanging(true)
1176      .extends_clause_prefer_hanging(true)
1177      .for_in_statement_prefer_hanging(true)
1178      .for_of_statement_prefer_hanging(true)
1179      .for_statement_prefer_hanging(true)
1180      .if_statement_prefer_hanging(true)
1181      .implements_clause_prefer_hanging(true)
1182      .import_declaration_prefer_hanging(true)
1183      .jsx_attributes_prefer_hanging(true)
1184      .object_expression_prefer_hanging(true)
1185      .object_pattern_prefer_hanging(true)
1186      .parameters_prefer_hanging(PreferHanging::OnlySingleItem)
1187      .sequence_expression_prefer_hanging(true)
1188      .switch_statement_prefer_hanging(true)
1189      .tuple_type_prefer_hanging(PreferHanging::OnlySingleItem)
1190      .type_literal_prefer_hanging(true)
1191      .type_parameters_prefer_hanging(PreferHanging::OnlySingleItem)
1192      .union_and_intersection_type_prefer_hanging(true)
1193      .variable_statement_prefer_hanging(true)
1194      .while_statement_prefer_hanging(true)
1195      /* member spacing */
1196      .enum_declaration_member_spacing(MemberSpacing::Maintain)
1197      /* next control flow position */
1198      .if_statement_next_control_flow_position(NextControlFlowPosition::SameLine)
1199      .try_statement_next_control_flow_position(NextControlFlowPosition::SameLine)
1200      .do_while_statement_next_control_flow_position(NextControlFlowPosition::SameLine)
1201      /* operator position */
1202      .binary_expression_operator_position(OperatorPosition::SameLine)
1203      .conditional_expression_operator_position(OperatorPosition::SameLine)
1204      .conditional_type_operator_position(OperatorPosition::SameLine)
1205      /* single body position */
1206      .if_statement_single_body_position(SameOrNextLinePosition::SameLine)
1207      .for_statement_single_body_position(SameOrNextLinePosition::SameLine)
1208      .for_in_statement_single_body_position(SameOrNextLinePosition::SameLine)
1209      .for_of_statement_single_body_position(SameOrNextLinePosition::SameLine)
1210      .while_statement_single_body_position(SameOrNextLinePosition::SameLine)
1211      /* trailing commas */
1212      .arguments_trailing_commas(TrailingCommas::Never)
1213      .parameters_trailing_commas(TrailingCommas::Never)
1214      .array_expression_trailing_commas(TrailingCommas::Never)
1215      .array_pattern_trailing_commas(TrailingCommas::Never)
1216      .enum_declaration_trailing_commas(TrailingCommas::Never)
1217      .import_declaration_trailing_commas(TrailingCommas::Never)
1218      .export_declaration_trailing_commas(TrailingCommas::Never)
1219      .object_expression_trailing_commas(TrailingCommas::Never)
1220      .object_pattern_trailing_commas(TrailingCommas::Never)
1221      .type_parameters_trailing_commas(TrailingCommas::Never)
1222      .tuple_type_trailing_commas(TrailingCommas::Never)
1223      .type_literal_trailing_commas(TrailingCommas::Never)
1224      /* use braces */
1225      .if_statement_use_braces(UseBraces::Always)
1226      .for_statement_use_braces(UseBraces::Always)
1227      .for_in_statement_use_braces(UseBraces::Always)
1228      .for_of_statement_use_braces(UseBraces::Always)
1229      .while_statement_use_braces(UseBraces::Always)
1230      /* prefer single line */
1231      .array_expression_prefer_single_line(false)
1232      .array_pattern_prefer_single_line(false)
1233      .arguments_prefer_single_line(false)
1234      .binary_expression_prefer_single_line(false)
1235      .computed_prefer_single_line(false)
1236      .conditional_expression_prefer_single_line(false)
1237      .conditional_type_prefer_single_line(false)
1238      .decorators_prefer_single_line(false)
1239      .export_declaration_prefer_single_line(false)
1240      .for_statement_prefer_single_line(false)
1241      .import_declaration_prefer_single_line(false)
1242      .jsx_attributes_prefer_single_line(false)
1243      .jsx_element_prefer_single_line(false)
1244      .mapped_type_prefer_single_line(false)
1245      .member_expression_prefer_single_line(false)
1246      .object_expression_prefer_single_line(false)
1247      .object_pattern_prefer_single_line(false)
1248      .parameters_prefer_single_line(false)
1249      .parentheses_prefer_single_line(false)
1250      .tuple_type_prefer_single_line(false)
1251      .type_literal_prefer_single_line(false)
1252      .type_parameters_prefer_single_line(false)
1253      .union_and_intersection_type_prefer_single_line(false)
1254      .variable_statement_prefer_single_line(false)
1255      /* force single line */
1256      .export_declaration_force_single_line(true)
1257      .import_declaration_force_single_line(true)
1258      /* force multi line specifiers */
1259      .export_declaration_force_multi_line(ForceMultiLine::Always)
1260      .import_declaration_force_multi_line(ForceMultiLine::Always)
1261      /* space settings */
1262      .binary_expression_space_surrounding_bitwise_and_arithmetic_operator(true)
1263      .comment_line_force_space_after_slashes(false)
1264      .construct_signature_space_after_new_keyword(true)
1265      .constructor_space_before_parentheses(true)
1266      .constructor_type_space_after_new_keyword(true)
1267      .do_while_statement_space_after_while_keyword(true)
1268      .export_declaration_space_surrounding_named_exports(true)
1269      .for_statement_space_after_for_keyword(true)
1270      .for_statement_space_after_semi_colons(true)
1271      .for_in_statement_space_after_for_keyword(true)
1272      .for_of_statement_space_after_for_keyword(true)
1273      .function_declaration_space_before_parentheses(true)
1274      .function_expression_space_before_parentheses(true)
1275      .function_expression_space_after_function_keyword(true)
1276      .get_accessor_space_before_parentheses(true)
1277      .if_statement_space_after_if_keyword(true)
1278      .import_declaration_space_surrounding_named_imports(true)
1279      .jsx_expression_container_space_surrounding_expression(true)
1280      .jsx_self_closing_element_space_before_slash(true)
1281      .method_space_before_parentheses(true)
1282      .object_expression_space_surrounding_properties(false)
1283      .object_pattern_space_surrounding_properties(false)
1284      .set_accessor_space_before_parentheses(true)
1285      .space_surrounding_properties(false)
1286      .tagged_template_space_before_literal(false)
1287      .type_annotation_space_before_colon(true)
1288      .type_assertion_space_before_expression(true)
1289      .type_literal_space_surrounding_properties(false)
1290      .while_statement_space_after_while_keyword(true)
1291      /* space around */
1292      .arguments_space_around(true)
1293      .array_expression_space_around(true)
1294      .array_pattern_space_around(true)
1295      .catch_clause_space_around(true)
1296      .do_while_statement_space_around(true)
1297      .for_in_statement_space_around(true)
1298      .for_of_statement_space_around(true)
1299      .for_statement_space_around(true)
1300      .if_statement_space_around(true)
1301      .parameters_space_around(true)
1302      .paren_expression_space_around(true)
1303      .switch_statement_space_around(true)
1304      .tuple_type_space_around(true)
1305      .while_statement_space_around(true);
1306
1307    let inner_config = config.get_inner_config();
1308    assert_eq!(inner_config.len(), 182);
1309    let diagnostics = resolve_config(inner_config, &Default::default()).diagnostics;
1310    assert_eq!(diagnostics.len(), 0);
1311  }
1312}