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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 10 additions & 2 deletions
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

Lines changed: 0 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 7 additions & 7 deletions
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)

0 commit comments

Comments
 (0)