Krinkle has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/387972 )

Change subject: build: Replace jshint/jscs with eslint
......................................................................

build: Replace jshint/jscs with eslint

Change-Id: Ic85a99fa261ac27549bcaa4a94a2112b9ed80e14
---
A .eslintrc.json
D .jscsrc
D .jshintignore
D .jshintrc
M Gruntfile.js
M modules/ext.wikimediaEvents.humanSearchRelevance.js
M modules/ext.wikimediaEvents.readingDepth.js
M modules/ext.wikimediaEvents.searchSatisfaction.js
M package.json
9 files changed, 65 insertions(+), 87 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents 
refs/changes/72/387972/1

diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..489d7b7
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,14 @@
+{
+       "extends": "wikimedia",
+       "env": {
+               "browser": true,
+               "jquery": true
+       },
+       "globals": {
+               "mediaWiki": false
+       },
+       "rules": {
+               "valid-jsdoc": 0,
+               "operator-linebreak" : 0
+       }
+}
diff --git a/.jscsrc b/.jscsrc
deleted file mode 100644
index 5e54610..0000000
--- a/.jscsrc
+++ /dev/null
@@ -1,5 +0,0 @@
-{
-       "preset": "wikimedia",
-       "es3": true,
-       "requireVarDeclFirst": null
-}
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index 3c3629e..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1 +0,0 @@
-node_modules
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index ff367dc..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,26 +0,0 @@
-{
-       // Enforcing
-       "bitwise": true,
-       "eqeqeq": true,
-       "freeze": true,
-       "latedef": true,
-       "noarg": true,
-       "nonew": true,
-       "undef": true,
-       "unused": true,
-
-       // Relaxing
-       "laxbreak": true,
-
-       // Environment
-       "browser": true,
-       "es3": true,
-
-       "predef": [
-               "mediaWiki",
-               "jQuery"
-       ],
-       "globals": {
-               "JSON": true
-       }
-}
diff --git a/Gruntfile.js b/Gruntfile.js
index 200c69f..c1b8031 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,19 +1,12 @@
-/*jshint node:true */
+/* eslint-env node */
 module.exports = function ( grunt ) {
        grunt.loadNpmTasks( 'grunt-banana-checker' );
-       grunt.loadNpmTasks( 'grunt-contrib-jshint' );
-       grunt.loadNpmTasks( 'grunt-jscs' );
+       grunt.loadNpmTasks( 'grunt-eslint' );
        grunt.loadNpmTasks( 'grunt-jsonlint' );
        grunt.loadNpmTasks( 'grunt-stylelint' );
 
        grunt.initConfig( {
-               jshint: {
-                       options: {
-                               jshintrc: true
-                       },
-                       all: '.'
-               },
-               jscs: {
+               eslint: {
                        all: [
                                '*.js',
                                'modules/**/*.js'
@@ -38,6 +31,6 @@
                }
        } );
 
-       grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana', 
'stylelint' ] );
+       grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana', 
'stylelint' ] );
        grunt.registerTask( 'default', 'test' );
 };
diff --git a/modules/ext.wikimediaEvents.humanSearchRelevance.js 
b/modules/ext.wikimediaEvents.humanSearchRelevance.js
index e2419ec..5803354 100644
--- a/modules/ext.wikimediaEvents.humanSearchRelevance.js
+++ b/modules/ext.wikimediaEvents.humanSearchRelevance.js
@@ -1,6 +1,8 @@
 ( function ( mw, $ ) {
        'use strict';
 
+       var config;
+
        function sample( acceptPercentage ) {
                var rand = mw.user.generateRandomSessionId(),
                        // take the first 52 bits of the rand value to match js
@@ -37,7 +39,7 @@
        // The config value is coded into the page output and cached in varnish.
        // That means any changes to sampling rates or pages chosen will take 
up to
        // a week to propogate into the wild.
-       var config = mw.config.get( 'wgWMESearchRelevancePages' );
+       config = mw.config.get( 'wgWMESearchRelevancePages' );
 
        // bad configuration
        if ( !config.hasOwnProperty( 'sampleRate' ) || !config.hasOwnProperty( 
'queries' ) ) {
diff --git a/modules/ext.wikimediaEvents.readingDepth.js 
b/modules/ext.wikimediaEvents.readingDepth.js
index ecc16dd..ba2d206 100644
--- a/modules/ext.wikimediaEvents.readingDepth.js
+++ b/modules/ext.wikimediaEvents.readingDepth.js
@@ -8,16 +8,30 @@
  */
 ( function ( $, mw, config, user, mwExperiments ) {
 
+       var pausedAt,
+               msPaused = 0,
+               perf = window.performance,
+               EVENT = {
+                       pageTitle: config.get( 'wgTitle' ),
+                       namespaceId: config.get( 'wgNamespaceNumber' ),
+                       skin: config.get( 'skin' ),
+                       isAnon: user.isAnon(),
+                       pageToken: user.generateRandomSessionId() +
+                               Math.floor( mw.now() ).toString() +
+                               user.generateRandomSessionId(),
+                       sessionToken: user.sessionId()
+               };
+
        /**
-       * If available return the time in ms till first paint
-       *
-       * @param {PerformanceTiming} perf See
-       *  https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming.
-       * @return {number|undefined} Time, in milliseconds since the UNIX 
epoch, when
-       *  the document was first painted by the UA; or `undefined` if the UA 
doesn't
-       *  report first paint time or reports a first paint time that's before 
the UA
-       *  began loading the document
-       */
+        * If available return the time in ms till first paint
+        *
+        * @param {PerformanceTiming} perf See
+        *  https://developer.mozilla.org/en-US/docs/Web/API/PerformanceTiming.
+        * @return {number|undefined} Time, in milliseconds since the UNIX 
epoch, when
+        *  the document was first painted by the UA; or `undefined` if the UA 
doesn't
+        *  report first paint time or reports a first paint time that's before 
the UA
+        *  began loading the document
+        */
        function getFirstPaintTime( perf ) {
                var chromeLoadTimes,
                        timing = perf.timing;
@@ -33,20 +47,6 @@
                        }
                }
        }
-
-       var pausedAt,
-               msPaused = 0,
-               perf = window.performance,
-               EVENT = {
-                       pageTitle: config.get( 'wgTitle' ),
-                       namespaceId: config.get( 'wgNamespaceNumber' ),
-                       skin: config.get( 'skin' ),
-                       isAnon: user.isAnon(),
-                       pageToken: user.generateRandomSessionId() +
-                               Math.floor( mw.now() ).toString() +
-                               user.generateRandomSessionId(),
-                       sessionToken: user.sessionId()
-               };
 
        /**
         * Pause the user's page session length timer based on information that 
they
@@ -88,11 +88,11 @@
        }
 
        /**
-       * Log an event to the Schema:ReadingDepth
-       *
-       * @param {string} action a valid value for the action property inside 
the
-       *         schema Schema:ReadingDepth
-       */
+        * Log an event to the Schema:ReadingDepth
+        *
+        * @param {string} action A valid value for the action property inside 
the
+        *      schema Schema:ReadingDepth
+        */
        function logEvent( action ) {
                var now,
                        timing = perf.timing,
@@ -134,8 +134,8 @@
        }
 
        /**
-        * @param {number} samplingRate - a float between 0 and 1 for which 
events
-        * in the schema should be logged.
+        * @param {number} samplingRate A float between 0 and 1 for which events
+        *  in the schema should be logged.
         * @return {boolean}
         */
        function isInSample( samplingRate ) {
diff --git a/modules/ext.wikimediaEvents.searchSatisfaction.js 
b/modules/ext.wikimediaEvents.searchSatisfaction.js
index 40b1cc1..a48355d 100644
--- a/modules/ext.wikimediaEvents.searchSatisfaction.js
+++ b/modules/ext.wikimediaEvents.searchSatisfaction.js
@@ -18,6 +18,7 @@
  * @license GNU GPL v2 or later
  * @author Erik Bernhardson <ebernhard...@wikimedia.org>
  */
+/* eslint-disable vars-on-top */
 ( function ( mw, $ ) {
        'use strict';
        // reject mobile users
@@ -86,8 +87,8 @@
                // currently loaded state
                var state = {},
                        storageNamespace = 'wmE-sS-',
-               // persistent state keys that have a lifetime. unlisted
-               // keys are not persisted between page loads.
+                       // persistent state keys that have a lifetime. unlisted
+                       // keys are not persisted between page loads.
                        ttl = {
                                sessionId: 10 * 60 * 1000,
                                subTest: 10 * 60 * 1000,
@@ -215,8 +216,8 @@
                                 */
                                oneIn = function ( populationSize ) {
                                        var rand = 
mw.user.generateRandomSessionId(),
-                                       // take the first 52 bits of the rand 
value to match js
-                                       // integer precision
+                                               // take the first 52 bits of 
the rand value to match js
+                                               // integer precision
                                                parsed = parseInt( rand.slice( 
0, 13 ), 16 );
                                        if ( populationSize < 1 ) {
                                                // Population size < 1 switches 
to percentage based
@@ -239,11 +240,11 @@
                                 */
                                chooseBucket = function ( buckets ) { // jshint 
ignore:line
                                        var rand = 
mw.user.generateRandomSessionId(),
-                                       // take the first 52 bits of the rand 
value to match js
-                                       // integer precision
+                                               // take the first 52 bits of 
the rand value to match js
+                                               // integer precision
                                                parsed = parseInt( rand.slice( 
0, 13 ), 16 ),
-                                       // step size between buckets. No -1 on 
pow or the maximum
-                                       // value would be past the end.
+                                               // step size between buckets. 
No -1 on pow or the maximum
+                                               // value would be past the end.
                                                step = Math.pow( 2, 52 ) / 
buckets.length;
                                        return buckets[ Math.floor( parsed / 
step ) ];
                                };
@@ -672,10 +673,10 @@
                                '.mw-search-result-heading a, 
#mw-search-DYM-suggestion, #mw-search-DYM-original, #mw-search-DYM-rewritten',
                                function ( evt ) {
                                        var wprov,
-                                       // Sometimes the click event is on a 
span inside the anchor
+                                               // Sometimes the click event is 
on a span inside the anchor
                                                $target = $( evt.target 
).closest( 'a' ),
-                                       // Distinguish between standard 
'on-wiki' results, and interwiki results that point
-                                       // to another language
+                                               // Distinguish between standard 
'on-wiki' results, and interwiki results that point
+                                               // to another language
                                                clickType = $target.closest( 
'.mw-search-result-heading' ).find( 'a.extiw' ).length > 0
                                                        ? 'iwclick'
                                                        : 'click',
diff --git a/package.json b/package.json
index e54bcdf..48248a5 100644
--- a/package.json
+++ b/package.json
@@ -4,10 +4,10 @@
     "test": "grunt test"
   },
   "devDependencies": {
+    "eslint-config-wikimedia": "0.5.0",
     "grunt": "1.0.1",
     "grunt-banana-checker": "0.4.0",
-    "grunt-contrib-jshint": "0.12.0",
-    "grunt-jscs": "2.6.0",
+    "grunt-eslint": "20.0.0",
     "grunt-jsonlint": "1.0.7",
     "grunt-stylelint": "0.8.0",
     "stylelint": "7.8.0",

-- 
To view, visit https://gerrit.wikimedia.org/r/387972
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic85a99fa261ac27549bcaa4a94a2112b9ed80e14
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikimediaEvents
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to