Skip to content

Commit 0d0e77f

Browse files
authored
frontend: Migrate from tslint to eslint in KWA (#2042)
* frontend: Remove TSLint Remove TSLint since it's deprecated. Signed-off-by: Elena Zioga <[email protected]> * frontend: Introduce ESLint Introduce ESLint by using the following Angular command [1]: ng add @angular-eslint/schematics [1] https://github.com/angular-eslint/angular-eslint#quick-start-with-angular-v12-and-later Signed-off-by: Elena Zioga <[email protected]> * frontend: Fix linting errors Fix linting errors. Signed-off-by: Elena Zioga <[email protected]> * gh-actions: Add GH action to run a lint check Introduce a Github action to run a lint check. Signed-off-by: Elena Zioga <[email protected]> Signed-off-by: Elena Zioga <[email protected]>
1 parent 88e6787 commit 0d0e77f

File tree

15 files changed

+1309
-148
lines changed

15 files changed

+1309
-148
lines changed

.github/workflows/test-node.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
name: Frontend Test
22

33
on:
4-
- pull_request
4+
pull_request:
5+
paths:
6+
- pkg/new-ui/v1beta1/frontend/**
57

68
concurrency:
79
group: ${{ github.workflow }}-${{ github.ref }}
810
cancel-in-progress: true
911

1012
jobs:
1113
test:
12-
name: Test
14+
name: Code format and lint
1315
runs-on: ubuntu-latest
1416

1517
steps:
@@ -21,11 +23,16 @@ jobs:
2123
with:
2224
node-version: 12.18.1
2325

24-
- name: Run Node test
26+
- name: Format katib code
2527
run: |
2628
npm install prettier --prefix ./pkg/new-ui/v1beta1/frontend
2729
make prettier-check
2830
31+
- name: Lint katib code
32+
run: |
33+
cd pkg/new-ui/v1beta1/frontend
34+
npm run lint-check
35+
2936
frontend-unit-tests:
3037
name: Frontend Unit Tests
3138
runs-on: ubuntu-latest
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": [
4+
"projects/**/*"
5+
],
6+
"overrides": [
7+
{
8+
"files": [
9+
"*.ts"
10+
],
11+
"parserOptions": {
12+
"project": [
13+
"tsconfig.json",
14+
"e2e/tsconfig.json"
15+
],
16+
"createDefaultProgram": true
17+
},
18+
"extends": [
19+
"plugin:@angular-eslint/recommended",
20+
"plugin:@angular-eslint/template/process-inline-templates"
21+
],
22+
"rules": {
23+
"@angular-eslint/directive-selector": [
24+
"error",
25+
{
26+
"type": "attribute",
27+
"prefix": "app",
28+
"style": "camelCase"
29+
}
30+
],
31+
"@angular-eslint/component-selector": [
32+
"error",
33+
{
34+
"type": "element",
35+
"prefix": "app",
36+
"style": "kebab-case"
37+
}
38+
]
39+
}
40+
},
41+
{
42+
"files": [
43+
"*.html"
44+
],
45+
"extends": [
46+
"plugin:@angular-eslint/template/recommended"
47+
],
48+
"rules": {}
49+
}
50+
]
51+
}

pkg/new-ui/v1beta1/frontend/angular.json

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@
3232
"output": "assets/monaco-editor"
3333
}
3434
],
35-
"styles": ["src/styles.scss", "src/assets/css/d3.parcoords.css"],
35+
"styles": [
36+
"src/styles.scss",
37+
"src/assets/css/d3.parcoords.css"
38+
],
3639
"scripts": [],
3740
"vendorChunk": true,
3841
"extractLicenses": false,
@@ -96,23 +99,17 @@
9699
"polyfills": "src/polyfills.ts",
97100
"tsConfig": "tsconfig.spec.json",
98101
"karmaConfig": "karma.conf.js",
99-
"assets": ["src/favicon.ico", "src/assets"],
100-
"styles": ["src/styles.scss"],
102+
"assets": [
103+
"src/favicon.ico",
104+
"src/assets"
105+
],
106+
"styles": [
107+
"src/styles.scss"
108+
],
101109
"scripts": [],
102110
"preserveSymlinks": true
103111
}
104112
},
105-
"lint": {
106-
"builder": "@angular-devkit/build-angular:tslint",
107-
"options": {
108-
"tsConfig": [
109-
"tsconfig.app.json",
110-
"tsconfig.spec.json",
111-
"e2e/tsconfig.json"
112-
],
113-
"exclude": ["**/node_modules/**"]
114-
}
115-
},
116113
"e2e": {
117114
"builder": "@angular-devkit/build-angular:protractor",
118115
"options": {
@@ -124,9 +121,21 @@
124121
"devServerTarget": "frontend:serve:production"
125122
}
126123
}
124+
},
125+
"lint": {
126+
"builder": "@angular-eslint/builder:lint",
127+
"options": {
128+
"lintFilePatterns": [
129+
"src/**/*.ts",
130+
"src/**/*.html"
131+
]
132+
}
127133
}
128134
}
129135
}
130136
},
131-
"defaultProject": "frontend"
137+
"defaultProject": "frontend",
138+
"cli": {
139+
"defaultCollection": "@angular-eslint/schematics"
140+
}
132141
}

0 commit comments

Comments
 (0)