From 48b106e610cf5dc31c9887d3d6dd3380970de46f Mon Sep 17 00:00:00 2001 From: Marius Rackwitz Date: Mon, 25 Jul 2016 16:26:28 +0200 Subject: [PATCH] Check if there is a global console to silent eslint --- lib/index.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/index.js b/lib/index.js index d2687de8..441e03f5 100644 --- a/lib/index.js +++ b/lib/index.js @@ -54,13 +54,18 @@ var types = Object.freeze({ }); Object.defineProperty(realmConstructor, 'Types', { get: function() { - var stack = new Error().stack.split("\n").slice(2).join("\n"); - var msg = '`Realm.Types` is deprecated! Please specify the type name as lowercase string instead!\n'+stack; - if (console.warn != undefined) { - console.warn(msg); - } - else { - console.log(msg); + if (typeof console != 'undefined') { + /* global console */ + /* eslint-disable no-console */ + var stack = new Error().stack.split("\n").slice(2).join("\n"); + var msg = '`Realm.Types` is deprecated! Please specify the type name as lowercase string instead!\n'+stack; + if (console.warn != undefined) { + console.warn(msg); + } + else { + console.log(msg); + } + /* eslint-enable no-console */ } return types; }