typescript - eslint indenteringsfel "Förväntad indentering på 2 mellanslag men hittade 4.", angular 14
Jag använder "eslint": "^8.23.0" i Angular 14
Allt fungerade bra när jag använde "eslint": "^8.22.0", efter uppdatering till 8.23.0 får jag följande fel:
Min eslint-konfiguration:
{
"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"
}
}
]
}
som du kan se är detta indent-konfiguration:
"indent": [
"error",
2,
{
"SwitchCase": 1
}
]
Jag testade följande konfiguration
"indent": [
"error",
2,
{
"SwitchCase": 1,
"ArrayExpression": "first"
}
]
Jag ändrar också eslint-konfigurationen till följande:
"indent": "off",
"@typescript-eslint/indent": [
"error",
2,
{
"SwitchCase": 1
}
],
men inget förändrades!
Svar #1
Efter att ha uppdaterat följande paket försvann problemet!
@typescript-eslint/eslint-plugin 5.36.0 → 5.36.1
@typescript-eslint/parser 5.36.0 → 5.36.1
Svar #2
Löst med dessa beroenden (i Angular 16-projekt) :
...
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/eslint-plugin-tslint": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"eslint": "^8.52.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsdoc": "^46.8.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
...

