xojs/xo

unicorn/template-indent fights with prettier/prettier over html`…` indentation

andersk opened this issue · 0 comments

When using an html`…` template inside a ternary condition, unicorn/template-indent wants different indentation than prettier/prettier, so the user needs to disable one of these.

(XO 0.48.0, Prettier 2.5.1.)

import html from 'escape-goat';

export function hello(condition) {
	return condition
		? html`
				<div>
					<p>Hello, world!</p>
				</div>
		  `
		: html`<div></div>`;
}
$ npx xo --prettier

  src.js:5:9
  ⚠  5:9  Templates should be properly indented.  unicorn/template-indent

  1 warning
import html from 'escape-goat';

export function hello(condition) {
	return condition
		? html`
			<div>
				<p>Hello, world!</p>
			</div>
		`
		: html`<div></div>`;
}
$ npx xo --prettier

  src.js:6:4
  ✖  6:4  Insert ↹   prettier/prettier
  ✖  7:1  Insert ↹   prettier/prettier
  ✖  8:4  Insert ↹   prettier/prettier
  ✖  9:3  Insert ··  prettier/prettier

  4 errors