refactor(docs-infra): fix some linting warnings (#32980)
PR Close #32980
This commit is contained in:
parent
a2d2a5d572
commit
d349cd91b1
@ -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
|
// Compute the version picker list from the current version and the versions in the navigation map
|
||||||
combineLatest(
|
combineLatest([
|
||||||
this.navigationService.versionInfo,
|
this.navigationService.versionInfo,
|
||||||
this.navigationService.navigationViews.pipe(map(views => views['docVersions'])))
|
this.navigationService.navigationViews.pipe(map(views => views['docVersions'])),
|
||||||
.subscribe(([versionInfo, versions]) => {
|
]).subscribe(([versionInfo, versions]) => {
|
||||||
// TODO(pbd): consider whether we can lookup the stable and next versions from the internet
|
// TODO(pbd): consider whether we can lookup the stable and next versions from the internet
|
||||||
const computedVersions: NavigationNode[] = [
|
const computedVersions: NavigationNode[] = [
|
||||||
{ title: 'next', url: 'https://next.angular.io' },
|
{ title: 'next', url: 'https://next.angular.io' },
|
||||||
@ -175,7 +175,7 @@ export class AppComponent implements OnInit {
|
|||||||
this.navigationService.versionInfo.subscribe(vi => this.versionInfo = vi);
|
this.navigationService.versionInfo.subscribe(vi => this.versionInfo = vi);
|
||||||
|
|
||||||
const hasNonEmptyToc = this.tocService.tocList.pipe(map(tocList => tocList.length > 0));
|
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);
|
.subscribe(([hasToc, showFloatingToc]) => this.hasFloatingToc = hasToc && showFloatingToc);
|
||||||
|
|
||||||
// Generally, we want to delay updating the shell (e.g. host classes, sidenav state) for the new
|
// 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).
|
// the new document applied prematurely).
|
||||||
// For the first document, though, (when we know there is no previous document), we want to
|
// 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.
|
// ensure the styles are applied as soon as possible to avoid flicker.
|
||||||
combineLatest(
|
combineLatest([
|
||||||
this.documentService.currentDocument, // ...needed to determine host classes
|
this.documentService.currentDocument, // ...needed to determine host classes
|
||||||
this.navigationService.currentNodes) // ...needed to determine `sidenav` state
|
this.navigationService.currentNodes, // ...needed to determine `sidenav` state
|
||||||
.pipe(first())
|
]).pipe(first())
|
||||||
.subscribe(() => this.updateShell());
|
.subscribe(() => this.updateShell());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ describe('AnnouncementBarComponent', () => {
|
|||||||
providers: [{ provide: Logger, useClass: MockLogger }]
|
providers: [{ provide: Logger, useClass: MockLogger }]
|
||||||
});
|
});
|
||||||
|
|
||||||
httpMock = injector.get(HttpTestingController);
|
httpMock = injector.inject(HttpTestingController);
|
||||||
mockLogger = injector.get(Logger);
|
mockLogger = injector.inject(Logger) as any;
|
||||||
fixture = TestBed.createComponent(AnnouncementBarComponent);
|
fixture = TestBed.createComponent(AnnouncementBarComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
element = fixture.nativeElement;
|
element = fixture.nativeElement;
|
||||||
|
@ -69,10 +69,10 @@ export class ApiListComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.filteredSections =
|
this.filteredSections =
|
||||||
combineLatest(
|
combineLatest([
|
||||||
this.apiService.sections,
|
this.apiService.sections,
|
||||||
this.criteriaSubject
|
this.criteriaSubject,
|
||||||
).pipe(
|
]).pipe(
|
||||||
map( results => ({ sections: results[0], criteria: results[1]})),
|
map( results => ({ sections: results[0], criteria: results[1]})),
|
||||||
map( results => (
|
map( results => (
|
||||||
results.sections
|
results.sections
|
||||||
|
@ -35,11 +35,7 @@ describe('ApiService', () => {
|
|||||||
it('subscribers should be completed/unsubscribed when service destroyed', () => {
|
it('subscribers should be completed/unsubscribed when service destroyed', () => {
|
||||||
let completed = false;
|
let completed = false;
|
||||||
|
|
||||||
service.sections.subscribe(
|
service.sections.subscribe({complete: () => completed = true});
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
() => completed = true
|
|
||||||
);
|
|
||||||
|
|
||||||
service.ngOnDestroy();
|
service.ngOnDestroy();
|
||||||
expect(completed).toBe(true);
|
expect(completed).toBe(true);
|
||||||
|
@ -43,7 +43,7 @@ describe('ContributorService', () => {
|
|||||||
|
|
||||||
it('contributors observable should complete', () => {
|
it('contributors observable should complete', () => {
|
||||||
let completed = false;
|
let completed = false;
|
||||||
contribService.contributors.subscribe(undefined, undefined, () => completed = true);
|
contribService.contributors.subscribe({complete: () => completed = true});
|
||||||
expect(completed).toBe(true, 'observable completed');
|
expect(completed).toBe(true, 'observable completed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@ describe('ElementsLoader', () => {
|
|||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
elementsLoader = injector.get(ElementsLoader);
|
elementsLoader = injector.inject(ElementsLoader);
|
||||||
compiler = injector.get(Compiler);
|
compiler = injector.inject(Compiler);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('loadContainedCustomElements()', () => {
|
describe('loadContainedCustomElements()', () => {
|
||||||
|
@ -23,7 +23,7 @@ describe('LazyCustomElementComponent', () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
mockLogger = injector.get(Logger);
|
mockLogger = injector.inject(Logger) as any;
|
||||||
fixture = TestBed.createComponent(LazyCustomElementComponent);
|
fixture = TestBed.createComponent(LazyCustomElementComponent);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ describe('ResourceService', () => {
|
|||||||
|
|
||||||
it('categories observable should complete', () => {
|
it('categories observable should complete', () => {
|
||||||
let completed = false;
|
let completed = false;
|
||||||
resourceService.categories.subscribe(undefined, undefined, () => completed = true);
|
resourceService.categories.subscribe({complete: () => completed = true});
|
||||||
expect(completed).toBe(true, 'observable completed');
|
expect(completed).toBe(true, 'observable completed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
|
import { Component, CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { By } from '@angular/platform-browser';
|
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 { ScrollService } from 'app/shared/scroll.service';
|
||||||
import { TocItem, TocService } from 'app/shared/toc.service';
|
import { TocItem, TocService } from 'app/shared/toc.service';
|
||||||
@ -465,10 +465,11 @@ class TestScrollService {
|
|||||||
class TestTocService {
|
class TestTocService {
|
||||||
tocList = new BehaviorSubject<TocItem[]>(getTestTocList());
|
tocList = new BehaviorSubject<TocItem[]>(getTestTocList());
|
||||||
activeItemIndex = new BehaviorSubject<number | null>(null);
|
activeItemIndex = new BehaviorSubject<number | null>(null);
|
||||||
|
|
||||||
setActiveIndex(index: number|null) {
|
setActiveIndex(index: number|null) {
|
||||||
this.activeItemIndex.next(index);
|
this.activeItemIndex.next(index);
|
||||||
if (asap.scheduled !== undefined) {
|
if (asapScheduler.actions.length > 0) {
|
||||||
asap.flush();
|
asapScheduler.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
// 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.
|
// 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.
|
// 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))
|
.pipe(takeUntil(this.onDestroy))
|
||||||
.subscribe(([index, items]) => {
|
.subscribe(([index, items]) => {
|
||||||
this.activeIndex = index;
|
this.activeIndex = index;
|
||||||
|
@ -30,11 +30,11 @@ describe('DocumentService', () => {
|
|||||||
|
|
||||||
function getServices(initialUrl: string = '') {
|
function getServices(initialUrl: string = '') {
|
||||||
const injector = createInjector(initialUrl);
|
const injector = createInjector(initialUrl);
|
||||||
httpMock = injector.get(HttpTestingController) as HttpTestingController;
|
httpMock = injector.inject(HttpTestingController);
|
||||||
return {
|
return {
|
||||||
locationService: injector.get(LocationService) as MockLocationService,
|
locationService: injector.inject(LocationService) as any as MockLocationService,
|
||||||
docService: injector.get(DocumentService) as DocumentService,
|
docService: injector.inject(DocumentService) as any as DocumentService,
|
||||||
logger: injector.get(Logger) as MockLogger
|
logger: injector.inject(Logger) as any as MockLogger,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ describe('NavigationService', () => {
|
|||||||
|
|
||||||
it('navigationViews observable should complete', () => {
|
it('navigationViews observable should complete', () => {
|
||||||
let completed = false;
|
let completed = false;
|
||||||
navService.navigationViews.subscribe(undefined, undefined, () => completed = true);
|
navService.navigationViews.subscribe({complete: () => completed = true});
|
||||||
|
|
||||||
httpMock.expectOne({method: 'get', url: navigationPath}).flush({});
|
httpMock.expectOne({method: 'get', url: navigationPath}).flush({});
|
||||||
expect(completed).toBe(true, 'observable completed');
|
expect(completed).toBe(true, 'observable completed');
|
||||||
|
@ -90,11 +90,12 @@ export class NavigationService {
|
|||||||
* See above for discussion of using `connect`.
|
* See above for discussion of using `connect`.
|
||||||
*/
|
*/
|
||||||
private getCurrentNodes(navigationViews: Observable<NavigationViews>): Observable<CurrentNodes> {
|
private getCurrentNodes(navigationViews: Observable<NavigationViews>): Observable<CurrentNodes> {
|
||||||
const currentNodes = combineLatest(
|
const currentNodes = combineLatest([
|
||||||
navigationViews.pipe(
|
navigationViews.pipe(
|
||||||
map(views => this.computeUrlToNavNodesMap(views))),
|
map(views => this.computeUrlToNavNodesMap(views))),
|
||||||
this.location.currentPath,
|
this.location.currentPath,
|
||||||
).pipe(
|
])
|
||||||
|
.pipe(
|
||||||
map((result) => ({navMap: result[0] , url: result[1]})),
|
map((result) => ({navMap: result[0] , url: result[1]})),
|
||||||
map((result) => {
|
map((result) => {
|
||||||
const matchSpecialUrls = /^api/.exec(result.url);
|
const matchSpecialUrls = /^api/.exec(result.url);
|
||||||
|
@ -22,7 +22,7 @@ describe('ReportingErrorHandler service', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should be registered on the AppModule', () => {
|
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));
|
expect(handler).toEqual(jasmine.any(ReportingErrorHandler));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user