chore(lint): enable semicolon and variable-name tslint checks

This commit is contained in:
Alex Eagle 2016-05-26 13:33:53 -07:00
parent 9096481744
commit ef0c32512c
13 changed files with 30 additions and 22 deletions

View File

@ -11,11 +11,11 @@ const path = require('path');
const srcsToFmt = ['tools/**/*.ts'];
gulp.task('lint', () => {
gulp.task('format:enforce', () => {
const format = require('gulp-clang-format');
const clangFormat = require('clang-format');
return gulp.src(srcsToFmt).pipe(
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
format.checkFormat('file', clangFormat, {verbose: true, fail: true}));
});
gulp.task('format', () => {
@ -25,6 +25,20 @@ gulp.task('format', () => {
format.format('file', clangFormat)).pipe(gulp.dest('.'));
});
gulp.task('lint', ['format:enforce', 'tools:build'], () => {
const tslint = require('gulp-tslint');
// Built-in rules are at
// https://github.com/palantir/tslint#supported-rules
const tslintConfig = require('./tslint.json');
return gulp.src(['modules/@angular/**/*.ts', '!modules/@angular/*/test/**'])
.pipe(tslint({
tslint: require('tslint').default,
configuration: tslintConfig,
rulesDirectory: 'dist/tools/tslint'
}))
.pipe(tslint.report('prose', {emitError: true}));
});
gulp.task('tools:build', (done) => { tsc('tools/', done); });

View File

@ -85,14 +85,14 @@ export class SpyLocation implements Location {
forward() {
if (this._historyIndex < (this._history.length - 1)) {
this._historyIndex++;
ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true})
ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true});
}
}
back() {
if (this._historyIndex > 0) {
this._historyIndex--;
ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true})
ObservableWrapper.callEmit(this._subject, {'url': this.path(), 'pop': true});
}
}

View File

@ -3,7 +3,7 @@ import * as ts from 'typescript';
import {AngularCompilerOptions, MetadataCollector, ModuleMetadata} from 'tsc-wrapped';
import * as fs from 'fs';
import * as path from 'path';
import {ImportGenerator, AssetUrl} from './compiler_private'
import {ImportGenerator, AssetUrl} from './compiler_private';
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;

View File

@ -19,7 +19,7 @@ export enum LifecycleHooks {
* values are instances of {@link SimpleChange}. See {@link OnChanges}
* @stable
*/
export interface SimpleChanges {[propName: string]: SimpleChange}
export interface SimpleChanges {[propName: string]: SimpleChange;}
export var LIFECYCLE_HOOKS_VALUES = [
LifecycleHooks.OnInit,

View File

@ -14,12 +14,10 @@
* ```
*/
export function async(fn: Function): Function {
return () => {
return new Promise<void>((finishCallback, failCallback) => {
return () => new Promise<void>((finishCallback, failCallback) => {
var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec'];
var testZoneSpec = new AsyncTestZoneSpec(finishCallback, failCallback, 'test');
var testZone = Zone.current.fork(testZoneSpec);
return testZone.run(fn);
});
}
}

View File

@ -11,7 +11,7 @@ export class Log {
fn(value) {
return (a1: any = null, a2: any = null, a3: any = null, a4: any = null, a5: any = null) => {
this.logItems.push(value);
}
};
}
clear(): void { this.logItems = []; }

View File

@ -134,7 +134,7 @@ export function inject(tokens: any[], fn: Function): Function {
let completer: AsyncTestCompleter = testInjector.get(AsyncTestCompleter);
testInjector.execute(tokens, fn);
return completer.promise;
}
};
} else {
// Return a synchronous test method with the injected tokens.
return () => { return getTestInjector().execute(tokens, fn); };
@ -155,7 +155,7 @@ export class InjectSetupWrapper {
return () => {
this._addProviders();
return inject_impl(tokens, fn)();
}
};
}
/** @Deprecated {use async(withProviders().inject())} */
@ -163,7 +163,7 @@ export class InjectSetupWrapper {
return () => {
this._addProviders();
return injectAsync_impl(tokens, fn)();
}
};
}
}

View File

@ -12,7 +12,7 @@ import {bootstrap} from '@angular/platform-browser';
</div>`
})
export class JsonPipeExample {
object: Object = {foo: 'bar', baz: 'qux', nested: {xyz: 3, numbers: [1, 2, 3, 4, 5]}}
object: Object = {foo: 'bar', baz: 'qux', nested: {xyz: 3, numbers: [1, 2, 3, 4, 5]}};
}
// #enddocregion

View File

@ -33,7 +33,7 @@ describe('another component',
// #enddocregion
// #docregion xdescribe
xdescribe('some component', () => { it('has a test', () => {throw 'This test will not run.'}); });
xdescribe('some component', () => { it('has a test', () => {throw 'This test will not run.';}); });
describe('another component', () => {
it('also has a test', () => {
// This test will run.

View File

@ -569,7 +569,7 @@ export function main() {
it(`should fail if public API for ${mod} has changed`, () => {
var symbols = getSymbolsFromLibrary(mod);
expect(diff(symbols, API[mod])).toEqual([]);
})
});
});
});
}

View File

@ -47,7 +47,7 @@ const IGNORE =
originalStack: true,
wrapperMessage: true,
wrapperStack: true, '@@observable': true
}
};
function collectTopLevelSymbols(prefix: string, lib: any):
string[] {

View File

@ -221,7 +221,7 @@ class UpgradeNg1ComponentAdapter implements OnInit, OnChanges, DoCheck {
ngOnInit() {
if (!this.directive.bindToController && this.directive.controller) {
this.buildController(this.directive.controller)
this.buildController(this.directive.controller);
}
var link = this.directive.link;
if (typeof link == 'object') link = (<angular.IDirectivePrePost>link).pre;

View File

@ -1,9 +1,5 @@
{
"rules": {
"requireInternalWithUnderscore": true,
"requireParameterType": true,
"requireReturnType": true,
"duplicateModuleImport": true,
"semicolon": true,
"variable-name": false
}