Skip to content

Commit 701fa18

Browse files
authored
feat: add angular 13 support (#80)
* fix!: update Schema ID keyword to support Angular 13 BREAKING CHANGE: Angular 12 and earlier versions are not supported * chore: update demo app to Angular 11 * chore: update demo-app to Angular 12 * chore: update demo-app to Angular 13 * chore: bump version to 3.0.0 * fix: remove explicit any type and fix build pipeline * ci: install demo-app dependencies before linting the project It's necessary to have the demo-app's eslint plugins installed before lint can be run. * chore: update @angular-eslint alpha version dependency to latest version
1 parent 1af22dd commit 701fa18

File tree

13 files changed

+118
-65
lines changed

13 files changed

+118
-65
lines changed

.github/workflows/test-e2e.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
with:
1818
node-version: ${{ env.NODE_VERSION }}
1919
- run: npm i --force
20+
- run: cd demo-app && npm i --force && cd ..
2021
- run: npm run build --if-present
2122
- run: npm test
2223
env:

demo-app/.eslintrc.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
],
15+
"createDefaultProgram": true
16+
},
17+
"extends": [
18+
"plugin:@angular-eslint/recommended",
19+
"plugin:@angular-eslint/template/process-inline-templates"
20+
],
21+
"rules": {
22+
"@angular-eslint/directive-selector": [
23+
"error",
24+
{
25+
"type": "attribute",
26+
"prefix": "app",
27+
"style": "camelCase"
28+
}
29+
],
30+
"@angular-eslint/component-selector": [
31+
"error",
32+
{
33+
"type": "element",
34+
"prefix": "app",
35+
"style": "kebab-case"
36+
}
37+
]
38+
}
39+
},
40+
{
41+
"files": [
42+
"*.html"
43+
],
44+
"extends": [
45+
"plugin:@angular-eslint/template/recommended"
46+
],
47+
"rules": {}
48+
}
49+
]
50+
}

demo-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ speed-measure-plugin.json
3232
.history/*
3333

3434
# misc
35+
/.angular/cache
3536
/.sass-cache
3637
/connect.lock
3738
/coverage

demo-app/angular.json

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
"styles": [
2626
"src/styles.css"
2727
],
28-
"scripts": []
28+
"scripts": [],
29+
"aot": false,
30+
"vendorChunk": true,
31+
"extractLicenses": false,
32+
"buildOptimizer": false,
33+
"sourceMap": true,
34+
"optimization": false,
35+
"namedChunks": true
2936
},
3037
"configurations": {
3138
"production": {
@@ -38,7 +45,6 @@
3845
"optimization": true,
3946
"outputHashing": "all",
4047
"sourceMap": false,
41-
"extractCss": true,
4248
"namedChunks": false,
4349
"aot": true,
4450
"extractLicenses": true,
@@ -52,14 +58,14 @@
5258
}
5359
]
5460
}
55-
}
61+
},
62+
"defaultConfiguration": ""
5663
},
5764
"serve": {
5865
"builder": "@angular-devkit/build-angular:dev-server",
5966
"options": {
6067
"browserTarget": "demo-app:build",
6168
"host": "localhost",
62-
"baseHref": "localhost",
6369
"port": 4200
6470
},
6571
"configurations": {
@@ -68,8 +74,7 @@
6874
},
6975
"stubbed": {
7076
"browserTarget": "demo-app:build",
71-
"publicHost": "localhost:4200",
72-
"progress": false
77+
"publicHost": "localhost:4200"
7378
}
7479
}
7580
},
@@ -96,19 +101,6 @@
96101
"scripts": []
97102
}
98103
},
99-
"lint": {
100-
"builder": "@angular-devkit/build-angular:tslint",
101-
"options": {
102-
"tsConfig": [
103-
"tsconfig.app.json",
104-
"tsconfig.spec.json",
105-
"e2e/tsconfig.json"
106-
],
107-
"exclude": [
108-
"**/node_modules/**"
109-
]
110-
}
111-
},
112104
"e2e": {
113105
"builder": "angular-testcafe:testcafe",
114106
"options": {
@@ -154,12 +146,22 @@
154146
]
155147
}
156148
}
149+
},
150+
"lint": {
151+
"builder": "@angular-eslint/builder:lint",
152+
"options": {
153+
"lintFilePatterns": [
154+
"src/**/*.ts",
155+
"src/**/*.html"
156+
]
157+
}
157158
}
158159
}
159160
}
160161
},
161162
"defaultProject": "demo-app",
162163
"cli": {
163-
"analytics": false
164+
"analytics": false,
165+
"defaultCollection": "@angular-eslint/schematics"
164166
}
165167
}

demo-app/package.json

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,35 +5,42 @@
55
"ng": "ng",
66
"start": "ng serve",
77
"build": "ng build",
8-
"test": "ng test",
98
"lint": "ng lint",
109
"e2e": "ng e2e -c passing"
1110
},
1211
"private": true,
1312
"dependencies": {
14-
"@angular/animations": "10.0.11",
15-
"@angular/common": "10.0.11",
16-
"@angular/compiler": "10.0.11",
17-
"@angular/core": "10.0.11",
18-
"@angular/forms": "10.0.11",
19-
"@angular/platform-browser": "10.0.11",
20-
"@angular/platform-browser-dynamic": "10.0.11",
21-
"@angular/router": "10.0.11",
13+
"@angular/animations": "13.0.1",
14+
"@angular/common": "13.0.1",
15+
"@angular/compiler": "13.0.1",
16+
"@angular/core": "13.0.1",
17+
"@angular/forms": "13.0.1",
18+
"@angular/platform-browser": "13.0.1",
19+
"@angular/platform-browser-dynamic": "13.0.1",
20+
"@angular/router": "13.0.1",
2221
"rxjs": "6.6.2",
23-
"tslib": "^2.0.1",
24-
"zone.js": "~0.11.1"
22+
"tslib": "^2.0.0",
23+
"zone.js": "~0.11.4"
2524
},
2625
"devDependencies": {
27-
"@angular-devkit/build-angular": "0.1000.6",
28-
"@angular/cli": "10.0.6",
29-
"@angular/compiler-cli": "10.0.11",
30-
"@angular/language-service": "10.0.11",
31-
"angular-testcafe": "file:..",
26+
"@angular-devkit/build-angular": "13.0.2",
27+
"@angular-eslint/builder": "13.0.1",
28+
"@angular-eslint/eslint-plugin": "13.0.1",
29+
"@angular-eslint/eslint-plugin-template": "13.0.1",
30+
"@angular-eslint/schematics": "13.0.1",
31+
"@angular-eslint/template-parser": "13.0.1",
32+
"@angular/cli": "13.0.2",
33+
"@angular/compiler-cli": "13.0.1",
34+
"@angular/language-service": "13.0.1",
3235
"@types/node": "~12.12.54",
3336
"@types/webpack-env": "^1.16.0",
37+
"@typescript-eslint/eslint-plugin": "5.3.0",
38+
"@typescript-eslint/parser": "5.3.0",
39+
"angular-testcafe": "file:..",
3440
"codelyzer": "^6.0.0",
41+
"eslint": "^8.1.0",
3542
"ts-node": "~8.10.2",
3643
"tslint": "~6.1.3",
37-
"typescript": "~3.9.7"
44+
"typescript": "~4.4.4"
3845
}
3946
}

demo-app/src/app/app.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { TestBed, async } from '@angular/core/testing';
1+
import { TestBed, waitForAsync } from '@angular/core/testing';
22
import { AppComponent } from './app.component';
33

44
describe('AppComponent', () => {
5-
beforeEach(async(() => {
5+
beforeEach(waitForAsync(() => {
66
TestBed.configureTestingModule({
77
declarations: [
88
AppComponent

demo-app/src/app/app.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Component } from '@angular/core';
22

3-
const opts = {
4-
selector: 'app-root',
3+
@Component({
4+
selector: 'app-root',
55
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.css']
7-
};
8-
9-
@Component(opts)
6+
styleUrls: ['./app.component.css']
7+
})
108

119
export class AppComponent {
1210
title = 'demo-app';

demo-app/src/environments/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ export const environment = {
1313
* This import should be commented out in production mode because it will have a negative impact
1414
* on performance if an error is thrown.
1515
*/
16-
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
16+
// import 'zone.js/plugins/zone-error'; // Included with Angular CLI.

demo-app/src/polyfills.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
* BROWSER POLYFILLS
1919
*/
2020

21-
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
22-
// import 'classlist.js'; // Run `npm install --save classlist.js`.
23-
24-
/**
25-
* Web Animations `@angular/platform-browser/animations`
26-
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27-
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28-
*/
29-
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30-
3121
/**
3222
* By default, zone.js will patch all possible macroTask and DomEvents
3323
* user can disable parts of macroTask/DomEvents patch by setting following flags
@@ -55,7 +45,7 @@
5545
/***************************************************************************************************
5646
* Zone JS is required by default for Angular itself.
5747
*/
58-
import 'zone.js/dist/zone'; // Included with Angular CLI.
48+
import 'zone.js'; // Included with Angular CLI.
5949

6050

6151
/***************************************************************************************************

demo-app/src/test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NOTE: This file is required by karma.conf.js and loads recursively all the .spec and framework files
22

33
import 'webpack-env';
4-
import 'zone.js/dist/zone-testing';
4+
import 'zone.js/testing';
55
import { getTestBed } from '@angular/core/testing';
66

77
import {
@@ -12,7 +12,9 @@ import {
1212
// First, initialize the Angular testing environment.
1313
getTestBed().initTestEnvironment(
1414
BrowserDynamicTestingModule,
15-
platformBrowserDynamicTesting()
15+
platformBrowserDynamicTesting(), {
16+
teardown: { destroyAfterEach: false }
17+
}
1618
);
1719
// Then we find all the tests.
1820
const context = require.context('./', true, /\.spec\.ts$/);

0 commit comments

Comments
 (0)