[英]ESLint throwing error in html and template files
I have an angular app and have just configured ESLint on the project and am getting this error on my index.html and it is complaining about a closing tag and not correctly reading this, I would like to ignore errors like this in the.html files.我有一个 angular 应用程序,刚刚在项目上配置了 ESLint,并且在我的 index.html 上出现此错误,它抱怨关闭标签并且没有正确读取,我想忽略文件中的此类错误。 . I am getting this error on the below tag
我在以下标签上收到此错误
error Parsing error: '>' expected错误解析错误:“>”预期
index.html索引.html
<!doctype html> <!doctype html>
Here is my esLinerc.json file这是我的 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"]
}
]
} }
I had installed我已经安装了
"@typescript-eslint/eslint-plugin": "5.27.1", "@typescript-eslint/parser": "5.27.1", “@typescript-eslint/eslint-plugin”:“5.27.1”,“@typescript-eslint/parser”:“5.27.1”,
earlier and read that i might have to install @angular-eslint/template-parser and have installed this as well,早些时候读到我可能必须安装 @angular-eslint/template-parser 并且也安装了它,
"@angular-eslint/template-parser": "^13.5.0", hoping that would ignore the bogus error and other errors where eslint is expecting a closing tag for component directives. “@angular-eslint/template-parser”:“^13.5.0”,希望这会忽略 eslint 期望组件指令的结束标记的虚假错误和其他错误。
I have tried to add the **.html files as well to the ignore patterns but am still getting template errors that are not valid.我尝试将 **.html 文件也添加到忽略模式中,但仍然收到无效的模板错误。 Can someone please point out what exact i need to make to ignore errors on.html files
有人可以指出我需要做什么才能忽略.html文件上的错误
Try this:尝试这个:
// eslint-disable-next-line
right before your html docutype就在您的 html 文档类型之前
You should ignore non-component html
files.您应该忽略非组件
html
文件。 Just edit ignorePatterns
section:只需编辑
ignorePatterns
部分:
"ignorePatterns": [
"/**/*.html",
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.