-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Labels
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 2.0.4
Playground link
--parser babel
Input:
// Prettier does not automatically wrap.
const myLongVariableName = /** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */ (fooBarBaz);
function jsdocCastInReturn() {
return /** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */ (fooBarBaz);
}
// Prettier wraps but add a newline, just because there's a trailing whitespace.
const myLongVariableName = /** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz);
function jsdocCastInReturn() {
return (/** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz));
}
// Prettier correctly formats and wraps the lines.
const myLongVariableName = /** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz);
function jsdocCastInReturn() {
return (/** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz));
}
Output:
// Prettier does not automatically wrap.
const myLongVariableName = /** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */ (fooBarBaz);
function jsdocCastInReturn() {
return /** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */ (fooBarBaz);
}
// Prettier wraps but add a newline, just because there's a trailing whitespace.
const myLongVariableName =
/** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz);
function jsdocCastInReturn() {
return (
/** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz)
);
}
// Prettier correctly formats and wraps the lines.
const myLongVariableName =
/** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz);
function jsdocCastInReturn() {
return (
/** @type {ThisIsAVeryLongTypeThatShouldTriggerLineWrapping} */
(fooBarBaz)
);
}
Expected behavior:
prettier
should automatically add new lines to wrap long constructs when using JSdoc casts, rather than having to manually add a line break. Also note that if you keep a trailing whitespace, prettier
adds an extra new line.
Metadata
Metadata
Assignees
Labels
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.