Skip to content

Commit 93055f7

Browse files
committed
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 angular#817
1 parent 33500e9 commit 93055f7

File tree

21 files changed

+32
-32
lines changed

21 files changed

+32
-32
lines changed

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ gulp.task('lint', ['build.tools'], function() {
278278
// https://github.com/palantir/tslint#supported-rules
279279
var tslintConfig = {
280280
"rules": {
281+
"semicolon": true,
281282
"requireReturnType": true
282283
}
283284
};

modules/angular2/src/change_detection/change_detection_jit_generator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export class ChangeDetectorJITGenerator {
182182
var lines = ListWrapper.createFixedSize(directiveFieldNames.length);
183183
for (var i = 0, iLen = directiveFieldNames.length; i < iLen; ++i) {
184184
lines[i] =
185-
`${directiveFieldNames[i]} = directives.getDirectiveFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`
185+
`${directiveFieldNames[i]} = directives.getDirectiveFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`;
186186
}
187187
return lines.join('\n');
188188
}
@@ -192,7 +192,7 @@ export class ChangeDetectorJITGenerator {
192192
var lines = ListWrapper.createFixedSize(detectorFieldNames.length);
193193
for (var i = 0, iLen = detectorFieldNames.length; i < iLen; ++i) {
194194
lines[i] = `${detectorFieldNames[i]} =
195-
directives.getDetectorFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`
195+
directives.getDetectorFor(${DIRECTIVES_ACCESSOR}[${i}].directiveIndex);`;
196196
}
197197
return lines.join('\n');
198198
}

modules/angular2/src/change_detection/parser/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class _ParseAST {
167167
expectIdentifierOrKeyword(): string {
168168
var n = this.next;
169169
if (!n.isIdentifier() && !n.isKeyword()) {
170-
this.error(`Unexpected token ${n}, expected identifier or keyword`)
170+
this.error(`Unexpected token ${n}, expected identifier or keyword`);
171171
}
172172
this.advance();
173173
return n.toString();
@@ -176,7 +176,7 @@ class _ParseAST {
176176
expectIdentifierOrKeywordOrString(): string {
177177
var n = this.next;
178178
if (!n.isIdentifier() && !n.isKeyword() && !n.isString()) {
179-
this.error(`Unexpected token ${n}, expected identifier, keyword, or string`)
179+
this.error(`Unexpected token ${n}, expected identifier, keyword, or string`);
180180
}
181181
this.advance();
182182
return n.toString();

modules/angular2/src/change_detection/pipes/date_pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ export class DatePipe extends BasePipe implements PipeFactory {
9696

9797
supports(obj): boolean { return isDate(obj) || isNumber(obj); }
9898

99-
create(cdRef: ChangeDetectorRef): Pipe { return this }
99+
create(cdRef: ChangeDetectorRef): Pipe { return this; }
100100
}

modules/angular2/src/change_detection/pipes/iterable_changes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export class IterableChanges extends BasePipe {
130130
record = this._verifyReinsertion(record, item, index);
131131
}
132132
record = record._next;
133-
index++
133+
index++;
134134
});
135135
this._length = index;
136136
}

modules/angular2/src/change_detection/pipes/json_pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ import {ChangeDetectorRef} from '../change_detector_ref';
2929
export class JsonPipe extends BasePipe implements PipeFactory {
3030
transform(value, args: List<any> = null): string { return Json.stringify(value); }
3131

32-
create(cdRef: ChangeDetectorRef): Pipe { return this }
32+
create(cdRef: ChangeDetectorRef): Pipe { return this; }
3333
}

modules/angular2/src/change_detection/pipes/number_pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class NumberPipe extends BasePipe implements PipeFactory {
4848

4949
supports(obj): boolean { return isNumber(obj); }
5050

51-
create(cdRef: ChangeDetectorRef): Pipe { return this }
51+
create(cdRef: ChangeDetectorRef): Pipe { return this; }
5252
}
5353

5454
/**

modules/angular2/src/change_detection/pipes/observable_pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class ObservablePipe implements Pipe {
6565

6666
_subscribe(obs: Observable): void {
6767
this._observable = obs;
68-
this._subscription = ObservableWrapper.subscribe(obs, value => {this._updateLatestValue(value)},
68+
this._subscription = ObservableWrapper.subscribe(obs, value => this._updateLatestValue(value),
6969
e => { throw e; });
7070
}
7171

modules/angular2/src/change_detection/pipes/pipes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class Pipes {
9595
},
9696
// Dependency technically isn't optional, but we can provide a better error message this way.
9797
deps: [[Pipes, new UnboundedMetadata(), new OptionalMetadata()]]
98-
})
98+
});
9999
}
100100

101101
private _getListOfFactories(type: string, obj: any): PipeFactory[] {

modules/angular2/src/core/annotations/decorators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export interface ViewDecorator extends TypeDecorator {
5252
renderer?: string,
5353
styles?: List<string>,
5454
styleUrls?: List<string>,
55-
}): ViewDecorator
55+
}): ViewDecorator;
5656
}
5757

5858
/**

0 commit comments

Comments
 (0)