From e9b8f9aa7c03af4a4a8754413fb6886cf5b1a55b Mon Sep 17 00:00:00 2001 From: Seth Davenport Date: Sun, 9 Jul 2017 21:45:31 -0400 Subject: [PATCH] Turn tsconfig settings to 11 (#438) Adding `"noUnusedLocals": true, "noUnusedParameters": true` caught a bunch of minor stuff. --- src/components/root-store.spec.ts | 8 +++----- src/components/sub-store.spec.ts | 3 +-- src/components/sub-store.ts | 5 +---- src/decorators/dispatch.spec.ts | 2 +- src/decorators/select.spec.ts | 4 ++-- src/decorators/select.ts | 6 +----- src/decorators/with-sub-store.spec.ts | 4 ++-- src/decorators/with-sub-store.ts | 1 - testing/ng-redux.mock.spec.ts | 2 +- testing/ng-redux.mock.ts | 20 ++++++++++---------- testing/observable-store.mock.ts | 5 ++--- tsconfig.build.json | 6 +++++- tsconfig.docs.json | 6 +++++- tsconfig.json | 9 +++++++-- tsconfig.testing.json | 6 +++++- 15 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/components/root-store.spec.ts b/src/components/root-store.spec.ts index 2db920b..8a1eecb 100644 --- a/src/components/root-store.spec.ts +++ b/src/components/root-store.spec.ts @@ -9,8 +9,6 @@ import { NgRedux } from './ng-redux'; import { RootStore } from './root-store'; import { select } from '../decorators/select'; -const returnPojo = () => ({}); - class MockNgZone { run = (fn: Function) => fn() } @@ -122,7 +120,7 @@ describe('NgRedux Observable Store', () => { const spy = jasmine .createSpy('spy') .and.callFake((foo: string) => { fooData = foo; }); - const foo$ = ngRedux + ngRedux .select(state => `${state.foo}-${state.baz}`) .subscribe(spy); @@ -153,7 +151,7 @@ describe('NgRedux Observable Store', () => { .and.callFake((data: IRecord) => fooData = data); const cmp = (a: IRecord, b: IRecord) => a.data === b.data; - const foo$ = ngRedux + ngRedux .select(state => ({ data: `${state.foo}-${state.baz}` }), cmp) .subscribe(spy); @@ -203,7 +201,7 @@ describe('NgRedux Observable Store', () => { bar: string; baz: number; - constructor(private _ngRedux: NgRedux) { + constructor(_ngRedux: NgRedux) { _ngRedux.select(n => n.foo).subscribe(foo => this.foo = foo); _ngRedux.select(n => n.bar).subscribe(bar => this.bar = bar); _ngRedux.select(n => n.baz).subscribe(baz => this.baz = baz); diff --git a/src/components/sub-store.spec.ts b/src/components/sub-store.spec.ts index 8ad54cc..19c958c 100644 --- a/src/components/sub-store.spec.ts +++ b/src/components/sub-store.spec.ts @@ -1,5 +1,4 @@ import { NgZone } from '@angular/core'; -import { async } from '@angular/core/testing' import { Action } from 'redux'; import { RootStore } from './root-store'; import { NgRedux } from './ng-redux'; @@ -22,7 +21,7 @@ interface IAppState { } describe('Substore', () => { - const defaultReducer = (state: any, action: Action) => state; + const defaultReducer = (state: any, _: Action) => state; const basePath = ['foo', 'bar']; let ngRedux: NgRedux; diff --git a/src/components/sub-store.ts b/src/components/sub-store.ts index 16816c3..0db8a30 100644 --- a/src/components/sub-store.ts +++ b/src/components/sub-store.ts @@ -1,15 +1,12 @@ -import { Dispatch, Reducer, Action } from 'redux'; +import { Dispatch, Reducer } from 'redux'; import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/distinctUntilChanged'; import { getIn } from '../utils/get-in'; -import { setIn } from '../utils/set-in'; import { PathSelector, Selector, - PropertySelector, - FunctionSelector, Comparator, resolveToFunctionSelector, } from './selectors'; diff --git a/src/decorators/dispatch.spec.ts b/src/decorators/dispatch.spec.ts index b4b39c0..39f074c 100644 --- a/src/decorators/dispatch.spec.ts +++ b/src/decorators/dispatch.spec.ts @@ -132,7 +132,7 @@ describe('@dispatch', () => { }); describe('On a substore', () => { - const localReducer = (state: any, action: Action) => state; + const localReducer = (state: any, _: Action) => state; @WithSubStore({ basePathMethodName: 'getBasePath', localReducer, diff --git a/src/decorators/select.spec.ts b/src/decorators/select.spec.ts index 7fddcb2..d812715 100644 --- a/src/decorators/select.spec.ts +++ b/src/decorators/select.spec.ts @@ -98,7 +98,7 @@ describe('Select decorators', () => { }); describe('when passed a comparator', () => { - const comparator = (x: any, y: any): boolean => y === 1; + const comparator = (_: any, y: any): boolean => y === 1; class MockClass { @select('baz', comparator) baz$: Observable }; it('should only trigger next when comparator returns true', done => { @@ -151,7 +151,7 @@ describe('Select decorators', () => { }); describe('when passed a comparator', () => { - const comparator = (x: any, y: any): boolean => y === 1; + const comparator = (_: any, y: any): boolean => y === 1; class MockClass { @select$('baz', transformer, comparator) baz$: Observable } it('should only trigger next when the comparator returns true', done => { diff --git a/src/decorators/select.ts b/src/decorators/select.ts index 3ac2f46..671eb54 100644 --- a/src/decorators/select.ts +++ b/src/decorators/select.ts @@ -1,10 +1,6 @@ -import { Observable } from 'rxjs/Observable'; -import { ReplaySubject } from 'rxjs/ReplaySubject'; import 'rxjs/add/operator/let' -import { NgRedux } from '../components/ng-redux'; -import { ObservableStore } from '../components/observable-store'; import { Selector, Comparator, Transformer } from '../components/selectors'; -import { IFractalStoreOptions, getInstanceSelection } from './helpers'; +import { getInstanceSelection } from './helpers'; /** * Selects an observable from the store, and attaches it to the decorated diff --git a/src/decorators/with-sub-store.spec.ts b/src/decorators/with-sub-store.spec.ts index e9108b5..19f2966 100644 --- a/src/decorators/with-sub-store.spec.ts +++ b/src/decorators/with-sub-store.spec.ts @@ -16,7 +16,7 @@ class MockNgZone { run = (fn: Function) => fn() } describe('@WithSubStore', () => { let ngRedux: NgRedux; - const localReducer = (state: any, action: Action) => state; + const localReducer = (state: any, _: Action) => state; const basePathMethodName = 'getSubStorePath'; beforeEach(() => { @@ -30,7 +30,7 @@ describe('@WithSubStore', () => { ngRedux = new RootStore(new MockNgZone() as NgZone); NgRedux.instance = ngRedux; ngRedux.configureStore( - (state: any, action: Action) => state, + (state: any, _: Action) => state, defaultState); }); diff --git a/src/decorators/with-sub-store.ts b/src/decorators/with-sub-store.ts index 0211c1e..dad472e 100644 --- a/src/decorators/with-sub-store.ts +++ b/src/decorators/with-sub-store.ts @@ -1,4 +1,3 @@ -import { Reducer } from 'redux'; import { IFractalStoreOptions, setClassOptions } from './helpers'; /** diff --git a/testing/ng-redux.mock.spec.ts b/testing/ng-redux.mock.spec.ts index c65c38d..0ff5959 100644 --- a/testing/ng-redux.mock.spec.ts +++ b/testing/ng-redux.mock.spec.ts @@ -1,4 +1,4 @@ -import { TestBed, async } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing'; import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import 'rxjs/add/operator/toArray'; diff --git a/testing/ng-redux.mock.ts b/testing/ng-redux.mock.ts index 4033186..9526def 100644 --- a/testing/ng-redux.mock.ts +++ b/testing/ng-redux.mock.ts @@ -2,13 +2,11 @@ import { NgRedux, Selector, Comparator, - ObservableStore, PathSelector, } from '@angular-redux/store'; -import { Reducer, Action, Dispatch, Middleware, Store, StoreEnhancer } from 'redux'; +import { Reducer, Dispatch, Middleware, Store, StoreEnhancer } from 'redux'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; -import { ReplaySubject } from 'rxjs/ReplaySubject'; import 'rxjs/add/observable/from'; import 'rxjs/add/operator/distinctUntilChanged'; import { MockObservableStore } from './observable-store.mock'; @@ -71,16 +69,18 @@ export class MockNgRedux extends NgRedux { return MockNgRedux.mockInstance; } - provideStore = (store: Store): void => {}; + provideStore = (_: Store): void => {}; configureStore = ( - rootReducer: Reducer, - initState: any, - middleware?: Middleware[], - enhancers?: StoreEnhancer[]): void => {}; + _: Reducer, + __: any, + ___?: Middleware[], + ____?: StoreEnhancer[]): void => {}; configureSubStore = this.mockRootStore.configureSubStore; - select = this.mockRootStore.select; - + select: ( + selector: Selector, + comparator?: Comparator) => Observable = this.mockRootStore.select; + dispatch = this.mockRootStore.dispatch as Dispatch; getState = this.mockRootStore.getState; subscribe = this.mockRootStore.subscribe; diff --git a/testing/observable-store.mock.ts b/testing/observable-store.mock.ts index faa9cc4..9d81c78 100644 --- a/testing/observable-store.mock.ts +++ b/testing/observable-store.mock.ts @@ -1,5 +1,4 @@ import { - NgRedux, Selector, Comparator, ObservableStore, @@ -7,7 +6,7 @@ import { } from '@angular-redux/store'; import { Observable } from 'rxjs/Observable'; import { Subject } from 'rxjs/Subject'; -import { Reducer, Action, Dispatch } from 'redux'; +import { Reducer, Dispatch } from 'redux'; import { ReplaySubject } from 'rxjs/ReplaySubject'; import 'rxjs/add/observable/from'; import 'rxjs/add/operator/distinctUntilChanged'; @@ -60,7 +59,7 @@ export class MockObservableStore implements ObservableStore { configureSubStore = ( basePath: PathSelector, - localReducer: Reducer): MockObservableStore => + _: Reducer): MockObservableStore => this.initSubStore(basePath) getSubStore = (...pathSelectors: PathSelector[]): MockObservableStore => { diff --git a/tsconfig.build.json b/tsconfig.build.json index d33ed79..193212c 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -19,7 +19,11 @@ "paths": { "@angular-redux/store": [ "./src/index.ts" ] }, - "skipLibCheck": true + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true }, "compileOnSave": false, "buildOnSave": false, diff --git a/tsconfig.docs.json b/tsconfig.docs.json index 539e383..6b3a0a4 100644 --- a/tsconfig.docs.json +++ b/tsconfig.docs.json @@ -15,7 +15,11 @@ "@angular-redux/store": ["src/index.ts"] }, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true }, "compileOnSave": false, "buildOnSave": false, diff --git a/tsconfig.json b/tsconfig.json index 384e976..06a1a01 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,12 +19,17 @@ "@angular-redux/store": ["src/index.ts"] }, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true }, "compileOnSave": false, "buildOnSave": false, "include": [ - "src/**/*.ts" + "src/**/*.ts", + "testing/**/*.ts" ], "exclude": [ "node_modules", diff --git a/tsconfig.testing.json b/tsconfig.testing.json index 45e07ca..da5834e 100644 --- a/tsconfig.testing.json +++ b/tsconfig.testing.json @@ -15,7 +15,11 @@ "@angular-redux/store": ["./lib/src"] }, "strict": true, - "skipLibCheck": true + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "pretty": true }, "compileOnSave": false, "buildOnSave": false,