将 @angular-eslint/template/eqeqeq 设置为 off 不适用于 angular 13
Posted
技术标签:
【中文标题】将 @angular-eslint/template/eqeqeq 设置为 off 不适用于 angular 13【英文标题】:Setting @angular-eslint/template/eqeqeq to off not working with angular 13 【发布时间】:2022-01-04 11:32:46 【问题描述】:设置"@angular-eslint/template/eqeqeq": "off"
,.eslintrc.json 上的配置不适用于 angular 13
.eslintrc.json
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
"files": [
"*.ts"
],
"parserOptions":
"project": [
"tsconfig.json",
"e2e/tsconfig.json"
],
"createDefaultProgram": true
,
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"prettier"
],
"plugins": ["prettier"],
"rules":
"@angular-eslint/component-selector": [
"error",
// "prefix": "app",
"style": "kebab-case",
"type": "element"
],
"@angular-eslint/directive-selector": [
"error",
// "prefix": "app",
"style": "camelCase",
"type": "attribute"
],
"@angular-eslint/template/eqeqeq": "off",
"@angular-eslint/no-host-metadata-property": "off",
"@angular-eslint/no-output-on-prefix": "off",
"@angular-eslint/no-output-native":"off"
// "@angular-eslint/template/eqeqeq":[
// "error",
// "allow-static": true
//
// ],
// "prettier/prettier": ["error", "parser": "angular" ]
,
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules":
]
异常
/Users/macbook/Projects/6clicks/src/LegalRegTech.Web.Host/src/app/main/rb-assessment/rba-details/rba-details.component.html
12:33 error Expected `===` but received `==` @angular-eslint/template/eqeqeq
15:33 error Expected `===` but received `==` @angular-eslint/template/eqeqeq
19:45 error Expected `!==` but received `!=` @angular-eslint/template/eqeqeq
75:21 error Expected `===` but received `==` @angular-eslint/template/eqeqeq
78:21 error Expected `===` but received `==` @angular-eslint/template/eqeqeq
【问题讨论】:
您能否在您的.eslintrc.json
中显示更多上下文?对我来说,这个确切的代码有效......
您是否尝试过重新启动编辑器?
@vitaliykotov 我正在终端上运行 ng lint
【参考方案1】:
您将此规则应用于*.ts
文件,但您需要将其应用于*.html
文件,因为它是模板文件的规则。因此,只需将规则移至 HTML 块即可。
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules":
"@angular-eslint/template/eqeqeq": "off"
【讨论】:
以上是关于将 @angular-eslint/template/eqeqeq 设置为 off 不适用于 angular 13的主要内容,如果未能解决你的问题,请参考以下文章
Javascript 将正则表达式 \\n 替换为 \n,将 \\t 替换为 \t,将 \\r 替换为 \r 等等