Unexpected line break in `v-for` ternary
Open
Nobody has claimed this yet.
lang:javascript
lang:vue
status:needs discussion
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 2.1.2
Playground link
--parser vue
Input:
<template>
<div v-for="
a_long_long_long_long_long_long_long_long_long_long_long_long_long of
a && b ?
[a, b, c,d,e,f,] :
[a, b, c,d,e,f,]"></div>
</template>
Output:
<template>
<div
v-for="a_long_long_long_long_long_long_long_long_long_long_long_long_long of a &&
b
? [a, b, c, d, e, f]
: [a, b, c, d, e, f]"
></div>
</template>
Expected behavior:
Should try to keep condition in one line, maybe like this
<template>
<div
v-for="a_long_long_long_long_long_long_long_long_long_long_long_long_long of
a && b
? [a, b, c, d, e, f]
: [a, b, c, d, e, f]"
></div>
</template>
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the case in the linked Prettier Playground using the --parser vue option, then trace the Vue formatting path for the v-for expression. Done means the condition remains on one line as shown in the expected output while the ternary branches retain their formatting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100