-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentshelp wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!We're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 1.16.4
Playground link
--no-bracket-spacing
--jsx-bracket-same-line
--parser typescript
--print-width 120
--single-quote
--trailing-comma all
--use-tabs
Input:
Broken: {
// [X] Wrap IIFE function expression in parens
// [ ] Keep JSDoc with function expression in parens
/** @type {Helpers} */
const helpers = (
/** @param {Partial<Helpers>} helpers */
(helpers = {}) => helpers
)();
}
Hack1: {
// [X] Unwrap function expression in parens inside lists
// [X] Keep comment blocks inside lists
/** @type {Helpers} */
const helpers = (
void '',
// TODO: await prettier fix
(
/** @param {Partial<Helpers>} helpers */
(helpers = {}) => helpers
)
)();
}
Hack2: {
// [X] Keep comment blocks inside lists
/** @type {Helpers} */
const helpers = [
// TODO: await prettier fix
/** @param {Partial<Helpers>} helpers */
(helpers = {}) => helpers
][0]();
}
Output:
Broken: {
// [X] Wrap IIFE function expression in parens
// [ ] Keep JSDoc with function expression in parens
/** @type {Helpers} */
const helpers = /** @param {Partial<Helpers>} helpers */
((helpers = {}) => helpers)();
}
Hack1: {
// [X] Unwrap function expression in parens inside lists
// [X] Keep comment blocks inside lists
/** @type {Helpers} */
const helpers = (void '',
// TODO: await prettier fix
/** @param {Partial<Helpers>} helpers */
(helpers = {}) => helpers)();
}
Hack2: {
// [X] Keep comment blocks inside lists
/** @type {Helpers} */
const helpers = [
// TODO: await prettier fix
/** @param {Partial<Helpers>} helpers */
(helpers = {}) => helpers,
][0]();
}
Expected behavior:
-
Wrap IIFE function expression in parens:
`const ƒ = () => {}()` -> `const ƒ = (() => {})()`
-
Keep JSDoc with function expression in parens:
`const ƒ = /** … */() => {}()` -> `const ƒ = (/** … */() => {})()`
Metadata
Metadata
Assignees
Labels
area:commentsIssues with how Prettier prints commentsIssues with how Prettier prints commentshelp wantedWe're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!We're a small group who can't get to every issue promptly. We’d appreciate help fixing this issue!lang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.