简体   繁体   English

eslint 缩进错误“预期缩进 2 个空格,但发现 4 个。”,angular 14

[英]eslint indent error "Expected indentation of 2 spaces but found 4.", angular 14

I'm using "eslint": "^8.23.0" in angular 14我在 angular 14 中使用"eslint": "^8.23.0"
Everything was OK when I used "eslint": "^8.22.0" , after update to 8.23.0 I'm getting the following error:当我使用"eslint": "^8.22.0"时一切正常,更新到8.23.0后出现以下错误:

eslint 缩进错误

eslint 缩进错误

My eslint config:我的 eslint 配置:

{
  "root": true,
  "ignorePatterns": [
    "projects/**/*"
  ],
  "overrides": [
    {
      "files": [
        "*.ts",
        "*.js",
        "*.tsx"
      ],
      "parserOptions": {
        "project": [
          "tsconfig.json"
        ],
        "createDefaultProgram": true
      },
      "extends": [
        "plugin:@angular-eslint/recommended",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "rules": {
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "app",
            "style": "camelCase"
          }
        ],
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "app",
            "style": "kebab-case"
          }
        ],
        "indent": [
          "error",
          2,
          {
            "SwitchCase": 1,
            "ArrayExpression": "first"
          }
        ],
        "@angular-eslint/template/eqeqeq": "off",
        "@typescript-eslint/naming-convention": "error",
        "quotes": "error",
        "semi": "error",
        "no-multiple-empty-lines": "error",
        "comma-dangle": "error"
      }
    },
    {
      "files": [
        "*.html",
        "*.css"
      ],
      "extends": [
        "plugin:@angular-eslint/template/recommended"
      ],
      "rules": {
        "@angular-eslint/template/eqeqeq": "off",
        "@angular-eslint/template/accessibility-elements-content": "error",
        "no-multiple-empty-lines": "error"
      }
    }
  ]
}

as you can see this is indent config:如您所见,这是indent配置:

"indent": [
 "error",
 2,
 {
  "SwitchCase": 1  
 }
]

I tested the following config我测试了以下配置

"indent": [
 "error",
 2,
 {
   "SwitchCase": 1,
   "ArrayExpression": "first"
 }
]

I also change eslint config to the following:我还将eslint配置更改为以下内容:

"indent": "off",
"@typescript-eslint/indent": [
  "error",
  2,
  {
    "SwitchCase": 1
  }
],

but nothing changed!但没有任何改变!

After update the following package, the problem gone!更新以下package后,问题消失!

@typescript-eslint/eslint-plugin  5.36.0  →  5.36.1
@typescript-eslint/parser         5.36.0  →  5.36.1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM