Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapping of arrow functions in the second argument of functions #622

Open
cjpearson opened this issue Apr 5, 2024 · 0 comments
Open

Wrapping of arrow functions in the second argument of functions #622

cjpearson opened this issue Apr 5, 2024 · 0 comments

Comments

@cjpearson
Copy link

Describe the bug

dprint-plugin-typescript version: 0.90.0

When an arrow function is the first argument to a function, there is a line break added after the arrow. However, when it's the second argument, the arguments are first placed on different lines. I would expect it to still break after the arrow in these cases. It does break after the arrow when the arrow function has braces.

Input Code

someElement.addEventListener('click', (event) => someEventHandlerFunction(event, anotherArg))
someElement.addEventListener('click', (event) => { someEventHandlerFunction(event, anotherArg) })
someElement.addEventListener((event) => someEventHandlerFunction(event, anotherArg));

Expected Output

someElement.addEventListener("click", (event) => 
  someEventHandlerFunction(event, anotherArg)
);
someElement.addEventListener("click", (event) => {
  someEventHandlerFunction(event, anotherArg);
});
someElement.addEventListener((event) =>
  someEventHandlerFunction(event, anotherArg)
);

(Prettier also breaks like the expected output)

Actual Output

someElement.addEventListener(
  "click",
  (event) => someEventHandlerFunction(event, anotherArg),
);
someElement.addEventListener("click", (event) => {
  someEventHandlerFunction(event, anotherArg);
});
someElement.addEventListener((event) =>
  someEventHandlerFunction(event, anotherArg)
);

dprint playground

prettier playground

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant