Skip to content

Commit 68577b5

Browse files
committed
style(linting): add global tslint rules
Adds tslint rules to be run across the workspace based off of the latest preset with some tweaks to taste closes #4. BREAKING CHANGES: - ConnectArray has been renamed to ConnectArrayDirective - ReactiveConnect has been renamed to ReactiveConnectDirective - Connect has been renamed to ConnectDirective - interfaces with an "I" prefix have had that prefix removed (e.g "IAppStore" -> "AppStore")
1 parent d047bb2 commit 68577b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+541
-732
lines changed

jest/tests-setup.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import 'core-js/es6/reflect';
22
import 'core-js/es7/reflect';
3+
import 'jest-zone-patch';
34
import 'zone.js';
4-
import 'zone.js/dist/proxy';
5-
import 'zone.js/dist/sync-test';
65
import 'zone.js/dist/async-test';
76
import 'zone.js/dist/fake-async-test';
8-
import 'jest-zone-patch';
7+
import 'zone.js/dist/proxy';
8+
import 'zone.js/dist/sync-test';
99

1010
import { TestBed } from '@angular/core/testing';
1111
import {

package.json

+10-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"clean:workspace-deps": "rimraf node_modules",
1010
"clean:package-deps": "rimraf packages/*/node_modules",
1111
"clean:coverage": "rimraf coverage",
12-
"lint": "npm-run-all -p lint:*",
12+
"lint": "tslint -p tsconfig.json",
1313
"lint:packages": "lerna run lint",
1414
"lint:prettier": "prettier -l \"**/*.*(ts|js|css|scss|json|md)\"",
1515
"test": "jest --coverage",
@@ -27,18 +27,26 @@
2727
]
2828
},
2929
"devDependencies": {
30+
"@angular/core": "6.1.0",
31+
"@angular/platform-browser": "6.1.0",
32+
"@angular/platform-browser-dynamic": "6.1.0",
3033
"@commitlint/cli": "7.0.0",
3134
"@commitlint/config-conventional": "7.0.1",
3235
"@commitlint/prompt-cli": "7.0.0",
3336
"@types/jest": "23.1.6",
37+
"codelyzer": "4.4.2",
38+
"core-js": "2.5.7",
3439
"husky": "0.14.3",
3540
"jest": "23.4.1",
3641
"jest-junit": "5.1.0",
3742
"jest-preset-angular": "5.2.3",
43+
"jest-zone-patch": "0.0.8",
3844
"lerna": "2.11.0",
3945
"lint-staged": "7.2.0",
4046
"npm-run-all": "4.1.3",
4147
"prettier": "1.13.7",
42-
"rimraf": "2.6.2"
48+
"rimraf": "2.6.2",
49+
"tslint": "5.11.0",
50+
"zone.js": "0.8.26"
4351
}
4452
}

packages/example-app/package.json

-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@
3737
"@angular/compiler-cli": "^4.1.0",
3838
"@types/node": "~6.0.71",
3939
"@types/redux-logger": "^3.0.0",
40-
"codelyzer": "~3.0.1",
4140
"protractor": "~5.1.1",
4241
"ts-node": "~3.0.2",
43-
"tslint": "~5.1.0",
4442
"typescript": "^2.4.1"
4543
}
4644
}

packages/example-app/src/app/animals/animal-list/component.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Component, Input } from '@angular/core';
2-
import { TestBed, async } from '@angular/core/testing';
2+
import { async, TestBed } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
4-
import { AnimalListComponent } from './component';
54
import { CoreModule } from '../../core/module';
65
import { AnimalType } from '../model';
6+
import { AnimalListComponent } from './component';
77

88
@Component({ selector: 'zoo-animal', template: '' })
99
class MockAnimalComponent {
@@ -19,7 +19,7 @@ xdescribe('AnimalListComponent', () => {
1919
}).compileComponents();
2020
}));
2121

22-
it(`should have as title 'Welcome to the Zoo'`, async(() => {
22+
it("should have as title 'Welcome to the Zoo'", async(() => {
2323
const fixture = TestBed.createComponent(AnimalListComponent);
2424
const animalList = fixture.debugElement.componentInstance;
2525

Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
22
import { Observable } from 'rxjs/Observable';
3-
import { IAnimal } from '../model';
3+
import { Animal } from '../model';
44

55
@Component({
66
selector: 'zoo-animal-list',
@@ -11,14 +11,14 @@ import { IAnimal } from '../model';
1111
export class AnimalListComponent {
1212
@Input() animalsName: string;
1313
@Input() animalType: string;
14-
@Input() animals: Observable<IAnimal[]>;
14+
@Input() animals: Observable<Animal[]>;
1515
@Input() loading: Observable<boolean>;
1616
@Input() error: Observable<any>;
1717

1818
// Since we're observing an array of items, we need to set up a 'trackBy'
1919
// parameter so Angular doesn't tear down and rebuild the list's DOM every
2020
// time there's an update.
21-
getKey(_, animal: IAnimal) {
21+
getKey(_, animal: Animal) {
2222
return animal.id;
2323
}
2424
}

packages/example-app/src/app/animals/animal/component.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { async, TestBed } from '@angular/core/testing';
21
import {
3-
NgReduxTestingModule,
42
MockNgRedux,
3+
NgReduxTestingModule,
54
} from '@angular-redux/store/testing';
6-
import { AnimalComponent } from './component';
7-
import { CoreModule } from '../../core/module';
5+
import { async, TestBed } from '@angular/core/testing';
86
import 'rxjs/add/operator/toArray';
7+
import { CoreModule } from '../../core/module';
8+
import { AnimalComponent } from './component';
99

1010
xdescribe('AnimalComponent', () => {
1111
let fixture;

packages/example-app/src/app/animals/animal/component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
21
import { dispatch, select, select$, WithSubStore } from '@angular-redux/store';
2+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
33
import { Observable } from 'rxjs/Observable';
44

5+
import { Animal } from '../model';
56
import { animalComponentReducer } from './reducers';
6-
import { IAnimal } from '../model';
77

8-
export const toSubTotal = (obs$: Observable<IAnimal>): Observable<number> =>
8+
export const toSubTotal = (obs$: Observable<Animal>): Observable<number> =>
99
obs$.map(s => s.ticketPrice * s.tickets);
1010

1111
/**

packages/example-app/src/app/animals/animal/reducers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Reducer, Action } from 'redux';
1+
import { Action, Reducer } from 'redux';
22
import { AnimalComponent } from './component';
33

44
export const ticketsReducer: Reducer<number> = (

packages/example-app/src/app/animals/api/actions.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Injectable } from '@angular/core';
21
import { dispatch } from '@angular-redux/store';
2+
import { Injectable } from '@angular/core';
33
import { FluxStandardAction } from 'flux-standard-action';
4-
import { IAnimal, AnimalType } from '../model';
4+
import { Animal, AnimalType } from '../model';
55

66
// Flux-standard-action gives us stronger typing of our actions.
7-
type Payload = IAnimal[];
7+
type Payload = Animal[];
88
interface MetaData {
99
animalType: AnimalType;
1010
}

packages/example-app/src/app/animals/api/epics.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { Injectable } from '@angular/core';
2-
import { Epic, createEpicMiddleware } from 'redux-observable';
3-
import { of } from 'rxjs/observable/of';
2+
import { createEpicMiddleware, Epic } from 'redux-observable';
43
import 'rxjs/add/operator/catch';
5-
import 'rxjs/add/operator/map';
64
import 'rxjs/add/operator/do';
5+
import 'rxjs/add/operator/map';
76
import 'rxjs/add/operator/startWith';
7+
import { of } from 'rxjs/observable/of';
88

9-
import { IAppState } from '../../store/model';
9+
import { AppState } from '../../store/model';
1010
import { AnimalType } from '../model';
1111
import { AnimalAPIAction, AnimalAPIActions } from './actions';
1212
import { AnimalAPIService } from './service';
1313

1414
const animalsNotAlreadyFetched = (
1515
animalType: AnimalType,
16-
state: IAppState,
16+
state: AppState,
1717
): boolean =>
1818
!(
1919
state[animalType] &&
@@ -32,13 +32,13 @@ export class AnimalAPIEpics {
3232
private actions: AnimalAPIActions,
3333
) {}
3434

35-
public createEpic(animalType: AnimalType) {
35+
createEpic(animalType: AnimalType) {
3636
return createEpicMiddleware(this.createLoadAnimalEpic(animalType));
3737
}
3838

3939
private createLoadAnimalEpic(
4040
animalType: AnimalType,
41-
): Epic<AnimalAPIAction, IAppState> {
41+
): Epic<AnimalAPIAction, AppState> {
4242
return (action$, store) =>
4343
action$
4444
.ofType(AnimalAPIActions.LOAD_ANIMALS)

packages/example-app/src/app/animals/api/reducer.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { AnimalAPIAction, AnimalAPIActions } from './actions';
2-
import { IAnimalList, AnimalType } from '../model';
31
import { indexBy, prop } from 'ramda';
42
import { Action } from 'redux';
3+
import { AnimalList, AnimalType } from '../model';
4+
import { AnimalAPIAction, AnimalAPIActions } from './actions';
55

6-
const INITIAL_STATE: IAnimalList = {
6+
const INITIAL_STATE: AnimalList = {
77
items: {},
88
loading: false,
99
error: null,
@@ -13,9 +13,9 @@ const INITIAL_STATE: IAnimalList = {
1313
// that only responds to actions for that particular animal type.
1414
export function createAnimalAPIReducer(animalType: AnimalType) {
1515
return function animalReducer(
16-
state: IAnimalList = INITIAL_STATE,
16+
state: AnimalList = INITIAL_STATE,
1717
a: Action,
18-
): IAnimalList {
18+
): AnimalList {
1919
const action = a as AnimalAPIAction;
2020
if (!action.meta || action.meta.animalType !== animalType) {
2121
return state;

packages/example-app/src/app/animals/api/service.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Injectable } from '@angular/core';
22
import { Http } from '@angular/http';
3-
import { Observable } from 'rxjs/Observable';
4-
import 'rxjs/add/operator/map';
53
import 'rxjs/add/observable/of';
4+
import 'rxjs/add/operator/map';
5+
import { Observable } from 'rxjs/Observable';
66

7-
import { ANIMAL_TYPES, AnimalType, IAnimal, fromServer } from '../model';
7+
import { Animal, ANIMAL_TYPES, AnimalType, fromServer } from '../model';
88

99
// A fake API on the internets.
1010
const URLS = {
@@ -16,7 +16,7 @@ const URLS = {
1616
export class AnimalAPIService {
1717
constructor(private http: Http) {}
1818

19-
getAll = (animalType: AnimalType): Observable<IAnimal[]> =>
19+
getAll = (animalType: AnimalType): Observable<Animal[]> =>
2020
this.http
2121
.get(URLS[animalType])
2222
.map(resp => resp.json())

packages/example-app/src/app/animals/model.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ export const ANIMAL_TYPES = {
66
// TODO: is there a way to improve this?
77
export type AnimalType = string;
88

9-
export interface IAnimal {
9+
export interface Animal {
1010
id: string;
1111
animalType: AnimalType;
1212
name: string;
1313
ticketPrice: number;
1414
tickets: number;
1515
}
1616

17-
export interface IAnimalList {
17+
export interface AnimalList {
1818
items: {};
1919
loading: boolean;
2020
error: any;
2121
}
2222

23-
export const fromServer = (record: any): IAnimal => ({
23+
export const fromServer = (record: any): Animal => ({
2424
id: record.name.toLowerCase(),
2525
animalType: record.animalType,
2626
name: record.name,

packages/example-app/src/app/animals/module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { NgModule } from '@angular/core';
21
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
33

44
import { CoreModule } from '../core/module';
5+
import { StoreModule } from '../store/module';
56
import { AnimalListComponent } from './animal-list/component';
67
import { AnimalAPIActions } from './api/actions';
78
import { AnimalAPIEpics } from './api/epics';
89
import { AnimalAPIService } from './api/service';
9-
import { StoreModule } from '../store/module';
1010

1111
import { AnimalComponent } from './animal/component';
1212

packages/example-app/src/app/component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1>
2-
{{title}}
2+
{{ title }}
33
</h1>
44
<nav>
55
<a routerLink="/elephants" routerLinkActive="active">Elephants</a>

packages/example-app/src/app/component.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { TestBed, async } from '@angular/core/testing';
1+
import { async, TestBed } from '@angular/core/testing';
22
import { RouterTestingModule } from '@angular/router/testing';
33
import { AppComponent } from './component';
44

@@ -10,7 +10,7 @@ xdescribe('AppComponent', () => {
1010
}).compileComponents();
1111
}));
1212

13-
it(`should have as title 'Welcome to the Zoo'`, async(() => {
13+
it("should have as title 'Welcome to the Zoo'", async(() => {
1414
const fixture = TestBed.createComponent(AppComponent);
1515
const app = fixture.debugElement.componentInstance;
1616
expect(app.title).toEqual('Welcome to the Zoo');

packages/example-app/src/app/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ChangeDetectionStrategy } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component } from '@angular/core';
22

33
@Component({
44
selector: 'zoo-root',

packages/example-app/src/app/core/counter/component.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
2+
ChangeDetectionStrategy,
23
Component,
4+
EventEmitter,
35
Input,
46
Output,
5-
ChangeDetectionStrategy,
6-
EventEmitter,
77
} from '@angular/core';
88

99
@Component({

packages/example-app/src/app/core/error-well/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Input, Component, ChangeDetectionStrategy } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
22
import { Observable } from 'rxjs/Observable';
33

44
@Component({

packages/example-app/src/app/core/module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { NgModule } from '@angular/core';
21
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
33

4-
import { SpinnerComponent } from './spinner/component';
5-
import { ErrorWellComponent } from './error-well/component';
64
import { CounterComponent } from './counter/component';
5+
import { ErrorWellComponent } from './error-well/component';
6+
import { SpinnerComponent } from './spinner/component';
77

88
@NgModule({
99
declarations: [SpinnerComponent, ErrorWellComponent, CounterComponent],

packages/example-app/src/app/elephants/module.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { NgModule } from '@angular/core';
21
import { CommonModule } from '@angular/common';
2+
import { NgModule } from '@angular/core';
33

4-
import { ElephantPageComponent } from './page';
54
import { AnimalModule } from '../animals/module';
65
import { CoreModule } from '../core/module';
76
import { StoreModule } from '../store/module';
7+
import { ElephantPageComponent } from './page';
88

99
@NgModule({
1010
declarations: [ElephantPageComponent],

packages/example-app/src/app/elephants/page.spec.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { TestBed } from '@angular/core/testing';
21
import {
3-
NgReduxTestingModule,
42
MockNgRedux,
3+
NgReduxTestingModule,
54
} from '@angular-redux/store/testing';
5+
import { TestBed } from '@angular/core/testing';
66

77
import { Component, Input } from '@angular/core';
88

9-
import { Observable } from 'rxjs/Observable';
109
import 'rxjs/add/observable/of';
11-
import 'rxjs/add/operator/toArray';
1210
import 'rxjs/add/operator/do';
11+
import 'rxjs/add/operator/toArray';
12+
import { Observable } from 'rxjs/Observable';
1313

14-
import { ElephantPageComponent } from './page';
1514
import { AnimalAPIActions } from '../animals/api/actions';
1615
import { ANIMAL_TYPES } from '../animals/model';
16+
import { ElephantPageComponent } from './page';
1717

1818
@Component({
1919
selector: 'zoo-animal-list',

0 commit comments

Comments
 (0)