Skip to content

Commit

Permalink
Add tslint rules and target es2017
Browse files Browse the repository at this point in the history
 
- curly: true, ignore-same-line
- newline-before-return: true
- sort-object-literal-keys: true
  • Loading branch information
Hetty82 committed Apr 28, 2018
1 parent 7110001 commit 869dc41
Show file tree
Hide file tree
Showing 26 changed files with 61 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import { environment } from '../environments/environment'
StoreModule.forRoot(fromStore.reducers, { metaReducers: fromStore.metaReducers }),
// DevTools Instrumentation must be imported after importing StoreModule
StoreDevtoolsModule.instrument({
name: 'h82 Games - NgRx DevTools',
logOnly: environment.production,
name: 'h82 Games - NgRx DevTools',
}),
StoreRouterConnectingModule.forRoot({ stateKey: 'router' }),

Expand Down
7 changes: 6 additions & 1 deletion src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,28 @@ import * as fromComponents from './core/components'
export const routes: Routes = [
{
path: '',
redirectTo: '/games',

pathMatch: 'full',
redirectTo: '/games',
},
{
path: 'login',

component: fromContainers.LoginComponent,
},
{
path: 'games',

component: fromContainers.GamesComponent,
},
{
path: 'friday',

loadChildren: './friday/friday.module#FridayModule',
},
{
path: '**',

component: fromComponents.NotFoundComponent,
},
]
2 changes: 1 addition & 1 deletion src/app/core/components/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Component } from '@angular/core'

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.sass'],
templateUrl: './app.component.html',
})
export class AppComponent {
title = 'Games'
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/components/layout/layout.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Component, OnInit, Input } from '@angular/core'

@Component({
selector: 'app-layout',
templateUrl: './layout.component.html',
styleUrls: ['./layout.component.sass'],
templateUrl: './layout.component.html',
})
export class LayoutComponent implements OnInit {
@Input() title: string
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/components/not-found/not-found.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Component } from '@angular/core'

@Component({
selector: 'app-not-found',
templateUrl: './not-found.component.html',
styleUrls: ['./not-found.component.sass'],
templateUrl: './not-found.component.html',
})
export class NotFoundComponent {
}
2 changes: 1 addition & 1 deletion src/app/core/containers/games/games.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import * as fromRoot from '../../../store'

@Component({
selector: 'app-games',
templateUrl: './games.component.html',
styleUrls: ['./games.component.sass'],
templateUrl: './games.component.html',
})
export class GamesComponent implements OnInit {
games$ = this.store.pipe(select(fromRoot.getGames))
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/containers/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as fromRoot from '../../../store'

@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.sass'],
templateUrl: './header.component.html',
})
export class HeaderComponent implements OnInit {
@Input() title: string
Expand Down
4 changes: 1 addition & 3 deletions src/app/core/containers/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Component, OnInit } from '@angular/core'
import { Store, select } from '@ngrx/store'

import { take } from 'rxjs/operators'


import * as fromRoot from '../../../store'


@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.sass'],
templateUrl: './login.component.html',
})
export class LoginComponent implements OnInit {
users$ = this.store.pipe(select(fromRoot.getUsers))
Expand Down
10 changes: 5 additions & 5 deletions src/app/core/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import * as fromServices from './services'


@NgModule({
imports: [
CommonModule,
RouterModule,
SharedModule,
],
declarations: [
...fromComponents.components,
...fromContainers.containers,
],
exports: [
fromComponents.AppComponent,
],
imports: [
CommonModule,
RouterModule,
SharedModule,
],
})
export class CoreModule {
static forRoot() {
Expand Down
6 changes: 4 additions & 2 deletions src/app/core/models/game.interface.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
export interface Game {
id: number
name: string

accessible: boolean
name: string
}

export const createTestGame = (id = 1): Game => {
return {
id,
name: 'Test Game',

accessible: true,
name: 'Test Game',
}
}
6 changes: 4 additions & 2 deletions src/app/core/models/user.interface.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
export interface User {
id: number
name: string

email: string
name: string
}

export const createTestUser = (id = 1): User => {
return {
id,
name: 'Test User',

email: '[email protected]',
name: 'Test User',
}
}

1 change: 1 addition & 0 deletions src/app/core/services/games.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class GamesService {

getGames() {
const url = environment.api.games

return this.http.get(url) as Observable<Game[]>
}
}
1 change: 1 addition & 0 deletions src/app/core/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class UserService {

getUsers() {
const url = environment.api.users

return this.http.get(url) as Observable<User[]>
}
}
4 changes: 2 additions & 2 deletions src/app/core/store/reducers/games.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ export function reducer(state: State = initialState, action: fromGames.GamesActi
...state,
entities,
ids,
loading: false,
loaded: true,
loading: false,
}
}

case fromGames.LOAD_GAMES_FAIL: {
return {
...state,
loading: false,
loaded: false,
loading: false,
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/core/store/reducers/user.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ export function reducer(state: State = initialState, action: fromUser.UserAction
...state,
entities,
ids,
loading: false,
loaded: true,
loading: false,
}
}

case fromUser.LOAD_USERS_FAIL: {
return {
...state,
loading: false,
loaded: false,
loading: false,
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/friday/components/friday/friday.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Component, OnInit } from '@angular/core'

@Component({
selector: 'app-fr-friday',
templateUrl: './friday.component.html',
styleUrls: ['./friday.component.sass'],
templateUrl: './friday.component.html',
})
export class FridayComponent implements OnInit {
constructor() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { FridayGameDetails } from '../../models/friday-game-details.model'

@Component({
selector: 'app-fr-active-game',
templateUrl: './active-game.component.html',
styleUrls: ['./active-game.component.sass'],
templateUrl: './active-game.component.html',
})
export class ActiveGameComponent implements OnInit, OnDestroy {
activeId: number
Expand Down
2 changes: 1 addition & 1 deletion src/app/friday/containers/games/games.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { User } from '../../../core/models/user.interface'

@Component({
selector: 'app-fr-games',
templateUrl: './games.component.html',
styleUrls: ['./games.component.sass'],
templateUrl: './games.component.html',
})
export class GamesComponent implements OnInit, OnDestroy {
activeGameId: GameId
Expand Down
14 changes: 7 additions & 7 deletions src/app/friday/friday.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import * as fromStore from './store'


@NgModule({
declarations: [
...fromComponents.components,
...fromContainers.containers,
],
exports: [
fromComponents.FridayComponent,
],
imports: [
// Angular
CommonModule,
Expand All @@ -28,13 +35,6 @@ import * as fromStore from './store'
// Other
SharedModule,
],
declarations: [
...fromComponents.components,
...fromContainers.containers,
],
exports: [
fromComponents.FridayComponent,
],
providers: fromServices.services,
})
export class FridayModule { }
2 changes: 2 additions & 0 deletions src/app/friday/friday.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import * as fromComponents from './components'
export const routes: Routes = [
{
path: '',

component: fromComponents.FridayComponent,
},
{
path: ':gameId',

component: fromContainers.ActiveGameComponent,
},
]
6 changes: 6 additions & 0 deletions src/app/friday/services/games.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class GamesService {

createGame(game: FridayGame) {
const url = environment.api.friday.games

return this.http.post(url, game).pipe(
delay(1000),
) as Observable<FridayGame>
Expand All @@ -26,34 +27,39 @@ export class GamesService {
createGameDetails(gameId: GameId) {
const url = environment.api.friday.gameDetails
const body = new FridayGameDetails(gameId)

return this.http.post(url, body).pipe(
delay(1000),
) as Observable<FridayGameDetails>
}

deleteGame(gameId: GameId) {
const url = environment.api.friday.games + '/' + gameId

return this.http.delete(url).pipe(
delay(1000),
) as Observable<GameId>
}

deleteGameDetails(gameId: GameId) {
const url = environment.api.friday.gameDetails + '/' + gameId

return this.http.delete(url).pipe(
delay(1000),
) as Observable<GameId>
}

getGamesByUser(userId: number) {
const url = environment.api.friday.games + `?userId=${userId}`

return this.http.get(url).pipe(
delay(1000),
) as Observable<FridayGame[]>
}

getGameDetails(gameId: GameId) {
const url = environment.api.friday.gameDetails + '/' + gameId

return this.http.get(url).pipe(
delay(1000),
) as Observable<FridayGameDetails>
Expand Down
4 changes: 2 additions & 2 deletions src/app/friday/store/reducers/games.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export function reducer(state: State = initialState, action: fromGames.GamesActi
return {
...state,
error: action.payload,
loading: false,
loaded: false,
loading: false,
}
}

Expand All @@ -130,8 +130,8 @@ export function reducer(state: State = initialState, action: fromGames.GamesActi
entities,
error: null,
ids,
loading: false,
loaded: true,
loading: false,
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import * as fromComponents from './components'


@NgModule({
imports: [
CommonModule,
],
declarations: [
...fromComponents.components,
],
exports: [
...fromComponents.components,
],
imports: [
CommonModule,
],
})
export class SharedModule { }
3 changes: 2 additions & 1 deletion src/app/store/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ export class CustomRouterStateSerializer implements fromRouter.RouterStateSerial
serialize(routerState: RouterStateSnapshot): RouterStateUrl {
let route = routerState.root

while (route.firstChild)
while (route.firstChild) {
route = route.firstChild
}

const { url, root: { queryParams } } = routerState
const { params } = route
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"moduleResolution": "node",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"target": "es5",
"target": "es2017",
"typeRoots": [
"node_modules/@types"
],
Expand Down
Loading

0 comments on commit 869dc41

Please sign in to comment.