In Prettier, how do I prevent HTML closing tag's ">" character being placed on a new line? In Prettier, how do I prevent HTML closing tag's ">" character being placed on a new line? vue.js vue.js

In Prettier, how do I prevent HTML closing tag's ">" character being placed on a new line?


I've found a solution to this problem. Leaving it here for people who land here by search.

Set the option --html-whitespace-sensitivity to ignore and you will get this output:

<template>  <div>    <div>      <div>        <div>          <div>            <ol>              <li>                <router-link class="xyz-class abc-class" to="/home">                  Home                </router-link>              </li>              <li>                <router-link class="xyz-class abc-class" to="/posts">                  Posts                </router-link>              </li>            </ol>          </div>        </div>      </div>    </div>  </div></template>

Although this is not recommended as whitespace formatting can cause issues like extra spacing around text and stuff, which might affect your UI design's consistency.

More info about this here: https://prettier.io/blog/2018/11/07/1.15.0.html#whitespace-sensitive-formatting


Thanks to this reply on GitHub: https://github.com/prettier/prettier/issues/9381#issuecomment-707156908