From e7c07379b27594e03b255c1b11e64bb9791bdcce Mon Sep 17 00:00:00 2001 From: Kevin Partington Date: Wed, 13 Apr 2016 22:34:31 -0500 Subject: [PATCH] Chore: Enable no-console rule in eslint-config-eslint (refs #5188) --- Makefile.js | 2 +- lib/logging.js | 2 ++ lib/timing.js | 2 +- packages/eslint-config-eslint/default.yml | 2 +- tests/lib/cli-engine.js | 6 ++++-- tests/lib/config/config-initializer.js | 20 ++++++++++---------- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Makefile.js b/Makefile.js index d4ff08217e3..da8f14b5180 100644 --- a/Makefile.js +++ b/Makefile.js @@ -3,7 +3,7 @@ * @author nzakas */ /* global cat, cd, cp, echo, exec, exit, find, ls, mkdir, pwd, rm, target, test*/ -/* eslint no-use-before-define: 0*/ +/* eslint no-use-before-define: "off", no-console: "off" */ "use strict"; //------------------------------------------------------------------------------ diff --git a/lib/logging.js b/lib/logging.js index f0ded092955..3f083d5e7cb 100644 --- a/lib/logging.js +++ b/lib/logging.js @@ -5,6 +5,8 @@ */ "use strict"; +/* eslint no-console: "off" */ + /* istanbul ignore next */ module.exports = { diff --git a/lib/timing.js b/lib/timing.js index c1346480fd8..53779348301 100644 --- a/lib/timing.js +++ b/lib/timing.js @@ -102,7 +102,7 @@ function display(data) { return ALIGN[index](":", w + 1, "-"); }).join("|")); - console.log(table.join("\n")); + console.log(table.join("\n")); // eslint-disable-line no-console } /* istanbul ignore next */ diff --git a/packages/eslint-config-eslint/default.yml b/packages/eslint-config-eslint/default.yml index 8217f06fd57..aa1da1846d3 100644 --- a/packages/eslint-config-eslint/default.yml +++ b/packages/eslint-config-eslint/default.yml @@ -32,7 +32,7 @@ rules: no-alert: "error" no-array-constructor: "error" no-caller: "error" - no-console: 0 + no-console: "error" no-delete-var: "error" no-eval: "error" no-extend-native: "error" diff --git a/tests/lib/cli-engine.js b/tests/lib/cli-engine.js index 967d93e53da..bc6fa4043fa 100644 --- a/tests/lib/cli-engine.js +++ b/tests/lib/cli-engine.js @@ -1851,13 +1851,15 @@ describe("CLIEngine", function() { }); describe("isPathIgnored", function() { + var sandbox; beforeEach(function() { - sinon.stub(console, "info").returns(void 0); + sandbox = sinon.sandbox.create(); + sandbox.stub(console, "info").returns(void 0); }); afterEach(function() { - console.info.restore(); + sandbox.restore(); }); it("should check if the given path is ignored", function() { diff --git a/tests/lib/config/config-initializer.js b/tests/lib/config/config-initializer.js index 5ce0002303c..2f767e6f646 100644 --- a/tests/lib/config/config-initializer.js +++ b/tests/lib/config/config-initializer.js @@ -213,8 +213,8 @@ describe("configInitializer", function() { describe("auto", function() { var config, - origLog, - completeSpy = sinon.spy(); + completeSpy = sinon.spy(), + sandbox; before(function() { var patterns = [ @@ -232,25 +232,25 @@ describe("configInitializer", function() { format: "JSON", commonjs: false }; - origLog = console.log; - console.log = function() {}; // necessary to replace, because of progress bar + + sandbox = sinon.sandbox.create(); + sandbox.stub(console, "log"); // necessary to replace, because of progress bar + process.chdir(fixtureDir); + try { config = init.processAnswers(answers); process.chdir(originalDir); } catch (err) { - // if processAnswers crashes, we need to be sure to restore cwd and console.log - console.log = origLog; + // if processAnswers crashes, we need to be sure to restore cwd process.chdir(originalDir); throw err; + } finally { + sandbox.restore(); // restore console.log() } }); - beforeEach(function() { - console.log = origLog; - }); - it("should create a config", function() { assert.isTrue(completeSpy.notCalled); assert.ok(config);