From eb625b222d1fe88737c0a9ab990d91654829703b Mon Sep 17 00:00:00 2001 From: Prateek Saxena Date: Tue, 25 Mar 2014 11:44:24 +0530 Subject: [PATCH] Add .jshintrc file and update core.js to remove errors Bug: 62997 Change-Id: I89d46c913994bd620ae904fbd626621be4aca170 --- .jshintrc | 26 ++++++++++++++++++++++++++ resources/ext.popups.core.js | 9 +++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000000000..b6d8dda08 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,26 @@ +{ + /* Common */ + + // Enforcing + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "latedef": true, + "newcap": true, + "noarg": true, + "noempty": true, + "nonew": true, + "quotmark": "single", + "trailing": true, + "undef": true, + "unused": true, + // Legacy + "onevar": true, + + /* Local */ + "predef": [ + "mediaWiki", + "jQuery" + ] +} \ No newline at end of file diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index c35ae1182..04f54d4bb 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -2,7 +2,9 @@ * https://en.wikipedia.org/wiki/User:Yair_rand/NavPopupsRestyled.js */ -/*global mw:false */ +/* global mw: false */ +/* global moment: false */ +/* jslint browser: true */ (function ( $ ) { $( document ).ready( function() { @@ -335,6 +337,10 @@ * @param {string} href */ function logEvent ( href ) { + if ( typeof mw.eventLog !== 'function' ) { + return false; + } + var dfd = $.Deferred(), event = { 'duration': Math.round( elDuration ), @@ -355,7 +361,6 @@ setTimeout( dfd.reject, 1000 ); elTime = elDuration = elAction = undefined; } - var logEvent = mw.eventLog ? mw.eventLog.logEvent : function () {}; /** * @method getSessionId