diff --git a/jest/tests-setup.ts b/jest/tests-setup.ts index d8d49d61..7aaa4af8 100644 --- a/jest/tests-setup.ts +++ b/jest/tests-setup.ts @@ -1,10 +1,14 @@ +// TODO: Should be able to remove this once dev dependencies are hoisted to the workspace +// tslint:disable:no-implicit-dependencies import 'core-js/es6/reflect'; import 'core-js/es7/reflect'; import 'zone.js'; -import 'zone.js/dist/proxy'; -import 'zone.js/dist/sync-test'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; +import 'zone.js/dist/proxy'; +import 'zone.js/dist/sync-test'; +// This must be loaded in after ZoneJS +// tslint:disable-next-line:ordered-imports import 'jest-zone-patch'; import { TestBed } from '@angular/core/testing'; diff --git a/package.json b/package.json index 24e5ada9..eb61db51 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "clean:workspace-deps": "rimraf node_modules", "clean:package-deps": "rimraf packages/*/node_modules", "clean:coverage": "rimraf coverage", - "lint": "npm-run-all -p lint:*", + "lint": "tslint -p tsconfig.json", "lint:packages": "lerna run lint", "lint:prettier": "prettier -l \"**/*.*(ts|js|css|scss|json|md)\"", "test": "jest --coverage", @@ -31,14 +31,17 @@ "@commitlint/config-conventional": "7.0.1", "@commitlint/prompt-cli": "7.0.0", "@types/jest": "23.1.6", + "codelyzer": "4.4.2", "husky": "0.14.3", "jest": "23.4.1", "jest-junit": "5.1.0", "jest-preset-angular": "5.2.3", + "jest-zone-patch": "0.0.8", "lerna": "2.11.0", "lint-staged": "7.2.0", "npm-run-all": "4.1.3", "prettier": "1.13.7", - "rimraf": "2.6.2" + "rimraf": "2.6.2", + "tslint": "5.11.0" } } diff --git a/packages/example-app/circle.yml b/packages/example-app/circle.yml deleted file mode 100644 index 74094de1..00000000 --- a/packages/example-app/circle.yml +++ /dev/null @@ -1,15 +0,0 @@ -machine: - node: - version: 6.9.5 - -dependencies: - # Circle CI's preinstalled yarn doesn't work with @angular/cli. Never versions - # of yarn do. - pre: - - curl -o- -L https://yarnpkg.com/install.sh | bash - override: - - yarn - -test: - override: - - yarn test diff --git a/packages/example-app/package.json b/packages/example-app/package.json index 0e49a12b..5bf9de96 100644 --- a/packages/example-app/package.json +++ b/packages/example-app/package.json @@ -37,10 +37,8 @@ "@angular/compiler-cli": "^4.1.0", "@types/node": "~6.0.71", "@types/redux-logger": "^3.0.0", - "codelyzer": "~3.0.1", "protractor": "~5.1.1", "ts-node": "~3.0.2", - "tslint": "~5.1.0", "typescript": "^2.4.1" } } diff --git a/packages/example-app/src/app/animals/animal-list/component.spec.ts b/packages/example-app/src/app/animals/animal-list/component.spec.ts index e5cf28be..f0d7a71a 100644 --- a/packages/example-app/src/app/animals/animal-list/component.spec.ts +++ b/packages/example-app/src/app/animals/animal-list/component.spec.ts @@ -1,9 +1,9 @@ import { Component, Input } from '@angular/core'; -import { TestBed, async } from '@angular/core/testing'; +import { async, TestBed } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; -import { AnimalListComponent } from './component'; import { CoreModule } from '../../core/module'; import { AnimalType } from '../model'; +import { AnimalListComponent } from './component'; @Component({ selector: 'zoo-animal', template: '' }) class MockAnimalComponent { @@ -19,7 +19,7 @@ xdescribe('AnimalListComponent', () => { }).compileComponents(); })); - it(`should have as title 'Welcome to the Zoo'`, async(() => { + it("should have as title 'Welcome to the Zoo'", async(() => { const fixture = TestBed.createComponent(AnimalListComponent); const animalList = fixture.debugElement.componentInstance; diff --git a/packages/example-app/src/app/animals/animal-list/component.ts b/packages/example-app/src/app/animals/animal-list/component.ts index 98a11ea7..2f4487ed 100644 --- a/packages/example-app/src/app/animals/animal-list/component.ts +++ b/packages/example-app/src/app/animals/animal-list/component.ts @@ -1,6 +1,6 @@ -import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { Observable } from 'rxjs/Observable'; -import { IAnimal } from '../model'; +import { Animal } from '../model'; @Component({ selector: 'zoo-animal-list', @@ -11,14 +11,14 @@ import { IAnimal } from '../model'; export class AnimalListComponent { @Input() animalsName: string; @Input() animalType: string; - @Input() animals: Observable; + @Input() animals: Observable; @Input() loading: Observable; @Input() error: Observable; // Since we're observing an array of items, we need to set up a 'trackBy' // parameter so Angular doesn't tear down and rebuild the list's DOM every // time there's an update. - getKey(_, animal: IAnimal) { + getKey(_, animal: Animal) { return animal.id; } } diff --git a/packages/example-app/src/app/animals/animal/component.spec.ts b/packages/example-app/src/app/animals/animal/component.spec.ts index 21626611..932c9676 100644 --- a/packages/example-app/src/app/animals/animal/component.spec.ts +++ b/packages/example-app/src/app/animals/animal/component.spec.ts @@ -1,11 +1,11 @@ -import { async, TestBed } from '@angular/core/testing'; import { - NgReduxTestingModule, MockNgRedux, + NgReduxTestingModule, } from '@angular-redux/store/testing'; -import { AnimalComponent } from './component'; -import { CoreModule } from '../../core/module'; +import { async, TestBed } from '@angular/core/testing'; import 'rxjs/add/operator/toArray'; +import { CoreModule } from '../../core/module'; +import { AnimalComponent } from './component'; xdescribe('AnimalComponent', () => { let fixture; diff --git a/packages/example-app/src/app/animals/animal/component.ts b/packages/example-app/src/app/animals/animal/component.ts index f2e89bb2..930cc6f1 100644 --- a/packages/example-app/src/app/animals/animal/component.ts +++ b/packages/example-app/src/app/animals/animal/component.ts @@ -1,11 +1,11 @@ -import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; import { dispatch, select, select$, WithSubStore } from '@angular-redux/store'; +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; import { Observable } from 'rxjs/Observable'; +import { Animal } from '../model'; import { animalComponentReducer } from './reducers'; -import { IAnimal } from '../model'; -export const toSubTotal = (obs$: Observable): Observable => +export const toSubTotal = (obs$: Observable): Observable => obs$.map(s => s.ticketPrice * s.tickets); /** diff --git a/packages/example-app/src/app/animals/animal/reducers.ts b/packages/example-app/src/app/animals/animal/reducers.ts index 770d288e..64e2ada8 100644 --- a/packages/example-app/src/app/animals/animal/reducers.ts +++ b/packages/example-app/src/app/animals/animal/reducers.ts @@ -1,4 +1,4 @@ -import { Reducer, Action } from 'redux'; +import { Action, Reducer } from 'redux'; import { AnimalComponent } from './component'; export const ticketsReducer: Reducer = ( diff --git a/packages/example-app/src/app/animals/api/actions.ts b/packages/example-app/src/app/animals/api/actions.ts index 5d98d50e..5dbc1d69 100644 --- a/packages/example-app/src/app/animals/api/actions.ts +++ b/packages/example-app/src/app/animals/api/actions.ts @@ -1,10 +1,10 @@ -import { Injectable } from '@angular/core'; import { dispatch } from '@angular-redux/store'; +import { Injectable } from '@angular/core'; import { FluxStandardAction } from 'flux-standard-action'; -import { IAnimal, AnimalType } from '../model'; +import { Animal, AnimalType } from '../model'; // Flux-standard-action gives us stronger typing of our actions. -type Payload = IAnimal[]; +type Payload = Animal[]; interface MetaData { animalType: AnimalType; } diff --git a/packages/example-app/src/app/animals/api/epics.ts b/packages/example-app/src/app/animals/api/epics.ts index 837582a0..d1035997 100644 --- a/packages/example-app/src/app/animals/api/epics.ts +++ b/packages/example-app/src/app/animals/api/epics.ts @@ -1,19 +1,19 @@ import { Injectable } from '@angular/core'; -import { Epic, createEpicMiddleware } from 'redux-observable'; -import { of } from 'rxjs/observable/of'; +import { createEpicMiddleware, Epic } from 'redux-observable'; import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/map'; import 'rxjs/add/operator/do'; +import 'rxjs/add/operator/map'; import 'rxjs/add/operator/startWith'; +import { of } from 'rxjs/observable/of'; -import { IAppState } from '../../store/model'; +import { AppState } from '../../store/model'; import { AnimalType } from '../model'; import { AnimalAPIAction, AnimalAPIActions } from './actions'; import { AnimalAPIService } from './service'; const animalsNotAlreadyFetched = ( animalType: AnimalType, - state: IAppState, + state: AppState, ): boolean => !( state[animalType] && @@ -32,13 +32,13 @@ export class AnimalAPIEpics { private actions: AnimalAPIActions, ) {} - public createEpic(animalType: AnimalType) { + createEpic(animalType: AnimalType) { return createEpicMiddleware(this.createLoadAnimalEpic(animalType)); } private createLoadAnimalEpic( animalType: AnimalType, - ): Epic { + ): Epic { return (action$, store) => action$ .ofType(AnimalAPIActions.LOAD_ANIMALS) diff --git a/packages/example-app/src/app/animals/api/reducer.ts b/packages/example-app/src/app/animals/api/reducer.ts index c6a08237..3ea3b249 100644 --- a/packages/example-app/src/app/animals/api/reducer.ts +++ b/packages/example-app/src/app/animals/api/reducer.ts @@ -1,9 +1,9 @@ -import { AnimalAPIAction, AnimalAPIActions } from './actions'; -import { IAnimalList, AnimalType } from '../model'; import { indexBy, prop } from 'ramda'; import { Action } from 'redux'; +import { AnimalList, AnimalType } from '../model'; +import { AnimalAPIAction, AnimalAPIActions } from './actions'; -const INITIAL_STATE: IAnimalList = { +const INITIAL_STATE: AnimalList = { items: {}, loading: false, error: null, @@ -13,9 +13,9 @@ const INITIAL_STATE: IAnimalList = { // that only responds to actions for that particular animal type. export function createAnimalAPIReducer(animalType: AnimalType) { return function animalReducer( - state: IAnimalList = INITIAL_STATE, + state: AnimalList = INITIAL_STATE, a: Action, - ): IAnimalList { + ): AnimalList { const action = a as AnimalAPIAction; if (!action.meta || action.meta.animalType !== animalType) { return state; diff --git a/packages/example-app/src/app/animals/api/service.ts b/packages/example-app/src/app/animals/api/service.ts index 8c66fe95..8ff199fc 100644 --- a/packages/example-app/src/app/animals/api/service.ts +++ b/packages/example-app/src/app/animals/api/service.ts @@ -1,10 +1,10 @@ import { Injectable } from '@angular/core'; import { Http } from '@angular/http'; -import { Observable } from 'rxjs/Observable'; -import 'rxjs/add/operator/map'; import 'rxjs/add/observable/of'; +import 'rxjs/add/operator/map'; +import { Observable } from 'rxjs/Observable'; -import { ANIMAL_TYPES, AnimalType, IAnimal, fromServer } from '../model'; +import { Animal, ANIMAL_TYPES, AnimalType, fromServer } from '../model'; // A fake API on the internets. const URLS = { @@ -16,7 +16,7 @@ const URLS = { export class AnimalAPIService { constructor(private http: Http) {} - getAll = (animalType: AnimalType): Observable => + getAll = (animalType: AnimalType): Observable => this.http .get(URLS[animalType]) .map(resp => resp.json()) diff --git a/packages/example-app/src/app/animals/model.ts b/packages/example-app/src/app/animals/model.ts index a6336388..523afd25 100644 --- a/packages/example-app/src/app/animals/model.ts +++ b/packages/example-app/src/app/animals/model.ts @@ -6,7 +6,7 @@ export const ANIMAL_TYPES = { // TODO: is there a way to improve this? export type AnimalType = string; -export interface IAnimal { +export interface Animal { id: string; animalType: AnimalType; name: string; @@ -14,13 +14,13 @@ export interface IAnimal { tickets: number; } -export interface IAnimalList { +export interface AnimalList { items: {}; loading: boolean; error: any; } -export const fromServer = (record: any): IAnimal => ({ +export const fromServer = (record: any): Animal => ({ id: record.name.toLowerCase(), animalType: record.animalType, name: record.name, diff --git a/packages/example-app/src/app/animals/module.ts b/packages/example-app/src/app/animals/module.ts index 996877f7..712857dd 100644 --- a/packages/example-app/src/app/animals/module.ts +++ b/packages/example-app/src/app/animals/module.ts @@ -1,12 +1,12 @@ -import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; import { CoreModule } from '../core/module'; +import { StoreModule } from '../store/module'; import { AnimalListComponent } from './animal-list/component'; import { AnimalAPIActions } from './api/actions'; import { AnimalAPIEpics } from './api/epics'; import { AnimalAPIService } from './api/service'; -import { StoreModule } from '../store/module'; import { AnimalComponent } from './animal/component'; diff --git a/packages/example-app/src/app/component.html b/packages/example-app/src/app/component.html index 3d8c9e84..14d981f5 100644 --- a/packages/example-app/src/app/component.html +++ b/packages/example-app/src/app/component.html @@ -1,5 +1,5 @@

- {{title}} + {{ title }}