added TSLint for TypeScript code style checking, fixed associated errors

This commit is contained in:
alecmerdler 2017-06-19 23:17:42 -07:00
parent 6a7722cadb
commit 41e7e559a6
43 changed files with 253 additions and 730 deletions

View file

@ -47,4 +47,4 @@ export class AvatarServiceImpl implements AvatarService {
return this.cache[cacheKey] = hash;
}
}
}

View file

@ -19,4 +19,4 @@ export abstract class AvatarService {
* @return hash The hash for the avatar image.
*/
public abstract computeHash(email?: string, name?: string): string;
}
}

View file

@ -73,7 +73,8 @@ export class BuildServiceImpl implements BuildService {
break;
case 'internalerror':
message = 'An internal system error occurred while building; the build will be retried in the next few minutes.';
message = 'An internal system error occurred while building; ' +
'the build will be retried in the next few minutes.';
break;
case 'cancelled':
@ -86,4 +87,4 @@ export class BuildServiceImpl implements BuildService {
return message;
}
}
}

View file

@ -16,4 +16,4 @@ export abstract class BuildService {
* @return buildMessage The message associated with the given phase.
*/
public abstract getBuildMessage(phase: string): string;
}
}

View file

@ -86,7 +86,7 @@ export class DataFileServiceImpl implements DataFileService {
var zip = null;
var zipFiles = null;
try {
var zip = new JSZip(buf);
zip = new JSZip(buf);
zipFiles = zip.files;
} catch (e) {
failure();
@ -164,9 +164,9 @@ export class DataFileServiceImpl implements DataFileService {
'name': this.getName(path),
'path': path,
'canRead': true,
'toBlob': (function(currentFile) {
'toBlob': (function(file) {
return function() {
return new Blob([currentFile.buffer], {type: 'application/octet-binary'});
return new Blob([file.buffer], {type: 'application/octet-binary'});
};
}(currentFile))
});
@ -179,4 +179,4 @@ export class DataFileServiceImpl implements DataFileService {
failure();
}
}
}
}

View file

@ -45,4 +45,4 @@ export abstract class DataFileService {
progress: (percent: number) => void,
error: () => void,
loaded: (uint8array: Uint8Array) => void): void;
}
}

View file

@ -104,11 +104,11 @@ export class DockerfileInfoImpl implements DockerfileInfo {
return null;
}
if (baseImage.indexOf(this.config.getDomain() + '/') != 0) {
if (baseImage.indexOf(`${this.config.getDomain()}/`) != 0) {
return null;
}
return baseImage.substring(this.config.getDomain().length + 1);
return baseImage.substring(<number>this.config.getDomain().length + 1);
}
public getBaseImage(): string | null {
@ -152,4 +152,4 @@ export class DockerfileInfoImpl implements DockerfileInfo {
return baseImageAndTag;
}
}
}

View file

@ -35,4 +35,4 @@ export abstract class DockerfileInfo {
* @return baseImageAndTag The base image and tag.
*/
public abstract getBaseImageAndTag(): string | null;
}
}

View file

@ -1,15 +1,11 @@
import { Injectable } from 'ng-metadata/core';
import { PageService } from './page.service';
import { PageService, QuayPage, QuayPageProfile } from './page.service';
@Injectable(PageService.name)
export class PageServiceImpl implements ng.IServiceProvider {
private pages: any = {};
constructor() {
}
private pages: {[pageName: string]: QuayPage} = {};
public create(pageName: string,
templateName: string,
@ -26,8 +22,8 @@ export class PageServiceImpl implements ng.IServiceProvider {
}
}
public get(pageName: string, profiles: any[]): any[] | null {
for (var i = 0; i < profiles.length; ++i) {
public get(pageName: string, profiles: QuayPageProfile[]): [QuayPageProfile, QuayPage] | null {
for (let i = 0; i < profiles.length; ++i) {
var current = profiles[i];
var key = current.id + ':' + pageName;
var page = this.pages[key];

View file

@ -22,7 +22,7 @@ export abstract class PageService implements ng.IServiceProvider {
* @param pageName The name of the page.
* @param profiles Available profiles to search.
*/
public abstract get(pageName: string, profiles: any[]): any[] | null;
public abstract get(pageName: string, profiles: QuayPageProfile[]): [QuayPageProfile, QuayPage] | null;
/**
* Provide the service instance.
@ -30,3 +30,24 @@ export abstract class PageService implements ng.IServiceProvider {
*/
public abstract $get(): PageService;
}
/**
* A type representing a registered application page.
*/
export type QuayPage = {
name: string;
controller: ng.IController;
templateName: string,
flags: {[key: string]: any};
};
/**
* Represents a page profile type.
*/
export type QuayPageProfile = {
id: string;
templatePath: string;
};

View file

@ -1,13 +1,13 @@
import { RouteBuilder } from './route-builder.service';
import { Injectable, Inject } from 'ng-metadata/core';
import { PageService } from '../page/page.service';
import { PageService, QuayPage, QuayPageProfile } from '../page/page.service';
@Injectable(RouteBuilder.name)
export class RouteBuilderImpl implements RouteBuilder {
public currentProfile: string = 'layout';
public profiles: any[] = [
public profiles: QuayPageProfile[] = [
// Start with the old pages (if we asked for it).
{id: 'old-layout', templatePath: '/static/partials/'},
// Fallback back combined new/existing pages.
@ -50,4 +50,4 @@ export class RouteBuilderImpl implements RouteBuilder {
return this;
}
}
}

View file

@ -15,4 +15,4 @@ export abstract class RouteBuilder {
* @param pagename The name of the page to associate with this route.
*/
public abstract route(path: string, pagename: string): RouteBuilder;
}
}

View file

@ -1,40 +0,0 @@
import { UtilServiceImpl } from './util.service.impl';
describe("UtilServiceImpl", () => {
var utilServiceImpl: UtilServiceImpl;
var $sanitizeMock: ng.sanitize.ISanitizeService;
beforeEach(() => {
$sanitizeMock = jasmine.createSpy('$sanitizeSpy').and.returnValue("");
utilServiceImpl = new UtilServiceImpl($sanitizeMock);
});
describe("isAdBlockEnabled", () => {
// TODO
});
describe("isEmailAddress", () => {
// TODO
});
describe("getMarkedDown", () => {
// TODO
});
describe("getFirstMarkdownLineAsText", () => {
// TODO
});
describe("escapeHtmlString", () => {
// TODO
});
describe("getRestUrl", () => {
// TODO
});
describe("textToSafeHtml", () => {
// TODO
});
});

View file

@ -1,39 +0,0 @@
import { Injectable, Inject } from 'ng-metadata/core';
import { UtilService } from './util.service';
@Injectable(UtilService.name)
export class UtilServiceImpl implements UtilService {
constructor(@Inject('$sanitize') private $sanitize: ng.sanitize.ISanitizeService) {
}
public isAdBlockEnabled(callback: (isEnabled: boolean) => void): void {
}
public isEmailAddress(str: string): boolean {
return null;
}
public getMarkedDown(str: string): string {
return null;
}
public getFirstMarkdownLineAsText(commentString: string, placeholderNeeded: boolean): string {
return null;
}
public escapeHtmlString(text: string): string {
return null;
}
public getRestUrl(args: any[]): string {
return null;
}
public textToSafeHtml(text: string): string {
return null;
}
}

View file

@ -1,19 +0,0 @@
/**
* Service which exposes various utility methods.
*/
export abstract class UtilService {
public abstract isAdBlockEnabled(callback: (isEnabled: boolean) => void): void;
public abstract isEmailAddress(str: string): boolean;
public abstract getMarkedDown(str: string): string;
public abstract getFirstMarkdownLineAsText(commentString: string, placeholderNeeded: boolean): string;
public abstract escapeHtmlString(text: string): string;
public abstract getRestUrl(args: any[]): string;
public abstract textToSafeHtml(text: string): string;
}

View file

@ -93,4 +93,4 @@ export class ViewArrayImpl implements ViewArray {
this.timerRef = null;
}
}
}
}

View file

@ -68,4 +68,4 @@ export abstract class ViewArray {
* @return viewArray New ViewArray instance.
*/
public abstract create(): ViewArrayImpl;
}
}