jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/339082 )
Change subject: build: Replace jscs/jshint with eslint and make pass; pin versions ...................................................................... build: Replace jscs/jshint with eslint and make pass; pin versions Fixed issues – > error 'caPILink' is assigned a value but never used > error '$summary' is not defined > error '$parsedHTML' is not defined Bug: T118941 Change-Id: Iff79501de8d80a860eebb4a6e31dc8fca3285505 --- A .eslintrc.json D .jshintignore D .jshintrc M Gruntfile.js M modules/collectors/ext.PerformanceInspector.imagesize.js M modules/collectors/ext.PerformanceInspector.modulescss.js M modules/collectors/ext.PerformanceInspector.newpp.js M modules/ext.PerformanceInspector.startup.js M modules/ext.PerformanceInspector.view.js M package.json 10 files changed, 46 insertions(+), 62 deletions(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..66e5300 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": "wikimedia", + "env": { + "browser": true, + "jquery": true, + "qunit": true + }, + "globals": { + "OO": false, + "mediaWiki": false, + "require": false + }, + "rules": { + "dot-notation": [ "error", { "allowKeywords": true } ], + "valid-jsdoc": 0, + "indent": 0 + } +} 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 f414e48..0000000 --- a/.jshintrc +++ /dev/null @@ -1,27 +0,0 @@ -{ - // Enforcing - "bitwise": true, - "eqeqeq": true, - "freeze": true, - "latedef": true, - "noarg": true, - "nonew": true, - "undef": true, - "unused": true, - "strict": false, - - // Relaxing - "es5": false, - - // Environment - "browser": true, - "jquery": true, - - "globals": { - "mediaWiki": false, - "OO": false, - "require": false, - "module": false, - "moment": false - } -} diff --git a/Gruntfile.js b/Gruntfile.js index 18101d6..be270bd 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,22 +1,17 @@ -/*jshint node:true */ +/* eslint-env node */ module.exports = function ( grunt ) { - grunt.loadNpmTasks( 'grunt-contrib-jshint' ); - grunt.loadNpmTasks( 'grunt-jsonlint' ); - grunt.loadNpmTasks( 'grunt-banana-checker' ); - grunt.loadNpmTasks( 'grunt-jscs' ); var conf = grunt.file.readJSON( 'extension.json' ); + grunt.loadNpmTasks( 'grunt-banana-checker' ); + grunt.loadNpmTasks( 'grunt-eslint' ); + grunt.loadNpmTasks( 'grunt-jsonlint' ); + grunt.initConfig( { - jshint: { - options: { - jshintrc: true - }, + eslint: { all: [ - 'modules/' + 'modules/**/*.js', + 'tests/**/*.js' ] - }, - jscs: { - src: '<%= jshint.all %>' }, banana: conf.MessagesDirs, jsonlint: { @@ -27,6 +22,6 @@ } } ); - grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] ); + grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/modules/collectors/ext.PerformanceInspector.imagesize.js b/modules/collectors/ext.PerformanceInspector.imagesize.js index ced9ada..dc987b5 100644 --- a/modules/collectors/ext.PerformanceInspector.imagesize.js +++ b/modules/collectors/ext.PerformanceInspector.imagesize.js @@ -68,7 +68,7 @@ } ); } for ( i = 0; i < img.length; i++ ) { - if ( img[ i ].currentSrc && img[ i ].currentSrc.indexOf( 'data:image' ) === -1 ) { + if ( img[ i ].currentSrc && img[ i ].currentSrc.indexOf( 'data:image' ) === -1 ) { promises.push( fetchContent( img[ i ].currentSrc ) ); } } @@ -96,12 +96,12 @@ url: values[ i ].url, sizeRaw: sizeRaw, size: humanSize( sizeRaw ), - warning: values[ i ].contentLength > warningLimitInBytes ? true : false + warning: values[ i ].contentLength > warningLimitInBytes } ); totalSize += sizeRaw; } - images.sort( function ( a, b ) { return b.sizeRaw - a.sizeRaw;} ); + images.sort( function ( a, b ) { return b.sizeRaw - a.sizeRaw; } ); deferred.resolve( { summary: { imagesSummary: mw.msg( 'performanceinspector-modules-summary-images', images.length, humanSize( totalSize ), warnings ) diff --git a/modules/collectors/ext.PerformanceInspector.modulescss.js b/modules/collectors/ext.PerformanceInspector.modulescss.js index b3fcc4c..253578b 100644 --- a/modules/collectors/ext.PerformanceInspector.modulescss.js +++ b/modules/collectors/ext.PerformanceInspector.modulescss.js @@ -6,7 +6,7 @@ return { name: name, selectors: mw.msg( 'performanceinspector-modules-css-used-selectors-values', stats.total !== 0 ? - ( stats.matched / stats.total * 100 ).toFixed( 2 ) + '%' : null, stats.matched, stats.total ), + ( stats.matched / stats.total * 100 ).toFixed( 2 ) + '%' : null, stats.matched, stats.total ), unmatchedSelectors: stats.unmatched, index: index }; diff --git a/modules/collectors/ext.PerformanceInspector.newpp.js b/modules/collectors/ext.PerformanceInspector.newpp.js index 5ae06ea..87129af 100644 --- a/modules/collectors/ext.PerformanceInspector.newpp.js +++ b/modules/collectors/ext.PerformanceInspector.newpp.js @@ -1,3 +1,4 @@ +/* global moment */ ( function ( mw ) { var newppCollector = function runNewPPCollector() { @@ -15,7 +16,7 @@ Object.keys( parserReport.limitreport ).forEach( function ( key ) { if ( key !== 'timingprofile' ) { item = parserReport.limitreport[ key ]; - limitReport.push( { name: mw.msg( 'performanceinspector-newpp-' + key ), value: item.limit ? mw.msg( 'performanceinspector-newpp-value-and-limit', item.value, item.limit ) : item } ); + limitReport.push( { name: mw.msg( 'performanceinspector-newpp-' + key ), value: item.limit ? mw.msg( 'performanceinspector-newpp-value-and-limit', item.value, item.limit ) : item } ); } } ); } @@ -51,8 +52,8 @@ // in some cases we don't have the wgPageParseReport, see https://phabricator.wikimedia.org/T145717 report = mw.config.get( 'wgPageParseReport' ); - parserReportSummary = report.limitreport ? mw.msg( 'performanceinspector-newpp-summary', mw.config.get( 'wgPageParseReport' ).limitreport.expensivefunctioncount.value ) : mw.msg( 'performanceinspector-newpp-missing-report' ); - mustacheView = report.limitreport ? generateMustacheView( mw.config.get( 'wgPageParseReport' ) ) : ''; + parserReportSummary = report.limitreport ? mw.msg( 'performanceinspector-newpp-summary', mw.config.get( 'wgPageParseReport' ).limitreport.expensivefunctioncount.value ) : mw.msg( 'performanceinspector-newpp-missing-report' ); + mustacheView = report.limitreport ? generateMustacheView( mw.config.get( 'wgPageParseReport' ) ) : ''; return { summary: { diff --git a/modules/ext.PerformanceInspector.startup.js b/modules/ext.PerformanceInspector.startup.js index 99f4293..d377680 100644 --- a/modules/ext.PerformanceInspector.startup.js +++ b/modules/ext.PerformanceInspector.startup.js @@ -3,8 +3,7 @@ inspectData; $document.ready( function () { - var caPI, - caPILink; + var caPI; function activatePI() { // Lets inspect the current page first, to make sure the result isn't @@ -62,7 +61,6 @@ } caPI = $( '#t-performanceinspector' ); - caPILink = caPI.find( 'a' ); caPI.on( 'click', onPIClick ); } ); diff --git a/modules/ext.PerformanceInspector.view.js b/modules/ext.PerformanceInspector.view.js index e2fdac2..e8f603b 100644 --- a/modules/ext.PerformanceInspector.view.js +++ b/modules/ext.PerformanceInspector.view.js @@ -1,4 +1,3 @@ -/*jshint undef:false */ ( function ( mw, $ ) { var PerformanceDialog = function PiDialog( config, summary, views ) { @@ -38,7 +37,8 @@ }; PerformanceDialog.prototype.initialize = function () { - var self = this, + var $summary, + self = this, summaryTemplate = mw.template.get( 'ext.PerformanceInspector.analyze', 'summary.mustache' ), /** * Help method for getting text messages @@ -70,6 +70,7 @@ // parse the templates and data we get from each info and convert the // to pages self.views.forEach( function ( result ) { + var $parsedHTML; result.data.msg = messageFunction; $parsedHTML = result.template.render( result.data ); @@ -116,7 +117,7 @@ module.exports.humanSize = function ( bytes ) { var i = 0, - units = [ 'size-bytes', 'size-kilobytes','size-megabytes', 'size-gigabytes' ]; + units = [ 'size-bytes', 'size-kilobytes', 'size-megabytes', 'size-gigabytes' ]; if ( !$.isNumeric( bytes ) || bytes === 0 ) { return bytes; @@ -126,7 +127,7 @@ } // Maintain one decimal for kB and above, but don't // add ".0" for bytes. - return mw.msg( units[ i ], bytes.toFixed( i > 0 ? 1 : 0 ) ) ; + return mw.msg( units[ i ], bytes.toFixed( i > 0 ? 1 : 0 ) ); }; }( mediaWiki, jQuery ) ); diff --git a/package.json b/package.json index 57d4e8c..d6a0fe0 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,10 @@ "test": "grunt test" }, "devDependencies": { - "grunt": "0.4.5", - "grunt-banana-checker": "^0.4.0", - "grunt-cli": "0.1.13", - "grunt-contrib-jshint": "^1.0.0", - "grunt-jscs": "^2.7.0", - "grunt-jsonlint": "^1.0.7" + "eslint-config-wikimedia": "0.3.0", + "grunt": "1.0.1", + "grunt-banana-checker": "0.5.0", + "grunt-eslint": "19.0.0", + "grunt-jsonlint": "1.0.8" } } -- To view, visit https://gerrit.wikimedia.org/r/339082 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iff79501de8d80a860eebb4a6e31dc8fca3285505 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/PerformanceInspector Gerrit-Branch: master Gerrit-Owner: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Gilles <gdu...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: Krinkle <krinklem...@gmail.com> Gerrit-Reviewer: Phedenskog <phedens...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits