我在我的Angular 15项目中添加了本地化功能(它可以正常工作)。但是现在对于.ts
文件,代码检查已经出现问题:
错误 '$localize' is not defined no-undef
这是.eslintrc.json
文件的内容:
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"env": {
"browser": true
},
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json"
],
"createDefaultProgram": true
},
"extends": [
"eslint:recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended"
],
"rules": {
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "ilg",
"style": "camelCase"
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "ilg",
"style": "kebab-case"
}
],
"@typescript-eslint/consistent-type-assertions": [
"error",
{
"assertionStyle": "as"
}
],
"max-statements-per-line": [
"error",
{
"max": 1
}
],
"constructor-super": "error",
"no-unused-vars": "off"
}
},
{
"files": [
"*.ts"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2019,
"project": "./tsconfig.json",
"sourceType": "module"
},
"plugins": [
"ngrx"
],
"rules": {
"@ngrx/updater-explicit-return-type": "warn",
"@ngrx/no-dispatch-in-effects": "warn",
"@ngrx/no-effects-in-providers": "error",
"@ngrx/prefer-action-creator-in-of-type": "warn",
"@ngrx/prefer-concat-latest-from": "warn",
"@ngrx/prefer-effect-callback-in-block-statement": "warn",
"@ngrx/use-effects-lifecycle-interface": "warn",
"@ngrx/avoid-combining-selectors": "warn",
"@ngrx/avoid-dispatching-multiple-actions-sequentially": "warn",
"@ngrx/avoid-duplicate-actions-in-reducer": "warn",
"@ngrx/avoid-mapping-selectors": "warn",
"@ngrx/good-action-hygiene": "warn",
"@ngrx/no-multiple-global-stores": "warn",
"@ngrx/no-reducer-in-key-names": "warn",
"@ngrx/no-store-subscription": "warn",
"@ngrx/no-typed-global-store": "warn",
"@ngrx/on-function-explicit-return-type": "warn",
"@ngrx/prefer-action-creator-in-dispatch": "warn",
"@ngrx/prefer-action-creator": "warn",
"@ngrx/prefer-inline-action-props": "warn",
"@ngrx/prefer-one-generic-in-create-for-feature-selector": "warn",
"@ngrx/prefer-selector-in-select": "warn",
"@ngrx/prefix-selectors-with-select": "warn",
"@ngrx/select-style": "warn",
"@ngrx/use-consistent-global-store-name": "warn"
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {}
},
{
"files": [
"*.ts"
],
"extends": [
"plugin:@ngrx/strict-requiring-type-checking"
]
}
]
}
polyfills.ts
包含 localize 的引入:
import "@angular/localize/init";
我该如何修复这个问题?我找不到任何解决方法。