From 7d5ca27b9db253174811b4a601f0a01115beec08 Mon Sep 17 00:00:00 2001 From: Steve Gravrock Date: Thu, 17 Sep 2020 13:33:25 -0700 Subject: [PATCH] Check for forgotten console and debugger statements --- spec/.eslintrc.js | 8 +++++++- spec/core/integration/EnvSpec.js | 3 +++ spec/core/matchers/matchersUtilSpec.js | 1 + spec/html/HtmlReporterSpec.js | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/.eslintrc.js b/spec/.eslintrc.js index bfbec213..636eed53 100644 --- a/spec/.eslintrc.js +++ b/spec/.eslintrc.js @@ -13,5 +13,11 @@ module.exports = { "no-unused-vars": "off", "no-trailing-spaces": "off", "block-spacing": "off", + + // Since linting is done at the end of the process and doesn't stop us + // from running tests, it makes sense to fail if debugger statements + // or console references are present. + "no-debugger": "error", + "no-console": "error", } -} +}; diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index a11897b3..2c09affd 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -2316,6 +2316,7 @@ describe("Env integration", function() { expect(result.deprecationWarnings).toEqual([ jasmine.objectContaining({ message: 'top level deprecation' }) ]); + /* eslint-disable-next-line no-console */ expect(console.error).toHaveBeenCalledWith('DEPRECATION: top level deprecation'); expect(reporter.suiteDone).toHaveBeenCalledWith(jasmine.objectContaining({ @@ -2324,6 +2325,7 @@ describe("Env integration", function() { jasmine.objectContaining({ message: 'suite level deprecation' }) ] })); + /* eslint-disable-next-line no-console */ expect(console.error).toHaveBeenCalledWith('DEPRECATION: suite level deprecation (in suite: suite)'); expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({ @@ -2332,6 +2334,7 @@ describe("Env integration", function() { jasmine.objectContaining({ message: 'spec level deprecation' }) ] })); + /* eslint-disable-next-line no-console */ expect(console.error).toHaveBeenCalledWith('DEPRECATION: spec level deprecation (in spec: suite spec)'); done(); diff --git a/spec/core/matchers/matchersUtilSpec.js b/spec/core/matchers/matchersUtilSpec.js index e3ee9e8c..387aa3e2 100644 --- a/spec/core/matchers/matchersUtilSpec.js +++ b/spec/core/matchers/matchersUtilSpec.js @@ -32,6 +32,7 @@ describe("matchersUtil", function() { // Be thorough but very slow when specified (usually on CI). if (process.env.JASMINE_LONG_PROPERTY_TESTS) { + /* eslint-disable-next-line no-console */ console.log( 'Using', many, diff --git a/spec/html/HtmlReporterSpec.js b/spec/html/HtmlReporterSpec.js index c41b68bb..2db0e160 100644 --- a/spec/html/HtmlReporterSpec.js +++ b/spec/html/HtmlReporterSpec.js @@ -104,6 +104,7 @@ describe('HtmlReporter', function() { passedExpectations: [], failedExpectations: [] }); + /* eslint-disable-next-line no-console */ expect(console.warn).toHaveBeenCalledWith( "Spec 'Some Name' has no expectations." ); @@ -118,6 +119,7 @@ describe('HtmlReporter', function() { passedExpectations: [], failedExpectations: [] }); + /* eslint-disable-next-line no-console */ expect(console.error).toHaveBeenCalledWith( "Spec 'Some Name' has no expectations." );