style(lint): re-format modules/@angular

This commit is contained in:
Alex Eagle
2016-06-08 16:38:52 -07:00
parent bbed364e7b
commit f39c9c9e75
589 changed files with 21829 additions and 24259 deletions

View File

@ -1,14 +1,13 @@
import {global, noop} from './lang';
export {PromiseWrapper, PromiseCompleter} from './promise';
import {Observable} from 'rxjs/Observable';
import {Subject} from 'rxjs/Subject';
import {PromiseObservable} from 'rxjs/observable/PromiseObservable';
import {toPromise} from 'rxjs/operator/toPromise';
import {global, noop} from './lang';
export {Observable} from 'rxjs/Observable';
export {Subject} from 'rxjs/Subject';
export {PromiseCompleter, PromiseWrapper} from './promise';
export class TimerWrapper {
static setTimeout(fn: (...args: any[]) => void, millis: number): number {
@ -24,10 +23,11 @@ export class TimerWrapper {
export class ObservableWrapper {
// TODO(vsavkin): when we use rxnext, try inferring the generic type from the first arg
static subscribe<T>(emitter: any, onNext: (value: T) => void, onError?: (exception: any) => void,
onComplete: () => void = () => {}): Object {
onError = (typeof onError === "function") && onError || noop;
onComplete = (typeof onComplete === "function") && onComplete || noop;
static subscribe<T>(
emitter: any, onNext: (value: T) => void, onError?: (exception: any) => void,
onComplete: () => void = () => {}): Object {
onError = (typeof onError === 'function') && onError || noop;
onComplete = (typeof onComplete === 'function') && onComplete || noop;
return emitter.subscribe({next: onNext, error: onError, complete: onComplete});
}
@ -92,7 +92,8 @@ export class ObservableWrapper {
* }
* ```
*
* The events payload can be accessed by the parameter `$event` on the components output event handler:
* The events payload can be accessed by the parameter `$event` on the components output event
* handler:
*
* ```
* <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
@ -134,21 +135,23 @@ export class EventEmitter<T> extends Subject<T> {
let completeFn = (): any /** TODO #9100 */ => null;
if (generatorOrNext && typeof generatorOrNext === 'object') {
schedulerFn = this.__isAsync ? (value: any /** TODO #9100 */) => { setTimeout(() => generatorOrNext.next(value)); } :
(value: any /** TODO #9100 */) => { generatorOrNext.next(value); };
schedulerFn = this.__isAsync ? (value: any /** TODO #9100 */) => {
setTimeout(() => generatorOrNext.next(value));
} : (value: any /** TODO #9100 */) => { generatorOrNext.next(value); };
if (generatorOrNext.error) {
errorFn = this.__isAsync ? (err) => { setTimeout(() => generatorOrNext.error(err)); } :
(err) => { generatorOrNext.error(err); };
(err) => { generatorOrNext.error(err); };
}
if (generatorOrNext.complete) {
completeFn = this.__isAsync ? () => { setTimeout(() => generatorOrNext.complete()); } :
() => { generatorOrNext.complete(); };
() => { generatorOrNext.complete(); };
}
} else {
schedulerFn = this.__isAsync ? (value: any /** TODO #9100 */) => { setTimeout(() => generatorOrNext(value)); } :
(value: any /** TODO #9100 */) => { generatorOrNext(value); };
schedulerFn = this.__isAsync ? (value: any /** TODO #9100 */) => {
setTimeout(() => generatorOrNext(value));
} : (value: any /** TODO #9100 */) => { generatorOrNext(value); };
if (error) {
errorFn =

View File

@ -1,4 +1,4 @@
import {isJsObject, global, isPresent, isBlank, isArray, getSymbolIterator} from './lang';
import {getSymbolIterator, global, isArray, isBlank, isJsObject, isPresent} from './lang';
export var Map = global.Map;
export var Set = global.Set;
@ -265,7 +265,7 @@ export class ListWrapper {
return solution;
}
static flatten<T>(list: Array<T | T[]>): T[] {
static flatten<T>(list: Array<T|T[]>): T[] {
var target: any[] /** TODO #???? */ = [];
_flattenArray(list, target);
return target;
@ -296,8 +296,8 @@ function _flattenArray(source: any[], target: any[]): any[] {
export function isListLikeIterable(obj: any): boolean {
if (!isJsObject(obj)) return false;
return isArray(obj) ||
(!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
(!(obj instanceof Map) && // JS Map are iterables but return entries as [k, v]
getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
}
export function areIterablesEqual(a: any, b: any, comparator: Function): boolean {

View File

@ -1,6 +1,6 @@
import {isPresent, isBlank} from './lang';
import {BaseWrappedException} from './base_wrapped_exception';
import {isListLikeIterable} from './collection';
import {isBlank, isPresent} from './lang';
class _ArrayLogger {
res: any[] = [];
@ -39,7 +39,7 @@ export class ExceptionHandler {
var l = new _ArrayLogger();
var e = new ExceptionHandler(l, false);
e.call(exception, stackTrace, reason);
return l.res.join("\n");
return l.res.join('\n');
}
call(exception: any, stackTrace: any = null, reason: string = null): void {
@ -50,7 +50,7 @@ export class ExceptionHandler {
this._logger.logGroup(`EXCEPTION: ${this._extractMessage(exception)}`);
if (isPresent(stackTrace) && isBlank(originalStack)) {
this._logger.logError("STACKTRACE:");
this._logger.logError('STACKTRACE:');
this._logger.logError(this._longStackTrace(stackTrace));
}
@ -63,12 +63,12 @@ export class ExceptionHandler {
}
if (isPresent(originalStack)) {
this._logger.logError("ORIGINAL STACKTRACE:");
this._logger.logError('ORIGINAL STACKTRACE:');
this._logger.logError(this._longStackTrace(originalStack));
}
if (isPresent(context)) {
this._logger.logError("ERROR CONTEXT:");
this._logger.logError('ERROR CONTEXT:');
this._logger.logError(context);
}
@ -87,7 +87,7 @@ export class ExceptionHandler {
/** @internal */
_longStackTrace(stackTrace: any): any {
return isListLikeIterable(stackTrace) ? (<any[]>stackTrace).join("\n\n-----async gap-----\n") :
return isListLikeIterable(stackTrace) ? (<any[]>stackTrace).join('\n\n-----async gap-----\n') :
stackTrace.toString();
}

View File

@ -8,7 +8,7 @@ export {ExceptionHandler} from './exception_handler';
*/
export class BaseException extends Error {
public stack: any;
constructor(public message: string = "--") {
constructor(public message: string = '--') {
super(message);
this.stack = (<any>new Error(message)).stack;
}
@ -23,8 +23,9 @@ export class BaseException extends Error {
export class WrappedException extends BaseWrappedException {
private _wrapperStack: any;
constructor(private _wrapperMessage: string, private _originalException: any /** TODO #9100 */, private _originalStack?: any /** TODO #9100 */,
private _context?: any /** TODO #9100 */) {
constructor(
private _wrapperMessage: string, private _originalException: any /** TODO #9100 */,
private _originalStack?: any /** TODO #9100 */, private _context?: any /** TODO #9100 */) {
super(_wrapperMessage);
this._wrapperStack = (<any>new Error(_wrapperMessage)).stack;
}

View File

@ -5,15 +5,16 @@ export enum NumberFormatStyle {
}
export class NumberFormatter {
static format(num: number, locale: string, style: NumberFormatStyle,
{minimumIntegerDigits = 1, minimumFractionDigits = 0, maximumFractionDigits = 3,
currency, currencyAsSymbol = false}: {
minimumIntegerDigits?: number,
minimumFractionDigits?: number,
maximumFractionDigits?: number,
currency?: string,
currencyAsSymbol?: boolean
} = {}): string {
static format(
num: number, locale: string, style: NumberFormatStyle,
{minimumIntegerDigits = 1, minimumFractionDigits = 0, maximumFractionDigits = 3, currency,
currencyAsSymbol = false}: {
minimumIntegerDigits?: number,
minimumFractionDigits?: number,
maximumFractionDigits?: number,
currency?: string,
currencyAsSymbol?: boolean
} = {}): string {
var intlOptions: Intl.NumberFormatOptions = {
minimumIntegerDigits: minimumIntegerDigits,
minimumFractionDigits: minimumFractionDigits,
@ -40,16 +41,11 @@ var PATTERN_ALIASES = {
digitCondition('second', 1),
])),
yMdjm: datePartGetterFactory(combine([
digitCondition('year', 1),
digitCondition('month', 1),
digitCondition('day', 1),
digitCondition('hour', 1),
digitCondition('minute', 1)
digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
digitCondition('hour', 1), digitCondition('minute', 1)
])),
yMMMMEEEEd: datePartGetterFactory(combine([
digitCondition('year', 1),
nameCondition('month', 4),
nameCondition('weekday', 4),
digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
digitCondition('day', 1)
])),
yMMMMd: datePartGetterFactory(
@ -115,8 +111,8 @@ function hourClockExtracter(inner: (date: Date, locale: string) => string): (
};
}
function hourExtracter(inner: (date: Date, locale: string) => string): (date: Date,
locale: string) => string {
function hourExtracter(inner: (date: Date, locale: string) => string): (
date: Date, locale: string) => string {
return function(date: Date, locale: string): string {
var result = inner(date, locale);
@ -124,8 +120,8 @@ function hourExtracter(inner: (date: Date, locale: string) => string): (date: Da
};
}
function hour12Modify(options: Intl.DateTimeFormatOptions,
value: boolean): Intl.DateTimeFormatOptions {
function hour12Modify(
options: Intl.DateTimeFormatOptions, value: boolean): Intl.DateTimeFormatOptions {
options.hour12 = value;
return options;
}
@ -191,14 +187,16 @@ function dateFormatter(format: string, date: Date, locale: string): string {
parts.forEach(part => {
fn = (DATE_FORMATS as any /** TODO #9100 */)[part];
text += fn ? fn(date, locale) :
part === "''" ? "'" : part.replace(/(^'|'$)/g, '').replace(/''/g, "'");
part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
});
return text;
}
var slice = [].slice;
function concat(array1: any /** TODO #9100 */, array2: any /** TODO #9100 */, index: any /** TODO #9100 */): string[] {
function concat(
array1: any /** TODO #9100 */, array2: any /** TODO #9100 */,
index: any /** TODO #9100 */): string[] {
return array1.concat(slice.call(array2, index));
}

View File

@ -121,19 +121,19 @@ export function isBlank(obj: any): boolean {
}
export function isBoolean(obj: any): boolean {
return typeof obj === "boolean";
return typeof obj === 'boolean';
}
export function isNumber(obj: any): boolean {
return typeof obj === "number";
return typeof obj === 'number';
}
export function isString(obj: any): boolean {
return typeof obj === "string";
return typeof obj === 'string';
}
export function isFunction(obj: any): boolean {
return typeof obj === "function";
return typeof obj === 'function';
}
export function isType(obj: any): boolean {
@ -180,7 +180,7 @@ export function stringify(token: any /** TODO #9100 */): string {
}
var res = token.toString();
var newLineIndex = res.indexOf("\n");
var newLineIndex = res.indexOf('\n');
return (newLineIndex === -1) ? res : res.substring(0, newLineIndex);
}
@ -195,7 +195,8 @@ export function deserializeEnum(val: any /** TODO #9100 */, values: Map<number,
return val;
}
export function resolveEnumToken(enumValue: any /** TODO #9100 */, val: any /** TODO #9100 */): string {
export function resolveEnumToken(
enumValue: any /** TODO #9100 */, val: any /** TODO #9100 */): string {
return enumValue[val];
}
@ -271,7 +272,7 @@ export class StringJoiner {
add(part: string): void { this.parts.push(part); }
toString(): string { return this.parts.join(""); }
toString(): string { return this.parts.join(''); }
}
export class NumberParseError extends Error {
@ -291,7 +292,7 @@ export class NumberWrapper {
static parseIntAutoRadix(text: string): number {
var result: number = parseInt(text);
if (isNaN(result)) {
throw new NumberParseError("Invalid integer literal when parsing " + text);
throw new NumberParseError('Invalid integer literal when parsing ' + text);
}
return result;
}
@ -311,8 +312,8 @@ export class NumberWrapper {
return result;
}
}
throw new NumberParseError("Invalid integer literal when parsing " + text + " in base " +
radix);
throw new NumberParseError(
'Invalid integer literal when parsing ' + text + ' in base ' + radix);
}
// TODO: NaN is a valid literal but is returned by parseFloat to indicate an error.
@ -341,11 +342,7 @@ export class RegExpWrapper {
regExp.lastIndex = 0;
return regExp.test(input);
}
static matcher(regExp: RegExp, input: string): {
re: RegExp;
input: string
}
{
static matcher(regExp: RegExp, input: string): {re: RegExp; input: string} {
// Reset regex state for the case
// someone did not loop over all matches
// last time.
@ -370,10 +367,7 @@ export class RegExpWrapper {
}
export class RegExpMatcherWrapper {
static next(matcher: {
re: RegExp;
input: string
}): RegExpExecArray {
static next(matcher: {re: RegExp; input: string}): RegExpExecArray {
return matcher.re.exec(matcher.input);
}
}
@ -386,7 +380,7 @@ export class FunctionWrapper {
// JS has NaN !== NaN
export function looseIdentical(a: any /** TODO #9100 */, b: any /** TODO #9100 */): boolean {
return a === b || typeof a === "number" && typeof b === "number" && isNaN(a) && isNaN(b);
return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
}
// JS considers NaN is the same as NaN for map Key (while NaN !== NaN otherwise)
@ -404,7 +398,7 @@ export function normalizeBool(obj: boolean): boolean {
}
export function isJsObject(o: any): boolean {
return o !== null && (typeof o === "function" || typeof o === "object");
return o !== null && (typeof o === 'function' || typeof o === 'object');
}
export function print(obj: Error | Object) {
@ -425,8 +419,9 @@ export class Json {
}
export class DateWrapper {
static create(year: number, month: number = 1, day: number = 1, hour: number = 0,
minutes: number = 0, seconds: number = 0, milliseconds: number = 0): Date {
static create(
year: number, month: number = 1, day: number = 1, hour: number = 0, minutes: number = 0,
seconds: number = 0, milliseconds: number = 0): Date {
return new Date(year, month - 1, day, hour, minutes, seconds, milliseconds);
}
static fromISOString(str: string): Date { return new Date(str); }
@ -456,7 +451,7 @@ export function setValueOnPath(global: any, path: string, value: any) {
// When Symbol.iterator doesn't exist, retrieves the key used in es6-shim
declare var Symbol: any /** TODO #9100 */;
var _symbolIterator: any /** TODO #9100 */ = null;
export function getSymbolIterator(): string | symbol {
export function getSymbolIterator(): string|symbol {
if (isBlank(_symbolIterator)) {
if (isPresent((<any>globalScope).Symbol) && isPresent(Symbol.iterator)) {
_symbolIterator = Symbol.iterator;
@ -475,8 +470,8 @@ export function getSymbolIterator(): string | symbol {
return _symbolIterator;
}
export function evalExpression(sourceUrl: string, expr: string, declarations: string,
vars: {[key: string]: any}): any {
export function evalExpression(
sourceUrl: string, expr: string, declarations: string, vars: {[key: string]: any}): any {
var fnBody = `${declarations}\nreturn ${expr}\n//# sourceURL=${sourceUrl}`;
var fnArgNames: any[] /** TODO #9100 */ = [];
var fnArgValues: any[] /** TODO #9100 */ = [];

View File

@ -1,7 +1,7 @@
export class PromiseCompleter<R> {
promise: Promise<R>;
resolve: (value?: R | PromiseLike<R>) => void;
resolve: (value?: R|PromiseLike<R>) => void;
reject: (error?: any, stackTrace?: string) => void;
constructor() {
@ -19,18 +19,19 @@ export class PromiseWrapper {
// Note: We can't rename this method into `catch`, as this is not a valid
// method name in Dart.
static catchError<T>(promise: Promise<T>,
onError: (error: any) => T | PromiseLike<T>): Promise<T> {
static catchError<T>(promise: Promise<T>, onError: (error: any) => T | PromiseLike<T>):
Promise<T> {
return promise.catch(onError);
}
static all<T>(promises: (T | Promise<T>)[]): Promise<T[]> {
static all<T>(promises: (T|Promise<T>)[]): Promise<T[]> {
if (promises.length == 0) return Promise.resolve([]);
return Promise.all(promises);
}
static then<T, U>(promise: Promise<T>, success: (value: T) => U | PromiseLike<U>,
rejection?: (error: any, stack?: any) => U | PromiseLike<U>): Promise<U> {
static then<T, U>(
promise: Promise<T>, success: (value: T) => U | PromiseLike<U>,
rejection?: (error: any, stack?: any) => U | PromiseLike<U>): Promise<U> {
return promise.then(success, rejection);
}