jenkins-bot has submitted this change and it was merged. Change subject: build: Replace jscs/jshint with eslint ......................................................................
build: Replace jscs/jshint with eslint Change-Id: Iff79501de8d80a860eebb4a6e31dc8fca3285505 --- A .eslintrc.json D .jscsrc D .jshintignore D .jshintrc M Gruntfile.js M modules/ext.templateDataGenerator.data.js M modules/ext.templateDataGenerator.sourceHandler.js M modules/ext.templateDataGenerator.ui.js M modules/ext.templateDataGenerator.ui.tdDialog.js M package.json M tests/ext.templateData.tests.js 11 files changed, 220 insertions(+), 260 deletions(-) Approvals: Jforrester: Looks good to me, approved jenkins-bot: Verified diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..98612da --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,17 @@ +{ + "extends": "wikimedia", + "env": { + "browser": true, + "jquery": true, + "qunit": true + }, + "globals": { + "OO": false, + "mw": false + }, + "rules": { + "dot-notation": [ "error", { "allowKeywords": true } ], + "valid-jsdoc": 0, + "no-alert": "error" + } +} diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 6a76f5d..0000000 --- a/.jscsrc +++ /dev/null @@ -1,21 +0,0 @@ -{ - "preset": "wikimedia", - "es3": true, - "jsDoc": { - "checkAnnotations": { - "preset": "jsduck5", - "extra": { - "this": "some", - "source": "some", - "see": "some" - } - }, - "checkTypes": "strictNativeCase", - "checkParamNames": true, - "checkRedundantAccess": true, - "checkRedundantReturns": true, - "requireNewlineAfterDescription": true, - "requireParamTypes": true, - "requireReturnTypes": true - } -} 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 b0f59f9..0000000 --- a/.jshintrc +++ /dev/null @@ -1,27 +0,0 @@ -{ - // Enforcing - "bitwise": true, - "eqeqeq": true, - "freeze": true, - "latedef": "nofunc", - "futurehostile": true, - "noarg": true, - "nonew": true, - "undef": true, - "unused": true, - - "strict": false, - - // Relaxing - "es5": false, - - // Environment - "browser": true, - "jquery": true, - - "globals": { - "mw": false, - "OO": false, - "QUnit": false - } -} diff --git a/Gruntfile.js b/Gruntfile.js index 09e1cd4..a20617b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -4,29 +4,22 @@ * @package TemplateData */ -/*jshint node:true */ +/* eslint-env node */ module.exports = function ( grunt ) { var conf = grunt.file.readJSON( 'extension.json' ); grunt.loadNpmTasks( 'grunt-banana-checker' ); - grunt.loadNpmTasks( 'grunt-contrib-jshint' ); grunt.loadNpmTasks( 'grunt-contrib-watch' ); - grunt.loadNpmTasks( 'grunt-jscs' ); + grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-stylelint' ); grunt.initConfig( { - jshint: { - options: { - jshintrc: true - }, + eslint: { all: [ 'modules/**/*.js', 'tests/**/*.js' ] - }, - jscs: { - src: '<%= jshint.all %>' }, stylelint: { all: [ @@ -43,14 +36,14 @@ banana: conf.MessagesDirs, watch: { files: [ - '.{stylelintrc,jscsrc,jshintignore,jshintrc}', - '<%= jshint.all %>', + '.{stylelintrc,eslintrc.json}', + '<%= eslint.all %>', '<%= stylelint.all %>' ], tasks: 'test' } } ); - grunt.registerTask( 'test', [ 'jshint', 'jscs', 'stylelint', 'jsonlint', 'banana' ] ); + grunt.registerTask( 'test', [ 'eslint', 'stylelint', 'jsonlint', 'banana' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/modules/ext.templateDataGenerator.data.js b/modules/ext.templateDataGenerator.data.js index 3538c7f..746b987 100644 --- a/modules/ext.templateDataGenerator.data.js +++ b/modules/ext.templateDataGenerator.data.js @@ -5,11 +5,8 @@ * @mixins OO.EventEmitter * * @constructor - * @param {Object} config Dialog configuration object */ -mw.TemplateData.Model = function mwTemplateDataModel( config ) { - config = config || {}; - +mw.TemplateData.Model = function mwTemplateDataModel() { // Mixin constructors OO.EventEmitter.call( this ); diff --git a/modules/ext.templateDataGenerator.sourceHandler.js b/modules/ext.templateDataGenerator.sourceHandler.js index 65a2ecb..dd23ff8 100644 --- a/modules/ext.templateDataGenerator.sourceHandler.js +++ b/modules/ext.templateDataGenerator.sourceHandler.js @@ -88,7 +88,7 @@ return this.getParametersFromTemplateSource( wikitext ) // This is always successful by definition .then( function ( templateSourceCodeParams ) { - return new mw.TemplateData.Model.static.newFromObject( + return mw.TemplateData.Model.static.newFromObject( tdObject, templateSourceCodeParams ); @@ -164,8 +164,8 @@ */ mw.TemplateData.SourceHandler.prototype.extractParametersFromTemplateCode = function ( templateCode ) { var matches, - paramNames = [], - paramExtractor = /{{3,}(.*?)[<|}]/mg; + paramNames = [], + paramExtractor = /{{3,}(.*?)[<|}]/mg; while ( ( matches = paramExtractor.exec( templateCode ) ) !== null ) { if ( $.inArray( matches[ 1 ], paramNames ) === -1 ) { @@ -248,7 +248,7 @@ * @param {string} parent Parent page */ mw.TemplateData.SourceHandler.prototype.setParentPage = function ( parent ) { - this.parentPage = parent || '' ; + this.parentPage = parent || ''; }; /** diff --git a/modules/ext.templateDataGenerator.ui.js b/modules/ext.templateDataGenerator.ui.js index c47e49c..40d92ba 100644 --- a/modules/ext.templateDataGenerator.ui.js +++ b/modules/ext.templateDataGenerator.ui.js @@ -23,6 +23,8 @@ // Edit window elements editOpenDialogButton, editNoticeLabel, + editArea, openEditDialog, onEditOpenDialogButton, + replaceTemplateData, onDialogApply; editArea = { /** @@ -116,7 +118,7 @@ var model; if ( data && data.action === 'accept' ) { // Open the dialog with an empty model - model = new mw.TemplateData.Model.static.newFromObject( + model = mw.TemplateData.Model.static.newFromObject( { params: {} }, sourceHandler.getTemplateSourceCodeParams() ); diff --git a/modules/ext.templateDataGenerator.ui.tdDialog.js b/modules/ext.templateDataGenerator.ui.tdDialog.js index 4e23e6c..ecbc1ce 100644 --- a/modules/ext.templateDataGenerator.ui.tdDialog.js +++ b/modules/ext.templateDataGenerator.ui.tdDialog.js @@ -588,7 +588,7 @@ } else { // Empty the input if ( prop.type === 'select' ) { - propInput.selectItem( propInput.getItemFromData( prop[ 'default' ] ) ); + propInput.selectItem( propInput.getItemFromData( prop.default ) ); } else if ( prop.type === 'boolean' ) { propInput.setSelected( false ); } else { diff --git a/package.json b/package.json index 1b81540..d0b85bf 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "doc": "jsduck" }, "devDependencies": { + "eslint-config-wikimedia": "0.3.0", "grunt": "1.0.1", "grunt-banana-checker": "0.5.0", - "grunt-contrib-jshint": "1.0.0", "grunt-contrib-watch": "1.0.0", - "grunt-jscs": "2.8.0", - "grunt-jsonlint": "1.0.7", + "grunt-eslint": "19.0.0", + "grunt-jsonlint": "1.0.8", "grunt-stylelint": "0.6.0", "stylelint-config-wikimedia": "0.3.0" } diff --git a/tests/ext.templateData.tests.js b/tests/ext.templateData.tests.js index 7eea8c9..e4370d0 100644 --- a/tests/ext.templateData.tests.js +++ b/tests/ext.templateData.tests.js @@ -151,198 +151,198 @@ // Test validation tools QUnit.test( 'Validation tools', function ( assert ) { var tests = { - compare: [ - { - obj1: {}, - obj2: [], - result: false, - msg: 'Compare: object vs array' - }, - { - obj1: null, - obj2: undefined, - result: false, - msg: 'Compare: null vs undefined' - }, - { - obj1: 'string', - obj2: undefined, - result: false, - msg: 'Compare: string vs undefined' - }, - { - obj1: undefined, - obj2: undefined, - result: true, - msg: 'Compare: undefined vs undefined' - }, - { - obj1: null, - obj2: null, - result: true, - msg: 'Compare: null vs null' - }, - { - obj1: 'A proper string.', - obj2: 'A proper string.', - result: true, - msg: 'Compare: strings' - }, - { - obj1: true, - obj2: true, - result: true, - msg: 'Compare: booleans' - }, - { - obj1: { 1: 'string', 2: 'another', 4: 'and another' }, - obj2: { 1: 'string', 2: 'another', 4: 'and another' }, - result: true, - allowSubset: true, - msg: 'Compare: plain object full equality' - }, - { - obj1: { 1: 'string', 2: 'another', 4: 'and another' }, - obj2: { 1: 'another', 2: 'and another', 4: 'string' }, - result: false, - allowSubset: true, - msg: 'Compare: plain object full inequality' - }, - { - obj1: { 1: 'string', 2: 'another', 4: 'and another' }, - obj2: { 4: 'and another' }, - result: true, - allowSubset: true, - msg: 'Compare: plain object subset equality' - }, - { - obj1: [ 'val1', 'val2', 'val3' ], - obj2: [ 'val1', 'val2', 'val3' ], - result: true, - msg: 'Compare: arrays' - }, - { - obj1: [ 'val1', 'val2', 'val3' ], - obj2: [ 'val1' ], - result: true, - allowSubset: true, - msg: 'Compare: array subset: true' - }, - { - obj1: [ 'val1', 'val2', 'val3' ], - obj2: [ 'val1' ], - result: false, - allowSubset: false, - msg: 'Compare: array subset: false' - }, - { - obj1: { - param1: { - type: 'unknown', - aliases: [ 'alias2', 'alias1', 'alias3' ], - description: 'Some description', - required: true, - suggested: false - }, - param2: { - required: true - } + compare: [ + { + obj1: {}, + obj2: [], + result: false, + msg: 'Compare: object vs array' + }, + { + obj1: null, + obj2: undefined, + result: false, + msg: 'Compare: null vs undefined' + }, + { + obj1: 'string', + obj2: undefined, + result: false, + msg: 'Compare: string vs undefined' + }, + { + obj1: undefined, + obj2: undefined, + result: true, + msg: 'Compare: undefined vs undefined' + }, + { + obj1: null, + obj2: null, + result: true, + msg: 'Compare: null vs null' + }, + { + obj1: 'A proper string.', + obj2: 'A proper string.', + result: true, + msg: 'Compare: strings' + }, + { + obj1: true, + obj2: true, + result: true, + msg: 'Compare: booleans' + }, + { + obj1: { 1: 'string', 2: 'another', 4: 'and another' }, + obj2: { 1: 'string', 2: 'another', 4: 'and another' }, + result: true, + allowSubset: true, + msg: 'Compare: plain object full equality' + }, + { + obj1: { 1: 'string', 2: 'another', 4: 'and another' }, + obj2: { 1: 'another', 2: 'and another', 4: 'string' }, + result: false, + allowSubset: true, + msg: 'Compare: plain object full inequality' + }, + { + obj1: { 1: 'string', 2: 'another', 4: 'and another' }, + obj2: { 4: 'and another' }, + result: true, + allowSubset: true, + msg: 'Compare: plain object subset equality' + }, + { + obj1: [ 'val1', 'val2', 'val3' ], + obj2: [ 'val1', 'val2', 'val3' ], + result: true, + msg: 'Compare: arrays' + }, + { + obj1: [ 'val1', 'val2', 'val3' ], + obj2: [ 'val1' ], + result: true, + allowSubset: true, + msg: 'Compare: array subset: true' + }, + { + obj1: [ 'val1', 'val2', 'val3' ], + obj2: [ 'val1' ], + result: false, + allowSubset: false, + msg: 'Compare: array subset: false' + }, + { + obj1: { + param1: { + type: 'unknown', + aliases: [ 'alias2', 'alias1', 'alias3' ], + description: 'Some description', + required: true, + suggested: false }, - obj2: { - param1: { - type: 'unknown', - aliases: [ 'alias2', 'alias1', 'alias3' ], - description: 'Some description', - required: true, - suggested: false - }, - param2: { - required: true - } + param2: { + required: true + } + }, + obj2: { + param1: { + type: 'unknown', + aliases: [ 'alias2', 'alias1', 'alias3' ], + description: 'Some description', + required: true, + suggested: false }, - result: true, - allowSubset: true, - msg: 'Compare: complex objects' + param2: { + required: true + } }, - { - obj1: { - param1: { - type: 'unknown', - aliases: [ 'alias1', 'alias2', 'alias3' ], - description: 'Some description', - required: true, - suggested: false - }, - param2: { - required: true - } + result: true, + allowSubset: true, + msg: 'Compare: complex objects' + }, + { + obj1: { + param1: { + type: 'unknown', + aliases: [ 'alias1', 'alias2', 'alias3' ], + description: 'Some description', + required: true, + suggested: false }, - obj2: { - param1: { - aliases: [ 'alias1', 'alias2', 'alias3' ], - suggested: false - } - }, - result: true, - allowSubset: true, - msg: 'Compare: complex objects subset' - } - ], - splitAndTrimArray: [ - { - string: 'str1 , str2 ', - delim: ',', - result: [ 'str1', 'str2' ], - msg: 'splitAndTrimArray: split and trim' + param2: { + required: true + } }, - { - string: 'str1, str2, , , , str3', - delim: ',', - result: [ 'str1', 'str2', 'str3' ], - msg: 'splitAndTrimArray: remove empty values' + obj2: { + param1: { + aliases: [ 'alias1', 'alias2', 'alias3' ], + suggested: false + } }, - { - string: 'str1|str2|str3', - delim: '|', - result: [ 'str1', 'str2', 'str3' ], - msg: 'splitAndTrimArray: different delimeter' - } - ], - arrayUnionWithoutEmpty: [ - { - arrays: [ [ 'en', 'he', '' ], [ 'he', 'de', '' ], [ 'en', 'de' ] ], - result: [ 'en', 'he', 'de' ], - msg: 'arrayUnionWithoutEmpty: Remove duplications' - }, - { - arrays: [ [ 'en', '', '' ], [ 'he', '', '' ], [ 'de', '' ] ], - result: [ 'en', 'he', 'de' ], - msg: 'arrayUnionWithoutEmpty: Remove empty values' - } - ], - props: { - all: [ - 'name', - 'aliases', - 'label', - 'description', - 'example', - 'type', - 'default', - 'autovalue', - 'deprecated', - 'deprecatedValue', - 'required', - 'suggested' - ], - language: [ - 'label', - 'description', - 'example', - 'default' - ] + result: true, + allowSubset: true, + msg: 'Compare: complex objects subset' } - }; + ], + splitAndTrimArray: [ + { + string: 'str1 , str2 ', + delim: ',', + result: [ 'str1', 'str2' ], + msg: 'splitAndTrimArray: split and trim' + }, + { + string: 'str1, str2, , , , str3', + delim: ',', + result: [ 'str1', 'str2', 'str3' ], + msg: 'splitAndTrimArray: remove empty values' + }, + { + string: 'str1|str2|str3', + delim: '|', + result: [ 'str1', 'str2', 'str3' ], + msg: 'splitAndTrimArray: different delimeter' + } + ], + arrayUnionWithoutEmpty: [ + { + arrays: [ [ 'en', 'he', '' ], [ 'he', 'de', '' ], [ 'en', 'de' ] ], + result: [ 'en', 'he', 'de' ], + msg: 'arrayUnionWithoutEmpty: Remove duplications' + }, + { + arrays: [ [ 'en', '', '' ], [ 'he', '', '' ], [ 'de', '' ] ], + result: [ 'en', 'he', 'de' ], + msg: 'arrayUnionWithoutEmpty: Remove empty values' + } + ], + props: { + all: [ + 'name', + 'aliases', + 'label', + 'description', + 'example', + 'type', + 'default', + 'autovalue', + 'deprecated', + 'deprecatedValue', + 'required', + 'suggested' + ], + language: [ + 'label', + 'description', + 'example', + 'default' + ] + } + }; QUnit.expect( tests.compare.length + -- To view, visit https://gerrit.wikimedia.org/r/325043 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iff79501de8d80a860eebb4a6e31dc8fca3285505 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TemplateData Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits