@ -64,13 +64,13 @@ describe('AppComponent', () => {
|
||||
const de = fixture.debugElement;
|
||||
const docViewerDe = de.query(By.css('aio-doc-viewer'));
|
||||
|
||||
documentService = de.injector.get(DocumentService) as DocumentService;
|
||||
documentService = de.injector.get<DocumentService>(DocumentService);
|
||||
docViewer = docViewerDe.nativeElement;
|
||||
docViewerComponent = docViewerDe.componentInstance;
|
||||
hamburger = de.query(By.css('.hamburger')).nativeElement;
|
||||
locationService = de.injector.get(LocationService) as any;
|
||||
locationService = de.injector.get<any>(LocationService);
|
||||
sidenav = de.query(By.directive(MatSidenav)).componentInstance;
|
||||
tocService = de.injector.get(TocService);
|
||||
tocService = de.injector.get<TocService>(TocService);
|
||||
|
||||
return waitForDoc && awaitDocRendered();
|
||||
};
|
||||
@ -463,7 +463,7 @@ describe('AppComponent', () => {
|
||||
let scrollToTopSpy: jasmine.Spy;
|
||||
|
||||
beforeEach(() => {
|
||||
scrollService = fixture.debugElement.injector.get(ScrollService);
|
||||
scrollService = fixture.debugElement.injector.get<ScrollService>(ScrollService);
|
||||
scrollSpy = spyOn(scrollService, 'scroll');
|
||||
scrollToTopSpy = spyOn(scrollService, 'scrollToTop');
|
||||
});
|
||||
|
@ -97,11 +97,11 @@ describe('ApiListComponent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('initial critera from location', () => {
|
||||
describe('initial criteria from location', () => {
|
||||
let locationService: TestLocationService;
|
||||
|
||||
beforeEach(() => {
|
||||
locationService = <any> fixture.componentRef.injector.get(LocationService);
|
||||
locationService = fixture.componentRef.injector.get<any>(LocationService);
|
||||
});
|
||||
|
||||
function expectOneItem(name: string, section: string, type: string, stability: string) {
|
||||
@ -110,7 +110,7 @@ describe('ApiListComponent', () => {
|
||||
component.filteredSections.subscribe(filtered => {
|
||||
expect(filtered.length).toBe(1, 'sections');
|
||||
expect(filtered[0].name).toBe(section, 'section name');
|
||||
const items = filtered[0].items.filter(item => item.show);
|
||||
const items = filtered[0].items.filter(i => i.show);
|
||||
expect(items.length).toBe(1, 'items');
|
||||
|
||||
const item = items[0];
|
||||
@ -168,7 +168,7 @@ describe('ApiListComponent', () => {
|
||||
let locationService: TestLocationService;
|
||||
|
||||
beforeEach(() => {
|
||||
locationService = <any> fixture.componentRef.injector.get(LocationService);
|
||||
locationService = fixture.componentRef.injector.get<any>(LocationService);
|
||||
});
|
||||
|
||||
it('should have query', () => {
|
||||
|
@ -16,9 +16,9 @@ import { ApiSection, ApiService } from './api.service';
|
||||
import { Option } from 'app/shared/select/select.component';
|
||||
|
||||
class SearchCriteria {
|
||||
query? = '';
|
||||
status? = 'all';
|
||||
type? = 'all';
|
||||
query ? = '';
|
||||
status ? = 'all';
|
||||
type ? = 'all';
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -21,7 +21,7 @@ describe('ApiService', () => {
|
||||
]
|
||||
});
|
||||
|
||||
service = injector.get(ApiService);
|
||||
service = injector.get<ApiService>(ApiService);
|
||||
httpMock = injector.get(HttpTestingController);
|
||||
});
|
||||
|
||||
|
@ -15,18 +15,18 @@ import { CodeComponent } from './code.component';
|
||||
*/
|
||||
@Component({
|
||||
selector: 'code-example',
|
||||
template: `
|
||||
template: `
|
||||
<!-- Content projection is used to get the content HTML provided to this component -->
|
||||
<div #content style="display: none"><ng-content></ng-content></div>
|
||||
|
||||
|
||||
<header *ngIf="title">{{title}}</header>
|
||||
|
||||
<aio-code [ngClass]="classes"
|
||||
[language]="language"
|
||||
[linenums]="linenums"
|
||||
[path]="path"
|
||||
[region]="region"
|
||||
[hideCopy]="hidecopy"
|
||||
<aio-code [ngClass]="classes"
|
||||
[language]="language"
|
||||
[linenums]="linenums"
|
||||
[path]="path"
|
||||
[region]="region"
|
||||
[hideCopy]="hidecopy"
|
||||
[title]="title">
|
||||
</aio-code>
|
||||
`,
|
||||
|
@ -87,7 +87,7 @@ describe('CodeTabsComponent', () => {
|
||||
region="region-B"
|
||||
title="title-B">
|
||||
Code example 2
|
||||
</code-pane>
|
||||
</code-pane>
|
||||
</code-tabs>
|
||||
`
|
||||
})
|
||||
|
@ -24,7 +24,7 @@ export interface TabInfo {
|
||||
template: `
|
||||
<!-- Use content projection so that the provided HTML's code-panes can be split into tabs -->
|
||||
<div #content style="display: none"><ng-content></ng-content></div>
|
||||
|
||||
|
||||
<mat-tab-group class="code-tab-group" disableRipple>
|
||||
<mat-tab style="overflow-y: hidden;" *ngFor="let tab of tabs">
|
||||
<ng-template mat-tab-label>
|
||||
@ -37,7 +37,7 @@ export interface TabInfo {
|
||||
[region]="tab.region"
|
||||
[title]="tab.title">
|
||||
</aio-code>
|
||||
</mat-tab>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
`,
|
||||
})
|
||||
|
@ -19,7 +19,7 @@ describe('ContributorService', () => {
|
||||
]
|
||||
});
|
||||
|
||||
contribService = injector.get(ContributorService);
|
||||
contribService = injector.get<ContributorService>(ContributorService);
|
||||
httpMock = injector.get(HttpTestingController);
|
||||
});
|
||||
|
||||
|
@ -11,5 +11,5 @@ export class Contributor {
|
||||
website?: string;
|
||||
twitter?: string;
|
||||
bio?: string;
|
||||
isFlipped? = false;
|
||||
isFlipped ? = false;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
type: TocType = 'None';
|
||||
isCollapsed = true;
|
||||
isEmbedded = false;
|
||||
@ViewChildren('tocItem') private items: QueryList<ElementRef>;
|
||||
@ViewChildren('createTocItem') private items: QueryList<ElementRef>;
|
||||
private onDestroy = new Subject();
|
||||
private primaryMax = 4;
|
||||
tocList: TocItem[];
|
||||
@ -90,5 +90,5 @@ export class TocComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
function count<T>(array: T[], fn: (item: T) => boolean) {
|
||||
return array.reduce((count, item) => fn(item) ? count + 1 : count, 0);
|
||||
return array.reduce((result, item) => fn(item) ? result + 1 : result, 0);
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ interface SvgIconMap {
|
||||
export class CustomIconRegistry extends MatIconRegistry {
|
||||
private preloadedSvgElements: SvgIconMap = {};
|
||||
|
||||
constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document, @Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) {
|
||||
constructor(http: HttpClient, sanitizer: DomSanitizer, @Optional() @Inject(DOCUMENT) document,
|
||||
@Inject(SVG_ICONS) svgIcons: SvgIconInfo[]) {
|
||||
super(http, sanitizer, document);
|
||||
this.loadSvgElements(svgIcons);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { DOCUMENT } from '@angular/platform-browser';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { fromEvent, Observable, ReplaySubject, Subject } from 'rxjs';
|
||||
import { auditTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { ReflectiveInjector } from '@angular/core';
|
||||
import { DOCUMENT, DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import { ScrollItem, ScrollSpyInfo, ScrollSpyService } from 'app/shared/scroll-spy.service';
|
||||
@ -33,8 +34,8 @@ describe('TocService', () => {
|
||||
|
||||
describe('tocList', () => {
|
||||
it('should emit the latest value to new subscribers', () => {
|
||||
const expectedValue1 = tocItem('Heading A');
|
||||
const expectedValue2 = tocItem('Heading B');
|
||||
const expectedValue1 = createTocItem('Heading A');
|
||||
const expectedValue2 = createTocItem('Heading B');
|
||||
let value1: TocItem[]|undefined;
|
||||
let value2: TocItem[]|undefined;
|
||||
|
||||
@ -48,8 +49,8 @@ describe('TocService', () => {
|
||||
});
|
||||
|
||||
it('should emit the same values to all subscribers', () => {
|
||||
const expectedValue1 = tocItem('Heading A');
|
||||
const expectedValue2 = tocItem('Heading B');
|
||||
const expectedValue1 = createTocItem('Heading A');
|
||||
const expectedValue2 = createTocItem('Heading B');
|
||||
const emittedValues: TocItem[][] = [];
|
||||
|
||||
tocService.tocList.subscribe(v => emittedValues.push(v));
|
||||
@ -149,8 +150,8 @@ describe('TocService', () => {
|
||||
describe('should clear tocList', () => {
|
||||
beforeEach(() => {
|
||||
// Start w/ dummy data from previous usage
|
||||
const expectedValue1 = tocItem('Heading A');
|
||||
const expectedValue2 = tocItem('Heading B');
|
||||
const expectedValue1 = createTocItem('Heading A');
|
||||
const expectedValue2 = createTocItem('Heading B');
|
||||
tocService.tocList.next([expectedValue1, expectedValue2]);
|
||||
expect(lastTocList).not.toEqual([]);
|
||||
});
|
||||
@ -369,7 +370,7 @@ class MockScrollSpyService {
|
||||
}
|
||||
}
|
||||
|
||||
function tocItem(title: string, level = 'h2', href = '', content = title) {
|
||||
function createTocItem(title: string, level = 'h2', href = '', content = title) {
|
||||
return { title, href, level, content };
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { DOCUMENT, DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { ScrollSpyInfo, ScrollSpyService } from 'app/shared/scroll-spy.service';
|
||||
|
||||
|
17
aio/src/tslint.json
Normal file
17
aio/src/tslint.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"directive-selector": [
|
||||
true,
|
||||
"attribute",
|
||||
"aio",
|
||||
"camelCase"
|
||||
],
|
||||
"component-selector": [
|
||||
true,
|
||||
"element",
|
||||
"aio",
|
||||
"kebab-case"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user