Ignore the indent in lit-html html function, with typescript-eslint lint rule

Viewed 226

Don't want to use eslint-disable-next-line, I'd like to ignore all the html result

import { html } from 'lit-html';
render() {
    // This part will have ugly indent
    return html`<div
      class=${classMap({
        'row-height': true,
      })}
    ></div>`;
}

Similar question: Ignore the indentation in a template literal, with the ESLint `indent` rule

I have tried

"@typescript-eslint/indent": ["error", "2", { "ignoredNodes": ["TemplateLiteral > *"] }]

But not working, because html() returns TemplateResult Object which is defined in lit-html, not a AST node type, right?

So is there any solution for this? Thanks in advance.

Related Info: https://eslint.org/docs/rules/indent#ignorednodes

1 Answers

Try to replace "TemplateLiteral > *" by "TemplateLiteral *" (i.e. remove the > character).

The > character indicates to only ignore the direct children. By removing it, you ignore all children, no matter how deep they are nested.

Related