diff --git a/modules/@angular/benchpress/test/firefox_extension/spec.ts b/modules/@angular/benchpress/test/firefox_extension/spec.ts index bb81aeb29becb..15033c08555f1 100644 --- a/modules/@angular/benchpress/test/firefox_extension/spec.ts +++ b/modules/@angular/benchpress/test/firefox_extension/spec.ts @@ -27,9 +27,7 @@ describe('firefox extension', function() { browser.driver.get(TEST_URL); - browser.executeScript('window.startProfiler()').then(function() { - console.log('started measuring perf'); - }); + browser.executeScript('window.startProfiler()'); browser.executeAsyncScript('setTimeout(arguments[0], 1000);'); browser.executeScript('window.forceGC()'); diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index 8e9dfff35834e..8b327f6e5371c 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -44,7 +44,7 @@ export class CodeGenerator { let root = this.options.basePath; for (const eachRootDir of this.options.rootDirs || []) { if (this.options.trace) { - console.log(`Check if ${filePath} is under rootDirs element ${eachRootDir}`); + console.error(`Check if ${filePath} is under rootDirs element ${eachRootDir}`); } if (path.relative(eachRootDir, filePath).indexOf('.') !== 0) { root = eachRootDir; diff --git a/modules/@angular/compiler-cli/src/path_mapped_compiler_host.ts b/modules/@angular/compiler-cli/src/path_mapped_compiler_host.ts index 6f01d29800d64..2a1af90ea4dff 100644 --- a/modules/@angular/compiler-cli/src/path_mapped_compiler_host.ts +++ b/modules/@angular/compiler-cli/src/path_mapped_compiler_host.ts @@ -56,7 +56,7 @@ export class PathMappedCompilerHost extends CompilerHost { ts.resolveModuleName(m, rootedContainingFile, this.options, this.context).resolvedModule; if (resolved) { if (this.options.traceResolution) { - console.log('resolve', m, containingFile, '=>', resolved.resolvedFileName); + console.error('resolve', m, containingFile, '=>', resolved.resolvedFileName); } return this.getCanonicalFileName(resolved.resolvedFileName); } @@ -71,7 +71,7 @@ export class PathMappedCompilerHost extends CompilerHost { */ fileNameToModuleName(importedFile: string, containingFile: string): string { if (this.options.traceResolution) { - console.log( + console.error( 'getImportPath from containingFile', containingFile, 'to importedFile', importedFile); } diff --git a/modules/@angular/compiler/src/aot/compiler.ts b/modules/@angular/compiler/src/aot/compiler.ts index f2895f3996123..98ddf80c251e6 100644 --- a/modules/@angular/compiler/src/aot/compiler.ts +++ b/modules/@angular/compiler/src/aot/compiler.ts @@ -369,7 +369,7 @@ export function extractProgramSymbols( files.filter(fileName => _filterFileByPatterns(fileName, options)).forEach(sourceFile => { const moduleMetadata = staticReflector.getModuleMetadata(sourceFile); if (!moduleMetadata) { - console.log(`WARNING: no metadata found for ${sourceFile}`); + console.error(`WARNING: no metadata found for ${sourceFile}`); return; } diff --git a/modules/@angular/compiler/src/aot/static_reflector.ts b/modules/@angular/compiler/src/aot/static_reflector.ts index e4792d4c1e163..a4a7b45b7d35e 100644 --- a/modules/@angular/compiler/src/aot/static_reflector.ts +++ b/modules/@angular/compiler/src/aot/static_reflector.ts @@ -163,7 +163,7 @@ export class StaticReflector implements ReflectorReader { } return parameters; } catch (e) { - console.log(`Failed on type ${JSON.stringify(type)} with error ${e}`); + console.error(`Failed on type ${JSON.stringify(type)} with error ${e}`); throw e; } } diff --git a/modules/@angular/examples/_common/e2e_util.ts b/modules/@angular/examples/_common/e2e_util.ts index c89f3d7293cc3..6d0deb77b2695 100644 --- a/modules/@angular/examples/_common/e2e_util.ts +++ b/modules/@angular/examples/_common/e2e_util.ts @@ -15,7 +15,6 @@ export function verifyNoBrowserErrors() { const errors: any[] = []; browserLog.filter(logEntry => { const msg = logEntry.message; - console.log('>> ' + msg); if (logEntry.level.value >= webdriver.logging.Level.INFO.value) { errors.push(msg); } diff --git a/modules/@angular/examples/facade/ts/async/observable.ts b/modules/@angular/examples/facade/ts/async/observable.ts index 59ce255f0cceb..739e8d372ad41 100644 --- a/modules/@angular/examples/facade/ts/async/observable.ts +++ b/modules/@angular/examples/facade/ts/async/observable.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Observable import {Observable} from 'rxjs/Observable'; import {Subscriber} from 'rxjs/Subscriber'; diff --git a/modules/@angular/examples/facade/ts/async/observable_patched.ts b/modules/@angular/examples/facade/ts/async/observable_patched.ts index 8304b348b02a0..0dbde026d32ef 100644 --- a/modules/@angular/examples/facade/ts/async/observable_patched.ts +++ b/modules/@angular/examples/facade/ts/async/observable_patched.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Observable import 'rxjs/add/operator/map'; diff --git a/modules/@angular/examples/facade/ts/async/observable_pure.ts b/modules/@angular/examples/facade/ts/async/observable_pure.ts index 08eb46b7a19c6..3028464088643 100644 --- a/modules/@angular/examples/facade/ts/async/observable_pure.ts +++ b/modules/@angular/examples/facade/ts/async/observable_pure.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Observable import {Observable} from 'rxjs/Observable'; import {Subscriber} from 'rxjs/Subscriber'; diff --git a/modules/@angular/examples/forms/ts/nestedFormArray/nested_form_array_example.ts b/modules/@angular/examples/forms/ts/nestedFormArray/nested_form_array_example.ts index c7daf00a238f2..346221acc7c6a 100644 --- a/modules/@angular/examples/forms/ts/nestedFormArray/nested_form_array_example.ts +++ b/modules/@angular/examples/forms/ts/nestedFormArray/nested_form_array_example.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Component import {Component} from '@angular/core'; import {FormArray, FormControl, FormGroup} from '@angular/forms'; diff --git a/modules/@angular/examples/forms/ts/nestedFormGroup/nested_form_group_example.ts b/modules/@angular/examples/forms/ts/nestedFormGroup/nested_form_group_example.ts index 1f8ace219118d..38c61535b8716 100644 --- a/modules/@angular/examples/forms/ts/nestedFormGroup/nested_form_group_example.ts +++ b/modules/@angular/examples/forms/ts/nestedFormGroup/nested_form_group_example.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Component import {Component} from '@angular/core'; import {FormControl, FormGroup, Validators} from '@angular/forms'; diff --git a/modules/@angular/examples/forms/ts/ngModelGroup/ng_model_group_example.ts b/modules/@angular/examples/forms/ts/ngModelGroup/ng_model_group_example.ts index 4c567c36ffdf8..fe794843f153a 100644 --- a/modules/@angular/examples/forms/ts/ngModelGroup/ng_model_group_example.ts +++ b/modules/@angular/examples/forms/ts/ngModelGroup/ng_model_group_example.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Component import {Component} from '@angular/core'; import {NgForm} from '@angular/forms'; diff --git a/modules/@angular/examples/forms/ts/simpleForm/simple_form_example.ts b/modules/@angular/examples/forms/ts/simpleForm/simple_form_example.ts index 691756e8237e8..b648cab7ca26d 100644 --- a/modules/@angular/examples/forms/ts/simpleForm/simple_form_example.ts +++ b/modules/@angular/examples/forms/ts/simpleForm/simple_form_example.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Component import {Component} from '@angular/core'; import {NgForm} from '@angular/forms'; diff --git a/modules/@angular/examples/forms/ts/simpleFormGroup/simple_form_group_example.ts b/modules/@angular/examples/forms/ts/simpleFormGroup/simple_form_group_example.ts index a128393e18e82..7ca0d21abe4ac 100644 --- a/modules/@angular/examples/forms/ts/simpleFormGroup/simple_form_group_example.ts +++ b/modules/@angular/examples/forms/ts/simpleFormGroup/simple_form_group_example.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ // #docregion Component import {Component} from '@angular/core'; import {FormControl, FormGroup, Validators} from '@angular/forms'; diff --git a/modules/@angular/facade/src/lang.ts b/modules/@angular/facade/src/lang.ts index 6654cb9129661..ed9eb36cf89f4 100644 --- a/modules/@angular/facade/src/lang.ts +++ b/modules/@angular/facade/src/lang.ts @@ -129,6 +129,7 @@ export function isJsObject(o: any): boolean { } export function print(obj: Error | Object) { + // tslint:disable-next-line:no-console console.log(obj); } diff --git a/modules/@angular/platform-browser/src/browser/browser_adapter.ts b/modules/@angular/platform-browser/src/browser/browser_adapter.ts index 86e0e965d35e3..d78a96320c2de 100644 --- a/modules/@angular/platform-browser/src/browser/browser_adapter.ts +++ b/modules/@angular/platform-browser/src/browser/browser_adapter.ts @@ -85,6 +85,7 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter { log(error: string): void { if (window.console) { + // tslint:disable-next-line:no-console window.console.log && window.console.log(error); } } diff --git a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts index 91e000133c0ad..852ffba1b8c37 100644 --- a/modules/@angular/platform-browser/src/browser/tools/common_tools.ts +++ b/modules/@angular/platform-browser/src/browser/tools/common_tools.ts @@ -75,7 +75,9 @@ export class AngularProfiler { (window.console.profileEnd)(profileName); } const msPerTick = (end - start) / numTicks; + // tslint:disable-next-line:no-console window.console.log(`ran ${numTicks} change detection cycles`); + // tslint:disable-next-line:no-console window.console.log(`${msPerTick.toFixed(2)} ms per check`); return new ChangeDetectionPerfRecord(msPerTick, numTicks); diff --git a/modules/@angular/platform-server/src/parse5_adapter.ts b/modules/@angular/platform-server/src/parse5_adapter.ts index 3673f25bbab59..55154592447f4 100644 --- a/modules/@angular/platform-server/src/parse5_adapter.ts +++ b/modules/@angular/platform-server/src/parse5_adapter.ts @@ -63,6 +63,7 @@ export class Parse5DomAdapter extends DomAdapter { logError(error: string) { console.error(error); } + // tslint:disable-next-line:no-console log(error: string) { console.log(error); } logGroup(error: string) { console.error(error); } diff --git a/modules/@angular/platform-webworker/src/web_workers/worker/worker_adapter.ts b/modules/@angular/platform-webworker/src/web_workers/worker/worker_adapter.ts index 4635efccb6203..3278c195e6b45 100644 --- a/modules/@angular/platform-webworker/src/web_workers/worker/worker_adapter.ts +++ b/modules/@angular/platform-webworker/src/web_workers/worker/worker_adapter.ts @@ -22,10 +22,12 @@ export class WorkerDomAdapter extends DomAdapter { if (console.error) { console.error(error); } else { + // tslint:disable-next-line:no-console console.log(error); } } + // tslint:disable-next-line:no-console log(error: any /** TODO #9100 */) { console.log(error); } logGroup(error: any /** TODO #9100 */) { @@ -33,6 +35,7 @@ export class WorkerDomAdapter extends DomAdapter { console.group(error); this.logError(error); } else { + // tslint:disable-next-line:no-console console.log(error); } } diff --git a/modules/@angular/upgrade/src/util.ts b/modules/@angular/upgrade/src/util.ts index 20fd7056d1f9f..744d3a4865a0b 100644 --- a/modules/@angular/upgrade/src/util.ts +++ b/modules/@angular/upgrade/src/util.ts @@ -15,7 +15,7 @@ export function stringify(obj: any): string { export function onError(e: any) { // TODO: (misko): We seem to not have a stack trace here! - console.log(e, e.stack); + console.error(e, e.stack); throw e; } diff --git a/modules/@angular/upgrade/test/upgrade_spec.ts b/modules/@angular/upgrade/test/upgrade_spec.ts index ae1e22d845f2b..90f21c510c1a4 100644 --- a/modules/@angular/upgrade/test/upgrade_spec.ts +++ b/modules/@angular/upgrade/test/upgrade_spec.ts @@ -41,7 +41,7 @@ export function main() { it('should throw an uncaught error', fakeAsync(() => { const resolveSpy = jasmine.createSpy('resolveSpy'); - spyOn(console, 'log'); + spyOn(console, 'error'); expect(() => { adapter.bootstrap(html(''), ['ng1']).ready(resolveSpy); @@ -50,14 +50,14 @@ export function main() { expect(resolveSpy).not.toHaveBeenCalled(); })); - it('should properly log to the console and re-throw', fakeAsync(() => { - spyOn(console, 'log'); + it('should output an error message to the console and re-throw', fakeAsync(() => { + spyOn(console, 'error'); expect(() => { adapter.bootstrap(html(''), ['ng1']); flushMicrotasks(); }).toThrowError(); - expect(console.log).toHaveBeenCalled(); - expect(console.log).toHaveBeenCalledWith(jasmine.any(Error), jasmine.any(String)); + expect(console.error).toHaveBeenCalled(); + expect(console.error).toHaveBeenCalledWith(jasmine.any(Error), jasmine.any(String)); })); }); diff --git a/modules/benchmarks/e2e_test/old/largetable_perf.ts b/modules/benchmarks/e2e_test/old/largetable_perf.ts index 9cabdcf1e544a..046c01e3854be 100644 --- a/modules/benchmarks/e2e_test/old/largetable_perf.ts +++ b/modules/benchmarks/e2e_test/old/largetable_perf.ts @@ -24,7 +24,6 @@ describe('ng2 largetable benchmark', function() { ['interpolation', 'interpolationAttr', 'interpolationFn'].forEach(function(benchmarkType) { it('should log the ng stats with: ' + benchmarkType, function(done) { - console.log('executing for type', benchmarkType); runClickBenchmark({ url: URL, buttons: ['#ng2DestroyDom', '#ng2CreateDom'], diff --git a/modules/benchmarks/src/util.ts b/modules/benchmarks/src/util.ts index 9ac8948e6ec0c..6edcbf5850c78 100644 --- a/modules/benchmarks/src/util.ts +++ b/modules/benchmarks/src/util.ts @@ -51,7 +51,6 @@ export function profile(create: () => void, destroy: () => void, name: string) { destroy(); } window.console.profileEnd(); - window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`); window.console.profile(name + ' w/o GC'); duration = 0; @@ -63,7 +62,6 @@ export function profile(create: () => void, destroy: () => void, name: string) { destroy(); } window.console.profileEnd(); - window.console.log(`Iterations: ${count}; time: ${duration / count} ms / iteration`); }; } diff --git a/modules/e2e_util/e2e_util.ts b/modules/e2e_util/e2e_util.ts index dd6f62883a90f..344190dca7389 100644 --- a/modules/e2e_util/e2e_util.ts +++ b/modules/e2e_util/e2e_util.ts @@ -59,7 +59,7 @@ export function verifyNoBrowserErrors() { browser.manage().logs().get('browser').then(function(browserLog: any) { const filteredLog = browserLog.filter(function(logEntry: any) { if (logEntry.level.value >= webdriver.logging.Level.INFO.value) { - console.log('>> ' + logEntry.message); + console.error('>> ' + logEntry.message); } return logEntry.level.value > webdriver.logging.Level.WARNING.value; }); diff --git a/modules/playground/e2e_test/web_workers/animations/animations_spec.ts b/modules/playground/e2e_test/web_workers/animations/animations_spec.ts index f0fc7113448d6..2e1e32fdf4b11 100644 --- a/modules/playground/e2e_test/web_workers/animations/animations_spec.ts +++ b/modules/playground/e2e_test/web_workers/animations/animations_spec.ts @@ -67,7 +67,7 @@ describe('WebWorkers Animations', function() { browser.wait(protractor.until.elementLocated(by.css(selector + ' .box')), 5000) .then(() => {}, () => { // jasmine will timeout if this gets called too many times - console.log('>> unexpected timeout -> browser.refresh()'); + console.error('>> unexpected timeout -> browser.refresh()'); browser.refresh(); waitForBootstrap(); }); diff --git a/modules/playground/e2e_test/web_workers/input/input_spec.ts b/modules/playground/e2e_test/web_workers/input/input_spec.ts index 903e4fb6d8bee..6605f57a78778 100644 --- a/modules/playground/e2e_test/web_workers/input/input_spec.ts +++ b/modules/playground/e2e_test/web_workers/input/input_spec.ts @@ -67,7 +67,7 @@ describe('WebWorkers Input', function() { }, () => { // jasmine will timeout if this gets called too many times - console.log('>> unexpected timeout -> browser.refresh()'); + console.error('>> unexpected timeout -> browser.refresh()'); browser.refresh(); waitForBootstrap(); }); diff --git a/modules/playground/src/model_driven_forms/index.ts b/modules/playground/src/model_driven_forms/index.ts index 1b6d2aabe1bd2..ebb78850a3b23 100644 --- a/modules/playground/src/model_driven_forms/index.ts +++ b/modules/playground/src/model_driven_forms/index.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ import {Component, Host, NgModule} from '@angular/core'; import {AbstractControl, FormBuilder, FormGroup, FormGroupDirective, ReactiveFormsModule, Validators} from '@angular/forms'; import {BrowserModule} from '@angular/platform-browser'; diff --git a/modules/playground/src/template_driven_forms/index.ts b/modules/playground/src/template_driven_forms/index.ts index 99ba9a2aa12e2..eae084b6f2eed 100644 --- a/modules/playground/src/template_driven_forms/index.ts +++ b/modules/playground/src/template_driven_forms/index.ts @@ -6,6 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ +/* tslint:disable:no-console */ import {Component, Directive, Host, NgModule} from '@angular/core'; import {FormControl, FormGroup, FormsModule, NG_VALIDATORS, NgForm} from '@angular/forms'; diff --git a/tools/@angular/tsc-wrapped/src/tsc.ts b/tools/@angular/tsc-wrapped/src/tsc.ts index 96afe1ae9a5bf..e68deb6d67942 100644 --- a/tools/@angular/tsc-wrapped/src/tsc.ts +++ b/tools/@angular/tsc-wrapped/src/tsc.ts @@ -27,6 +27,7 @@ export interface CompilerInterface { const DEBUG = false; function debug(msg: string, ...o: any[]) { + // tslint:disable-next-line:no-console if (DEBUG) console.log(msg, ...o); } diff --git a/tools/tsc-watch/index.ts b/tools/tsc-watch/index.ts index d50ca67c18ce2..67cf8c604fa37 100644 --- a/tools/tsc-watch/index.ts +++ b/tools/tsc-watch/index.ts @@ -21,11 +21,9 @@ function processOutputEmitterCodeGen(): Promise { return new Promise((resolve, reject) => { const outDir = 'dist/all/@angular/compiler/test/'; const promises: Promise[] = []; - console.log('Processing codegen...'); OFFLINE_COMPILE.forEach((file: string) => { const codegen = require('../../all/@angular/compiler/test/' + file + '.js'); if (codegen.emit) { - console.log(` ${file} has changed, regenerating...`); promises.push(Promise.resolve(codegen.emit()).then((code) => { writeFileSync(outDir + file + '.ts', code); })); @@ -36,7 +34,6 @@ function processOutputEmitterCodeGen(): Promise { .then(() => { const args = ['--project', 'tools/cjs-jasmine/tsconfig-output_emitter_codegen.json']; - console.log(' compiling changes: tsc ' + args.join(' ')); const tsc = spawn(TSC, args, {stdio: 'pipe'}); tsc.stdout.on('data', (data: any) => process.stdout.write(data)); tsc.stderr.on('data', (data: any) => process.stderr.write(data)); diff --git a/tools/tsc-watch/tsc_watch.ts b/tools/tsc-watch/tsc_watch.ts index 4d4974aec8891..02e2fe29008e1 100644 --- a/tools/tsc-watch/tsc_watch.ts +++ b/tools/tsc-watch/tsc_watch.ts @@ -37,7 +37,6 @@ export class TscWatch { start: string, complete: string, onStartCmds?: Array, onChangeCmds?: Array }) { - console.log('Watching:', tsconfig, 'in', process.cwd()); this.tsconfig = tsconfig; this.start = start; this.error = error; @@ -67,14 +66,12 @@ export class TscWatch { const args = argsOrCmd as Array; return new Promise((resolve, reject) => { const [cmd, ...options] = args; - console.log('=====>', cmd, options.join(' ')); const childProcess = spawn(cmd, options, {stdio: 'pipe'}); childProcess.stdout.on('data', stdOut); childProcess.stderr.on('data', stdErr); const onExit = () => childProcess.kill(); childProcess.on('close', (code: number) => { process.removeListener('exit', onExit); - console.log('EXIT:', code, '<=====', args.join(' ')); code ? reject(code) : resolve(code); }); process.on('exit', onExit); @@ -98,7 +95,6 @@ export class TscWatch { consumeLine(buffer: Buffer, isStdError: boolean) { const line = '' + buffer; if (contains(line, this.start)) { - console.log('=============================================================================='); stdOut(buffer, isStdError); this.state = State.waiting; } else if (contains(line, this.error)) { @@ -106,15 +102,15 @@ export class TscWatch { this.state = State.error; } else if (contains(line, this.complete)) { stdOut(buffer, isStdError); - console.log('------------------------------------------------------------------------------'); if (this.state == State.error) { - console.log('Errors found.... (response not triggered)'); + console.error('Errors found.... (response not triggered)'); if (this.runOnce) process.exit(1); this.state = State.idle; } else { if (this.triggered) { this.triggered.then( - () => this.triggerCmds(), (e) => console.log('Error while running commands....', e)); + () => this.triggerCmds(), + (e) => console.error('Error while running commands....', e)); } else { this.triggerCmds(); } diff --git a/tslint.json b/tslint.json index d1bff34f45009..5792864049218 100644 --- a/tslint.json +++ b/tslint.json @@ -5,6 +5,7 @@ ], "rules": { "file-header": [true, "Copyright Google Inc\\."], + "no-console": [true, "log"], "no-duplicate-imports": true, "no-duplicate-variable": true, "no-jasmine-focus": true,