From 116946fb11794f2986ba9b88baf8920a62e6f982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=A1ko=20Hevery?= Date: Thu, 16 Aug 2018 15:55:45 -0700 Subject: [PATCH] style: tslint enforces no debugger statements left behind (#25532) PR Close #25532 --- .../src/ngcc/test/host/esm2015_host_spec.ts | 1 - .../src/ngcc/test/host/esm5_host_spec.ts | 2 - .../annotations/test/selector_scope_spec.ts | 1 - packages/core/src/di/injectable.ts | 6 +-- packages/core/src/render3/assert.ts | 1 + packages/core/testing/src/testing_internal.ts | 1 + tools/symbol-extractor/symbol_extractor.ts | 3 -- tslint.json | 51 +++++++++++++++---- 8 files changed, 44 insertions(+), 22 deletions(-) diff --git a/packages/compiler-cli/src/ngcc/test/host/esm2015_host_spec.ts b/packages/compiler-cli/src/ngcc/test/host/esm2015_host_spec.ts index b30866ade3..03a35831cd 100644 --- a/packages/compiler-cli/src/ngcc/test/host/esm2015_host_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/host/esm2015_host_spec.ts @@ -530,7 +530,6 @@ describe('Esm2015ReflectionHost', () => { const host = new Esm2015ReflectionHost(program.getTypeChecker()); const classNode = getDeclaration(program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isClassDeclaration); - debugger; const members = host.getMembersOfClass(classNode); const staticMethod = members.find(member => member.name === 'staticMethod') !; diff --git a/packages/compiler-cli/src/ngcc/test/host/esm5_host_spec.ts b/packages/compiler-cli/src/ngcc/test/host/esm5_host_spec.ts index 92b9ab0719..172eefb98f 100644 --- a/packages/compiler-cli/src/ngcc/test/host/esm5_host_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/host/esm5_host_spec.ts @@ -414,7 +414,6 @@ describe('Esm5ReflectionHost', () => { const host = new Esm5ReflectionHost(program.getTypeChecker()); const classNode = getDeclaration( program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isVariableDeclaration); - debugger; const decorators = host.getDecoratorsOfDeclaration(classNode) !; expect(decorators).toBeDefined(); @@ -584,7 +583,6 @@ describe('Esm5ReflectionHost', () => { const host = new Esm5ReflectionHost(program.getTypeChecker()); const classNode = getDeclaration( program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', ts.isVariableDeclaration); - debugger; const members = host.getMembersOfClass(classNode); const staticMethod = members.find(member => member.name === 'staticMethod') !; diff --git a/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts b/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts index 0fab44b047..d45fde154a 100644 --- a/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts +++ b/packages/compiler-cli/src/ngtsc/annotations/test/selector_scope_spec.ts @@ -130,7 +130,6 @@ describe('SelectorScopeRegistry', () => { registry.registerSelector(ProgramCmp, 'program-cmp'); - debugger; const scope = registry.lookupCompilationScope(ProgramCmp) !; expect(scope).toBeDefined(); expect(scope.directives).toBeDefined(); diff --git a/packages/core/src/di/injectable.ts b/packages/core/src/di/injectable.ts index 5d60296260..43f109aff1 100644 --- a/packages/core/src/di/injectable.ts +++ b/packages/core/src/di/injectable.ts @@ -60,10 +60,8 @@ export interface Injectable { providedIn?: Type|'root'|null; } * @Annotation */ export const Injectable: InjectableDecorator = makeDecorator( - 'Injectable', undefined, undefined, undefined, (type: Type, meta: Injectable) => { - debugger; - return R3_COMPILE_INJECTABLE(type, meta); - }); + 'Injectable', undefined, undefined, undefined, + (type: Type, meta: Injectable) => R3_COMPILE_INJECTABLE(type, meta)); /** * Type representing injectable service. diff --git a/packages/core/src/render3/assert.ts b/packages/core/src/render3/assert.ts index d75978c7d4..ed570acfe8 100644 --- a/packages/core/src/render3/assert.ts +++ b/packages/core/src/render3/assert.ts @@ -77,6 +77,7 @@ export function assertNgModuleType( } function throwError(msg: string): never { + // tslint:disable-next-line debugger; // Left intentionally for better debugger experience. throw new Error(`ASSERTION ERROR: ${msg}`); } diff --git a/packages/core/testing/src/testing_internal.ts b/packages/core/testing/src/testing_internal.ts index 2ee60282ed..670dbf8a26 100644 --- a/packages/core/testing/src/testing_internal.ts +++ b/packages/core/testing/src/testing_internal.ts @@ -116,6 +116,7 @@ function _it( jsmFn: Function, testName: string, testFn: (done?: DoneFn) => any, testTimeout = 0): void { if (runnerStack.length == 0) { // This left here intentionally, as we should never get here, and it aids debugging. + // tslint:disable-next-line debugger; throw new Error('Empty Stack!'); } diff --git a/tools/symbol-extractor/symbol_extractor.ts b/tools/symbol-extractor/symbol_extractor.ts index ed34816472..3a5e90f40b 100644 --- a/tools/symbol-extractor/symbol_extractor.ts +++ b/tools/symbol-extractor/symbol_extractor.ts @@ -61,9 +61,6 @@ export class SymbolExtractor { // Left for easier debugging. // console.log('###', ts.SyntaxKind[child.kind], child.getText()); } - if (symbols.length && symbols[symbols.length - 1].name == 'type') { - debugger; - } } visitor(source); symbols.sort(SymbolExtractor.symbolSort); diff --git a/tslint.json b/tslint.json index abf8688092..1f29ebb7c8 100644 --- a/tslint.json +++ b/tslint.json @@ -5,27 +5,56 @@ "node_modules/tslint-eslint-rules/dist/rules" ], "rules": { - "file-header": [true, "Copyright Google Inc\\."], - "no-console": [true, "log"], + "file-header": [ + true, + "Copyright Google Inc\\." + ], + "no-console": [ + true, + "log" + ], "no-duplicate-imports": true, "no-duplicate-variable": true, "no-jasmine-focus": true, "no-var-keyword": true, "require-internal-with-underscore": true, "rollup-config": true, - "semicolon": [true], - "variable-name": [true, "ban-keywords"], - "no-inner-declarations": [true, "function"] + "semicolon": [ + true + ], + "variable-name": [ + true, + "ban-keywords" + ], + "no-inner-declarations": [ + true, + "function" + ], + "no-debugger": true }, "jsRules": { - "file-header": [true, "Copyright Google Inc\\."], - "no-console": [true, "log"], + "file-header": [ + true, + "Copyright Google Inc\\." + ], + "no-console": [ + true, + "log" + ], "no-duplicate-imports": true, "no-duplicate-variable": true, "no-jasmine-focus": true, "require-internal-with-underscore": true, - "semicolon": [true], - "variable-name": [true, "ban-keywords"], - "no-inner-declarations": [true, "function"] + "semicolon": [ + true + ], + "variable-name": [ + true, + "ban-keywords" + ], + "no-inner-declarations": [ + true, + "function" + ] } -} +} \ No newline at end of file