首页 > 解决方案 > 忽略 lit-html html 函数中的缩进,使用 typescript-eslint lint 规则

问题描述

不想使用 eslint-disable-next-line,我想忽略所有html结果

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

类似问题:使用 ESLint `indent` 规则忽略模板文字中的缩进

我努力了

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

但不起作用,因为html()返回TemplateResult定义在 中的 Object lit-html,而不是 AST 节点类型,对吧?

那么有什么解决方案吗?提前致谢。

相关信息: https ://eslint.org/docs/rules/indent#ignorednodes

标签: eslinttypescript-eslintlit-html

解决方案


推荐阅读