build(docs-infra): upgrade tslint to 5.15.0 and codelyzer to 5.0.0 (#29926)
This commit also changes the `tslint.json` config file to (reasonably closely) match what the cli would generate for a new app. PR Close #29926
This commit is contained in:

committed by
Andrew Kushnir

parent
eb85c8a742
commit
282167a37f
@ -789,7 +789,7 @@ describe('AppComponent', () => {
|
||||
{ path: 'news', title: 'News', type: 'marketing', keywords: '', titleWords: '', deprecated: false }
|
||||
];
|
||||
|
||||
searchService.searchResults.next({ query: 'something', results: results });
|
||||
searchService.searchResults.next({ query: 'something', results });
|
||||
component.showSearchResults = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
|
@ -284,10 +284,10 @@ export class AppComponent implements OnInit {
|
||||
|
||||
notificationDismissed() {
|
||||
this.notificationAnimating = true;
|
||||
// this should be kept in sync with the animation durations in:
|
||||
// - aio/src/styles/2-modules/_notification.scss
|
||||
// - aio/src/app/layout/notification/notification.component.ts
|
||||
setTimeout(() => this.notificationAnimating = false, 250);
|
||||
// this should be kept in sync with the animation durations in:
|
||||
// - aio/src/styles/2-modules/_notification.scss
|
||||
// - aio/src/app/layout/notification/notification.component.ts
|
||||
setTimeout(() => this.notificationAnimating = false, 250);
|
||||
this.updateHostClasses();
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ export class ApiService implements OnDestroy {
|
||||
private _sections = this.sectionsSubject.pipe(takeUntil(this.onDestroy));
|
||||
|
||||
/**
|
||||
* Return a cached observable of API sections from a JSON file.
|
||||
* API sections is an array of Angular top modules and metadata about their API documents (items).
|
||||
* Return a cached observable of API sections from a JSON file.
|
||||
* API sections is an array of Angular top modules and metadata about their API documents (items).
|
||||
*/
|
||||
get sections() {
|
||||
|
||||
|
@ -48,16 +48,15 @@ export class CodeTabsComponent implements OnInit, AfterViewInit {
|
||||
|
||||
@Input() linenums: string;
|
||||
|
||||
@ViewChild('content', { static: true }) content: ElementRef;
|
||||
@ViewChild('content', { static: true }) content: ElementRef<HTMLDivElement>;
|
||||
|
||||
@ViewChildren(CodeComponent) codeComponents: QueryList<CodeComponent>;
|
||||
|
||||
ngOnInit() {
|
||||
this.tabs = [];
|
||||
const codeExamples = this.content.nativeElement.querySelectorAll('code-pane');
|
||||
const codeExamples = Array.from(this.content.nativeElement.querySelectorAll('code-pane'));
|
||||
|
||||
for (let i = 0; i < codeExamples.length; i++) {
|
||||
const tabContent = codeExamples[i];
|
||||
for (const tabContent of codeExamples) {
|
||||
this.tabs.push(this.getTabInfo(tabContent));
|
||||
}
|
||||
}
|
||||
@ -69,7 +68,7 @@ export class CodeTabsComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
/** Gets the extracted TabInfo data from the provided code-pane element. */
|
||||
private getTabInfo(tabContent: HTMLElement): TabInfo {
|
||||
private getTabInfo(tabContent: Element): TabInfo {
|
||||
return {
|
||||
class: tabContent.getAttribute('class'),
|
||||
code: tabContent.innerHTML,
|
||||
|
@ -177,9 +177,9 @@ describe('DocViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should fall back to `textContent` if `innerText` is not available', () => {
|
||||
const querySelector_ = targetEl.querySelector;
|
||||
const querySelector = targetEl.querySelector;
|
||||
spyOn(targetEl, 'querySelector').and.callFake((selector: string) => {
|
||||
const elem = querySelector_.call(targetEl, selector);
|
||||
const elem = querySelector.call(targetEl, selector);
|
||||
return elem && Object.defineProperties(elem, {
|
||||
innerText: {value: undefined},
|
||||
textContent: {value: 'Text Content'},
|
||||
@ -192,9 +192,9 @@ describe('DocViewerComponent', () => {
|
||||
});
|
||||
|
||||
it('should still use `innerText` if available but empty', () => {
|
||||
const querySelector_ = targetEl.querySelector;
|
||||
const querySelector = targetEl.querySelector;
|
||||
spyOn(targetEl, 'querySelector').and.callFake((selector: string) => {
|
||||
const elem = querySelector_.call(targetEl, selector);
|
||||
const elem = querySelector.call(targetEl, selector);
|
||||
return elem && Object.defineProperties(elem, {
|
||||
innerText: { value: '' },
|
||||
textContent: { value: 'Text Content' }
|
||||
|
@ -30,7 +30,9 @@ export class SearchBoxComponent implements OnInit {
|
||||
private searchSubject = new Subject<string>();
|
||||
|
||||
@ViewChild('searchBox', { static: true }) searchBox: ElementRef;
|
||||
// tslint:disable-next-line: no-output-on-prefix
|
||||
@Output() onSearch = this.searchSubject.pipe(distinctUntilChanged(), debounceTime(this.searchDebounce));
|
||||
// tslint:disable-next-line: no-output-on-prefix
|
||||
@Output() onFocus = new EventEmitter<string>();
|
||||
|
||||
constructor(private locationService: LocationService) { }
|
||||
|
@ -21,17 +21,17 @@ addEventListener('message', handleMessage);
|
||||
|
||||
// Create the lunr index - the docs should be an array of objects, each object containing
|
||||
// the path and search terms for a page
|
||||
function createIndex(loadIndex: IndexLoader): lunr.Index {
|
||||
function createIndex(loadIndexFn: IndexLoader): lunr.Index {
|
||||
// The lunr typings are missing QueryLexer so we have to add them here manually.
|
||||
const queryLexer = (lunr as any as { QueryLexer: { termSeparator: RegExp } }).QueryLexer;
|
||||
queryLexer.termSeparator = lunr.tokenizer.separator = /\s+/;
|
||||
return lunr(/** @this */function () {
|
||||
return lunr(/** @this */function() {
|
||||
this.ref('path');
|
||||
this.field('titleWords', { boost: 10 });
|
||||
this.field('headingWords', { boost: 5 });
|
||||
this.field('members', { boost: 4 });
|
||||
this.field('keywords', { boost: 2 });
|
||||
loadIndex(this);
|
||||
loadIndexFn(this);
|
||||
});
|
||||
}
|
||||
|
||||
@ -42,16 +42,16 @@ function handleMessage(message: { data: WebWorkerMessage }): void {
|
||||
const payload = message.data.payload;
|
||||
switch (type) {
|
||||
case 'load-index':
|
||||
makeRequest(SEARCH_TERMS_URL, function (searchInfo: PageInfo[]) {
|
||||
makeRequest(SEARCH_TERMS_URL, function(searchInfo: PageInfo[]) {
|
||||
index = createIndex(loadIndex(searchInfo));
|
||||
postMessage({ type: type, id: id, payload: true });
|
||||
postMessage({ type, id, payload: true });
|
||||
});
|
||||
break;
|
||||
case 'query-index':
|
||||
postMessage({ type: type, id: id, payload: { query: payload, results: queryIndex(payload) } });
|
||||
postMessage({ type, id, payload: { query: payload, results: queryIndex(payload) } });
|
||||
break;
|
||||
default:
|
||||
postMessage({ type: type, id: id, payload: { error: 'invalid message type' } })
|
||||
postMessage({ type, id, payload: { error: 'invalid message type' } });
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ function makeRequest(url: string, callback: (response: any) => void): void {
|
||||
|
||||
// The JSON file that is loaded should be an array of PageInfo:
|
||||
const searchDataRequest = new XMLHttpRequest();
|
||||
searchDataRequest.onload = function () {
|
||||
searchDataRequest.onload = function() {
|
||||
callback(JSON.parse(this.responseText));
|
||||
};
|
||||
searchDataRequest.open('GET', url);
|
||||
@ -92,7 +92,7 @@ function queryIndex(query: string): PageInfo[] {
|
||||
results = index.search(query + ' ' + titleQuery);
|
||||
}
|
||||
// Map the hits into info about each page to be returned as results
|
||||
return results.map(function (hit) { return pages[hit.ref]; });
|
||||
return results.map(function(hit) { return pages[hit.ref]; });
|
||||
}
|
||||
} catch (e) {
|
||||
// If the search query cannot be parsed the index throws an error
|
||||
|
@ -10,7 +10,7 @@ export interface AttrMap {
|
||||
* Attribute map keys are forced lowercase for case-insensitive lookup.
|
||||
* @param el The source of the attributes.
|
||||
*/
|
||||
export function getAttrs(el: HTMLElement | ElementRef): AttrMap {
|
||||
export function getAttrs(el: HTMLElement | ElementRef): AttrMap {
|
||||
const attrs: NamedNodeMap = el instanceof ElementRef ? el.nativeElement.attributes : el.attributes;
|
||||
const attrMap: AttrMap = {};
|
||||
for (const attr of attrs as any as Attr[] /* cast due to https://github.com/Microsoft/TypeScript/issues/2695 */) {
|
||||
@ -47,7 +47,7 @@ export function boolFromValue(attrValue: string | undefined, def: boolean = fals
|
||||
* @param def Default boolean value when attribute is undefined.
|
||||
*/
|
||||
export function getBoolFromAttribute(
|
||||
el: HTMLElement | ElementRef,
|
||||
el: HTMLElement | ElementRef,
|
||||
attr: string | string[],
|
||||
def: boolean = false): boolean {
|
||||
return boolFromValue(getAttrValue(getAttrs(el), attr), def);
|
||||
|
@ -230,7 +230,7 @@ describe('ScrollService', () => {
|
||||
|
||||
describe('#scrollToTop', () => {
|
||||
it('should scroll to top', () => {
|
||||
const topOfPageElement = <Element><any> new MockElement();
|
||||
const topOfPageElement = new MockElement() as any as Element;
|
||||
document.getElementById.and.callFake(
|
||||
(id: string) => id === 'top-of-page' ? topOfPageElement : null
|
||||
);
|
||||
@ -253,7 +253,7 @@ describe('ScrollService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#needToFixScrollPosition', async() => {
|
||||
describe('#needToFixScrollPosition', async () => {
|
||||
it('should return true when popState event was fired after a back navigation if the browser supports ' +
|
||||
'scrollRestoration`. Otherwise, needToFixScrollPosition() returns false', () => {
|
||||
|
||||
@ -305,7 +305,7 @@ describe('ScrollService', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#scrollAfterRender', async() => {
|
||||
describe('#scrollAfterRender', async () => {
|
||||
|
||||
let scrollSpy: jasmine.Spy;
|
||||
let scrollToTopSpy: jasmine.Spy;
|
||||
|
@ -16,6 +16,7 @@ export class SelectComponent implements OnInit {
|
||||
@Input()
|
||||
options: Option[];
|
||||
|
||||
// tslint:disable-next-line: no-output-native
|
||||
@Output()
|
||||
change = new EventEmitter<{option: Option, index: number}>();
|
||||
|
||||
|
@ -264,7 +264,7 @@ describe('TocService', () => {
|
||||
it('should have "SafeHtml" content which is heading\'s innerHTML ', () => {
|
||||
const heading = headings[3];
|
||||
const content = lastTocList[3].content;
|
||||
expect((<TestSafeHtml>content).changingThisBreaksApplicationSecurity)
|
||||
expect((content as TestSafeHtml).changingThisBreaksApplicationSecurity)
|
||||
.toEqual(heading.innerHTML);
|
||||
});
|
||||
|
||||
@ -321,7 +321,7 @@ describe('TocService', () => {
|
||||
});
|
||||
|
||||
it('should have removed anchor link from tocItem html content', () => {
|
||||
expect((<TestSafeHtml>tocItem.content)
|
||||
expect((tocItem.content as TestSafeHtml)
|
||||
.changingThisBreaksApplicationSecurity)
|
||||
.toEqual('Setup to develop <i>locally</i>.');
|
||||
});
|
||||
|
@ -56,9 +56,8 @@ export class TocService {
|
||||
private extractHeadingSafeHtml(heading: HTMLHeadingElement) {
|
||||
const div: HTMLDivElement = this.document.createElement('div');
|
||||
div.innerHTML = heading.innerHTML;
|
||||
const anchorLinks: NodeListOf<HTMLAnchorElement> = div.querySelectorAll('a');
|
||||
for (let i = 0; i < anchorLinks.length; i++) {
|
||||
const anchorLink = anchorLinks[i];
|
||||
const anchorLinks = Array.from(div.querySelectorAll('a'));
|
||||
for (const anchorLink of anchorLinks) {
|
||||
if (!anchorLink.classList.contains('header-link')) {
|
||||
// this is an anchor that contains actual content that we want to keep
|
||||
// move the contents of the anchor into its parent
|
||||
|
@ -59,7 +59,7 @@ export class SwUpdatesService implements OnDestroy {
|
||||
}
|
||||
|
||||
private log(message: string) {
|
||||
const timestamp = (new Date).toISOString();
|
||||
const timestamp = new Date().toISOString();
|
||||
this.logger.log(`[SwUpdates - ${timestamp}]: ${message}`);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": "../tslint.json",
|
||||
"rules": {
|
||||
"directive-selector": [
|
||||
true,
|
||||
"attribute",
|
||||
"aio",
|
||||
"camelCase"
|
||||
],
|
||||
"component-selector": [
|
||||
true,
|
||||
"element",
|
||||
"aio",
|
||||
"kebab-case"
|
||||
]
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user