Skip to content

Commit

Permalink
refactor: rename onlyWhenMultiple to whenMultiple (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Apr 2, 2024
1 parent f8e1615 commit 5b7320e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion deployment/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"const": "never",
"description": ""
}, {
"const": "onlyWhenMultiple",
"const": "whenMultiple",
"description": "Force multiple lines only if importing more than one thing."
}]
},
Expand Down
4 changes: 2 additions & 2 deletions src/configuration/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ pub enum ForceMultiLine {
/// Always force multiline imports/exports.
Always,
/// Mulitline imports/exports should be forced only when importing/exporting multiple items.
OnlyWhenMultiple,
WhenMultiple,
}

generate_str_to_from![ForceMultiLine, [Always, "always"], [Never, "never"], [OnlyWhenMultiple, "onlyWhenMultiple"]];
generate_str_to_from![ForceMultiLine, [Always, "always"], [Never, "never"], [WhenMultiple, "whenMultiple"]];

/// Where to place the opening brace.
#[derive(Clone, PartialEq, Copy, Serialize, Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ fn gen_export_named_decl<'a>(node: &NamedExport<'a>, context: &mut Context<'a>)

let force_multi_line = !force_single_line
&& ((context.config.export_declaration_force_multi_line == ForceMultiLine::Always)
|| (named_exports.len() > 1 && context.config.export_declaration_force_multi_line == ForceMultiLine::OnlyWhenMultiple));
|| (named_exports.len() > 1 && context.config.export_declaration_force_multi_line == ForceMultiLine::WhenMultiple));

let should_single_line = force_single_line
|| (default_export.is_none()
Expand Down Expand Up @@ -1226,7 +1226,7 @@ fn gen_import_decl<'a>(node: &ImportDecl<'a>, context: &mut Context<'a>) -> Prin
let force_single_line = context.config.import_declaration_force_single_line && !contains_line_or_multiline_comment(node.into(), context.program);

let force_multi_line = context.config.import_declaration_force_multi_line == ForceMultiLine::Always
|| (named_imports.len() > 1 && context.config.import_declaration_force_multi_line == ForceMultiLine::OnlyWhenMultiple);
|| (named_imports.len() > 1 && context.config.import_declaration_force_multi_line == ForceMultiLine::WhenMultiple);

let should_single_line = force_single_line
|| (default_import.is_none()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
~~ exportDeclaration.forceMultiLine: onlyWhenMultiple, lineWidth: 40 ~~
~~ exportDeclaration.forceMultiLine: whenMultiple, lineWidth: 40 ~~
== should never add a new line between exports ==
export { testing, a, b, c, d, e } from "./test.ts";
export { testing, a, b, c, d, e // test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
~~ importDeclaration.forceMultiLine: onlyWhenMultiple, lineWidth: 40 ~~
~~ importDeclaration.forceMultiLine: whenMultiple, lineWidth: 40 ~~
== should break imports when more than one ==
import { a, b } from "./test.ts";

Expand Down

0 comments on commit 5b7320e

Please sign in to comment.