├── .editorconfig ├── .gitignore ├── .prettierrc ├── README.md ├── angular.json ├── browserslist ├── e2e ├── protractor.conf.js ├── src │ ├── app.e2e-spec.ts │ └── app.po.ts └── tsconfig.e2e.json ├── package-lock.json ├── package.json ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.css │ ├── app.component.html │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ ├── auth │ │ ├── +xstate │ │ │ ├── auth-machine.config.ts │ │ │ ├── auth-machine.events.ts │ │ │ ├── auth-machine.schema.ts │ │ │ └── auth-machine.service.ts │ │ ├── auth-can-load.service.ts │ │ ├── auth-routing.module.ts │ │ ├── auth.module.ts │ │ ├── auth.service.ts │ │ ├── login.component.html │ │ ├── login.component.spec.ts │ │ └── login.component.ts │ ├── home │ │ ├── article-list.component.html │ │ ├── article-list.component.spec.ts │ │ ├── article-list.component.ts │ │ ├── articles-routing.module.ts │ │ └── articles.module.ts │ └── shared │ │ ├── api │ │ ├── api.module.ts │ │ ├── api.service.ts │ │ └── types.ts │ │ ├── list-errors │ │ ├── list-errors.component.html │ │ └── list-errors.component.ts │ │ └── shared.module.ts ├── assets │ └── .gitkeep ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── favicon.ico ├── index.html ├── karma.conf.js ├── main.ts ├── polyfills.ts ├── styles.css ├── test.ts ├── tsconfig.app.json ├── tsconfig.spec.json └── tslint.json ├── tsconfig.json └── tslint.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | max_line_length = off 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | 8 | # dependencies 9 | /node_modules 10 | 11 | # profiling files 12 | chrome-profiler-events.json 13 | speed-measure-plugin.json 14 | 15 | # IDEs and editors 16 | /.idea 17 | .project 18 | .classpath 19 | .c9/ 20 | *.launch 21 | .settings/ 22 | *.sublime-workspace 23 | 24 | # IDE - VSCode 25 | .vscode/* 26 | !.vscode/settings.json 27 | !.vscode/tasks.json 28 | !.vscode/launch.json 29 | !.vscode/extensions.json 30 | .history/* 31 | 32 | # misc 33 | /.sass-cache 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | npm-debug.log 38 | yarn-error.log 39 | testem.log 40 | /typings 41 | 42 | # System Files 43 | .DS_Store 44 | Thumbs.db 45 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true 3 | } 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AngularXstate 2 | 3 | ## ❗️ I'd suggest you to have a look on [this repository](https://github.com/stefanoslig/xstate-angular). It's the repository I try to keep up to date with the latest version of angular, it contains more examples and also a published [library](https://www.npmjs.com/package/xstate-angular). 4 | 5 | 6 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.3.2. 7 | 8 | ## Development server 9 | 10 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. 11 | 12 | ## Code scaffolding 13 | 14 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 15 | 16 | ## Build 17 | 18 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build. 19 | 20 | ## Running unit tests 21 | 22 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 23 | 24 | ## Running end-to-end tests 25 | 26 | Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/). 27 | 28 | ## Further help 29 | 30 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). 31 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "angular-xstate": { 7 | "root": "", 8 | "sourceRoot": "src", 9 | "projectType": "application", 10 | "prefix": "app", 11 | "schematics": {}, 12 | "architect": { 13 | "build": { 14 | "builder": "@angular-devkit/build-angular:browser", 15 | "options": { 16 | "outputPath": "dist/angular-xstate", 17 | "index": "src/index.html", 18 | "main": "src/main.ts", 19 | "polyfills": "src/polyfills.ts", 20 | "tsConfig": "src/tsconfig.app.json", 21 | "assets": [ 22 | "src/favicon.ico", 23 | "src/assets" 24 | ], 25 | "styles": [ 26 | "src/styles.css" 27 | ], 28 | "scripts": [] 29 | }, 30 | "configurations": { 31 | "production": { 32 | "fileReplacements": [ 33 | { 34 | "replace": "src/environments/environment.ts", 35 | "with": "src/environments/environment.prod.ts" 36 | } 37 | ], 38 | "optimization": true, 39 | "outputHashing": "all", 40 | "sourceMap": false, 41 | "extractCss": true, 42 | "namedChunks": false, 43 | "aot": true, 44 | "extractLicenses": true, 45 | "vendorChunk": false, 46 | "buildOptimizer": true, 47 | "budgets": [ 48 | { 49 | "type": "initial", 50 | "maximumWarning": "2mb", 51 | "maximumError": "5mb" 52 | } 53 | ] 54 | } 55 | } 56 | }, 57 | "serve": { 58 | "builder": "@angular-devkit/build-angular:dev-server", 59 | "options": { 60 | "browserTarget": "angular-xstate:build" 61 | }, 62 | "configurations": { 63 | "production": { 64 | "browserTarget": "angular-xstate:build:production" 65 | } 66 | } 67 | }, 68 | "extract-i18n": { 69 | "builder": "@angular-devkit/build-angular:extract-i18n", 70 | "options": { 71 | "browserTarget": "angular-xstate:build" 72 | } 73 | }, 74 | "test": { 75 | "builder": "@angular-devkit/build-angular:karma", 76 | "options": { 77 | "main": "src/test.ts", 78 | "polyfills": "src/polyfills.ts", 79 | "tsConfig": "src/tsconfig.spec.json", 80 | "karmaConfig": "src/karma.conf.js", 81 | "styles": [ 82 | "src/styles.css" 83 | ], 84 | "scripts": [], 85 | "assets": [ 86 | "src/favicon.ico", 87 | "src/assets" 88 | ] 89 | } 90 | }, 91 | "lint": { 92 | "builder": "@angular-devkit/build-angular:tslint", 93 | "options": { 94 | "tsConfig": [ 95 | "src/tsconfig.app.json", 96 | "src/tsconfig.spec.json" 97 | ], 98 | "exclude": [ 99 | "**/node_modules/**" 100 | ] 101 | } 102 | } 103 | } 104 | }, 105 | "angular-xstate-e2e": { 106 | "root": "e2e/", 107 | "projectType": "application", 108 | "prefix": "", 109 | "architect": { 110 | "e2e": { 111 | "builder": "@angular-devkit/build-angular:protractor", 112 | "options": { 113 | "protractorConfig": "e2e/protractor.conf.js", 114 | "devServerTarget": "angular-xstate:serve" 115 | }, 116 | "configurations": { 117 | "production": { 118 | "devServerTarget": "angular-xstate:serve:production" 119 | } 120 | } 121 | }, 122 | "lint": { 123 | "builder": "@angular-devkit/build-angular:tslint", 124 | "options": { 125 | "tsConfig": "e2e/tsconfig.e2e.json", 126 | "exclude": [ 127 | "**/node_modules/**" 128 | ] 129 | } 130 | } 131 | } 132 | } 133 | }, 134 | "defaultProject": "angular-xstate" 135 | } -------------------------------------------------------------------------------- /browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /e2e/protractor.conf.js: -------------------------------------------------------------------------------- 1 | // Protractor configuration file, see link for more information 2 | // https://github.com/angular/protractor/blob/master/lib/config.ts 3 | 4 | const { SpecReporter } = require('jasmine-spec-reporter'); 5 | 6 | exports.config = { 7 | allScriptsTimeout: 11000, 8 | specs: [ 9 | './src/**/*.e2e-spec.ts' 10 | ], 11 | capabilities: { 12 | 'browserName': 'chrome' 13 | }, 14 | directConnect: true, 15 | baseUrl: 'http://localhost:4200/', 16 | framework: 'jasmine', 17 | jasmineNodeOpts: { 18 | showColors: true, 19 | defaultTimeoutInterval: 30000, 20 | print: function() {} 21 | }, 22 | onPrepare() { 23 | require('ts-node').register({ 24 | project: require('path').join(__dirname, './tsconfig.e2e.json') 25 | }); 26 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); 27 | } 28 | }; -------------------------------------------------------------------------------- /e2e/src/app.e2e-spec.ts: -------------------------------------------------------------------------------- 1 | import { AppPage } from './app.po'; 2 | import { browser, logging } from 'protractor'; 3 | 4 | describe('workspace-project App', () => { 5 | let page: AppPage; 6 | 7 | beforeEach(() => { 8 | page = new AppPage(); 9 | }); 10 | 11 | it('should display welcome message', () => { 12 | page.navigateTo(); 13 | expect(page.getTitleText()).toEqual('Welcome to angular-xstate!'); 14 | }); 15 | 16 | afterEach(async () => { 17 | // Assert that there are no errors emitted from the browser 18 | const logs = await browser.manage().logs().get(logging.Type.BROWSER); 19 | expect(logs).not.toContain(jasmine.objectContaining({ 20 | level: logging.Level.SEVERE, 21 | })); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /e2e/src/app.po.ts: -------------------------------------------------------------------------------- 1 | import { browser, by, element } from 'protractor'; 2 | 3 | export class AppPage { 4 | navigateTo() { 5 | return browser.get('/'); 6 | } 7 | 8 | getTitleText() { 9 | return element(by.css('app-root h1')).getText(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /e2e/tsconfig.e2e.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "module": "commonjs", 6 | "target": "es5", 7 | "types": [ 8 | "jasmine", 9 | "jasminewd2", 10 | "node" 11 | ] 12 | } 13 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-xstate", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve", 7 | "build": "ng build", 8 | "test": "ng test", 9 | "lint": "ng lint", 10 | "e2e": "ng e2e" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "~8.0.0", 15 | "@angular/common": "~8.0.0", 16 | "@angular/compiler": "~8.0.0", 17 | "@angular/core": "~8.0.0", 18 | "@angular/forms": "~8.0.0", 19 | "@angular/platform-browser": "~8.0.0", 20 | "@angular/platform-browser-dynamic": "~8.0.0", 21 | "@angular/router": "~8.0.0", 22 | "core-js": "^2.5.4", 23 | "rxjs": "~6.5.2", 24 | "tslib": "^1.9.0", 25 | "xstate": "4.6.1", 26 | "zone.js": "~0.9.1" 27 | }, 28 | "devDependencies": { 29 | "@angular-devkit/build-angular": "~0.800.0", 30 | "@angular/cli": "~8.0.2", 31 | "@angular/compiler-cli": "~8.0.0", 32 | "@angular/language-service": "~8.0.0", 33 | "@types/node": "~8.9.4", 34 | "@types/jasmine": "~2.8.8", 35 | "@types/jasminewd2": "~2.0.3", 36 | "codelyzer": "^5.0.1", 37 | "jasmine-core": "~2.99.1", 38 | "jasmine-spec-reporter": "~4.2.1", 39 | "karma": "~3.1.1", 40 | "karma-chrome-launcher": "~2.2.0", 41 | "karma-coverage-istanbul-reporter": "~2.0.1", 42 | "karma-jasmine": "~1.1.2", 43 | "karma-jasmine-html-reporter": "^0.2.2", 44 | "protractor": "~5.4.0", 45 | "ts-node": "~7.0.0", 46 | "tslint": "~5.11.0", 47 | "typescript": "~3.4.5" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { AuthCanLoad } from './auth/auth-can-load.service'; 4 | 5 | const routes: Routes = [ 6 | { 7 | path: '', 8 | loadChildren: () => import('./home/articles.module').then(mod => mod.ArticlesModule), 9 | canLoad: [AuthCanLoad] 10 | } 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forRoot(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class AppRoutingModule {} 18 | -------------------------------------------------------------------------------- /src/app/app.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanoslig/angular-xstate/7996f562f35374663b3ab5a9cc93a57c756a3c31/src/app/app.component.css -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed, async } from '@angular/core/testing'; 2 | import { RouterTestingModule } from '@angular/router/testing'; 3 | import { AppComponent } from './app.component'; 4 | 5 | describe('AppComponent', () => { 6 | beforeEach(async(() => { 7 | TestBed.configureTestingModule({ 8 | imports: [RouterTestingModule], 9 | declarations: [AppComponent] 10 | }).compileComponents(); 11 | })); 12 | 13 | it('should create the app', () => { 14 | const fixture = TestBed.createComponent(AppComponent); 15 | const app = fixture.debugElement.componentInstance; 16 | expect(app).toBeTruthy(); 17 | }); 18 | 19 | it(`should have as title 'angular-xstate'`, () => { 20 | const fixture = TestBed.createComponent(AppComponent); 21 | const app = fixture.debugElement.componentInstance; 22 | expect(app.title).toEqual('angular-xstate'); 23 | }); 24 | 25 | it('should render title in a h1 tag', () => { 26 | const fixture = TestBed.createComponent(AppComponent); 27 | fixture.detectChanges(); 28 | const compiled = fixture.debugElement.nativeElement; 29 | expect(compiled.querySelector('h1').textContent).toContain('Welcome to angular-xstate!'); 30 | }); 31 | }); 32 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent {} 9 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { BrowserModule } from '@angular/platform-browser'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { SharedModule } from './shared/shared.module'; 7 | import { AuthModule } from './auth/auth.module'; 8 | 9 | @NgModule({ 10 | declarations: [AppComponent], 11 | imports: [AuthModule, BrowserModule, AppRoutingModule, SharedModule], 12 | bootstrap: [AppComponent] 13 | }) 14 | export class AppModule {} 15 | -------------------------------------------------------------------------------- /src/app/auth/+xstate/auth-machine.config.ts: -------------------------------------------------------------------------------- 1 | import { MachineConfig } from 'xstate'; 2 | import { AuthSchema, AuthContext } from './auth-machine.schema'; 3 | import { AuthEvent } from './auth-machine.events'; 4 | 5 | export const context: AuthContext = { 6 | user: { 7 | email: '', 8 | token: '', 9 | username: '', 10 | bio: '', 11 | image: '' 12 | }, 13 | errors: [] 14 | }; 15 | 16 | export const authMachineConfig: MachineConfig< 17 | AuthContext, 18 | AuthSchema, 19 | AuthEvent 20 | > = { 21 | id: 'login', 22 | context, 23 | initial: 'boot', 24 | states: { 25 | boot: { 26 | on: { 27 | '': [ 28 | { target: 'loggedOut', cond: 'isLoggedOut' }, 29 | { target: 'loggedIn' } 30 | ] 31 | } 32 | }, 33 | loggedOut: { 34 | on: { 35 | SUBMIT: [ 36 | { 37 | target: 'loading' 38 | } 39 | ] 40 | } 41 | }, 42 | loggedIn: { 43 | type: 'final' 44 | }, 45 | requestErr: { 46 | on: { 47 | SUBMIT: 'loading' 48 | } 49 | }, 50 | loading: { 51 | invoke: { 52 | id: 'login', 53 | src: 'requestLogin' 54 | }, 55 | on: { 56 | SUCCESS: { 57 | target: 'loggedIn', 58 | actions: ['assignUser', 'loginSuccess'] 59 | }, 60 | FAILURE: { 61 | target: 'requestErr', 62 | actions: ['assignErrors'] 63 | } 64 | } 65 | } 66 | } 67 | }; 68 | -------------------------------------------------------------------------------- /src/app/auth/+xstate/auth-machine.events.ts: -------------------------------------------------------------------------------- 1 | import { User } from 'src/app/shared/api/types'; 2 | 3 | export class Init { 4 | readonly type = 'INIT'; 5 | } 6 | export class LoginSubmit { 7 | readonly type = 'SUBMIT'; 8 | constructor(public username: string, public password: string) {} 9 | } 10 | 11 | export class LoginFail { 12 | readonly type = 'FAILURE'; 13 | constructor(public errors: Errors) {} 14 | } 15 | 16 | export class LoginSuccess { 17 | readonly type = 'SUCCESS'; 18 | constructor(public userInfo: User) {} 19 | } 20 | 21 | export type AuthEvent = Init | LoginSubmit | LoginSuccess | LoginFail; 22 | 23 | export interface Errors { 24 | [key: string]: string; 25 | } 26 | -------------------------------------------------------------------------------- /src/app/auth/+xstate/auth-machine.schema.ts: -------------------------------------------------------------------------------- 1 | import { User } from 'src/app/shared/api/types'; 2 | 3 | export interface AuthSchema { 4 | states: { 5 | boot: {}; 6 | loggedOut: {}; 7 | loggedIn: {}; 8 | requestErr: {}; 9 | loading: {}; 10 | }; 11 | } 12 | 13 | export interface AuthContext { 14 | user: User; 15 | errors: string[]; 16 | } 17 | -------------------------------------------------------------------------------- /src/app/auth/+xstate/auth-machine.service.ts: -------------------------------------------------------------------------------- 1 | import { fromEventPattern, of } from 'rxjs'; 2 | import { 3 | interpret, 4 | Machine, 5 | MachineOptions, 6 | State, 7 | assign, 8 | EventObject 9 | } from 'xstate'; 10 | import { Injectable } from '@angular/core'; 11 | import { AuthService } from '../auth.service'; 12 | import { authMachineConfig } from './auth-machine.config'; 13 | import { AuthSchema, AuthContext } from './auth-machine.schema'; 14 | import { map, catchError } from 'rxjs/operators'; 15 | import { Router } from '@angular/router'; 16 | import { LoginSuccess, AuthEvent, LoginFail } from './auth-machine.events'; 17 | 18 | @Injectable() 19 | export class AuthMachine { 20 | authMachineOptions: Partial> = { 21 | services: { 22 | requestLogin: (_, event) => 23 | this.authService 24 | .login({ email: event.username, password: event.password }) 25 | .pipe( 26 | map(user => new LoginSuccess(user)), 27 | catchError(result => of(new LoginFail(result.error.errors))) 28 | ) 29 | }, 30 | guards: { 31 | isLoggedOut: () => !localStorage.getItem('jwtToken') 32 | }, 33 | actions: { 34 | assignUser: assign((_, event) => ({ 35 | user: event.userInfo 36 | })), 37 | assignErrors: assign((_, event) => ({ 38 | errors: Object.keys(event.errors || {}).map( 39 | key => `${key} ${event.errors[key]}` 40 | ) 41 | })), 42 | loginSuccess: (ctx, _) => { 43 | localStorage.setItem('jwtToken', ctx.user.token); 44 | this.router.navigateByUrl(''); 45 | } 46 | } 47 | }; 48 | 49 | private _authMachine = Machine( 50 | authMachineConfig 51 | ).withConfig(this.authMachineOptions); 52 | private service = interpret(this._authMachine, { devTools: true }).start(); 53 | 54 | authState$ = fromEventPattern<[State, EventObject]>( 55 | handler => { 56 | return this.service.onTransition(handler); 57 | }, 58 | (_, service) => service.stop() 59 | ).pipe(map(([state, _]) => state)); 60 | 61 | send(event: AuthEvent) { 62 | this.service.send(event); 63 | } 64 | 65 | constructor(private authService: AuthService, private router: Router) {} 66 | } 67 | -------------------------------------------------------------------------------- /src/app/auth/auth-can-load.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Router, CanLoad } from '@angular/router'; 3 | 4 | @Injectable() 5 | export class AuthCanLoad implements CanLoad { 6 | constructor(private router: Router) {} 7 | 8 | canLoad(): boolean { 9 | if (!localStorage.getItem('jwtToken')) { 10 | this.router.navigate(['/login']); 11 | return false; 12 | } 13 | return true; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/app/auth/auth-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { LoginComponent } from './login.component'; 4 | 5 | const routes: Routes = [ 6 | { 7 | path: 'login', 8 | component: LoginComponent 9 | } 10 | ]; 11 | 12 | @NgModule({ 13 | imports: [RouterModule.forChild(routes)], 14 | exports: [RouterModule] 15 | }) 16 | export class AuthRoutingModule {} 17 | -------------------------------------------------------------------------------- /src/app/auth/auth.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | import { AuthRoutingModule } from './auth-routing.module'; 5 | import { LoginComponent } from './login.component'; 6 | import { ReactiveFormsModule } from '@angular/forms'; 7 | import { AuthMachine } from './+xstate/auth-machine.service'; 8 | import { AuthService } from './auth.service'; 9 | import { SharedModule } from '../shared/shared.module'; 10 | import { AuthCanLoad } from './auth-can-load.service'; 11 | 12 | @NgModule({ 13 | declarations: [LoginComponent], 14 | imports: [CommonModule, ReactiveFormsModule, AuthRoutingModule, SharedModule], 15 | providers: [AuthMachine, AuthService, AuthCanLoad] 16 | }) 17 | export class AuthModule {} 18 | -------------------------------------------------------------------------------- /src/app/auth/auth.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { Observable } from 'rxjs'; 3 | import { map } from 'rxjs/operators'; 4 | import { ApiService } from '../shared/api/api.service'; 5 | import { User } from '../shared/api/types'; 6 | 7 | @Injectable() 8 | export class AuthService { 9 | constructor(private apiService: ApiService) {} 10 | 11 | user(): Observable<{ user: User }> { 12 | return this.apiService.get('/user'); 13 | } 14 | 15 | login(credentials: { email: string; password: string }): Observable { 16 | return this.apiService 17 | .post('/users/login', { user: credentials }) 18 | .pipe(map(r => r.user)); 19 | } 20 | 21 | register(credentials: { 22 | username: string; 23 | email: string; 24 | password: string; 25 | }): Observable { 26 | return this.apiService 27 | .post('/users', { user: credentials }) 28 | .pipe(map(r => r.user)); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/app/auth/login.component.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |

Login

6 |
7 |
8 |
9 | 10 |
11 | Email format is not valid 12 |
13 |
14 | Email is required 15 |
16 |
17 |
18 | 24 |
25 | Password is required 26 |
27 |
28 | 35 |
36 |
37 | 38 |
39 |
40 |
41 |
42 | -------------------------------------------------------------------------------- /src/app/auth/login.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { LoginComponent } from './login.component'; 4 | 5 | describe('LoginComponent', () => { 6 | let component: LoginComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [LoginComponent] 12 | }).compileComponents(); 13 | })); 14 | 15 | beforeEach(() => { 16 | fixture = TestBed.createComponent(LoginComponent); 17 | component = fixture.componentInstance; 18 | fixture.detectChanges(); 19 | }); 20 | 21 | it('should create', () => { 22 | expect(component).toBeTruthy(); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /src/app/auth/login.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | import { 3 | FormBuilder, 4 | FormGroup, 5 | Validators, 6 | AbstractControl 7 | } from '@angular/forms'; 8 | import { Observable } from 'rxjs'; 9 | import { AuthMachine } from './+xstate/auth-machine.service'; 10 | import { map } from 'rxjs/operators'; 11 | import { LoginSubmit } from './+xstate/auth-machine.events'; 12 | 13 | @Component({ 14 | selector: 'app-login', 15 | templateUrl: './login.component.html', 16 | changeDetection: ChangeDetectionStrategy.OnPush 17 | }) 18 | export class LoginComponent implements OnInit { 19 | loginForm: FormGroup; 20 | emailCtr: AbstractControl; 21 | passwordCtr: AbstractControl; 22 | loading$: Observable; 23 | 24 | constructor( 25 | private fb: FormBuilder, 26 | private authMachineService: AuthMachine 27 | ) {} 28 | 29 | ngOnInit() { 30 | this.loginForm = this.fb.group({ 31 | email: [ 32 | { value: '', disabled: false }, 33 | [Validators.email, Validators.required] 34 | ], 35 | password: [{ value: '', disabled: false }, [Validators.required]] 36 | }); 37 | this.emailCtr = this.loginForm.get('email'); 38 | this.passwordCtr = this.loginForm.get('password'); 39 | 40 | this.loading$ = this.authMachineService.authState$.pipe( 41 | map(state => state.matches('loading')) 42 | ); 43 | } 44 | 45 | submitForm() { 46 | this.authMachineService.send( 47 | new LoginSubmit(this.emailCtr.value, this.passwordCtr.value) 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/app/home/article-list.component.html: -------------------------------------------------------------------------------- 1 |

2 | article-list works! 3 |

4 | -------------------------------------------------------------------------------- /src/app/home/article-list.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | 3 | import { ArticleListComponent } from './article-list.component'; 4 | 5 | describe('ArticleListComponent', () => { 6 | let component: ArticleListComponent; 7 | let fixture: ComponentFixture; 8 | 9 | beforeEach(async(() => { 10 | TestBed.configureTestingModule({ 11 | declarations: [ ArticleListComponent ] 12 | }) 13 | .compileComponents(); 14 | })); 15 | 16 | beforeEach(() => { 17 | fixture = TestBed.createComponent(ArticleListComponent); 18 | component = fixture.componentInstance; 19 | fixture.detectChanges(); 20 | }); 21 | 22 | it('should create', () => { 23 | expect(component).toBeTruthy(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/app/home/article-list.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-article-list', 5 | templateUrl: './article-list.component.html', 6 | changeDetection: ChangeDetectionStrategy.OnPush 7 | }) 8 | export class ArticleListComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit() { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/app/home/articles-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { Routes, RouterModule } from '@angular/router'; 3 | import { ArticleListComponent } from './article-list.component'; 4 | 5 | const routes: Routes = [ 6 | { 7 | path: '', 8 | pathMatch: 'full', 9 | component: ArticleListComponent 10 | } 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forChild(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class ArticlesRoutingModule {} 18 | -------------------------------------------------------------------------------- /src/app/home/articles.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | import { ArticlesRoutingModule } from './articles-routing.module'; 5 | import { ArticleListComponent } from './article-list.component'; 6 | 7 | @NgModule({ 8 | declarations: [ArticleListComponent], 9 | imports: [ 10 | CommonModule, 11 | ArticlesRoutingModule 12 | ] 13 | }) 14 | export class ArticlesModule { } 15 | -------------------------------------------------------------------------------- /src/app/shared/api/api.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { ApiService } from './api.service'; 5 | import { HttpClientModule } from '@angular/common/http'; 6 | 7 | @NgModule({ 8 | imports: [CommonModule, HttpClientModule], 9 | providers: [ApiService] 10 | }) 11 | export class ApiModule {} 12 | -------------------------------------------------------------------------------- /src/app/shared/api/api.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { environment } from 'src/environments/environment'; 5 | 6 | @Injectable() 7 | export class ApiService { 8 | constructor(private http: HttpClient) {} 9 | 10 | get(url: string, params: HttpParams = new HttpParams()): Observable { 11 | return this.http.get(`${environment.api_url}${url}`, { headers: this.headers, params }); 12 | } 13 | 14 | post(url: string, data: Object = {}): Observable { 15 | return this.http.post(`${environment.api_url}${url}`, JSON.stringify(data), { headers: this.headers }); 16 | } 17 | 18 | put(url: string, data: Object = {}): Observable { 19 | return this.http.put(`${environment.api_url}${url}`, JSON.stringify(data), { headers: this.headers }); 20 | } 21 | 22 | delete(url: string): Observable { 23 | return this.http.delete(`${environment.api_url}${url}`, { headers: this.headers }); 24 | } 25 | 26 | get headers(): HttpHeaders { 27 | const headersConfig = { 28 | 'Content-Type': 'application/json', 29 | Accept: 'application/json' 30 | }; 31 | 32 | return new HttpHeaders(headersConfig); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/app/shared/api/types.ts: -------------------------------------------------------------------------------- 1 | export interface Profile { 2 | username: string; 3 | bio: string; 4 | image: string; 5 | following: boolean; 6 | loading: boolean; 7 | } 8 | 9 | export interface ArticleData { 10 | slug: string; 11 | title: string; 12 | description: string; 13 | body: string; 14 | tagList: string[]; 15 | createdAt: string; 16 | updatedAt: string; 17 | favorited: boolean; 18 | favoritesCount: number; 19 | author: Profile; 20 | } 21 | 22 | export interface User { 23 | email: string; 24 | token: string; 25 | username: string; 26 | bio: string; 27 | image: string; 28 | } 29 | -------------------------------------------------------------------------------- /src/app/shared/list-errors/list-errors.component.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • 3 | {{ error }} 4 |
  • 5 |
-------------------------------------------------------------------------------- /src/app/shared/list-errors/list-errors.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core'; 2 | import { Subject, Observable } from 'rxjs'; 3 | import { map } from 'rxjs/operators'; 4 | import { AuthMachine } from 'src/app/auth/+xstate/auth-machine.service'; 5 | 6 | @Component({ 7 | selector: 'app-list-errors', 8 | templateUrl: './list-errors.component.html', 9 | changeDetection: ChangeDetectionStrategy.OnPush 10 | }) 11 | export class ListErrorsComponent implements OnInit, OnDestroy { 12 | errors$: Observable; 13 | unsubscribe$: Subject = new Subject(); 14 | 15 | constructor(private authMachineService: AuthMachine) {} 16 | 17 | ngOnInit() { 18 | this.errors$ = this.authMachineService.authState$.pipe(map(state => state.context.errors)); 19 | } 20 | 21 | ngOnDestroy() { 22 | this.unsubscribe$.next(); 23 | this.unsubscribe$.complete(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/app/shared/shared.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { ApiModule } from './api/api.module'; 4 | import { ListErrorsComponent } from './list-errors/list-errors.component'; 5 | 6 | @NgModule({ 7 | declarations: [ListErrorsComponent], 8 | imports: [ 9 | CommonModule, 10 | ApiModule 11 | ], 12 | exports: [ListErrorsComponent] 13 | }) 14 | export class SharedModule { } 15 | -------------------------------------------------------------------------------- /src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanoslig/angular-xstate/7996f562f35374663b3ab5a9cc93a57c756a3c31/src/assets/.gitkeep -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true, 3 | api_url: 'https://conduit.productionready.io/api' 4 | }; 5 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false, 7 | api_url: 'https://conduit.productionready.io/api' 8 | }; 9 | 10 | /* 11 | * For easier debugging in development mode, you can import the following file 12 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 13 | * 14 | * This import should be commented out in production mode because it will have a negative impact 15 | * on performance if an error is thrown. 16 | */ 17 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 18 | -------------------------------------------------------------------------------- /src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefanoslig/angular-xstate/7996f562f35374663b3ab5a9cc93a57c756a3c31/src/favicon.ico -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | AngularXstate 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 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 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | /*************************************************************************************************** 56 | * Zone JS is required by default for Angular itself. 57 | */ 58 | import 'zone.js/dist/zone'; // Included with Angular CLI. 59 | 60 | 61 | /*************************************************************************************************** 62 | * APPLICATION IMPORTS 63 | */ 64 | -------------------------------------------------------------------------------- /src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/app", 5 | "types": [] 6 | }, 7 | "exclude": [ 8 | "test.ts", 9 | "**/*.spec.ts" 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "test.ts", 12 | "polyfills.ts" 13 | ], 14 | "include": [ 15 | "**/*.spec.ts", 16 | "**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [ 5 | true, 6 | "attribute", 7 | "app", 8 | "camelCase" 9 | ], 10 | "component-selector": [ 11 | true, 12 | "element", 13 | "app", 14 | "kebab-case" 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "rulesDirectory": [ 3 | "codelyzer" 4 | ], 5 | "rules": { 6 | "arrow-return-shorthand": true, 7 | "callable-types": true, 8 | "class-name": true, 9 | "comment-format": [ 10 | true, 11 | "check-space" 12 | ], 13 | "curly": true, 14 | "deprecation": { 15 | "severity": "warn" 16 | }, 17 | "eofline": true, 18 | "forin": true, 19 | "import-blacklist": [ 20 | true, 21 | "rxjs/Rx" 22 | ], 23 | "import-spacing": true, 24 | "indent": [ 25 | true, 26 | "spaces" 27 | ], 28 | "interface-over-type-literal": true, 29 | "label-position": true, 30 | "max-line-length": [ 31 | true, 32 | 140 33 | ], 34 | "member-access": false, 35 | "member-ordering": [ 36 | true, 37 | { 38 | "order": [ 39 | "static-field", 40 | "instance-field", 41 | "static-method", 42 | "instance-method" 43 | ] 44 | } 45 | ], 46 | "no-arg": true, 47 | "no-bitwise": true, 48 | "no-console": [ 49 | true, 50 | "debug", 51 | "info", 52 | "time", 53 | "timeEnd", 54 | "trace" 55 | ], 56 | "no-construct": true, 57 | "no-debugger": true, 58 | "no-duplicate-super": true, 59 | "no-empty": false, 60 | "no-empty-interface": true, 61 | "no-eval": true, 62 | "no-inferrable-types": [ 63 | true, 64 | "ignore-params" 65 | ], 66 | "no-misused-new": true, 67 | "no-non-null-assertion": true, 68 | "no-redundant-jsdoc": true, 69 | "no-shadowed-variable": true, 70 | "no-string-literal": false, 71 | "no-string-throw": true, 72 | "no-switch-case-fall-through": true, 73 | "no-trailing-whitespace": true, 74 | "no-unnecessary-initializer": true, 75 | "no-unused-expression": true, 76 | "no-use-before-declare": true, 77 | "no-var-keyword": true, 78 | "object-literal-sort-keys": false, 79 | "one-line": [ 80 | true, 81 | "check-open-brace", 82 | "check-catch", 83 | "check-else", 84 | "check-whitespace" 85 | ], 86 | "prefer-const": true, 87 | "quotemark": [ 88 | true, 89 | "single" 90 | ], 91 | "radix": true, 92 | "semicolon": [ 93 | true, 94 | "always" 95 | ], 96 | "triple-equals": [ 97 | true, 98 | "allow-null-check" 99 | ], 100 | "typedef-whitespace": [ 101 | true, 102 | { 103 | "call-signature": "nospace", 104 | "index-signature": "nospace", 105 | "parameter": "nospace", 106 | "property-declaration": "nospace", 107 | "variable-declaration": "nospace" 108 | } 109 | ], 110 | "unified-signatures": true, 111 | "variable-name": false, 112 | "whitespace": [ 113 | true, 114 | "check-branch", 115 | "check-decl", 116 | "check-operator", 117 | "check-separator", 118 | "check-type" 119 | ], 120 | "no-output-on-prefix": true, 121 | "no-inputs-metadata-property": true, 122 | "no-outputs-metadata-property": true, 123 | "no-host-metadata-property": true, 124 | "no-input-rename": true, 125 | "no-output-rename": true, 126 | "use-lifecycle-interface": true, 127 | "use-pipe-transform-interface": true, 128 | "component-class-suffix": true, 129 | "directive-class-suffix": true 130 | } 131 | } 132 | --------------------------------------------------------------------------------