refactor(docs-infra): fix some linting warnings (#32980)

PR Close #32980
This commit is contained in:
George Kalpakas 2019-10-03 22:00:39 +03:00 committed by Miško Hevery
parent a2d2a5d572
commit d349cd91b1
14 changed files with 36 additions and 35 deletions

View File

@ -144,10 +144,10 @@ export class AppComponent implements OnInit {
});
// Compute the version picker list from the current version and the versions in the navigation map
combineLatest(
combineLatest([
this.navigationService.versionInfo,
this.navigationService.navigationViews.pipe(map(views => views['docVersions'])))
.subscribe(([versionInfo, versions]) => {
this.navigationService.navigationViews.pipe(map(views => views['docVersions'])),
]).subscribe(([versionInfo, versions]) => {
// TODO(pbd): consider whether we can lookup the stable and next versions from the internet
const computedVersions: NavigationNode[] = [
{ title: 'next', url: 'https://next.angular.io' },
@ -175,7 +175,7 @@ export class AppComponent implements OnInit {
this.navigationService.versionInfo.subscribe(vi => this.versionInfo = vi);
const hasNonEmptyToc = this.tocService.tocList.pipe(map(tocList => tocList.length > 0));
combineLatest(hasNonEmptyToc, this.showFloatingToc)
combineLatest([hasNonEmptyToc, this.showFloatingToc])
.subscribe(([hasToc, showFloatingToc]) => this.hasFloatingToc = hasToc && showFloatingToc);
// Generally, we want to delay updating the shell (e.g. host classes, sidenav state) for the new
@ -183,10 +183,10 @@ export class AppComponent implements OnInit {
// the new document applied prematurely).
// For the first document, though, (when we know there is no previous document), we want to
// ensure the styles are applied as soon as possible to avoid flicker.
combineLatest(
combineLatest([
this.documentService.currentDocument, // ...needed to determine host classes
this.navigationService.currentNodes) // ...needed to determine `sidenav` state
.pipe(first())
this.navigationService.currentNodes, // ...needed to determine `sidenav` state
]).pipe(first())
.subscribe(() => this.updateShell());
}

View File

@ -25,8 +25,8 @@ describe('AnnouncementBarComponent', () => {
providers: [{ provide: Logger, useClass: MockLogger }]
});
httpMock = injector.get(HttpTestingController);
mockLogger = injector.get(Logger);
httpMock = injector.inject(HttpTestingController);
mockLogger = injector.inject(Logger) as any;
fixture = TestBed.createComponent(AnnouncementBarComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@ -69,10 +69,10 @@ export class ApiListComponent implements OnInit {
ngOnInit() {
this.filteredSections =
combineLatest(
combineLatest([
this.apiService.sections,
this.criteriaSubject
).pipe(
this.criteriaSubject,
]).pipe(
map( results => ({ sections: results[0], criteria: results[1]})),
map( results => (
results.sections

View File

@ -35,11 +35,7 @@ describe('ApiService', () => {
it('subscribers should be completed/unsubscribed when service destroyed', () => {
let completed = false;
service.sections.subscribe(
undefined,
undefined,
() => completed = true
);
service.sections.subscribe({complete: () => completed = true});
service.ngOnDestroy();
expect(completed).toBe(true);

View File

@ -43,7 +43,7 @@ describe('ContributorService', () => {
it('contributors observable should complete', () => {
let completed = false;
contribService.contributors.subscribe(undefined, undefined, () => completed = true);
contribService.contributors.subscribe({complete: () => completed = true});
expect(completed).toBe(true, 'observable completed');
});

View File

@ -35,8 +35,8 @@ describe('ElementsLoader', () => {
]
});
elementsLoader = injector.get(ElementsLoader);
compiler = injector.get(Compiler);
elementsLoader = injector.inject(ElementsLoader);
compiler = injector.inject(Compiler);
});
describe('loadContainedCustomElements()', () => {

View File

@ -23,7 +23,7 @@ describe('LazyCustomElementComponent', () => {
],
});
mockLogger = injector.get(Logger);
mockLogger = injector.inject(Logger) as any;
fixture = TestBed.createComponent(LazyCustomElementComponent);
});

View File

@ -43,7 +43,7 @@ describe('ResourceService', () => {
it('categories observable should complete', () => {
let completed = false;
resourceService.categories.subscribe(undefined, undefined, () => completed = true);
resourceService.categories.subscribe({complete: () => completed = true});
expect(completed).toBe(true, 'observable completed');
});

View File

@ -1,7 +1,7 @@
import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { asapScheduler as asap, BehaviorSubject } from 'rxjs';
import { asapScheduler, BehaviorSubject } from 'rxjs';
import { ScrollService } from 'app/shared/scroll.service';
import { TocItem, TocService } from 'app/shared/toc.service';
@ -465,10 +465,11 @@ class TestScrollService {
class TestTocService {
tocList = new BehaviorSubject<TocItem[]>(getTestTocList());
activeItemIndex = new BehaviorSubject<number | null>(null);
setActiveIndex(index: number|null) {
this.activeItemIndex.next(index);
if (asap.scheduled !== undefined) {
asap.flush();
if (asapScheduler.actions.length > 0) {
asapScheduler.flush();
}
}
}

View File

@ -52,7 +52,10 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy {
// We use the `asap` scheduler because updates to `activeItemIndex` are triggered by DOM changes,
// which, in turn, are caused by the rendering that happened due to a ChangeDetection.
// Without asap, we would be updating the model while still in a ChangeDetection handler, which is disallowed by Angular.
combineLatest(this.tocService.activeItemIndex.pipe(subscribeOn(asapScheduler)), this.items.changes.pipe(startWith(this.items)))
combineLatest([
this.tocService.activeItemIndex.pipe(subscribeOn(asapScheduler)),
this.items.changes.pipe(startWith(this.items)),
])
.pipe(takeUntil(this.onDestroy))
.subscribe(([index, items]) => {
this.activeIndex = index;

View File

@ -30,11 +30,11 @@ describe('DocumentService', () => {
function getServices(initialUrl: string = '') {
const injector = createInjector(initialUrl);
httpMock = injector.get(HttpTestingController) as HttpTestingController;
httpMock = injector.inject(HttpTestingController);
return {
locationService: injector.get(LocationService) as MockLocationService,
docService: injector.get(DocumentService) as DocumentService,
logger: injector.get(Logger) as MockLogger
locationService: injector.inject(LocationService) as any as MockLocationService,
docService: injector.inject(DocumentService) as any as DocumentService,
logger: injector.inject(Logger) as any as MockLogger,
};
}

View File

@ -47,7 +47,7 @@ describe('NavigationService', () => {
it('navigationViews observable should complete', () => {
let completed = false;
navService.navigationViews.subscribe(undefined, undefined, () => completed = true);
navService.navigationViews.subscribe({complete: () => completed = true});
httpMock.expectOne({method: 'get', url: navigationPath}).flush({});
expect(completed).toBe(true, 'observable completed');

View File

@ -90,11 +90,12 @@ export class NavigationService {
* See above for discussion of using `connect`.
*/
private getCurrentNodes(navigationViews: Observable<NavigationViews>): Observable<CurrentNodes> {
const currentNodes = combineLatest(
const currentNodes = combineLatest([
navigationViews.pipe(
map(views => this.computeUrlToNavNodesMap(views))),
this.location.currentPath,
).pipe(
])
.pipe(
map((result) => ({navMap: result[0] , url: result[1]})),
map((result) => {
const matchSpecialUrls = /^api/.exec(result.url);

View File

@ -22,7 +22,7 @@ describe('ReportingErrorHandler service', () => {
});
it('should be registered on the AppModule', () => {
handler = TestBed.configureTestingModule({ imports: [AppModule] }).get(ErrorHandler);
handler = TestBed.configureTestingModule({ imports: [AppModule] }).inject(ErrorHandler) as any;
expect(handler).toEqual(jasmine.any(ReportingErrorHandler));
});