Skip to content

Commit 251c836

Browse files
committed
migrate to eslint
1 parent 52f79de commit 251c836

File tree

5 files changed

+126
-168
lines changed

5 files changed

+126
-168
lines changed

.eslintrc.json

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": [
4+
"projects/**/*"
5+
],
6+
"overrides": [
7+
{
8+
"plugins": [
9+
"jsdoc",
10+
"prefer-arrow"
11+
],
12+
"files": [
13+
"*.ts"
14+
],
15+
"parserOptions": {
16+
"project": [
17+
"tsconfig.json",
18+
"e2e/tsconfig.json"
19+
],
20+
"createDefaultProgram": true
21+
},
22+
"extends": [
23+
"plugin:import/recommended",
24+
"plugin:jsdoc/recommended",
25+
"plugin:@angular-eslint/ng-cli-compat",
26+
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
27+
"plugin:@angular-eslint/template/process-inline-templates"
28+
],
29+
"rules": {
30+
"@angular-eslint/component-selector": [
31+
"error",
32+
{
33+
"type": "element",
34+
"prefix": "app",
35+
"style": "kebab-case"
36+
}
37+
],
38+
"@angular-eslint/directive-selector": [
39+
"error",
40+
{
41+
"type": "attribute",
42+
"prefix": "app",
43+
"style": "camelCase"
44+
}
45+
],
46+
"@typescript-eslint/explicit-member-accessibility": [
47+
"off",
48+
{
49+
"accessibility": "explicit"
50+
}
51+
],
52+
"arrow-parens": [
53+
"off",
54+
"always"
55+
],
56+
"import/order": "off",
57+
"@typescript-eslint/no-unused-vars": "error",
58+
"@typescript-eslint/no-var-requires": "error",
59+
"no-trailing-spaces": "off",
60+
"no-underscore-dangle": "off",
61+
"no-duplicate-imports": "error",
62+
"no-unused-expressions": "error",
63+
"@typescript-eslint/consistent-type-definitions": "error",
64+
"@typescript-eslint/dot-notation": "off",
65+
"max-len": [
66+
"error",
67+
{
68+
"code": 180
69+
}
70+
],
71+
"prefer-arrow/prefer-arrow-functions": [
72+
"warn",
73+
{
74+
"disallowPrototype": true,
75+
"singleReturnOnly": false,
76+
"classPropertiesAllowed": false
77+
}
78+
]
79+
}
80+
},
81+
{
82+
"files": [
83+
"*.html"
84+
],
85+
"extends": [
86+
"plugin:@angular-eslint/template/recommended"
87+
],
88+
"rules": {}
89+
}
90+
]
91+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This project was generated with [Angular CLI](https://github.com/angular/angular
1919
- Migrate to Angular 10
2020
- Named and multiple router outlets
2121
- Migrate to Angular 11
22+
- Migrate tslint to esLint
2223

2324
## Unit Tests
2425

angular.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
"ngswConfigPath": "ngsw-config.json"
7777
},
7878
"fr": {
79-
"localize": ["fr"],
79+
"localize": [
80+
"fr"
81+
],
8082
"outputPath": "dist/fr"
8183
}
8284
}
@@ -102,15 +104,11 @@
102104
}
103105
},
104106
"lint": {
105-
"builder": "@angular-devkit/build-angular:tslint",
107+
"builder": "@angular-eslint/builder:lint",
106108
"options": {
107-
"tsConfig": [
108-
"tsconfig.app.json",
109-
"tsconfig.spec.json",
110-
"e2e/tsconfig.json"
111-
],
112-
"exclude": [
113-
"**/node_modules/**"
109+
"lintFilePatterns": [
110+
"src/**/*.ts",
111+
"src/**/*.html"
114112
]
115113
}
116114
},
@@ -186,5 +184,8 @@
186184
"@schematics/angular:directive": {
187185
"prefix": "app"
188186
}
187+
},
188+
"cli": {
189+
"defaultCollection": "@angular-eslint/schematics"
189190
}
190191
}

package.json

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
"i18n:extract": "ng xi18n --output-path assets/i18n"
2424
},
2525
"license": "ISC",
26+
"husky": {
27+
"hooks": {
28+
"pre-commit": "lint-staged --relative"
29+
}
30+
},
31+
"lint-staged": {
32+
"src/**/*.{ts,html}": [
33+
"eslint --fix"
34+
]
35+
},
2636
"dependencies": {
2737
"@angular/animations": "~11.2.14",
2838
"@angular/cdk": "^11.2.13",
@@ -55,6 +65,11 @@
5565
},
5666
"devDependencies": {
5767
"@angular-devkit/build-angular": "~0.1102.19",
68+
"@angular-eslint/builder": "4.3.1",
69+
"@angular-eslint/eslint-plugin": "4.3.1",
70+
"@angular-eslint/eslint-plugin-template": "4.3.1",
71+
"@angular-eslint/schematics": "4.3.1",
72+
"@angular-eslint/template-parser": "4.3.1",
5873
"@angular/cli": "~11.2.19",
5974
"@angular/compiler-cli": "~11.2.14",
6075
"@nguniversal/builders": "^9.1.1",
@@ -64,21 +79,27 @@
6479
"@types/jest": "^27.0.1",
6580
"@types/mime-types": "^2.1.1",
6681
"@types/node": "^12.11.1",
82+
"@typescript-eslint/eslint-plugin": "4.16.1",
83+
"@typescript-eslint/parser": "4.16.1",
6784
"babel-jest": "^27.1.1",
68-
"codelyzer": "^6.0.0",
6985
"compression": "^1.7.4",
86+
"eslint": "^7.6.0",
87+
"eslint-plugin-import": "^2.26.0",
88+
"eslint-plugin-jsdoc": "^39.3.2",
89+
"eslint-plugin-prefer-arrow": "^1.2.3",
90+
"husky": "^8.0.1",
7091
"http-server": "^0.12.3",
7192
"jest": "^27.1.1",
7293
"jest-html-reporter": "^3.1.0",
7394
"jest-jasmine2": "^27.5.1",
7495
"jest-preset-angular": "^9.0.7",
7596
"mime-types": "^2.1.34",
97+
"lint-staged": "^13.0.2",
7698
"protractor": "~7.0.0",
7799
"sass": "^1.52.3",
78100
"ts-loader": "^8.2.0",
79101
"ts-node": "~8.3.0",
80-
"tslint": "~6.1.0",
81-
"typescript": "4.0.8",
102+
"typescript": "4.1.6",
82103
"webpack": "^4.46.0",
83104
"webpack-bundle-analyzer": "^4.5.0",
84105
"webpack-cli": "^4.4.0",

tslint.json

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)