From ef0c32512cd91356f802c329ef69e29a7a8dcdf7 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Thu, 26 May 2016 13:33:53 -0700 Subject: [PATCH] chore(lint): enable semicolon and variable-name tslint checks --- gulpfile.js | 18 ++++++++++++++++-- .../@angular/common/testing/location_mock.ts | 4 ++-- .../compiler_cli/src/reflector_host.ts | 2 +- .../core/src/metadata/lifecycle_hooks.ts | 2 +- modules/@angular/core/testing/async.ts | 4 +--- modules/@angular/core/testing/logger.ts | 2 +- modules/@angular/core/testing/test_injector.ts | 6 +++--- .../pipes/ts/json_pipe/json_pipe_example.ts | 2 +- .../@angular/examples/testing/ts/testing.ts | 2 +- .../integration_test/public_api_spec.ts | 2 +- .../symbol_inspector/symbol_inspector.ts | 2 +- .../upgrade/src/upgrade_ng1_adapter.ts | 2 +- tslint.json | 4 ---- 13 files changed, 30 insertions(+), 22 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index bd450456dd..3172d20fe6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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); }); diff --git a/modules/@angular/common/testing/location_mock.ts b/modules/@angular/common/testing/location_mock.ts index f5f9f7505c..e017caa733 100644 --- a/modules/@angular/common/testing/location_mock.ts +++ b/modules/@angular/common/testing/location_mock.ts @@ -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}); } } diff --git a/modules/@angular/compiler_cli/src/reflector_host.ts b/modules/@angular/compiler_cli/src/reflector_host.ts index 75d1983d87..bb3dec84de 100644 --- a/modules/@angular/compiler_cli/src/reflector_host.ts +++ b/modules/@angular/compiler_cli/src/reflector_host.ts @@ -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)$/; diff --git a/modules/@angular/core/src/metadata/lifecycle_hooks.ts b/modules/@angular/core/src/metadata/lifecycle_hooks.ts index 7fcb70a8c1..885dead94c 100644 --- a/modules/@angular/core/src/metadata/lifecycle_hooks.ts +++ b/modules/@angular/core/src/metadata/lifecycle_hooks.ts @@ -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, diff --git a/modules/@angular/core/testing/async.ts b/modules/@angular/core/testing/async.ts index dc401a708e..d95681145f 100644 --- a/modules/@angular/core/testing/async.ts +++ b/modules/@angular/core/testing/async.ts @@ -14,12 +14,10 @@ * ``` */ export function async(fn: Function): Function { - return () => { - return new Promise((finishCallback, failCallback) => { + return () => new Promise((finishCallback, failCallback) => { var AsyncTestZoneSpec = Zone['AsyncTestZoneSpec']; var testZoneSpec = new AsyncTestZoneSpec(finishCallback, failCallback, 'test'); var testZone = Zone.current.fork(testZoneSpec); return testZone.run(fn); }); - } } diff --git a/modules/@angular/core/testing/logger.ts b/modules/@angular/core/testing/logger.ts index 96828eb39d..77e23a2c12 100644 --- a/modules/@angular/core/testing/logger.ts +++ b/modules/@angular/core/testing/logger.ts @@ -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 = []; } diff --git a/modules/@angular/core/testing/test_injector.ts b/modules/@angular/core/testing/test_injector.ts index 89e864e268..fe80ffac0d 100644 --- a/modules/@angular/core/testing/test_injector.ts +++ b/modules/@angular/core/testing/test_injector.ts @@ -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)(); - } + }; } } diff --git a/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts index 650ae7f872..73b7188612 100644 --- a/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts @@ -12,7 +12,7 @@ import {bootstrap} from '@angular/platform-browser'; ` }) 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 diff --git a/modules/@angular/examples/testing/ts/testing.ts b/modules/@angular/examples/testing/ts/testing.ts index 2af6f8e033..0d7207aa82 100644 --- a/modules/@angular/examples/testing/ts/testing.ts +++ b/modules/@angular/examples/testing/ts/testing.ts @@ -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. diff --git a/modules/@angular/integration_test/public_api_spec.ts b/modules/@angular/integration_test/public_api_spec.ts index 543fbc1548..7e40a46e53 100644 --- a/modules/@angular/integration_test/public_api_spec.ts +++ b/modules/@angular/integration_test/public_api_spec.ts @@ -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([]); - }) + }); }); }); } diff --git a/modules/@angular/integration_test/symbol_inspector/symbol_inspector.ts b/modules/@angular/integration_test/symbol_inspector/symbol_inspector.ts index bc6f9f58ed..2c86dc73d3 100644 --- a/modules/@angular/integration_test/symbol_inspector/symbol_inspector.ts +++ b/modules/@angular/integration_test/symbol_inspector/symbol_inspector.ts @@ -47,7 +47,7 @@ const IGNORE = originalStack: true, wrapperMessage: true, wrapperStack: true, '@@observable': true - } + }; function collectTopLevelSymbols(prefix: string, lib: any): string[] { diff --git a/modules/@angular/upgrade/src/upgrade_ng1_adapter.ts b/modules/@angular/upgrade/src/upgrade_ng1_adapter.ts index 2935ae49aa..0e1f19811a 100644 --- a/modules/@angular/upgrade/src/upgrade_ng1_adapter.ts +++ b/modules/@angular/upgrade/src/upgrade_ng1_adapter.ts @@ -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 = (link).pre; diff --git a/tslint.json b/tslint.json index 798d48fc41..f60d014a2f 100644 --- a/tslint.json +++ b/tslint.json @@ -1,9 +1,5 @@ { "rules": { - "requireInternalWithUnderscore": true, - "requireParameterType": true, - "requireReturnType": true, - "duplicateModuleImport": true, "semicolon": true, "variable-name": false }