From baf4ce0dd0d6e118b902a9d225d78b132d01032d Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 2 Aug 2017 15:23:33 -0700 Subject: [PATCH] build: enable TSLint on the packages folder (#18459) porting PRs #18392 and #18441 to 4.x --- .../browser/src/dsl/animation_ast_builder.ts | 2 +- .../src/render/animation_engine_next.ts | 4 +-- .../src/render/transition_animation_engine.ts | 1 + .../browser/test/dsl/animation_spec.ts | 6 ++-- .../test/dsl/animation_trigger_spec.ts | 4 +-- packages/common/http/src/request.ts | 7 ++-- packages/common/http/src/response.ts | 7 ++-- packages/common/http/src/xhr.ts | 35 +++++++++---------- packages/common/http/test/jsonp_spec.ts | 10 +++--- packages/common/http/test/params_spec.ts | 2 +- packages/common/http/test/xhr_spec.ts | 2 +- packages/common/http/test/xsrf_spec.ts | 2 +- packages/common/http/testing/src/backend.ts | 2 +- packages/compiler-cli/src/codegen.ts | 2 +- .../src/diagnostics/check_types.ts | 6 ++-- packages/compiler-cli/src/ngc.ts | 11 +++--- .../src/transformers/entry_points.ts | 8 +++++ .../transformers/module_filename_resolver.ts | 11 ++++-- .../src/transformers/node_emitter.ts | 4 +-- .../compiler-cli/src/transformers/program.ts | 9 +++-- .../compiler-cli/test/diagnostics/mocks.ts | 2 ++ .../test/diagnostics/symbol_query_spec.ts | 2 +- packages/compiler-cli/test/ngc_spec.ts | 11 +++--- packages/compiler/src/aot/compiler_options.ts | 2 +- packages/compiler/src/aot/static_reflector.ts | 2 +- packages/compiler/src/ml_parser/ast.ts | 2 +- packages/compiler/src/output/output_ast.ts | 2 +- packages/compiler/test/aot/compiler_spec.ts | 2 +- .../test/i18n/extractor_merger_spec.ts | 2 +- .../compiler/test/output/output_jit_spec.ts | 2 +- packages/compiler/test/parse_util_spec.ts | 28 +++++++-------- packages/core/src/application_init.ts | 9 +++-- .../differs/default_iterable_differ.ts | 6 ++-- packages/core/src/view/element.ts | 2 +- packages/core/src/view/provider.ts | 2 +- packages/core/src/view/refs.ts | 1 + .../animation/animation_integration_spec.ts | 2 +- packages/core/test/application_init_spec.ts | 2 +- .../change_detection_integration_spec.ts | 2 +- .../src/directives/default_value_accessor.ts | 3 ++ .../forms/test/reactive_integration_spec.ts | 2 +- .../test/security/html_sanitizer_spec.ts | 2 +- packages/router/src/apply_redirects.ts | 7 ++-- packages/router/src/router.ts | 2 +- packages/router/src/utils/collection.ts | 2 +- packages/router/test/integration.spec.ts | 2 +- tools/gulp-tasks/lint.js | 4 +++ tools/public_api_guard/forms/forms.d.ts | 3 -- 48 files changed, 133 insertions(+), 112 deletions(-) diff --git a/packages/animations/browser/src/dsl/animation_ast_builder.ts b/packages/animations/browser/src/dsl/animation_ast_builder.ts index d373ab145c..c541d133aa 100644 --- a/packages/animations/browser/src/dsl/animation_ast_builder.ts +++ b/packages/animations/browser/src/dsl/animation_ast_builder.ts @@ -201,7 +201,7 @@ export class AnimationAstBuilderVisitor implements AnimationDslVisitor { } else { styles.push(styleTuple as ɵStyleData); } - }) + }); } else { styles.push(metadata.styles); } diff --git a/packages/animations/browser/src/render/animation_engine_next.ts b/packages/animations/browser/src/render/animation_engine_next.ts index 4aa25fc0db..d7d598cbe1 100644 --- a/packages/animations/browser/src/render/animation_engine_next.ts +++ b/packages/animations/browser/src/render/animation_engine_next.ts @@ -29,8 +29,8 @@ export class AnimationEngine { this._transitionEngine = new TransitionAnimationEngine(driver, normalizer); this._timelineEngine = new TimelineAnimationEngine(driver, normalizer); - this._transitionEngine.onRemovalComplete = - (element: any, context: any) => { this.onRemovalComplete(element, context); } + this._transitionEngine.onRemovalComplete = (element: any, context: any) => + this.onRemovalComplete(element, context); } registerTrigger( diff --git a/packages/animations/browser/src/render/transition_animation_engine.ts b/packages/animations/browser/src/render/transition_animation_engine.ts index 1f41927a84..c77e665a00 100644 --- a/packages/animations/browser/src/render/transition_animation_engine.ts +++ b/packages/animations/browser/src/render/transition_animation_engine.ts @@ -490,6 +490,7 @@ export class TransitionAnimationEngine { // this method is designed to be overridden by the code that uses this engine public onRemovalComplete = (element: any, context: any) => {}; + // tslint:disable-next-line _onRemovalComplete(element: any, context: any) { this.onRemovalComplete(element, context); } constructor(public driver: AnimationDriver, private _normalizer: AnimationStyleNormalizer) {} diff --git a/packages/animations/browser/test/dsl/animation_spec.ts b/packages/animations/browser/test/dsl/animation_spec.ts index d022379e12..75733fd808 100644 --- a/packages/animations/browser/test/dsl/animation_spec.ts +++ b/packages/animations/browser/test/dsl/animation_spec.ts @@ -427,17 +427,17 @@ export function main() { it('should throw an error when an input variable is not provided when invoked and is not a default value', () => { - expect(() => {invokeAnimationSequence(rootElement, [style({color: '{{ color }}'})])}) + expect(() => invokeAnimationSequence(rootElement, [style({color: '{{ color }}'})])) .toThrowError(/Please provide a value for the animation param color/); expect( - () => {invokeAnimationSequence( + () => invokeAnimationSequence( rootElement, [ style({color: '{{ start }}'}), animate('{{ time }}', style({color: '{{ end }}'})), ], - buildParams({start: 'blue', end: 'red'}))}) + buildParams({start: 'blue', end: 'red'}))) .toThrowError(/Please provide a value for the animation param time/); }); }); diff --git a/packages/animations/browser/test/dsl/animation_trigger_spec.ts b/packages/animations/browser/test/dsl/animation_trigger_spec.ts index eeb200005f..da95bad47c 100644 --- a/packages/animations/browser/test/dsl/animation_trigger_spec.ts +++ b/packages/animations/browser/test/dsl/animation_trigger_spec.ts @@ -182,7 +182,7 @@ export function main() { const trans = buildTransition(result, element, false, true) !; expect(trans.timelines[0].keyframes).toEqual([ {offset: 0, color: 'red'}, {offset: 1, color: 'green'} - ]) + ]); }); it('should match `1` and `0` state styles on a `true <=> false` boolean transition given boolean values', @@ -195,7 +195,7 @@ export function main() { const trans = buildTransition(result, element, false, true) !; expect(trans.timelines[0].keyframes).toEqual([ {offset: 0, color: 'orange'}, {offset: 1, color: 'blue'} - ]) + ]); }); describe('aliases', () => { diff --git a/packages/common/http/src/request.ts b/packages/common/http/src/request.ts index 7673e71f0e..a77da15f7d 100644 --- a/packages/common/http/src/request.ts +++ b/packages/common/http/src/request.ts @@ -15,8 +15,11 @@ import {HttpParams} from './params'; * All values are optional and will override default values if provided. */ interface HttpRequestInit { - headers?: HttpHeaders, reportProgress?: boolean, params?: HttpParams, - responseType?: 'arraybuffer'|'blob'|'json'|'text', withCredentials?: boolean, + headers?: HttpHeaders; + reportProgress?: boolean; + params?: HttpParams; + responseType?: 'arraybuffer'|'blob'|'json'|'text'; + withCredentials?: boolean; } /** diff --git a/packages/common/http/src/response.ts b/packages/common/http/src/response.ts index 0850505cc5..a56e4da14d 100644 --- a/packages/common/http/src/response.ts +++ b/packages/common/http/src/response.ts @@ -120,7 +120,10 @@ export interface HttpUserEvent { type: HttpEventType.User; } * * @experimental */ -export interface HttpJsonParseError { error: Error, text: string, } +export interface HttpJsonParseError { + error: Error; + text: string; +} /** * Union type for all possible events on the response stream. @@ -233,7 +236,7 @@ export class HttpHeaderResponse extends HttpResponseBase { status: update.status !== undefined ? update.status : this.status, statusText: update.statusText || this.statusText, url: update.url || this.url || undefined, - }) + }); } } diff --git a/packages/common/http/src/xhr.ts b/packages/common/http/src/xhr.ts index 8f35a98ffe..88ad2e2658 100644 --- a/packages/common/http/src/xhr.ts +++ b/packages/common/http/src/xhr.ts @@ -268,27 +268,26 @@ export class HttpXhrBackend implements HttpBackend { // The upload progress event handler, which is only registered if // progress events are enabled. - const onUpProgress = - (event: ProgressEvent) => { - // Upload progress events are simpler. Begin building the progress - // event. - let progress: HttpUploadProgressEvent = { - type: HttpEventType.UploadProgress, - loaded: event.loaded, - }; + const onUpProgress = (event: ProgressEvent) => { + // Upload progress events are simpler. Begin building the progress + // event. + let progress: HttpUploadProgressEvent = { + type: HttpEventType.UploadProgress, + loaded: event.loaded, + }; - // If the total number of bytes being uploaded is available, include - // it. - if (event.lengthComputable) { - progress.total = event.total; - } + // If the total number of bytes being uploaded is available, include + // it. + if (event.lengthComputable) { + progress.total = event.total; + } - // Send the event. - observer.next(progress); - } + // Send the event. + observer.next(progress); + }; - // By default, register for load and error events. - xhr.addEventListener('load', onLoad); + // By default, register for load and error events. + xhr.addEventListener('load', onLoad); xhr.addEventListener('error', onError); // Progress events are only enabled if requested. diff --git a/packages/common/http/test/jsonp_spec.ts b/packages/common/http/test/jsonp_spec.ts index 1a7bb49254..141cd544db 100644 --- a/packages/common/http/test/jsonp_spec.ts +++ b/packages/common/http/test/jsonp_spec.ts @@ -56,11 +56,11 @@ export function main() { }); describe('throws an error', () => { it('when request method is not JSONP', - () => {expect(() => backend.handle(SAMPLE_REQ.clone({method: 'GET'}))) - .toThrowError(JSONP_ERR_WRONG_METHOD)}); + () => expect(() => backend.handle(SAMPLE_REQ.clone({method: 'GET'}))) + .toThrowError(JSONP_ERR_WRONG_METHOD)); it('when response type is not json', - () => {expect(() => backend.handle(SAMPLE_REQ.clone({responseType: 'text'}))) - .toThrowError(JSONP_ERR_WRONG_RESPONSE_TYPE)}); + () => expect(() => backend.handle(SAMPLE_REQ.clone({responseType: 'text'}))) + .toThrowError(JSONP_ERR_WRONG_RESPONSE_TYPE)); it('when callback is never called', (done: DoneFn) => { backend.handle(SAMPLE_REQ).subscribe(undefined, (err: HttpErrorResponse) => { expect(err.status).toBe(0); @@ -69,7 +69,7 @@ export function main() { done(); }); document.mockLoad(); - }) + }); }); }); } diff --git a/packages/common/http/test/params_spec.ts b/packages/common/http/test/params_spec.ts index 27c2d83d76..8bc167836b 100644 --- a/packages/common/http/test/params_spec.ts +++ b/packages/common/http/test/params_spec.ts @@ -13,7 +13,7 @@ export function main() { describe('initialization', () => { it('should be empty at construction', () => { const body = new HttpParams(); - expect(body.toString()).toEqual('') + expect(body.toString()).toEqual(''); }); it('should parse an existing url', () => { diff --git a/packages/common/http/test/xhr_spec.ts b/packages/common/http/test/xhr_spec.ts index cdc3162a95..fc9dff6422 100644 --- a/packages/common/http/test/xhr_spec.ts +++ b/packages/common/http/test/xhr_spec.ts @@ -271,7 +271,7 @@ export function main() { done(); }); factory.mock.mockFlush(200, 'OK', 'Test'); - }) + }); }); describe('corrects for quirks', () => { it('by normalizing 1223 status to 204', (done: DoneFn) => { diff --git a/packages/common/http/test/xsrf_spec.ts b/packages/common/http/test/xsrf_spec.ts index f59b7df84d..1c5c235432 100644 --- a/packages/common/http/test/xsrf_spec.ts +++ b/packages/common/http/test/xsrf_spec.ts @@ -64,7 +64,7 @@ export function main() { }); describe('HttpXsrfCookieExtractor', () => { let document: {[key: string]: string}; - let extractor: HttpXsrfCookieExtractor + let extractor: HttpXsrfCookieExtractor; beforeEach(() => { document = { cookie: 'XSRF-TOKEN=test', diff --git a/packages/common/http/testing/src/backend.ts b/packages/common/http/testing/src/backend.ts index 1cb5e2b125..3de345b984 100644 --- a/packages/common/http/testing/src/backend.ts +++ b/packages/common/http/testing/src/backend.ts @@ -126,7 +126,7 @@ export class HttpClientTestingBackend implements HttpBackend, HttpTestingControl const requests = open.map(testReq => { const url = testReq.request.urlWithParams.split('?')[0]; const method = testReq.request.method; - return `${method} ${url}` + return `${method} ${url}`; }) .join(', '); throw new Error(`Expected no open requests, found ${open.length}: ${requests}`); diff --git a/packages/compiler-cli/src/codegen.ts b/packages/compiler-cli/src/codegen.ts index 8207c74e2e..6ea5a6aae4 100644 --- a/packages/compiler-cli/src/codegen.ts +++ b/packages/compiler-cli/src/codegen.ts @@ -96,7 +96,7 @@ export class CodeGenerator { } } if (!transContent) { - missingTranslation = MissingTranslationStrategy.Ignore + missingTranslation = MissingTranslationStrategy.Ignore; } const {compiler: aotCompiler} = compiler.createAotCompiler(ngCompilerHost, { translations: transContent, diff --git a/packages/compiler-cli/src/diagnostics/check_types.ts b/packages/compiler-cli/src/diagnostics/check_types.ts index 3a2030043d..0029f2fe60 100644 --- a/packages/compiler-cli/src/diagnostics/check_types.ts +++ b/packages/compiler-cli/src/diagnostics/check_types.ts @@ -203,11 +203,9 @@ class TypeCheckingHost implements ts.CompilerHost { } writeFile: ts.WriteFileCallback = - () => { throw new Error('Unexpected write in diagnostic program'); } + () => { throw new Error('Unexpected write in diagnostic program'); }; - getCurrentDirectory(): string { - return this.host.getCurrentDirectory(); - } + getCurrentDirectory(): string { return this.host.getCurrentDirectory(); } getDirectories(path: string): string[] { return this.host.getDirectories(path); } diff --git a/packages/compiler-cli/src/ngc.ts b/packages/compiler-cli/src/ngc.ts index 0b71512894..c5c315c256 100644 --- a/packages/compiler-cli/src/ngc.ts +++ b/packages/compiler-cli/src/ngc.ts @@ -134,12 +134,11 @@ export function performCompilation( const rootFileNames = files.map(f => path.normalize(f)); - const addGeneratedFileName = - (fileName: string) => { - if (fileName.startsWith(basePath) && TS_EXT.exec(fileName)) { - rootFileNames.push(fileName); - } - } + const addGeneratedFileName = (fileName: string) => { + if (fileName.startsWith(basePath) && TS_EXT.exec(fileName)) { + rootFileNames.push(fileName); + } + }; if (ngOptions.flatModuleOutFile && !ngOptions.skipMetadataEmit) { const {host: bundleHost, indexName, errors} = diff --git a/packages/compiler-cli/src/transformers/entry_points.ts b/packages/compiler-cli/src/transformers/entry_points.ts index b55b4c81ad..4e4f5b1721 100644 --- a/packages/compiler-cli/src/transformers/entry_points.ts +++ b/packages/compiler-cli/src/transformers/entry_points.ts @@ -1,3 +1,11 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + import * as ts from 'typescript'; import {CompilerHost, CompilerOptions, Program} from './api'; diff --git a/packages/compiler-cli/src/transformers/module_filename_resolver.ts b/packages/compiler-cli/src/transformers/module_filename_resolver.ts index ba4ebd1971..491695910b 100644 --- a/packages/compiler-cli/src/transformers/module_filename_resolver.ts +++ b/packages/compiler-cli/src/transformers/module_filename_resolver.ts @@ -1,8 +1,15 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + import * as path from 'path'; import * as ts from 'typescript'; -import {ModuleFilenameResolver} from './api'; -import {CompilerOptions} from './api'; +import {CompilerOptions, ModuleFilenameResolver} from './api'; const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/; const DTS = /\.d\.ts$/; diff --git a/packages/compiler-cli/src/transformers/node_emitter.ts b/packages/compiler-cli/src/transformers/node_emitter.ts index f5b81ec6c0..8adc7e8f64 100644 --- a/packages/compiler-cli/src/transformers/node_emitter.ts +++ b/packages/compiler-cli/src/transformers/node_emitter.ts @@ -32,7 +32,7 @@ export class TypeScriptNodeEmitter { } statements[0] = ts.setSyntheticLeadingComments( statements[0], - [{kind: ts.SyntaxKind.MultiLineCommentTrivia, text: preamble, pos: -1, end: -1}]) + [{kind: ts.SyntaxKind.MultiLineCommentTrivia, text: preamble, pos: -1, end: -1}]); } return [newSourceFile, converter.getNodeMap()]; } @@ -279,7 +279,7 @@ class _NodeEmitterVisitor implements StatementVisitor, ExpressionVisitor { return this.record( expr, ts.createCall( expr.fn.visitExpression(this, null), /* typeArguments */ undefined, - expr.args.map(arg => arg.visitExpression(this, null)))) + expr.args.map(arg => arg.visitExpression(this, null)))); } visitInstantiateExpr(expr: InstantiateExpr): RecordedNode { diff --git a/packages/compiler-cli/src/transformers/program.ts b/packages/compiler-cli/src/transformers/program.ts index 17b5d34024..cdf38591c0 100644 --- a/packages/compiler-cli/src/transformers/program.ts +++ b/packages/compiler-cli/src/transformers/program.ts @@ -15,8 +15,7 @@ import * as ts from 'typescript'; import {CompilerHost as AotCompilerHost, CompilerHostContext} from '../compiler_host'; import {TypeChecker} from '../diagnostics/check_types'; -import {CompilerHost, CompilerOptions, DiagnosticCategory} from './api'; -import {Diagnostic, EmitFlags, Program} from './api'; +import {CompilerHost, CompilerOptions, Diagnostic, DiagnosticCategory, EmitFlags, Program} from './api'; import {getAngularEmitterTransformFactory} from './node_emitter_transform'; const GENERATED_FILES = /\.ngfactory\.js$|\.ngstyle\.js$|\.ngsummary\.js$/; @@ -144,7 +143,7 @@ class AngularCompilerProgram implements Program { } private get structuralDiagnostics(): Diagnostic[] { - return this.analyzedModules && this._structuralDiagnostics + return this.analyzedModules && this._structuralDiagnostics; } private get stubs(): GeneratedFile[] { @@ -171,7 +170,7 @@ class AngularCompilerProgram implements Program { } private get generatedFiles(): GeneratedFile[] { - return this._generatedFiles || (this._generatedFiles = this.generateFiles()) + return this._generatedFiles || (this._generatedFiles = this.generateFiles()); } private get typeChecker(): TypeChecker { @@ -329,7 +328,7 @@ function createProgramWithStubsHost( generatedFiles: GeneratedFile[], originalProgram: ts.Program, originalHost: ts.CompilerHost): ts.CompilerHost { interface FileData { - g: GeneratedFile + g: GeneratedFile; s?: ts.SourceFile; } return new class implements ts.CompilerHost { diff --git a/packages/compiler-cli/test/diagnostics/mocks.ts b/packages/compiler-cli/test/diagnostics/mocks.ts index 6cd06d8616..c87acd9f96 100644 --- a/packages/compiler-cli/test/diagnostics/mocks.ts +++ b/packages/compiler-cli/test/diagnostics/mocks.ts @@ -110,12 +110,14 @@ const summaryResolver = new AotSummaryResolver( staticSymbolCache); export class DiagnosticContext { + // tslint:disable _analyzedModules: NgAnalyzedModules; _staticSymbolResolver: StaticSymbolResolver|undefined; _reflector: StaticReflector|undefined; _errors: {e: any, path?: string}[] = []; _resolver: CompileMetadataResolver|undefined; _refletor: StaticReflector; + // tslint:enable constructor( public service: ts.LanguageService, public program: ts.Program, diff --git a/packages/compiler-cli/test/diagnostics/symbol_query_spec.ts b/packages/compiler-cli/test/diagnostics/symbol_query_spec.ts index cf7d7697e6..317b26ed3e 100644 --- a/packages/compiler-cli/test/diagnostics/symbol_query_spec.ts +++ b/packages/compiler-cli/test/diagnostics/symbol_query_spec.ts @@ -45,7 +45,7 @@ describe('symbol query', () => { options.basePath = '/quickstart'; const aotHost = new CompilerHost(program, options, host, {verboseInvalidExpression: true}); context = new DiagnosticContext(service, program, checker, aotHost); - query = getSymbolQuery(program, checker, sourceFile, emptyPipes) + query = getSymbolQuery(program, checker, sourceFile, emptyPipes); }); it('should be able to get undefined for an unknown symbol', () => { diff --git a/packages/compiler-cli/test/ngc_spec.ts b/packages/compiler-cli/test/ngc_spec.ts index 2c272d0c96..46c76d54f8 100644 --- a/packages/compiler-cli/test/ngc_spec.ts +++ b/packages/compiler-cli/test/ngc_spec.ts @@ -321,12 +321,11 @@ describe('ngc command-line', () => { throw new Error(`Expected ${fileName} to be emitted (outDir: ${outDir})`); } }; - const shouldNotExist = - (fileName: string) => { - if (fs.existsSync(path.resolve(outDir, fileName))) { - throw new Error(`Did not expect ${fileName} to be emitted (outDir: ${outDir})`); - } - } + const shouldNotExist = (fileName: string) => { + if (fs.existsSync(path.resolve(outDir, fileName))) { + throw new Error(`Did not expect ${fileName} to be emitted (outDir: ${outDir})`); + } + }; it('should be able to generate a flat module library', () => { writeConfig(` diff --git a/packages/compiler/src/aot/compiler_options.ts b/packages/compiler/src/aot/compiler_options.ts index 772ce3ca12..ed260b3a6a 100644 --- a/packages/compiler/src/aot/compiler_options.ts +++ b/packages/compiler/src/aot/compiler_options.ts @@ -14,5 +14,5 @@ export interface AotCompilerOptions { translations?: string; missingTranslation?: MissingTranslationStrategy; enableLegacyTemplate?: boolean; - enableSummariesForJit?: boolean + enableSummariesForJit?: boolean; } diff --git a/packages/compiler/src/aot/static_reflector.ts b/packages/compiler/src/aot/static_reflector.ts index 5a9a74ed2b..29dde3e274 100644 --- a/packages/compiler/src/aot/static_reflector.ts +++ b/packages/compiler/src/aot/static_reflector.ts @@ -621,7 +621,7 @@ export class StaticReflector implements CompileReflector { } return simplifyInContext(context, value, depth, references + 1); } - return simplify(value) + return simplify(value); }); } return IGNORE; diff --git a/packages/compiler/src/ml_parser/ast.ts b/packages/compiler/src/ml_parser/ast.ts index 0a5b0e6449..3bd8742fed 100644 --- a/packages/compiler/src/ml_parser/ast.ts +++ b/packages/compiler/src/ml_parser/ast.ts @@ -142,7 +142,7 @@ export function findNode(nodes: Node[], position: number): HtmlAstPath { return true; } } - } + }; visitAll(visitor, nodes); diff --git a/packages/compiler/src/output/output_ast.ts b/packages/compiler/src/output/output_ast.ts index 8cd09a93e1..d98f67f4d1 100644 --- a/packages/compiler/src/output/output_ast.ts +++ b/packages/compiler/src/output/output_ast.ts @@ -228,7 +228,7 @@ export class ReadVarExpr extends Expression { set(value: Expression): WriteVarExpr { if (!this.name) { - throw new Error(`Built in variable ${this.builtin} can not be assigned to.`) + throw new Error(`Built in variable ${this.builtin} can not be assigned to.`); } return new WriteVarExpr(this.name, value, null, this.sourceSpan); } diff --git a/packages/compiler/test/aot/compiler_spec.ts b/packages/compiler/test/aot/compiler_spec.ts index faf041d9a8..a515126e51 100644 --- a/packages/compiler/test/aot/compiler_spec.ts +++ b/packages/compiler/test/aot/compiler_spec.ts @@ -28,7 +28,7 @@ describe('compiler (unbundled Angular)', () => { describe('aot source mapping', () => { const componentPath = '/app/app.component.ts'; - const ngComponentPath = 'ng:///app/app.component.ts' + const ngComponentPath = 'ng:///app/app.component.ts'; let rootDir: MockDirectory; let appDir: MockDirectory; diff --git a/packages/compiler/test/i18n/extractor_merger_spec.ts b/packages/compiler/test/i18n/extractor_merger_spec.ts index 641b769c3f..0618e0408f 100644 --- a/packages/compiler/test/i18n/extractor_merger_spec.ts +++ b/packages/compiler/test/i18n/extractor_merger_spec.ts @@ -490,7 +490,7 @@ export function main() { .toEqual( 'foo
{count, plural, =0 {

}}
'); }); - }) + }); }); } diff --git a/packages/compiler/test/output/output_jit_spec.ts b/packages/compiler/test/output/output_jit_spec.ts index 017ddf8cb6..b9aad8dadf 100644 --- a/packages/compiler/test/output/output_jit_spec.ts +++ b/packages/compiler/test/output/output_jit_spec.ts @@ -31,5 +31,5 @@ export function main() { expect(Object.keys(args).length).toBe(20); }); }); - }) + }); } \ No newline at end of file diff --git a/packages/compiler/test/parse_util_spec.ts b/packages/compiler/test/parse_util_spec.ts index 65521cf451..9c9ce43f0b 100644 --- a/packages/compiler/test/parse_util_spec.ts +++ b/packages/compiler/test/parse_util_spec.ts @@ -6,23 +6,21 @@ * found in the LICENSE file at https://angular.io/license */ -import {ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../src/parse_util' +import {ParseError, ParseErrorLevel, ParseLocation, ParseSourceFile, ParseSourceSpan} from '../src/parse_util'; export function main() { - describe( - 'ParseError', - () => { - it('should reflect the level in the message', () => { - const file = new ParseSourceFile(`foo\nbar\nfoo`, 'url'); - const start = new ParseLocation(file, 4, 1, 0); - const end = new ParseLocation(file, 6, 1, 2); - const span = new ParseSourceSpan(start, end); + describe('ParseError', () => { + it('should reflect the level in the message', () => { + const file = new ParseSourceFile(`foo\nbar\nfoo`, 'url'); + const start = new ParseLocation(file, 4, 1, 0); + const end = new ParseLocation(file, 6, 1, 2); + const span = new ParseSourceSpan(start, end); - const fatal = new ParseError(span, 'fatal', ParseErrorLevel.ERROR); - expect(fatal.toString()).toEqual('fatal ("foo\n[ERROR ->]bar\nfoo"): url@1:0'); + const fatal = new ParseError(span, 'fatal', ParseErrorLevel.ERROR); + expect(fatal.toString()).toEqual('fatal ("foo\n[ERROR ->]bar\nfoo"): url@1:0'); - const warning = new ParseError(span, 'warning', ParseErrorLevel.WARNING); - expect(warning.toString()).toEqual('warning ("foo\n[WARNING ->]bar\nfoo"): url@1:0'); - }); - }); + const warning = new ParseError(span, 'warning', ParseErrorLevel.WARNING); + expect(warning.toString()).toEqual('warning ("foo\n[WARNING ->]bar\nfoo"): url@1:0'); + }); + }); } \ No newline at end of file diff --git a/packages/core/src/application_init.ts b/packages/core/src/application_init.ts index fdc1966a00..b801ab26b4 100644 --- a/packages/core/src/application_init.ts +++ b/packages/core/src/application_init.ts @@ -45,11 +45,10 @@ export class ApplicationInitStatus { const asyncInitPromises: Promise[] = []; - const complete = - () => { - this._done = true; - this.resolve(); - } + const complete = () => { + this._done = true; + this.resolve(); + }; if (this.appInits) { for (let i = 0; i < this.appInits.length; i++) { diff --git a/packages/core/src/change_detection/differs/default_iterable_differ.ts b/packages/core/src/change_detection/differs/default_iterable_differ.ts index 6f5686b165..a73a597904 100644 --- a/packages/core/src/change_detection/differs/default_iterable_differ.ts +++ b/packages/core/src/change_detection/differs/default_iterable_differ.ts @@ -52,11 +52,9 @@ export class DefaultIterableDiffer implements IterableDiffer, IterableChan // Keeps track of records where custom track by is the same, but item identity has changed private _identityChangesHead: IterableChangeRecord_|null = null; private _identityChangesTail: IterableChangeRecord_|null = null; - private _trackByFn: TrackByFunction + private _trackByFn: TrackByFunction; - constructor(trackByFn?: TrackByFunction) { - this._trackByFn = trackByFn || trackByIdentity; - } + constructor(trackByFn?: TrackByFunction) { this._trackByFn = trackByFn || trackByIdentity; } get collection() { return this._collection; } diff --git a/packages/core/src/view/element.ts b/packages/core/src/view/element.ts index cf69acb758..0f24d4c7d9 100644 --- a/packages/core/src/view/element.ts +++ b/packages/core/src/view/element.ts @@ -196,7 +196,7 @@ function renderEventHandlerClosure(view: ViewData, index: number, eventName: str // Attention: Don't rethrow, to keep in sync with directive events. view.root.errorHandler.handleError(e); } - } + }; } diff --git a/packages/core/src/view/provider.ts b/packages/core/src/view/provider.ts index be71c31a1f..dd6e7380bc 100644 --- a/packages/core/src/view/provider.ts +++ b/packages/core/src/view/provider.ts @@ -145,7 +145,7 @@ function eventHandlerClosure(view: ViewData, index: number, eventName: string) { // Attention: Don't rethrow, as it would cancel Observable subscriptions! view.root.errorHandler.handleError(e); } - } + }; } export function checkAndUpdateDirectiveInline( diff --git a/packages/core/src/view/refs.ts b/packages/core/src/view/refs.ts index 2318ca6f45..7d09900624 100644 --- a/packages/core/src/view/refs.ts +++ b/packages/core/src/view/refs.ts @@ -466,6 +466,7 @@ export function createNgModuleRef( class NgModuleRef_ implements NgModuleData, InternalNgModuleRef { private _destroyListeners: (() => void)[] = []; private _destroyed: boolean = false; + // tslint:disable-next-line public _providers: any[]; constructor( diff --git a/packages/core/test/animation/animation_integration_spec.ts b/packages/core/test/animation/animation_integration_spec.ts index 775c73c2a4..79fc180e13 100644 --- a/packages/core/test/animation/animation_integration_spec.ts +++ b/packages/core/test/animation/animation_integration_spec.ts @@ -1790,7 +1790,7 @@ export function main() { class Cmp { exp: string; log: any[] = []; - callback = (event: any) => { this.log.push(`${event.phaseName} => ${event.toState}`); } + callback = (event: any) => this.log.push(`${event.phaseName} => ${event.toState}`); } TestBed.configureTestingModule({ diff --git a/packages/core/test/application_init_spec.ts b/packages/core/test/application_init_spec.ts index ae0bd543c4..693d538876 100644 --- a/packages/core/test/application_init_spec.ts +++ b/packages/core/test/application_init_spec.ts @@ -35,7 +35,7 @@ export function main() { return () => { const initStatus = injector.get(ApplicationInitStatus); initStatus.donePromise.then(() => { expect(completerResolver).toBe(true); }); - } + }; }; promise = new Promise((res) => { resolve = res; }); TestBed.configureTestingModule({ diff --git a/packages/core/test/linker/change_detection_integration_spec.ts b/packages/core/test/linker/change_detection_integration_spec.ts index 8db439d1a4..e5d7b3f508 100644 --- a/packages/core/test/linker/change_detection_integration_spec.ts +++ b/packages/core/test/linker/change_detection_integration_spec.ts @@ -1353,7 +1353,7 @@ export function main() { tpl: TemplateRef; @Input() - outerTpl: TemplateRef + outerTpl: TemplateRef; constructor(public cdRef: ChangeDetectorRef) {} log(id: string) { log.push(`inner-${id}`); } diff --git a/packages/forms/src/directives/default_value_accessor.ts b/packages/forms/src/directives/default_value_accessor.ts index f550dc6213..6208323338 100644 --- a/packages/forms/src/directives/default_value_accessor.ts +++ b/packages/forms/src/directives/default_value_accessor.ts @@ -83,14 +83,17 @@ export class DefaultValueAccessor implements ControlValueAccessor { this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled); } + /** @internal */ _handleInput(value: any): void { if (!this._compositionMode || (this._compositionMode && !this._composing)) { this.onChange(value); } } + /** @internal */ _compositionStart(): void { this._composing = true; } + /** @internal */ _compositionEnd(value: any): void { this._composing = false; this._compositionMode && this.onChange(value); diff --git a/packages/forms/test/reactive_integration_spec.ts b/packages/forms/test/reactive_integration_spec.ts index 1dfd3c63d3..2b5b48f454 100644 --- a/packages/forms/test/reactive_integration_spec.ts +++ b/packages/forms/test/reactive_integration_spec.ts @@ -1698,7 +1698,7 @@ export function main() { tick(100); expect(resultArr.length) - .toEqual(2, `Expected original observable to be canceled on the next value change.`) + .toEqual(2, `Expected original observable to be canceled on the next value change.`); })); diff --git a/packages/platform-browser/test/security/html_sanitizer_spec.ts b/packages/platform-browser/test/security/html_sanitizer_spec.ts index 144a052168..51afd6d159 100644 --- a/packages/platform-browser/test/security/html_sanitizer_spec.ts +++ b/packages/platform-browser/test/security/html_sanitizer_spec.ts @@ -123,7 +123,7 @@ export function main() { // depending on the browser, we might ge an exception } try { - sanitizeHtml(defaultDoc, '
') + sanitizeHtml(defaultDoc, '
'); } catch (e) { // depending on the browser, we might ge an exception } diff --git a/packages/router/src/apply_redirects.ts b/packages/router/src/apply_redirects.ts index 8000df3368..0d8c386938 100644 --- a/packages/router/src/apply_redirects.ts +++ b/packages/router/src/apply_redirects.ts @@ -444,8 +444,11 @@ function match(segmentGroup: UrlSegmentGroup, route: Route, segments: UrlSegment if (!res) { return { - matched: false, consumedSegments: [], lastChild: 0, positionalParamSegments: {}, - } + matched: false, + consumedSegments: [], + lastChild: 0, + positionalParamSegments: {}, + }; } return { diff --git a/packages/router/src/router.ts b/packages/router/src/router.ts index a5970a15a6..a3d1b65e43 100644 --- a/packages/router/src/router.ts +++ b/packages/router/src/router.ts @@ -1128,7 +1128,7 @@ class ActivateRoutes { const children: {[outletName: string]: any} = nodeChildrenAsMap(route); const contexts = route.value.component ? context.children : parentContexts; - forEach(children, (v: any, k: string) => {this.deactivateRouteAndItsChildren(v, contexts)}); + forEach(children, (v: any, k: string) => this.deactivateRouteAndItsChildren(v, contexts)); if (context.outlet) { // Destroy the component diff --git a/packages/router/src/utils/collection.ts b/packages/router/src/utils/collection.ts index 36ffcca7d8..b96cadb1de 100644 --- a/packages/router/src/utils/collection.ts +++ b/packages/router/src/utils/collection.ts @@ -64,7 +64,7 @@ export function forEach(map: {[key: string]: V}, callback: (v: V, k: strin export function waitForMap( obj: {[k: string]: A}, fn: (k: string, a: A) => Observable): Observable<{[k: string]: B}> { if (Object.keys(obj).length === 0) { - return of ({}) + return of ({}); } const waitHead: Observable[] = []; diff --git a/packages/router/test/integration.spec.ts b/packages/router/test/integration.spec.ts index adeab68c68..a9b3dba3f2 100644 --- a/packages/router/test/integration.spec.ts +++ b/packages/router/test/integration.spec.ts @@ -1070,7 +1070,7 @@ describe('Integration', () => { return map.call(of (null), () => { log.push('resolver2'); observer.next(null); - observer.complete() + observer.complete(); }); } }, diff --git a/tools/gulp-tasks/lint.js b/tools/gulp-tasks/lint.js index cacf7e0d00..6a1496327b 100644 --- a/tools/gulp-tasks/lint.js +++ b/tools/gulp-tasks/lint.js @@ -9,9 +9,13 @@ module.exports = (gulp) => () => { // todo(vicb): add .js files when supported // see https://github.com/palantir/tslint/pull/1515 './modules/**/*.ts', + './packages/**/*.ts', './tools/**/*.ts', './*.ts', + // Ignore node_modules directories + '!**/node_modules/**', + // Ignore TypeScript mocks because it's not managed by us '!./tools/@angular/tsc-wrapped/test/typescript.mocks.ts', diff --git a/tools/public_api_guard/forms/forms.d.ts b/tools/public_api_guard/forms/forms.d.ts index fcd570bc0a..52f41aa218 100644 --- a/tools/public_api_guard/forms/forms.d.ts +++ b/tools/public_api_guard/forms/forms.d.ts @@ -144,9 +144,6 @@ export declare class DefaultValueAccessor implements ControlValueAccessor { onChange: (_: any) => void; onTouched: () => void; constructor(_renderer: Renderer2, _elementRef: ElementRef, _compositionMode: boolean); - _compositionEnd(value: any): void; - _compositionStart(): void; - _handleInput(value: any): void; registerOnChange(fn: (_: any) => void): void; registerOnTouched(fn: () => void): void; setDisabledState(isDisabled: boolean): void;