I would like to be able to utilize the eslint angular template that checks for i18n tags as shown here https://github.com/angular-eslint/angular-eslint/blob/master/packages/eslint-plugin-template/src/rules/i18n.ts and listed here https://github.com/angular-eslint/angular-eslint#readme, but there isn't really any helpful instruction on how to activate it or what needs to be put in the config to make it work. I just need to know how to turn it "on" to start checking. Any help would be appreciated.
Update:
Here is an example of what I am trying (and failing) at doing:
In .eslintrc.json
, I am trying to add @angular-eslint/template/i18n:
{
"root": true,
"ignorePatterns": [
"projects/**/*"
],
"overrides": [
{
"files": [
"*.ts"
],
"parserOptions": {
"project": [
"tsconfig.json" ],
"createDefaultProgram": true,
"tsconfigRootDir": "",
"ecmaVersion": 2017
},
"env": {
"es6": true
},
"extends": [
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/template/process-inline-templates"
],
"rules": {
"arrow-body-style": 0,
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "enumMember",
"format": [
"camelCase",
"UPPER_CASE"
]
}
],
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/dot-notation": "off",
"@typescript-eslint/explicit-member-accessibility": [
"off",
{
"accessibility": "explicit"
}
],
"@typescript-eslint/no-non-null-assertion": "off",
"brace-style": [
"error",
"1tbs"
],
// note you must disable the base rule as it can report incorrect errors
"no-shadow": "off",
"@typescript-eslint/no-shadow": [
"error"
]
}
},
{
"files": [
"*.html"
],
"extends": [
"plugin:@angular-eslint/template/recommended"
],
"rules": {
"@angular-eslint/template/i18n": [
"warn",
{ "items": ["check-id", "check-text"] }
]
}
}
]
}
When I do this, I get the error:
An unhandled exception occurred: .eslintrc.json#overrides[1]:
Configuration for rule "@angular-eslint/template/i18n" is invalid:
Value {"items":["check-id","check-text"],"checkId":true,"checkText":true,"checkAttributes":true,"ignoreAttributes":["charset","class","color","colspan","fill","formControlName","height","href","id","lang","src","stroke","stroke-width","style","svgIcon","tabindex","target","type","viewBox","width","xmlns"]} should NOT have additional properties.
If I change the name from @angular-eslint/template/i18n to template-i18n, it runs and scans all of my .html files, but returns an error for each one that says 1:1 error Definition for rule 'template-i18n' was not found template-i18n
i18n-lint **/*.html
for example, I only get the dist/index.html and the src/index.html, when currently, no html in the project has any i18n. Is there a way to accomplish this without the code-scripting you mention (i.e. with the cli)? – Godbey