Skip to content

Commit

Permalink
test: move rules to overrides to separate concerns
Browse files Browse the repository at this point in the history
We rarely apply ESLint configuration to all files. Hence, we extract
rules specific to file types to have a stricker separation of concerns.

As part of this change, we also simplify recommended rules since some
rules are subset of others.
  • Loading branch information
tancnle committed Jun 3, 2022
1 parent e541078 commit 8900899
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{
"root": true,
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "warn"
},
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"browser": true,
"jasmine": true
},
"overrides": [
{
"files": ["*.ts"],
"parserOptions": {
"project": ["tsconfig.*?.json"],
"createDefaultProgram": true
},
"extends": ["plugin:@typescript-eslint/recommended", "plugin:@angular-eslint/recommended"],
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@angular-eslint/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"env": {
"browser": true,
"jasmine": true
},
"rules": {
"@angular-eslint/no-empty-lifecycle-method": "warn",
"@angular-eslint/component-class-suffix": "warn",
Expand All @@ -43,7 +43,7 @@
"@typescript-eslint/no-this-alias": "warn",
"no-dupe-class-members": "warn",
"no-prototype-builtins": "warn",
"no-unused-vars": "warn",
"no-unused-vars": "off",
"no-useless-escape": "warn",
"no-var": "warn",
"quotes": [
Expand All @@ -53,19 +53,21 @@
"allowTemplateLiterals": true
}
],
"prefer-const": "warn"
"prefer-const": "warn",
"prettier/prettier": "warn"
}
},
{
"files": ["*.component.html"],
"extends": ["plugin:@angular-eslint/template/recommended"],
"extends": ["plugin:@angular-eslint/template/recommended", "plugin:prettier/recommended"],
"rules": {
"max-len": [
"warn",
{
"code": 140
}
]
],
"prettier/prettier": "warn"
}
},
{
Expand Down

0 comments on commit 8900899

Please sign in to comment.