Skip to content

Commit f23accb

Browse files
authored
fix: correct spaceBeforeParentheses for export default function with name (#645)
1 parent 050ccf8 commit f23accb

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

src/generation/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2581,7 +2581,7 @@ fn gen_fn_expr<'a>(node: &FnExpr<'a>, context: &mut Context<'a>) -> PrintItems {
25812581
let items = gen_function_decl_or_expr(
25822582
FunctionDeclOrExprNode {
25832583
node: node.into(),
2584-
is_func_decl: false,
2584+
is_func_decl: node.parent().kind() == NodeKind::ExportDefaultDecl && node.ident.is_some(),
25852585
ident: node.ident,
25862586
declare: false,
25872587
func: node.function,

tests/specs/declarations/function/Function_SpaceBeforeParentheses_True.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
function test<T>() {
44
}
55

6+
export default function test() {
7+
}
8+
69
[expect]
710
function test<T> () {
811
}
912

13+
export default function test () {
14+
}
15+
1016
== should format with a space before the parens even when multi-line ==
1117
function test(param, otherParam, testing) {
1218
}

tests/specs/expressions/FunctionExpression/FunctionExpression_SpaceBeforeParentheses_True.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const w = function test<T>(testing, thisOut){
88
const x = function*() {};
99
const y = function ident() {};
1010

11+
export default function test() {
12+
}
13+
export default function() {
14+
}
15+
1116
[expect]
1217
const t = function (p, u) {};
1318
const u = function<T> (p, u) {};
@@ -19,3 +24,8 @@ const w = function test<T> (
1924
};
2025
const x = function* () {};
2126
const y = function ident () {};
27+
28+
export default function test() {
29+
}
30+
export default function () {
31+
}

0 commit comments

Comments
 (0)