AMAN SHARMA
AMAN SHARMA

Reputation: 341

Why doesn't prettier allow me to break the function arguments into multiline?

Prettier automatically changes

    it(
      "Throws error if item has source: false and doesn't have children",
      () => {
        const rawData = [{ slug: 'item-name', source: false }]

        jest.doMock('../sidebar.json', () => rawData)

        expect(() => require('./helper')).toThrow(
          new Error(
            "If you set 'source' to false, you had to add at least one child"
          )
        )
      }
    )

to this

    it("Throws error if item has source: false and doesn't have children", () => {
      const rawData = [{ slug: 'item-name', source: false }]

      jest.doMock('../sidebar.json', () => rawData)

      expect(() => require('./helper')).toThrow(
        new Error(
          "If you set 'source' to false, you had to add at least one child"
        )
      )
    })

My prettier configuration:

semi: false
singleQuote: true
trailingComma: none
printWidth: 80
tabWidth: 2
useTabs: false
proseWrap: always

It somehow doesn't respect the printWidth rule and writes all the arguments into one line.

My current workaround is // prettier-ignore but is there a better solution?

Upvotes: 2

Views: 2775

Answers (1)

diachedelic
diachedelic

Reputation: 2359

Prettier treats test framework function calls differently to other function calls, forcing them all onto the same line.

source

Upvotes: 3

Related Questions