chore(lint): require semicolons
Relying on ASI (automatic semicolon insertion) is allowed in TypeScript because JavaScript allows it. However, when we run clang-format it doesn’t understand that these statements are terminated with a newline and changes the indentation, in bad cases even breaking the code. Fixes #817
This commit is contained in:
parent
33500e986b
commit
93055f78ea
@ -278,6 +278,7 @@ gulp.task('lint', ['build.tools'], function() {
|
|||||||
// https://github.com/palantir/tslint#supported-rules
|
// https://github.com/palantir/tslint#supported-rules
|
||||||
var tslintConfig = {
|
var tslintConfig = {
|
||||||
"rules": {
|
"rules": {
|
||||||
|
"semicolon": true,
|
||||||
"requireReturnType": true
|
"requireReturnType": true
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -182,7 +182,7 @@ export class ChangeDetectorJITGenerator {
|
|||||||
var lines = ListWrapper.createFixedSize(directiveFieldNames.length);
|
var lines = ListWrapper.createFixedSize(directiveFieldNames.length);
|
||||||
for (var i = 0, iLen = directiveFieldNames.length; i < iLen; ++i) {
|
for (var i = 0, iLen = directiveFieldNames.length; i < iLen; ++i) {
|
||||||
lines[i] =
|
lines[i] =
|
||||||
`${directiveFieldNames[i]} = directives.getDirectiveFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`
|
`${directiveFieldNames[i]} = directives.getDirectiveFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`;
|
||||||
}
|
}
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ export class ChangeDetectorJITGenerator {
|
|||||||
var lines = ListWrapper.createFixedSize(detectorFieldNames.length);
|
var lines = ListWrapper.createFixedSize(detectorFieldNames.length);
|
||||||
for (var i = 0, iLen = detectorFieldNames.length; i < iLen; ++i) {
|
for (var i = 0, iLen = detectorFieldNames.length; i < iLen; ++i) {
|
||||||
lines[i] = `${detectorFieldNames[i]} =
|
lines[i] = `${detectorFieldNames[i]} =
|
||||||
directives.getDetectorFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`
|
directives.getDetectorFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`;
|
||||||
}
|
}
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ class _ParseAST {
|
|||||||
expectIdentifierOrKeyword(): string {
|
expectIdentifierOrKeyword(): string {
|
||||||
var n = this.next;
|
var n = this.next;
|
||||||
if (!n.isIdentifier() && !n.isKeyword()) {
|
if (!n.isIdentifier() && !n.isKeyword()) {
|
||||||
this.error(`Unexpected token ${n}, expected identifier or keyword`)
|
this.error(`Unexpected token ${n}, expected identifier or keyword`);
|
||||||
}
|
}
|
||||||
this.advance();
|
this.advance();
|
||||||
return n.toString();
|
return n.toString();
|
||||||
@ -176,7 +176,7 @@ class _ParseAST {
|
|||||||
expectIdentifierOrKeywordOrString(): string {
|
expectIdentifierOrKeywordOrString(): string {
|
||||||
var n = this.next;
|
var n = this.next;
|
||||||
if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
|
if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
|
||||||
this.error(`Unexpected token ${n}, expected identifier, keyword, or string`)
|
this.error(`Unexpected token ${n}, expected identifier, keyword, or string`);
|
||||||
}
|
}
|
||||||
this.advance();
|
this.advance();
|
||||||
return n.toString();
|
return n.toString();
|
||||||
|
@ -96,5 +96,5 @@ export class DatePipe extends BasePipe implements PipeFactory {
|
|||||||
|
|
||||||
supports(obj): boolean { return isDate(obj) || isNumber(obj); }
|
supports(obj): boolean { return isDate(obj) || isNumber(obj); }
|
||||||
|
|
||||||
create(cdRef: ChangeDetectorRef): Pipe { return this }
|
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ export class IterableChanges extends BasePipe {
|
|||||||
record = this._verifyReinsertion(record, item, index);
|
record = this._verifyReinsertion(record, item, index);
|
||||||
}
|
}
|
||||||
record = record._next;
|
record = record._next;
|
||||||
index++
|
index++;
|
||||||
});
|
});
|
||||||
this._length = index;
|
this._length = index;
|
||||||
}
|
}
|
||||||
|
@ -29,5 +29,5 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
|||||||
export class JsonPipe extends BasePipe implements PipeFactory {
|
export class JsonPipe extends BasePipe implements PipeFactory {
|
||||||
transform(value, args: List<any> = null): string { return Json.stringify(value); }
|
transform(value, args: List<any> = null): string { return Json.stringify(value); }
|
||||||
|
|
||||||
create(cdRef: ChangeDetectorRef): Pipe { return this }
|
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ export class NumberPipe extends BasePipe implements PipeFactory {
|
|||||||
|
|
||||||
supports(obj): boolean { return isNumber(obj); }
|
supports(obj): boolean { return isNumber(obj); }
|
||||||
|
|
||||||
create(cdRef: ChangeDetectorRef): Pipe { return this }
|
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,7 +65,7 @@ export class ObservablePipe implements Pipe {
|
|||||||
|
|
||||||
_subscribe(obs: Observable): void {
|
_subscribe(obs: Observable): void {
|
||||||
this._observable = obs;
|
this._observable = obs;
|
||||||
this._subscription = ObservableWrapper.subscribe(obs, value => {this._updateLatestValue(value)},
|
this._subscription = ObservableWrapper.subscribe(obs, value => this._updateLatestValue(value),
|
||||||
e => { throw e; });
|
e => { throw e; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export class Pipes {
|
|||||||
},
|
},
|
||||||
// Dependency technically isn't optional, but we can provide a better error message this way.
|
// Dependency technically isn't optional, but we can provide a better error message this way.
|
||||||
deps: [[Pipes, new UnboundedMetadata(), new OptionalMetadata()]]
|
deps: [[Pipes, new UnboundedMetadata(), new OptionalMetadata()]]
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getListOfFactories(type: string, obj: any): PipeFactory[] {
|
private _getListOfFactories(type: string, obj: any): PipeFactory[] {
|
||||||
|
@ -52,7 +52,7 @@ export interface ViewDecorator extends TypeDecorator {
|
|||||||
renderer?: string,
|
renderer?: string,
|
||||||
styles?: List<string>,
|
styles?: List<string>,
|
||||||
styleUrls?: List<string>,
|
styleUrls?: List<string>,
|
||||||
}): ViewDecorator
|
}): ViewDecorator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -300,7 +300,7 @@ export function bootstrap(appComponentType: Type,
|
|||||||
bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector));
|
bootstrapProcess.resolve(new ApplicationRef(componentRef, appComponentType, appInjector));
|
||||||
};
|
};
|
||||||
PromiseWrapper.then(compRefToken, tick,
|
PromiseWrapper.then(compRefToken, tick,
|
||||||
(err, stackTrace) => {bootstrapProcess.reject(err, stackTrace)});
|
(err, stackTrace) => bootstrapProcess.reject(err, stackTrace));
|
||||||
});
|
});
|
||||||
|
|
||||||
return bootstrapProcess.promise;
|
return bootstrapProcess.promise;
|
||||||
|
@ -100,7 +100,7 @@ export class AppViewManagerUtils {
|
|||||||
if (atIndex == 0) {
|
if (atIndex == 0) {
|
||||||
sibling = null;
|
sibling = null;
|
||||||
} else {
|
} else {
|
||||||
sibling = ListWrapper.last(viewContainer.views[atIndex - 1].rootElementInjectors)
|
sibling = ListWrapper.last(viewContainer.views[atIndex - 1].rootElementInjectors);
|
||||||
}
|
}
|
||||||
var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
|
var elementInjector = contextView.elementInjectors[contextBoundElementIndex];
|
||||||
for (var i = view.rootElementInjectors.length - 1; i >= 0; i--) {
|
for (var i = view.rootElementInjectors.length - 1; i >= 0; i--) {
|
||||||
|
@ -62,7 +62,7 @@ export class NgZone {
|
|||||||
if (global.zone) {
|
if (global.zone) {
|
||||||
this._disabled = false;
|
this._disabled = false;
|
||||||
this._mountZone = global.zone;
|
this._mountZone = global.zone;
|
||||||
this._innerZone = this._createInnerZone(this._mountZone, enableLongStackTrace)
|
this._innerZone = this._createInnerZone(this._mountZone, enableLongStackTrace);
|
||||||
} else {
|
} else {
|
||||||
this._disabled = true;
|
this._disabled = true;
|
||||||
this._mountZone = null;
|
this._mountZone = null;
|
||||||
@ -159,9 +159,9 @@ export class NgZone {
|
|||||||
|
|
||||||
if (enableLongStackTrace) {
|
if (enableLongStackTrace) {
|
||||||
errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone,
|
errorHandling = StringMapWrapper.merge(Zone.longStackTraceZone,
|
||||||
{onError: function(e) { ngZone._onError(this, e) }});
|
{onError: function(e) { ngZone._onError(this, e); }});
|
||||||
} else {
|
} else {
|
||||||
errorHandling = {onError: function(e) { ngZone._onError(this, e) }};
|
errorHandling = {onError: function(e) { ngZone._onError(this, e); }};
|
||||||
}
|
}
|
||||||
|
|
||||||
return zone.fork(errorHandling)
|
return zone.fork(errorHandling)
|
||||||
@ -200,7 +200,7 @@ export class NgZone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
'$scheduleMicrotask': function(parentScheduleMicrotask) {
|
'$scheduleMicrotask': function(parentScheduleMicrotask) {
|
||||||
return function(fn) {
|
return function(fn) {
|
||||||
@ -213,7 +213,7 @@ export class NgZone {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
parentScheduleMicrotask.call(this, microtask);
|
parentScheduleMicrotask.call(this, microtask);
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
_innerZone: true
|
_innerZone: true
|
||||||
});
|
});
|
||||||
|
@ -164,7 +164,7 @@ export class NgSwitchWhen {
|
|||||||
this._view = new SwitchView(viewContainer, protoViewRef);
|
this._view = new SwitchView(viewContainer, protoViewRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy() { this._switch }
|
onDestroy() { this._switch; }
|
||||||
|
|
||||||
set ngSwitchWhen(value) {
|
set ngSwitchWhen(value) {
|
||||||
this._switch._onWhenValueChanged(this._value, value, this._view);
|
this._switch._onWhenValueChanged(this._value, value, this._view);
|
||||||
|
@ -22,7 +22,7 @@ var createMapFromPairs: {(pairs: List<any>): Map<any, any>} = (function() {
|
|||||||
map.set(pair[0], pair[1]);
|
map.set(pair[0], pair[1]);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
};
|
||||||
})();
|
})();
|
||||||
var createMapFromMap: {(m: Map<any, any>): Map<any, any>} = (function() {
|
var createMapFromMap: {(m: Map<any, any>): Map<any, any>} = (function() {
|
||||||
try {
|
try {
|
||||||
@ -35,7 +35,7 @@ var createMapFromMap: {(m: Map<any, any>): Map<any, any>} = (function() {
|
|||||||
var map = new Map();
|
var map = new Map();
|
||||||
m.forEach((v, k) => { map.set(k, v); });
|
m.forEach((v, k) => { map.set(k, v); });
|
||||||
return map;
|
return map;
|
||||||
}
|
};
|
||||||
})();
|
})();
|
||||||
var _clearValues: {(m: Map<any, any>)} = (function() {
|
var _clearValues: {(m: Map<any, any>)} = (function() {
|
||||||
if ((<any>(new Map()).keys()).next) {
|
if ((<any>(new Map()).keys()).next) {
|
||||||
@ -49,7 +49,7 @@ var _clearValues: {(m: Map<any, any>)} = (function() {
|
|||||||
} else {
|
} else {
|
||||||
return function _clearValuesWithForeEach(m: Map<any, any>) {
|
return function _clearValuesWithForeEach(m: Map<any, any>) {
|
||||||
m.forEach((v, k) => { m.set(k, null); });
|
m.forEach((v, k) => { m.set(k, null); });
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ declare module Intl {
|
|||||||
format(value: number): string;
|
format(value: number): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
var NumberFormat: { new (locale?: string, options?: NumberFormatOptions): NumberFormat; }
|
var NumberFormat: {new (locale?: string, options?: NumberFormatOptions): NumberFormat};
|
||||||
|
|
||||||
interface DateTimeFormatOptions {
|
interface DateTimeFormatOptions {
|
||||||
localeMatcher?: string;
|
localeMatcher?: string;
|
||||||
@ -35,7 +35,7 @@ declare module Intl {
|
|||||||
format(date?: Date | number): string;
|
format(date?: Date | number): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
var DateTimeFormat: { new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat; }
|
var DateTimeFormat: {new (locale?: string, options?: DateTimeFormatOptions): DateTimeFormat};
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NumberFormatStyle {
|
export enum NumberFormatStyle {
|
||||||
|
@ -26,7 +26,7 @@ export class Validators {
|
|||||||
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
|
return isPresent(errors) ? StringMapWrapper.merge(res, errors) : res;
|
||||||
}, {});
|
}, {});
|
||||||
return StringMapWrapper.isEmpty(res) ? null : res;
|
return StringMapWrapper.isEmpty(res) ? null : res;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static group(c: modelModule.ControlGroup): StringMap<string, boolean> {
|
static group(c: modelModule.ControlGroup): StringMap<string, boolean> {
|
||||||
|
@ -42,7 +42,7 @@ export class XHRConnection implements Connection {
|
|||||||
responseOptions = baseResponseOptions.merge(responseOptions);
|
responseOptions = baseResponseOptions.merge(responseOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObservableWrapper.callNext(this.response, new Response(responseOptions))
|
ObservableWrapper.callNext(this.response, new Response(responseOptions));
|
||||||
});
|
});
|
||||||
// TODO(jeffbcross): make this more dynamic based on body type
|
// TODO(jeffbcross): make this more dynamic based on body type
|
||||||
|
|
||||||
|
@ -80,8 +80,7 @@ export class StyleInliner {
|
|||||||
if (isPromise(inlinedCss)) {
|
if (isPromise(inlinedCss)) {
|
||||||
// wait until nested @import are inlined
|
// wait until nested @import are inlined
|
||||||
return (<Promise<string>>inlinedCss)
|
return (<Promise<string>>inlinedCss)
|
||||||
.then((css) => {return prefix + this._transformImportedCss(css, mediaQuery, url) +
|
.then((css) => prefix + this._transformImportedCss(css, mediaQuery, url) + '\n');
|
||||||
'\n'});
|
|
||||||
} else {
|
} else {
|
||||||
// there are no nested @import, return the css
|
// there are no nested @import, return the css
|
||||||
return prefix + this._transformImportedCss(<string>inlinedCss, mediaQuery, url) + '\n';
|
return prefix + this._transformImportedCss(<string>inlinedCss, mediaQuery, url) + '\n';
|
||||||
|
@ -70,7 +70,7 @@ export interface ParameterDecorator {
|
|||||||
/**
|
/**
|
||||||
* Invoke as ES7 decorator.
|
* Invoke as ES7 decorator.
|
||||||
*/
|
*/
|
||||||
(cls: Type, unusedKey: any, index: number): void
|
(cls: Type, unusedKey: any, index: number): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractAnnotation(annotation: any): any {
|
function extractAnnotation(annotation: any): any {
|
||||||
|
@ -102,7 +102,7 @@ export class Serializer {
|
|||||||
|
|
||||||
class ASTWithSourceSerializer {
|
class ASTWithSourceSerializer {
|
||||||
static serialize(tree: ASTWithSource): Object {
|
static serialize(tree: ASTWithSource): Object {
|
||||||
return { 'input': tree.source, 'location': tree.location }
|
return { 'input': tree.source, 'location': tree.location };
|
||||||
}
|
}
|
||||||
|
|
||||||
static deserialize(obj: any, data: string): AST {
|
static deserialize(obj: any, data: string): AST {
|
||||||
@ -186,7 +186,7 @@ class ElementBinderSerializer {
|
|||||||
'eventBindings': Serializer.serialize(binder.eventBindings, EventBinding),
|
'eventBindings': Serializer.serialize(binder.eventBindings, EventBinding),
|
||||||
'textBindings': Serializer.serialize(binder.textBindings, ASTWithSource),
|
'textBindings': Serializer.serialize(binder.textBindings, ASTWithSource),
|
||||||
'readAttributes': Serializer.mapToObject(binder.readAttributes)
|
'readAttributes': Serializer.mapToObject(binder.readAttributes)
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static deserialize(obj): ElementBinder {
|
static deserialize(obj): ElementBinder {
|
||||||
@ -211,7 +211,7 @@ class ProtoViewDtoSerializer {
|
|||||||
return {
|
return {
|
||||||
'render': null, 'elementBinders': Serializer.serialize(view.elementBinders, ElementBinder),
|
'render': null, 'elementBinders': Serializer.serialize(view.elementBinders, ElementBinder),
|
||||||
'variableBindings': Serializer.mapToObject(view.variableBindings), 'type': view.type
|
'variableBindings': Serializer.mapToObject(view.variableBindings), 'type': view.type
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static deserialize(obj): ProtoViewDto {
|
static deserialize(obj): ProtoViewDto {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user