Skip to content

formatter: fail & empty lines added when character immediately after multi-line template expression in .vue files #16945

Description

@adrianjost

Issue

Having any character after a multi-line template expression in a vue template causes the formatter to add empty lines to the expression and the check mode always fails.

Reproduction Example

Good

<template>
  <div>
    {{
      (
        something.something.very.long.code ??
        fail("this is even longer to enforce multiple lines")
      ).toUpperCase()
    }}
  </div>
</template>

stays like this when running ./node_modules/.bin/oxfmt .
./node_modules/.bin/oxfmt --check . does not report any error

Bug

<template>
  <div>
    {{
      (
        something.something.very.long.code ??
        fail("this is even longer to enforce multiple lines")
      ).toUpperCase()
    }}.
  </div>
</template>

note the . immediately after the }} of the template expression.
./node_modules/.bin/oxfmt --check . now fails on this file.

When now executing ./node_modules/.bin/oxfmt . the new output is:

<template>
  <div>
    {{
      (
        something.something.very.long.code ??
        fail("this is even longer to enforce multiple lines")
      ).toUpperCase()

    }}.
  </div>
</template>

and with each execution another line is added. So after 5 executions it looks like:

<template>
  <div>
    {{
      (
        something.something.very.long.code ??
        fail("this is even longer to enforce multiple lines")
      ).toUpperCase()





    }}.
  </div>
</template>

./node_modules/.bin/oxfmt --check . fails on all of the examples.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions