Skip to content

Commit

Permalink
fix: correct spaceBeforeParentheses for export default function wit…
Browse files Browse the repository at this point in the history
…h name (#645)
  • Loading branch information
dsherret authored Jul 2, 2024
1 parent 050ccf8 commit f23accb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/generation/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,7 @@ fn gen_fn_expr<'a>(node: &FnExpr<'a>, context: &mut Context<'a>) -> PrintItems {
let items = gen_function_decl_or_expr(
FunctionDeclOrExprNode {
node: node.into(),
is_func_decl: false,
is_func_decl: node.parent().kind() == NodeKind::ExportDefaultDecl && node.ident.is_some(),
ident: node.ident,
declare: false,
func: node.function,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
function test<T>() {
}

export default function test() {
}

[expect]
function test<T> () {
}

export default function test () {
}

== should format with a space before the parens even when multi-line ==
function test(param, otherParam, testing) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ const w = function test<T>(testing, thisOut){
const x = function*() {};
const y = function ident() {};

export default function test() {
}
export default function() {
}

[expect]
const t = function (p, u) {};
const u = function<T> (p, u) {};
Expand All @@ -19,3 +24,8 @@ const w = function test<T> (
};
const x = function* () {};
const y = function ident () {};

export default function test() {
}
export default function () {
}

0 comments on commit f23accb

Please sign in to comment.