Skip to content

Commit 6246b16

Browse files
chore(lint): Use EMPTY for rxjs
1 parent 7cf0804 commit 6246b16

File tree

6 files changed

+36
-28
lines changed

6 files changed

+36
-28
lines changed

src/analytics/analytics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';
2-
import { empty, Observable, of } from 'rxjs';
2+
import { EMPTY, Observable, of } from 'rxjs';
33
import { isPlatformBrowser } from '@angular/common';
44
import { map, observeOn, shareReplay, switchMap, tap } from 'rxjs/operators';
55
import { FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseAppConfig, FirebaseOptions, ɵAngularFireSchedulers, ɵfirebaseAppFactory, ɵlazySDKProxy, ɵPromiseProxy } from '@angular/fire';
@@ -80,7 +80,7 @@ export class AngularFireAnalytics {
8080
if (!analytics) {
8181
analytics = of(undefined).pipe(
8282
observeOn(new ɵAngularFireSchedulers(zone).outsideAngular),
83-
switchMap(() => isPlatformBrowser(platformId) ? import('firebase/analytics') : empty()),
83+
switchMap(() => isPlatformBrowser(platformId) ? import('firebase/analytics') : EMPTY),
8484
map(() => ɵfirebaseAppFactory(options, zone, nameOrConfig)),
8585
map(app => app.analytics()),
8686
tap(analytics => {

src/messaging/messaging.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
import { Inject, Injectable, NgZone, Optional, PLATFORM_ID } from '@angular/core';
22
import { messaging } from 'firebase/app';
3-
import { empty, Observable, of, throwError } from 'rxjs';
3+
import { EMPTY, Observable, of, throwError } from 'rxjs';
44
import { catchError, concat, defaultIfEmpty, map, mergeMap, observeOn, switchMap } from 'rxjs/operators';
55
import { FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseAppConfig, FirebaseOptions, ɵAngularFireSchedulers, ɵfirebaseAppFactory, ɵlazySDKProxy, ɵPromiseProxy } from '@angular/fire';
66
import { isPlatformServer } from '@angular/common';
77

8-
export interface AngularFireMessaging extends Omit<ɵPromiseProxy<messaging.Messaging>, 'deleteToken'|'getToken'|'requestPermission'> {}
8+
export interface AngularFireMessaging extends Omit<ɵPromiseProxy<messaging.Messaging>, 'deleteToken' | 'getToken' | 'requestPermission'> {
9+
}
910

1011
@Injectable({
1112
providedIn: 'any'
1213
})
1314
export class AngularFireMessaging {
1415

1516
public readonly requestPermission: Observable<void>;
16-
public readonly getToken: Observable<string|null>;
17-
public readonly tokenChanges: Observable<string|null>;
17+
public readonly getToken: Observable<string | null>;
18+
public readonly tokenChanges: Observable<string | null>;
1819
public readonly messages: Observable<{}>;
19-
public readonly requestToken: Observable<string|null>;
20+
public readonly requestToken: Observable<string | null>;
2021
public readonly deleteToken: (token: string) => Observable<boolean>;
2122

2223
constructor(
2324
@Inject(FIREBASE_OPTIONS) options: FirebaseOptions,
24-
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string|FirebaseAppConfig|null|undefined,
25+
@Optional() @Inject(FIREBASE_APP_NAME) nameOrConfig: string | FirebaseAppConfig | null | undefined,
26+
// tslint:disable-next-line:ban-types
2527
@Inject(PLATFORM_ID) platformId: Object,
2628
zone: NgZone
2729
) {
2830
const schedulers = new ɵAngularFireSchedulers(zone);
2931

3032
const messaging = of(undefined).pipe(
3133
observeOn(schedulers.outsideAngular),
32-
switchMap(() => isPlatformServer(platformId) ? empty() : import('firebase/messaging')),
34+
switchMap(() => isPlatformServer(platformId) ? EMPTY : import('firebase/messaging')),
3335
map(() => ɵfirebaseAppFactory(options, zone, nameOrConfig)),
3436
map(app => app.messaging())
3537
);
@@ -38,7 +40,7 @@ export class AngularFireMessaging {
3840

3941
this.requestPermission = messaging.pipe(
4042
observeOn(schedulers.outsideAngular),
41-
switchMap(messaging => messaging.requestPermission()),
43+
switchMap(messaging => messaging.requestPermission())
4244
);
4345

4446
} else {

src/performance/performance.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';
2-
import { EMPTY, empty, Observable, of, Subscription } from 'rxjs';
2+
import { EMPTY, Observable, of, Subscription } from 'rxjs';
33
import { map, shareReplay, switchMap, tap } from 'rxjs/operators';
44
import { performance } from 'firebase/app';
55
import { FirebaseApp, ɵlazySDKProxy, ɵPromiseProxy } from '@angular/fire';
@@ -65,7 +65,7 @@ const trace$ = (traceId: string) => {
6565
};
6666
});
6767
} else {
68-
return empty();
68+
return EMPTY;
6969
}
7070
};
7171

src/remote-config/remote-config.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Inject, Injectable, InjectionToken, NgZone, Optional, PLATFORM_ID } from '@angular/core';
2-
import { concat, empty, MonoTypeOperatorFunction, Observable, of, OperatorFunction, pipe } from 'rxjs';
2+
import { concat, EMPTY, MonoTypeOperatorFunction, Observable, of, OperatorFunction, pipe } from 'rxjs';
33
import { debounceTime, distinctUntilChanged, filter, groupBy, map, mergeMap, observeOn, scan, shareReplay, startWith, switchMap, tap, withLatestFrom } from 'rxjs/operators';
44
import { FIREBASE_APP_NAME, FIREBASE_OPTIONS, FirebaseAppConfig, FirebaseOptions, ɵAngularFireSchedulers, ɵfirebaseAppFactory, ɵlazySDKProxy, ɵPromiseProxy } from '@angular/fire';
55
import { remoteConfig } from 'firebase/app';
@@ -14,6 +14,7 @@ export const DEFAULTS = new InjectionToken<ConfigTemplate>('angularfire2.remoteC
1414

1515
export interface AngularFireRemoteConfig extends ɵPromiseProxy<remoteConfig.RemoteConfig> {
1616
}
17+
1718
// TODO look into the types here, I don't like the anys
1819
const proxyAll = (observable: Observable<Parameter[]>, as: 'numbers' | 'booleans' | 'strings') => new Proxy(
1920
observable.pipe(mapToObject(as as any)), {
@@ -90,7 +91,7 @@ export class AngularFireRemoteConfig {
9091

9192
const remoteConfig$ = of(undefined).pipe(
9293
observeOn(schedulers.outsideAngular),
93-
switchMap(() => isPlatformBrowser(platformId) ? import('firebase/remote-config') : empty()),
94+
switchMap(() => isPlatformBrowser(platformId) ? import('firebase/remote-config') : EMPTY),
9495
map(() => ɵfirebaseAppFactory(options, zone, nameOrConfig)),
9596
map(app => app.remoteConfig()),
9697
tap(rc => {
@@ -183,8 +184,6 @@ const scanToParametersArray = (
183184
}, [] as Array<Parameter>)
184185
);
185186

186-
const AS_TO_FN = { strings: 'asString', numbers: 'asNumber', booleans: 'asBoolean' };
187-
const STATIC_VALUES = { numbers: 0, booleans: false, strings: undefined };
188187

189188
export const budget = <T>(interval: number): MonoTypeOperatorFunction<T> => (source: Observable<T>) => new Observable<T>(observer => {
190189
let timedOut = false;
@@ -227,6 +226,9 @@ const typedMethod = (it: any) => {
227226
}
228227
};
229228

229+
const AS_TO_FN = { strings: 'asString', numbers: 'asNumber', booleans: 'asBoolean' };
230+
const STATIC_VALUES = { numbers: 0, booleans: false, strings: undefined };
231+
230232
export function scanToObject(): OperatorFunction<Parameter, { [key: string]: string | undefined }>;
231233
export function scanToObject(to: 'numbers'): OperatorFunction<Parameter, { [key: string]: number | undefined }>;
232234
export function scanToObject(to: 'booleans'): OperatorFunction<Parameter, { [key: string]: boolean | undefined }>;

src/schematics/ng-add.jasmine.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Tree } from '@angular-devkit/schematics';
22
import { setupProject } from './ng-add';
33

4-
54
const PROJECT_NAME = 'pie-ka-chu';
65
const PROJECT_ROOT = 'pirojok';
76
const FIREBASE_PROJECT = 'pirojok-111e3';
@@ -555,7 +554,7 @@ describe('ng-add', () => {
555554
project: PROJECT_NAME
556555
});
557556

558-
const workspace = JSON.parse((await result.read('angular.json'))!.toString());
557+
const workspace = JSON.parse((await result.read('angular.json')).toString());
559558
expect(workspace.projects['pie-ka-chu'].architect.deploy.options.ssr).toBeTrue();
560559
});
561560

@@ -569,7 +568,7 @@ describe('ng-add', () => {
569568
project: PROJECT_NAME
570569
});
571570

572-
const firebaseJson = JSON.parse((await result.read('firebase.json'))!.toString());
571+
const firebaseJson = JSON.parse((await result.read('firebase.json')).toString());
573572
expect(firebaseJson).toEqual(universalFirebaseJson);
574573
});
575574
});

tools/build.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async function replacePackageCoreVersion() {
3131
async function replacePackageJsonVersions() {
3232
const path = dest('package.json');
3333
const root = await rootPackage;
34-
let pkg = await import(path);
34+
const pkg = await import(path);
3535
Object.keys(pkg.peerDependencies).forEach(peer => {
3636
pkg.peerDependencies[peer] = root.dependencies[peer];
3737
});
@@ -53,7 +53,7 @@ async function replaceSchematicVersions() {
5353
}
5454

5555
function spawnPromise(command: string, args: string[]) {
56-
return new Promise(resolve => spawn(command, args, {stdio: 'inherit'}).on('close', resolve));
56+
return new Promise(resolve => spawn(command, args, { stdio: 'inherit' }).on('close', resolve));
5757
}
5858

5959
async function compileSchematics() {
@@ -93,19 +93,19 @@ function measureLibrary() {
9393
async function buildDocs() {
9494
// INVESTIGATE json to stdout rather than FS?
9595
await Promise.all(MODULES.map(module => spawnPromise('npx', ['typedoc', `./src/${module}`, '--json', `./dist/typedocs/${module}.json`])));
96-
const entries = await Promise.all(MODULES.map(async (module, index) => {
96+
const entries = await Promise.all(MODULES.map(async (module) => {
9797
const buffer = await readFile(`./dist/typedocs/${module}.json`);
9898
const typedoc = JSON.parse(buffer.toString());
9999
// TODO infer the entryPoint from the package.json
100100
const entryPoint = typedoc.children.find((c: any) => c.name === '"public_api"');
101101
const allChildren = [].concat(...typedoc.children.map(child =>
102102
// TODO chop out the working directory and filename
103-
child.children ? child.children.map(c => ({...c, path: dirname(child.originalName.split(process.cwd())[1])})) : []
103+
child.children ? child.children.map(c => ({ ...c, path: dirname(child.originalName.split(process.cwd())[1]) })) : []
104104
));
105105
return entryPoint.children
106106
.filter(c => c.name[0] !== 'ɵ' && c.name[0] !== '_' /* private */)
107-
.map(child => ({...allChildren.find(c => child.target === c.id)}))
108-
.reduce((acc, child) => ({...acc, [encodeURIComponent(child.name)]: child}), {});
107+
.map(child => ({ ...allChildren.find(c => child.target === c.id) }))
108+
.reduce((acc, child) => ({ ...acc, [encodeURIComponent(child.name)]: child }), {});
109109
}));
110110
const root = await rootPackage;
111111
const pipes = ['MonoTypeOperatorFunction', 'OperatorFunction', 'AuthPipe', 'UnaryFunction'];
@@ -125,11 +125,16 @@ async function buildDocs() {
125125
return child.kindString;
126126
}
127127
};
128-
const table_of_contents = entries.reduce((acc, entry, index) =>
129-
({...acc, [MODULES[index]]: {name: ENTRY_NAMES[index], exports: Object.keys(entry).reduce((acc, key) => ({...acc, [key]: tocType(entry[key])}), {})}}),
128+
const tableOfContents = entries.reduce((acc, entry, index) =>
129+
({
130+
...acc, [MODULES[index]]: {
131+
name: ENTRY_NAMES[index],
132+
exports: Object.keys(entry).reduce((acc, key) => ({ ...acc, [key]: tocType(entry[key]) }), {})
133+
}
134+
}),
130135
{}
131136
);
132-
const afdoc = entries.reduce((acc, entry, index) => ({...acc, [MODULES[index]]: entry }), { table_of_contents });
137+
const afdoc = entries.reduce((acc, entry, index) => ({ ...acc, [MODULES[index]]: entry }), { table_of_contents: tableOfContents });
133138
return writeFile(`./api-${root.version}.json`, JSON.stringify(afdoc, null, 2));
134139
}
135140

0 commit comments

Comments
 (0)