Skip to content

Commit

Permalink
chore(lint): Fix some lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NothingEverHappens committed Apr 28, 2020
1 parent 9e19b14 commit 7df1608
Show file tree
Hide file tree
Showing 69 changed files with 423 additions and 423 deletions.
4 changes: 2 additions & 2 deletions sample/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { APP_BASE_HREF } from '@angular/common';
import { existsSync } from 'fs';

// Polyfill XMLHttpRequest and WS for Firebase
global['XMLHttpRequest'] = require("xhr2");
global['WebSocket'] = require("ws");
global.XMLHttpRequest = require('xhr2');
global.WebSocket = require('ws');

// The Express app is exported so that it can be used by serverless Functions.
export function app() {
Expand Down
2 changes: 1 addition & 1 deletion sample/src/app/storage/storage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { startWith, tap } from 'rxjs/operators';
import { makeStateKey, TransferState } from '@angular/platform-browser';
import { trace } from '@angular/fire/performance';

const TRANSPARENT_PNG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
const TRANSPARENT_PNG = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';

@Component({
selector: 'app-storage',
Expand Down
16 changes: 8 additions & 8 deletions sample/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const environment = {
production: true,
firebase: {
apiKey: "AIzaSyA7CNE9aHbcSEbt9y03QReJ-Xr0nwKg7Yg",
authDomain: "aftest-94085.firebaseapp.com",
databaseURL: "https://aftest-94085.firebaseio.com",
projectId: "aftest-94085",
storageBucket: "aftest-94085.appspot.com",
messagingSenderId: "480362569154",
appId: "1:480362569154:web:2fe6f75104cdfb82f50a5b",
measurementId: "G-CBRYER9PJR"
apiKey: 'AIzaSyA7CNE9aHbcSEbt9y03QReJ-Xr0nwKg7Yg',
authDomain: 'aftest-94085.firebaseapp.com',
databaseURL: 'https://aftest-94085.firebaseio.com',
projectId: 'aftest-94085',
storageBucket: 'aftest-94085.appspot.com',
messagingSenderId: '480362569154',
appId: '1:480362569154:web:2fe6f75104cdfb82f50a5b',
measurementId: 'G-CBRYER9PJR'
}
};
16 changes: 8 additions & 8 deletions sample/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
export const environment = {
production: false,
firebase: {
apiKey: "AIzaSyA7CNE9aHbcSEbt9y03QReJ-Xr0nwKg7Yg",
authDomain: "aftest-94085.firebaseapp.com",
databaseURL: "https://aftest-94085.firebaseio.com",
projectId: "aftest-94085",
storageBucket: "aftest-94085.appspot.com",
messagingSenderId: "480362569154",
appId: "1:480362569154:web:2fe6f75104cdfb82f50a5b",
measurementId: "G-CBRYER9PJR"
apiKey: 'AIzaSyA7CNE9aHbcSEbt9y03QReJ-Xr0nwKg7Yg',
authDomain: 'aftest-94085.firebaseapp.com',
databaseURL: 'https://aftest-94085.firebaseio.com',
projectId: 'aftest-94085',
storageBucket: 'aftest-94085.appspot.com',
messagingSenderId: '480362569154',
appId: '1:480362569154:web:2fe6f75104cdfb82f50a5b',
measurementId: 'G-CBRYER9PJR'
}
};

Expand Down
40 changes: 20 additions & 20 deletions src/analytics/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ const ANNOTATIONS = '__annotations__';
export class ScreenTrackingService implements OnDestroy {

private disposable: Subscription|undefined;

constructor(
analytics: AngularFireAnalytics,
@Optional() router:Router,
@Optional() title:Title,
@Optional() router: Router,
@Optional() title: Title,
componentFactoryResolver: ComponentFactoryResolver,
@Inject(PLATFORM_ID) platformId:Object,
@Optional() @Inject(DEBUG_MODE) debugModeEnabled:boolean|null,
@Inject(PLATFORM_ID) platformId: Object,
@Optional() @Inject(DEBUG_MODE) debugModeEnabled: boolean|null,
zone: NgZone,
injector: Injector
) {
if (!router || !isPlatformBrowser(platformId)) { return this }
if (!router || !isPlatformBrowser(platformId)) { return this; }
zone.runOutsideAngular(() => {
const activationEndEvents = router.events.pipe(filter<ActivationEnd>(e => e instanceof ActivationEnd));
const navigationEndEvents = router.events.pipe(filter<NavigationEnd>(e => e instanceof NavigationEnd));
Expand All @@ -64,13 +64,13 @@ export class ScreenTrackingService implements OnDestroy {
[OUTLET_KEY]: activationEnd.snapshot.outlet
};
if (title) {
params[PAGE_TITLE_KEY] = title.getTitle()
params[PAGE_TITLE_KEY] = title.getTitle();
}
const component = activationEnd.snapshot.component;
const routeConfig = activationEnd.snapshot.routeConfig;
const loadChildren = routeConfig && routeConfig.loadChildren;
// TODO figure out how to handle minification
if (typeof loadChildren === "string") {
if (typeof loadChildren === 'string') {
// SEMVER: this is the older lazy load style "./path#ClassName", drop this when we drop old ng
// TODO is it worth seeing if I can look up the component factory selector from the module name?
// it's lazy so it's not registered with componentFactoryResolver yet... seems a pain for a depreciated style
Expand All @@ -82,7 +82,7 @@ export class ScreenTrackingService implements OnDestroy {
return of({...params, [SCREEN_CLASS_KEY]: componentFactory.selector });
} else if (loadChildren) {
const loadedChildren = loadChildren();
var loadedChildren$: Observable<any> = (loadedChildren instanceof Observable) ? loadedChildren : from(Promise.resolve(loadedChildren));
const loadedChildren$: Observable<any> = (loadedChildren instanceof Observable) ? loadedChildren : from(Promise.resolve(loadedChildren));
return loadedChildren$.pipe(
map(lazyModule => {
if (lazyModule instanceof NgModuleFactory) {
Expand All @@ -94,14 +94,14 @@ export class ScreenTrackingService implements OnDestroy {
try {
const componentFactory = moduleRef.componentFactoryResolver.resolveComponentFactory(component!);
return {...params, [SCREEN_CLASS_KEY]: componentFactory.selector};
} catch(_) {
} catch (_) {
return {...params, [SCREEN_CLASS_KEY]: DEFAULT_SCREEN_CLASS};
}
} else {
// JIT look at the annotations
// INVESTIGATE are there public APIs for this stuff?
const declarations = [].concat.apply([], (lazyModule[ANNOTATIONS] || []).map((f:any) => f.declarations));
const selectors = [].concat.apply([], declarations.map((c:any) => (c[ANNOTATIONS] || []).map((f:any) => f.selector)));
const declarations = [].concat.apply([], (lazyModule[ANNOTATIONS] || []).map((f: any) => f.declarations));
const selectors = [].concat.apply([], declarations.map((c: any) => (c[ANNOTATIONS] || []).map((f: any) => f.selector)));
// should I just be grabbing the selector like this or should i match against the route component?
// const routerModule = lazyModule.ngInjectorDef.imports.find(i => i.ngModule && ....);
// const route = routerModule.providers[0].find(p => p.provide == ROUTES).useValue[0];
Expand All @@ -127,7 +127,7 @@ export class ScreenTrackingService implements OnDestroy {
[SCREEN_CLASS_KEY]: params[SCREEN_CLASS_KEY]
});
if (title) {
analytics.updateConfig({ [PAGE_TITLE_KEY]: params[PAGE_TITLE_KEY] })
analytics.updateConfig({ [PAGE_TITLE_KEY]: params[PAGE_TITLE_KEY] });
}
}
}),
Expand All @@ -144,11 +144,11 @@ export class ScreenTrackingService implements OnDestroy {
).subscribe();
});
}

ngOnDestroy() {
if (this.disposable) { this.disposable.unsubscribe(); }
}

}

@Injectable({
Expand All @@ -162,7 +162,7 @@ export class UserTrackingService implements OnDestroy {
constructor(
analytics: AngularFireAnalytics,
zone: NgZone,
@Inject(PLATFORM_ID) platformId:Object
@Inject(PLATFORM_ID) platformId: Object
) {
const schedulers = new ɵAngularFireSchedulers(zone);

Expand All @@ -186,11 +186,11 @@ export class UserTrackingService implements OnDestroy {
}

// this is an INT64 in iOS/Android but use INT32 cause javascript
let nextScreenInstanceID = Math.floor(Math.random() * (2**32 - 1)) - 2**31;
let nextScreenInstanceID = Math.floor(Math.random() * (2 ** 32 - 1)) - 2 ** 31;

const knownScreenInstanceIDs: {[key:string]: number} = {};
const knownScreenInstanceIDs: {[key: string]: number} = {};

const getScreenInstanceID = (params:{[key:string]: any}) => {
const getScreenInstanceID = (params: {[key: string]: any}) => {
// unique the screen class against the outlet name
const screenInstanceKey = [
params[SCREEN_CLASS_KEY],
Expand All @@ -203,4 +203,4 @@ const getScreenInstanceID = (params:{[key:string]: any}) => {
knownScreenInstanceIDs[screenInstanceKey] = ret;
return ret;
}
}
};
2 changes: 1 addition & 1 deletion src/analytics/analytics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ describe('AngularFireAnalytics', () => {
expect(analytics.app).toBeDefined();
});

});
});
42 changes: 21 additions & 21 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { map, tap, shareReplay, switchMap, observeOn } from 'rxjs/operators';
import { FirebaseAppConfig, FirebaseOptions, ɵAngularFireSchedulers, ɵlazySDKProxy, FIREBASE_OPTIONS, FIREBASE_APP_NAME, ɵfirebaseAppFactory, ɵPromiseProxy } from '@angular/fire';
import { analytics } from 'firebase';

export interface Config {[key:string]: any};
export interface Config {[key: string]: any; }

export const COLLECTION_ENABLED = new InjectionToken<boolean>('angularfire2.analytics.analyticsCollectionEnabled');
export const APP_VERSION = new InjectionToken<string>('angularfire2.analytics.appVersion');
Expand All @@ -21,11 +21,11 @@ const GTAG_CONFIG_COMMAND = 'config';
const GTAG_FUNCTION_NAME = 'gtag';
const DATA_LAYER_NAME = 'dataLayer';

export interface AngularFireAnalytics extends ɵPromiseProxy<analytics.Analytics> {};
export interface AngularFireAnalytics extends ɵPromiseProxy<analytics.Analytics> {}

let gtag: (...args: any[]) => void;
let analyticsInitialized: Promise<void>;
const analyticsInstanceCache: {[key:string]: Observable<analytics.Analytics>} = {};
const analyticsInstanceCache: {[key: string]: Observable<analytics.Analytics>} = {};

@Injectable({
providedIn: 'any'
Expand All @@ -35,30 +35,30 @@ export class AngularFireAnalytics {
async updateConfig(config: Config) {
await analyticsInitialized;
gtag(GTAG_CONFIG_COMMAND, this.options[ANALYTICS_ID_FIELD], { ...config, update: true });
};
}

constructor(
@Inject(FIREBASE_OPTIONS) private options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(COLLECTION_ENABLED) analyticsCollectionEnabled:boolean|null,
@Optional() @Inject(APP_VERSION) providedAppVersion:string|null,
@Optional() @Inject(APP_NAME) providedAppName:string|null,
@Optional() @Inject(DEBUG_MODE) debugModeEnabled:boolean|null,
@Optional() @Inject(CONFIG) providedConfig:Config|null,
@Inject(PLATFORM_ID) platformId:Object,
@Inject(FIREBASE_OPTIONS) private options: FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string|FirebaseAppConfig|null|undefined,
@Optional() @Inject(COLLECTION_ENABLED) analyticsCollectionEnabled: boolean|null,
@Optional() @Inject(APP_VERSION) providedAppVersion: string|null,
@Optional() @Inject(APP_NAME) providedAppName: string|null,
@Optional() @Inject(DEBUG_MODE) debugModeEnabled: boolean|null,
@Optional() @Inject(CONFIG) providedConfig: Config|null,
@Inject(PLATFORM_ID) platformId: Object,
zone: NgZone
) {

if (!analyticsInitialized) {
if (isPlatformBrowser(platformId)) {
gtag = window[GTAG_FUNCTION_NAME] || function() { window[DATA_LAYER_NAME].push(arguments) };
gtag = window[GTAG_FUNCTION_NAME] || function() { window[DATA_LAYER_NAME].push(arguments); };
window[DATA_LAYER_NAME] = window[DATA_LAYER_NAME] || [];
analyticsInitialized = zone.runOutsideAngular(() =>
new Promise(resolve => {
window[GTAG_FUNCTION_NAME] = (...args: any[]) => {
if (args[0] == 'js') { resolve() }
if (args[0] == 'js') { resolve(); }
gtag(...args);
}
};
})
);
} else {
Expand All @@ -75,20 +75,20 @@ export class AngularFireAnalytics {
map(() => ɵfirebaseAppFactory(options, zone, nameOrConfig)),
map(app => app.analytics()),
tap(analytics => {
if (analyticsCollectionEnabled === false) { analytics.setAnalyticsCollectionEnabled(false) }
if (analyticsCollectionEnabled === false) { analytics.setAnalyticsCollectionEnabled(false); }
}),
shareReplay({ bufferSize: 1, refCount: false }),
);
analyticsInstanceCache[options[ANALYTICS_ID_FIELD]] = analytics;
}

if (providedConfig) { this.updateConfig(providedConfig) }
if (providedAppName) { this.updateConfig({ [APP_NAME_KEY]: providedAppName }) }
if (providedAppVersion) { this.updateConfig({ [APP_VERSION_KEY]: providedAppVersion }) }
if (debugModeEnabled) { this.updateConfig({ [DEBUG_MODE_KEY]: 1 }) }
if (providedConfig) { this.updateConfig(providedConfig); }
if (providedAppName) { this.updateConfig({ [APP_NAME_KEY]: providedAppName }); }
if (providedAppVersion) { this.updateConfig({ [APP_VERSION_KEY]: providedAppVersion }); }
if (debugModeEnabled) { this.updateConfig({ [DEBUG_MODE_KEY]: 1 }); }

return ɵlazySDKProxy(this, analytics, zone);

}

}
}
4 changes: 2 additions & 2 deletions src/auth-guard/auth-guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ describe('AngularFireAuthGuard', () => {
afterEach(done => {
app.delete().then(done, done);
});

it('should be injectable', () => {
expect(router).toBeTruthy();
});
});
});
10 changes: 5 additions & 5 deletions src/auth-guard/auth-guard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, Inject, Optional, NgZone } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
import { Observable, of, pipe, UnaryFunction } from 'rxjs';
import { map, switchMap, take, observeOn, shareReplay } from 'rxjs/operators'
import { map, switchMap, take, observeOn, shareReplay } from 'rxjs/operators';
import { User } from 'firebase/app';
import { ɵAngularFireSchedulers, FirebaseOptions, FirebaseAppConfig, FIREBASE_OPTIONS, FIREBASE_APP_NAME, ɵfirebaseAppFactory } from '@angular/fire';

Expand All @@ -16,8 +16,8 @@ export class AngularFireAuthGuard implements CanActivate {
authState: Observable<User|null>;

constructor(
@Inject(FIREBASE_OPTIONS) options:FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig:string|FirebaseAppConfig|null|undefined,
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string|FirebaseAppConfig|null|undefined,
zone: NgZone,
private router: Router
) {
Expand All @@ -40,7 +40,7 @@ export class AngularFireAuthGuard implements CanActivate {
return this.authState.pipe(
take(1),
authPipeFactory(next, state),
map(can => typeof can == "boolean" ? can : this.router.createUrlTree(<any[]>can))
map(can => typeof can == 'boolean' ? can : this.router.createUrlTree(can as any[]))
);
}

Expand All @@ -55,6 +55,6 @@ export const isNotAnonymous: AuthPipe = map(user => !!user && !user.isAnonymous)
export const idTokenResult = switchMap((user: User|null) => user ? user.getIdTokenResult() : of(null));
export const emailVerified: AuthPipe = map(user => !!user && user.emailVerified);
export const customClaims = pipe(idTokenResult, map(idTokenResult => idTokenResult ? idTokenResult.claims : []));
export const hasCustomClaim = (claim:string) => pipe(customClaims, map(claims => claims.hasOwnProperty(claim)));
export const hasCustomClaim = (claim: string) => pipe(customClaims, map(claims => claims.hasOwnProperty(claim)));
export const redirectUnauthorizedTo = (redirect: any[]) => pipe(loggedIn, map(loggedIn => loggedIn || redirect));
export const redirectLoggedInTo = (redirect: any[]) => pipe(loggedIn, map(loggedIn => loggedIn && redirect || true));
2 changes: 1 addition & 1 deletion src/auth-guard/public_api.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './auth-guard';
export * from './auth-guard.module';
export * from './auth-guard.module';
18 changes: 9 additions & 9 deletions src/auth/auth.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { User } from 'firebase/app';
import { Observable, Subject } from 'rxjs'
import { Observable, Subject } from 'rxjs';
import { TestBed, inject } from '@angular/core/testing';
import { FirebaseApp, FIREBASE_OPTIONS, AngularFireModule, FIREBASE_APP_NAME } from '@angular/fire';
import { AngularFireAuth, AngularFireAuthModule } from './public_api';
Expand All @@ -16,10 +16,10 @@ function authSkip(auth: Observable<any>, count: number): Observable<any> {
return skip.call(auth, 1);
}

const firebaseUser = <User> {
const firebaseUser = {
uid: '12345',
providerData: [{ displayName: 'jeffbcrossyface' }]
};
} as User;

describe('AngularFireAuth', () => {
let app: FirebaseApp;
Expand All @@ -40,12 +40,12 @@ describe('AngularFireAuth', () => {
})();

mockAuthState = new Subject<User>();
//@ts-ignore
// @ts-ignore
spyOn(afAuth, 'authState').and.returnValue(mockAuthState);
//@ts-ignore
// @ts-ignore
spyOn(afAuth, 'idToken').and.returnValue(mockAuthState);
(<any>afAuth).authState = mockAuthState as Observable<User>;
(<any>afAuth).idToken = mockAuthState as Observable<User>;
(afAuth as any).authState = mockAuthState as Observable<User>;
(afAuth as any).idToken = mockAuthState as Observable<User>;
});

afterEach(() => {
Expand All @@ -55,7 +55,7 @@ describe('AngularFireAuth', () => {
describe('Zones', () => {
it('should call operators and subscriber in the same zone as when service was initialized', (done) => {
// Initialize the app outside of the zone, to mimick real life behavior.
let ngZone = Zone.current.fork({
const ngZone = Zone.current.fork({
name: 'ngZone'
});
ngZone.run(() => {
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('AngularFireAuth', () => {
count = count + 1;
mockAuthState.next(firebaseUser);
} else {
expect(<any>user).toEqual(firebaseUser);
expect(user as any).toEqual(firebaseUser);
subs.unsubscribe();
done();
}
Expand Down
Loading

0 comments on commit 7df1608

Please sign in to comment.