prettier: Conflict with eslint-plugin-vue recommended rules
Prettier 1.15.1 Playground link
--html-whitespace-sensitivity ignore
--parser vue
--single-quote
Input:
<template>
<article class="e-cInput">
<header class="e-cInput__header">
<h3 class="e-cInput__title">{{ $t(title) }}</h3>
<div class="e-cInput__actions">
<div class="e-cInput__action e-cInput__action--settings">
<el-dropdown
trigger="click"
@command="handleCommand"
>
<button
type="button"
>
<svg :viewBox="icons.settings.viewBox">
<use :xlink:href="`#${icons.settings.id}`" />
</svg>
</button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete">{{ $t('delete') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div v-if="!isFirst" class="e-cInput__action e-cInput__action--move"
>
<button
type="button"
@click="$emit('move-up')"
>
<svg :viewBox="icons.arrowUp.viewBox">
<use :xlink:href="`#${icons.arrowUp.id}`" />
</svg>
</button>
</div>
<div
v-if="!isLast"
class="e-cInput__action e-cInput__action--move"
>
<button
type="button"
@click="$emit('move-down')"
>
<svg :viewBox="icons.arrowDown.viewBox">
<use :xlink:href="`#${icons.arrowDown.id}`" />
</svg>
</button>
</div>
</div>
</header>
<div class="e-cInput__content">
<slot />
</div>
</article>
</template>
Output:
<template>
<article class="e-cInput">
<header class="e-cInput__header">
<h3 class="e-cInput__title">{{ $t(title) }}</h3>
<div class="e-cInput__actions">
<div class="e-cInput__action e-cInput__action--settings">
<el-dropdown trigger="click" @command="handleCommand">
<button type="button">
<svg :viewBox="icons.settings.viewBox">
<use :xlink:href="`#${icons.settings.id}`" />
</svg>
</button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete">
{{ $t('delete') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div v-if="!isFirst" class="e-cInput__action e-cInput__action--move">
<button type="button" @click="$emit('move-up');">
<svg :viewBox="icons.arrowUp.viewBox">
<use :xlink:href="`#${icons.arrowUp.id}`" />
</svg>
</button>
</div>
<div v-if="!isLast" class="e-cInput__action e-cInput__action--move">
<button type="button" @click="$emit('move-down');">
<svg :viewBox="icons.arrowDown.viewBox">
<use :xlink:href="`#${icons.arrowDown.id}`" />
</svg>
</button>
</div>
</div>
</header>
<div class="e-cInput__content"><slot /></div>
</article>
</template>
Expected behavior:
<template>
<article class="e-cInput">
<header class="e-cInput__header">
<h3 class="e-cInput__title">{{ $t(title) }}</h3>
<div class="e-cInput__actions">
<div class="e-cInput__action e-cInput__action--settings">
<el-dropdown
trigger="click"
@command="handleCommand"
>
<button type="button">
<svg :viewBox="icons.settings.viewBox">
<use :xlink:href="`#${icons.settings.id}`" />
</svg>
</button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="delete">
{{ $t('delete') }}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div
v-if="!isFirst"
class="e-cInput__action e-cInput__action--move"
>
<button
type="button"
@click="$emit('move-up');"
>
<svg :viewBox="icons.arrowUp.viewBox">
<use :xlink:href="`#${icons.arrowUp.id}`" />
</svg>
</button>
</div>
<div
v-if="!isLast"
class="e-cInput__action e-cInput__action--move"
>
<button
type="button"
@click="$emit('move-down');"
>
<svg :viewBox="icons.arrowDown.viewBox">
<use :xlink:href="`#${icons.arrowDown.id}`" />
</svg>
</button>
</div>
</div>
</header>
<div class="e-cInput__content"><slot /></div>
</article>
</template>
eslint-plugin-vue with recommended settings requires html-attributes on seperate lines if an element has more than one attribute: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-attributes-per-line.md
is there a prettier-option to prevent errors by prettier?
✘ https://google.com/#q=prettier%2Fprettier Replace `⏎··········v-if="!isLast"⏎··········class="e-cInput__action·e-cInput__action--move"⏎········` with `·v-if="!isLast"·class="e-cInput__action·e-cInput__action--move"`
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 25 (11 by maintainers)
Wouldn’t it be better to adjust prettier to follow the official style-guide? https://vuejs.org/v2/style-guide/#Multi-attribute-elements-strongly-recommended
You should disable all stylistics rules when you use prettier
We should probably add support for eslint-plugin-vue in eslint-config-prettier. @CinKon Would you like to take a stab at it?
I’ve released eslint-config-prettier 3.3.0 with support for eslint-plugin-vue! 🎉
–> #3101
Formatting style guides are not strictly followed by Prettier though.
Unfortunately, It turns off all rules that are unnecessary or might conflict with Prettier. It is not what I expected…
https://github.com/prettier/eslint-config-prettier/blob/e47f4acd0746d1e2af875cb9ee2fc6dd1af12593/vue.js#L4-L19
I expected exactly what @CinKon said in the first comment. Besides, when you said “add support for
eslint-plugin-vue
”, I thought Prettier will somehow follow the official style guide. But after the release ofeslint-config-prettier
, I realize that I can’t get what I expected with the current version of Prettier. I will find another way #5440 or request for ignoring based on languages #5408 Thanks.I just open #5408 to request for this. I don’t think Prettier have such thing. I think is because it was not needed before the support for HTML landed, as the most common scenario for want this is having multiple languages in one file, that I think it was not supported before.
Yeah, this is propably the same problematic as https://github.com/prettier/prettier/issues/3847. I assume I can either use a linter OR prettier in that case…