jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/355224 )
Change subject: Use eslint to lint JavaScript instead of jscs and jshint ...................................................................... Use eslint to lint JavaScript instead of jscs and jshint Bug: T165843 Change-Id: I45354d6849276b21be9d4ae34af7d993846f5351 --- R .eslintignore A .eslintrc.json D .jscsrc D .jshintrc M .travis.yml M Gruntfile.js M lib/jquery.ui/jquery.ui.languagesuggester.js M lib/jquery.ui/jquery.ui.unitsuggester.js M lib/jquery/jquery.AnimationEvent.js M lib/jquery/jquery.inputautoexpand.js M package.json A tests/.eslintrc.json M tests/lib/jquery.event/jquery.event.special.eachchange.tests.js M tests/lib/jquery/jquery.PurposedCallbacks.tests.js M tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js M tests/src/jquery.valueview.ExpertStore.tests.js 16 files changed, 62 insertions(+), 178 deletions(-) Approvals: jenkins-bot: Verified Thiemo Mättig (WMDE): Looks good to me, approved diff --git a/.jshintignore b/.eslintignore similarity index 63% rename from .jshintignore rename to .eslintignore index c2658d7..7e5da87 100644 --- a/.jshintignore +++ b/.eslintignore @@ -1 +1,2 @@ node_modules/ +vendor/ diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..8922209 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,29 @@ +{ + "extends": "wikimedia", + "env": { + "browser": true, + "jquery": true + }, + "globals": { + "dataValues": false, + "globeCoordinate": false, + "mediaWiki": false, + "util": false, + "valueFormatters": false, + "valueParsers": false + }, + "rules": { + "array-bracket-spacing": "off", + "comma-spacing": "off", + "computed-property-spacing": "off", + "indent": "off", + "no-underscore-dangle": "off", + "no-unused-vars": "off", + "one-var": "off", + "operator-linebreak": "off", + "space-before-function-paren": "off", + "valid-jsdoc": "off", + "vars-on-top": "off", + "wrap-iife": "off" + } +} diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index fd10385..0000000 --- a/.jscsrc +++ /dev/null @@ -1,94 +0,0 @@ -{ - // ---- - // This is a copy of the wikimedia preset so we can disable some of the rules - - "requireCurlyBraces": [ - "if", - "else", - "for", - "while", - "do", - "try", - "catch" - ], - "requireSpaceBeforeKeywords": true, - "requireSpaceBeforeBlockStatements": true, - "requireParenthesesAroundIIFE": true, - "requireSpacesInConditionalExpression": true, - "disallowSpacesInNamedFunctionExpression": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInFunctionDeclaration": { - "beforeOpeningRoundBrace": true - }, - "disallowSpacesInCallExpression": true, - "requireBlocksOnNewline": 1, - "disallowEmptyBlocks": true, - "requireSpacesInsideObjectBrackets": "all", - "requireSpacesInsideParentheses": "all", - "disallowQuotedKeysInObjects": "allButReserved", - "disallowSpaceAfterObjectKeys": true, - "requireSpaceBeforeObjectValues": true, - "requireCommaBeforeLineBreak": true, - "disallowSpaceAfterPrefixUnaryOperators": true, - "disallowSpaceBeforePostfixUnaryOperators": true, - "disallowSpaceBeforeBinaryOperators": [ - "," - ], - "requireSpaceBeforeBinaryOperators": true, - "requireSpaceAfterBinaryOperators": true, - "disallowImplicitTypeConversion": [ - "binary", - "string" - ], - "requireCamelCaseOrUpperCaseIdentifiers": true, - "disallowKeywords": [ - "with" - ], - "disallowMixedSpacesAndTabs": true, - "disallowMultipleLineBreaks": true, - "disallowOperatorBeforeLineBreak": [ - "." - ], - "disallowTrailingWhitespace": true, - "disallowTrailingComma": true, - "disallowKeywordsOnNewLine": [ - "else", - "catch" - ], - "requireLineBreakAfterVariableAssignment": true, - "requireLineFeedAtFileEnd": true, - "requireCapitalizedConstructors": true, - "requireDotNotation": true, - "disallowYodaConditions": true, - "requireSpaceAfterLineComment": true, - "disallowNewlineBeforeBlockStatements": true, - "validateLineBreaks": "LF", - "validateQuoteMarks": "'", - - // ---- - // Rules from wikimedia preset we don't follow - - // "validateIndentation": "\t", - // "requireSpaceAfterKeywords": true, - // "requireMultipleVarDecl": "onevar", - // "disallowDanglingUnderscores": true, - // "requireSpacesInsideArrayBrackets": "all", - - // ---- - // Own rules - - "requireSpaceAfterKeywords": [ - "if", - "else", - "for", - "while", - "do", - "switch", - "return", - "try", - "catch" - ], - - "excludeFiles": [ "node_modules/**", "vendor/**" ] -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 7f42490..0000000 --- a/.jshintrc +++ /dev/null @@ -1,50 +0,0 @@ -{ - "camelcase": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "latedef": true, - "newcap": true, - "supernew": true, - "shadow": true, - "noarg": true, - "noempty": true, - "nonew": true, - "quotmark": "single", - "trailing": true, - "undef": true, - "unused": "vars", - "laxbreak": true, - "laxcomma": false, - "onevar": false, - "bitwise": false, - "forin": false, - "regexp": false, - "strict": true, - "scripturl": true, - - // Environment - "browser": true, - - // Globals - "globals": { - "dataValues": false, - "globeCoordinate": false, - "jQuery": false, - "QUnit": false, - "sinon": false, - "time": false, - "util": false, - "valueFormatters": false, - "valueParsers": false - }, - - "overrides": { - "lib/jquery.ui/jquery.ui.listrotator.js": { - "globals": { - "mediaWiki": false - } - } - } - -} diff --git a/.travis.yml b/.travis.yml index 429d464..e924d93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,10 @@ - 5.5 install: - - npm install -g jshint - - npm install -g jscs + - npm install -g eslint script: - - jshint . - - jscs . + - eslint . notifications: irc: diff --git a/Gruntfile.js b/Gruntfile.js index 8e2c4eb..642492a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,26 +1,14 @@ 'use strict'; -/*jshint node:true */ +/* eslint-env node */ module.exports = function ( grunt ) { - grunt.loadNpmTasks( 'grunt-contrib-jshint' ); + grunt.loadNpmTasks( 'grunt-eslint' ); grunt.loadNpmTasks( 'grunt-jsonlint' ); grunt.loadNpmTasks( 'grunt-banana-checker' ); - grunt.loadNpmTasks( 'grunt-jscs' ); grunt.initConfig( { - jshint: { - options: { - jshintrc: true - }, - all: [ - '*.js', - 'src/**/*.js', - 'lib/**/*.js', - 'tests/**/*.js' - ] - }, - jscs: { - src: '<%= jshint.all %>' + eslint: { + all: '.' }, banana: { options: { @@ -40,6 +28,6 @@ } } ); - grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint', 'banana' ] ); + grunt.registerTask( 'test', [ 'eslint', 'jsonlint', 'banana' ] ); grunt.registerTask( 'default', 'test' ); }; diff --git a/lib/jquery.ui/jquery.ui.languagesuggester.js b/lib/jquery.ui/jquery.ui.languagesuggester.js index 3f28b3a..f81c653 100644 --- a/lib/jquery.ui/jquery.ui.languagesuggester.js +++ b/lib/jquery.ui/jquery.ui.languagesuggester.js @@ -58,7 +58,7 @@ regex = this._escapeRegex( term ), matcher = new RegExp( regex, 'i' ), subCodeMatcher = new RegExp( '^' + regex + '-', 'i' ), - prefixMatcher = new RegExp( '^' + regex, 'i' ), + prefixMatcher = new RegExp( '^' + regex, 'i' ), promoters = [ function( item ) { return item.code.toLowerCase() === term.toLowerCase(); }, function( item ) { return subCodeMatcher.test( item.code ); }, diff --git a/lib/jquery.ui/jquery.ui.unitsuggester.js b/lib/jquery.ui/jquery.ui.unitsuggester.js index bee4085..2136646 100644 --- a/lib/jquery.ui/jquery.ui.unitsuggester.js +++ b/lib/jquery.ui/jquery.ui.unitsuggester.js @@ -209,7 +209,7 @@ if ( entityStub.aliases ) { $label.append( - $( '<span class="ui-unitsuggester-aliases">' ).text( ' (' + entityStub.aliases.join( ', ' ) + ')' ) + $( '<span class="ui-unitsuggester-aliases">' ).text( ' (' + entityStub.aliases.join( ', ' ) + ')' ) ); } diff --git a/lib/jquery/jquery.AnimationEvent.js b/lib/jquery/jquery.AnimationEvent.js index 10ecf62..477ec26 100644 --- a/lib/jquery/jquery.AnimationEvent.js +++ b/lib/jquery/jquery.AnimationEvent.js @@ -149,8 +149,8 @@ // matter since they will be overwritten when creating an instance, but do it the "clean" way // anyhow: SELF.prototype = new $.Event(); - delete( SELF.prototype.timeStamp ); - delete( SELF.prototype[ jQuery.expando ] ); + delete SELF.prototype.timeStamp; + delete SELF.prototype[ jQuery.expando ]; /** * All animation step callback option names usable in `jQuery.Animation`'s options. diff --git a/lib/jquery/jquery.inputautoexpand.js b/lib/jquery/jquery.inputautoexpand.js index b74ac57..6e78683 100644 --- a/lib/jquery/jquery.inputautoexpand.js +++ b/lib/jquery/jquery.inputautoexpand.js @@ -309,7 +309,7 @@ if ( newWidth < minWidth ) { newWidth = minWidth; - } else if ( newWidth >= maxWidth ) { + } else if ( newWidth >= maxWidth ) { newWidth = maxWidth; } diff --git a/package.json b/package.json index 571e811..d9b99f2 100644 --- a/package.json +++ b/package.json @@ -5,11 +5,11 @@ "test": "grunt test" }, "devDependencies": { + "eslint-config-wikimedia": "0.4.0", "grunt": "0.4.5", "grunt-cli": "0.1.13", - "grunt-contrib-jshint": "0.11.2", "grunt-banana-checker": "0.3.0", - "grunt-jscs": "2.1.0", + "grunt-eslint": "19.0.0", "grunt-jsonlint": "1.0.4" } } diff --git a/tests/.eslintrc.json b/tests/.eslintrc.json new file mode 100644 index 0000000..0613436 --- /dev/null +++ b/tests/.eslintrc.json @@ -0,0 +1,12 @@ +{ + "extends": "../.eslintrc.json", + "env": { + "qunit": true + }, + "globals": { + "sinon": false + }, + "rules": { + "dot-notation": "off" + } +} diff --git a/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js b/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js index 6f2fb2a..4a22e10 100644 --- a/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js +++ b/tests/lib/jquery.event/jquery.event.special.eachchange.tests.js @@ -21,7 +21,7 @@ */ function generateInputElement( attributes ) { return $( '<input/>', $.extend( { - class: 'test_eachchange', + 'class': 'test_eachchange', type: 'text', name: 'test', value: '' diff --git a/tests/lib/jquery/jquery.PurposedCallbacks.tests.js b/tests/lib/jquery/jquery.PurposedCallbacks.tests.js index 24c6b06..2e0d835 100644 --- a/tests/lib/jquery/jquery.PurposedCallbacks.tests.js +++ b/tests/lib/jquery/jquery.PurposedCallbacks.tests.js @@ -240,7 +240,7 @@ 'Executed all callbacks registered for purpose, except the ones removed again.' ); - var feedback = []; + feedback = []; pcf.remove( 'bar', [ fn1, fn4 ] ); pc.fireWith( feedback, [ 'foo', 'bar' ] ); assert.deepEqual( diff --git a/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js b/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js index 507b6f1..17a414d 100644 --- a/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js +++ b/tests/src/ExpertExtender/ExpertExtender.CalendarHint.tests.js @@ -57,7 +57,7 @@ }, null ); - var $extender = $( '<div />' ).appendTo( 'body' ) ; + var $extender = $( '<div />' ).appendTo( 'body' ); calendarHint.init( $extender ); calendarHint.draw(); @@ -81,7 +81,7 @@ }, setSpy ); - var $extender = $( '<div />' ).appendTo( 'body' ) ; + var $extender = $( '<div />' ).appendTo( 'body' ); assert.equal( timeValue.getOption( 'calendarModel' ), 'http://www.wikidata.org/entity/Q1985727' ); @@ -112,7 +112,7 @@ }, setSpy ); - var $extender = $( '<div />' ).appendTo( 'body' ) ; + var $extender = $( '<div />' ).appendTo( 'body' ); calendarHint.init( $extender ); calendarHint.draw(); diff --git a/tests/src/jquery.valueview.ExpertStore.tests.js b/tests/src/jquery.valueview.ExpertStore.tests.js index 67bc319..9440796 100644 --- a/tests/src/jquery.valueview.ExpertStore.tests.js +++ b/tests/src/jquery.valueview.ExpertStore.tests.js @@ -223,7 +223,7 @@ * parameter. Each inner array should contain a DataTypeMock object or a DataValue * constructor and an Expert constructor which is expected to be registered for it. */ - function expertStoreRegistrationTest( assert, toRegister, toExpect ) { + function expertStoreRegistrationTest( assert, toRegister, toExpect ) { assert.expect( toRegister.length + toExpect.length ); var expertStore = new vv.ExpertStore(); -- To view, visit https://gerrit.wikimedia.org/r/355224 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I45354d6849276b21be9d4ae34af7d993846f5351 Gerrit-PatchSet: 1 Gerrit-Project: data-values/value-view Gerrit-Branch: master Gerrit-Owner: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits