javascript html和模板文件中的ESLint抛出错误

vngu2lb8  于 12个月前  发布在  Java
关注(0)|答案(3)|浏览(118)

我有一个Angular 的应用程序,并刚刚配置了ESLint的项目,并得到这个错误对我的index.html,它是抱怨一个关闭标记,并没有正确地阅读这一点,我想忽略这样的错误在.html文件。我在下面的标签上得到这个错误
错误解析错误:'>'预期

index.html

<!doctype html>
这是我的esLinerc.json文件

{
"env": {
    "browser": true,
    "es2021": true,
    "jasmine": true
},
"extends": [
    "eslint:recommended",
    "plugin:jasmine/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module"
},
"plugins": [
    "@typescript-eslint",
    "jasmine"
],
"ignorePatterns": [
    "/**/*.js",
    "**/vendor/*.js",
    "/**/*.component.html"
],
"rules": {
    "no-use-before-define": "off",
    "no-unused-vars": "off",
    "no-extra-boolean-cast": "off",
    "no-mixed-spaces-and-tabs": "off",
    "no-irregular-whitespace": "off",
   
"overrides": [
    {
        "files": ["*.component.html"],
        "parser": "@angular-eslint/template-parser",
        "parserOptions": {
          "project": "./tsconfig.app.json",
          "ecmaVersion": 2020,
          "sourceType": "module"
        },
        "rules": {
            "@typescript-eslint/dot-notation": "off",
            "@typescript-eslint/no-implied-eval": "off",
            "@typescript-eslint/no-throw-literal": "off",
            "strict": "off",
            "import/first": "off",
            "lines-around-directive": "off"
          },
        "plugins": ["@angular-eslint/template"]
      }
]

}
我已经安装
“@typescript-eslint/eslint-plugin”:“5.27.1”,“@typescript-eslint/parser”:“5.27.1”,
之前读到我可能需要安装@angular-eslint/template-parser,并且也安装了这个,
“@angular-eslint/template-parser”:“^13.5.0”,希望这会忽略虚假错误和其他错误,其中eslint期望组件指令的结束标记。
我已经尝试将**.html文件也添加到忽略模式中,但仍然得到无效的模板错误。有人可以请指出什么确切我需要作出忽略错误的。html文件

f0ofjuux

f0ofjuux1#

您应该忽略非组件html文件。只需编辑ignorePatterns部分:

"ignorePatterns": [
  "/**/*.html",
],
luaexgnf

luaexgnf2#

试试这个:

// eslint-disable-next-line

在你的html文档类型之前

bxpogfeg

bxpogfeg3#

尝试从Android Studio更新,如果你有它,在顶部菜单中单击“工具”>“Flutter”>“Flutter升级”。
否则运行“Flutter Upgrade -f“x1c 0d1x

相关问题