Skip to content

why the if comment is line breaked? #10250

@w-log

Description

@w-log

Is there any way to prevent line break?

Prettier 2.2.1
Playground link

--html-whitespace-sensitivity ignore
--parser babel
--prose-wrap always
--quote-props preserve
--no-semi
--single-quote

Input:

const taskA = () => {}
const taskB = () => {}
const taskC = () => {}

/**
  * @param {boolean} is - test param
  */
function test(is) {
  if(is) taskA() // is === True => TaskA
  else if(!is) taskB() // is === False => TaskB
  else taskC() // is === undefined => TaskC
}

Output:

const taskA = () => {}
const taskB = () => {}
const taskC = () => {}

/**
 * @param {boolean} is - test param
 */
function test(is) {
  if (is) taskA()
  // is === True => TaskA
  else if (!is) taskB()
  // is === False => TaskB
  else taskC() // is === undefined => TaskC
}

Expected behavior:

const taskA = () => {}
const taskB = () => {}
const taskC = () => {}

/**
 * @param {boolean} is - test param
 */
function test(is) {
  if (is) taskA() // is === True => TaskA
  else if (!is) taskB() // is === False => TaskB
  else taskC() // is === undefined => TaskC
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:commentsIssues with how Prettier prints commentslang:javascriptIssues affecting JS

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions