Browse Source

fix: remove console statements

Gerald 9 years ago
parent
commit
8967486703

+ 4 - 1
.eslintrc.yml

@@ -6,7 +6,10 @@ rules:
   comma-dangle:
     - 0
   no-console:
-    - 0
+    - 2
+    - allow:
+      - warn
+      - error
   no-empty:
     - 0
 

+ 1 - 1
src/background/db.js

@@ -14,7 +14,7 @@ VMDB.prototype.openDB = function () {
     };
     request.onerror = function (e) {
       var err = e.target.error;
-      console.log('IndexedDB error: ' + err.message);
+      console.error('IndexedDB error: ' + err.message);
       reject(err);
     };
     request.onupgradeneeded = function (e) {

+ 0 - 1
src/background/main.js

@@ -229,7 +229,6 @@ _.messenger = function () {
       try {
         port && port.postMessage(data);
       } catch (e) {
-        console.log(e);
         port = null;
       }
     },

+ 1 - 1
src/background/requests.js

@@ -94,7 +94,7 @@ var requests = function () {
       req.finalUrl = details.url;
       xhr.send(details.data);
     } catch (e) {
-      console.log(e);
+      console.warn(e);
     }
   }
 

+ 1 - 0
src/background/sync/index.js

@@ -1,3 +1,4 @@
+/* eslint no-console: 0 */
 var sync = function () {
   var services = [];
   var servicesReady = [];

+ 6 - 4
src/injected.js

@@ -223,7 +223,7 @@ var comm = {
     }catch(e){
       var msg = 'Error running script: ' + name + '\n' + e;
       if(e.message) msg += '\n' + e.message;
-      console.log(msg);
+      console.error(msg);
     }
   },
   initRequest: function() {
@@ -410,7 +410,7 @@ var comm = {
                 try {
                   val = JSON.parse(v);
                 } catch(e) {
-                  console.log(e);
+                  console.warn(e);
                 }
                 break;
               default:
@@ -480,7 +480,9 @@ var comm = {
         },
       },
       GM_log: {
+        /* eslint-disable no-console */
         value: function (data) {console.log(data);},
+        /* eslint-enable no-console */
       },
       GM_openInTab: {
         value: function (url) {
@@ -536,7 +538,7 @@ var comm = {
         try {
           var func = new Function('g', code);
         } catch(e) {
-          console.log('Syntax error in script: ' + name + '\n' + e.message);
+          console.error('Syntax error in script: ' + name + '\n' + e.message);
           return;
         }
         comm.runCode(name, func, wrapper);
@@ -607,7 +609,7 @@ function newTab(url) {
 function handleC(e) {
   var req = e.detail;
   if (!req) {
-    console.log('[Violentmonkey] Invalid data! There might be unsupported data format.');
+    console.error('[Violentmonkey] Invalid data! There might be unsupported data format.');
     return;
   }
   var maps = {

+ 1 - 1
src/options/views/tab-settings.js

@@ -83,7 +83,7 @@ var SettingsTab = BaseView.extend({
       try {
         vm = JSON.parse(text);
       } catch (e) {
-        console.log('Error parsing ViolentMonkey configuration.');
+        console.warn('Error parsing ViolentMonkey configuration.');
       }
       vm = vm || {};
       _.forEach(vm.values, function (value, key) {