WMDE-leszek has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/364235 )

Change subject: Lint JS with eslint
......................................................................

Lint JS with eslint

Bug: T165843
Change-Id: I5930ac47a1291d2af83eb4181cc2178fbd3e8c4b
---
R .eslintignore
A .eslintrc.json
D .jscsrc
D .jshintrc
M Gruntfile.js
M package.json
M src/RepoApi.js
A tests/.eslintrc.json
8 files changed, 46 insertions(+), 137 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseJavaScriptApi 
refs/changes/35/364235/1

diff --git a/.jshintignore b/.eslintignore
similarity index 100%
rename from .jshintignore
rename to .eslintignore
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..7d9a351
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,23 @@
+{
+       "extends": "wikimedia",
+       "env": {
+               "browser": true,
+               "jquery": true
+       },
+       "globals": {
+               "util": false,
+               "wikibase": false
+       },
+       "rules": {
+               "computed-property-spacing": "off",
+               "indent": "off",
+               "keyword-spacing": "off",
+               "no-underscore-dangle": "off",
+               "no-use-before-define": [ "error", "nofunc" ],
+               "one-var": "off",
+               "operator-linebreak": "off",
+               "space-before-function-paren": "off",
+               "spaced-comment": "off",
+               "vars-on-top": "off"
+       }
+}
diff --git a/.jscsrc b/.jscsrc
deleted file mode 100644
index caeeec6..0000000
--- a/.jscsrc
+++ /dev/null
@@ -1,59 +0,0 @@
-{
-       "preset": "wikimedia",
-       // Rules from wikimedia preset we don't yet? follow
-       "disallowDanglingUnderscores": null,
-       "requireVarDeclFirst": null,
-       "requireSpacesInsideBrackets": null,
-       "requireSpacesInsideObjectBrackets": null,
-       "validateIndentation": null,
-       "validateQuoteMarks": null,
-       "requireSpacesInsideParentheses": null,
-       "requireMultipleVarDecl": null,
-       "requireSpaceAfterKeywords": [
-               "do",
-               //"for",
-               //"if",
-               "else",
-               "switch",
-               "case",
-               "try",
-               "catch",
-               "void",
-               "while",
-               "with",
-               "return",
-               "typeof"
-               //"function"
-       ],
-       "jsDoc": {
-               // what we don't yet follow is commented out
-               "checkAnnotations": {
-                       "extra": {
-                               //"TODO:": "some",
-                               "class": "some",
-                               "since": "some",
-                               "author": "some",
-                               "return": "some",
-                               "private": false,
-                               "param": "some",
-                               "throws": "some",
-                               "static": false,
-                               "readonly": false,
-                               "property": "some",
-                               "ignore": false,
-                               "constructor": false,
-                               "singleton": false,
-                               "member": "some",
-                               "method": "some",
-                               "extends": "some",
-                               "license": "some",
-                               //"note:": "some",
-                               //"option": "some",
-                               "see": "some"
-                               //"todo": "some",
-                               //"triggers": "some"
-                       }
-               }
-       },
-       "excludeFiles": [ "node_modules/**", "vendor/**" ]
-}
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 22d9a4f..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,61 +0,0 @@
-{
-       "bitwise": true, // Prohibit bitwise operators (&, |, ^, etc.).
-       "camelcase": true, // Force variable names to be camelcase
-       "curly": true, // Require {} for every new block or scope.
-       "eqeqeq": true, // Require triple equals i.e. `===`.
-       "esversion": 5,
-       "forin": false, // Don't expect `for in` loops to call 
`hasOwnPrototype`.
-       "freeze": true, // Prohibit overwriting prototypes of native objects 
such as Array, Date and so on.
-       "immed": true, // Require immediate invocations to be wrapped in parens 
e.g. `( function(){}() );`
-       "latedef": "nofunc", // Prohibit variable use before definition.
-       "newcap": true, // Require capitalization of all constructor functions 
e.g. `new F()`.
-       "noarg": true, // Prohibit use of `arguments.caller` and 
`arguments.callee`.
-       "noempty": true, // Prohibit use of empty blocks.
-       "nonbsp": true, // Prohibit nbsp
-       "nonew": true, // Prohibit use of constructors for side-effects.
-       "plusplus": false, // Allow use of `++` & `--`.
-       "regexp": true, // Prohibit `.` and `[^...]` in regular expressions.
-       "undef": true, // Require all non-global variables be declared before 
they are used.
-       "unused": false, // Don't warn about unused variables
-       "strict": true, // Require `use strict` pragma in every file.
-       "trailing": true, // Prohibit trailing whitespaces.
-
-       "asi": false, // Don't tolerate Automatic Semicolon Insertion (no 
semicolons).
-       "boss": false, // Don't tolerate assignments inside if, for & while. 
Usually conditions & loops are for comparison, not assignments.
-       "debug": false, // Don't allow debugger statements e.g. browser 
breakpoints.
-       "eqnull": false, // Don't tolerate use of `== null`.
-       "evil": false, // Don't tolerate use of `eval`.
-       "expr": false, // Don't tolerate `ExpressionStatement` as Programs.
-       "funcscope": false, // Don't tolerate declarations of variables inside 
of control structures while accessing them later from the outside.
-       "globalstrict": false, // Don't allow global "use strict" (also enables 
'strict').
-       "iterator": false, // Don't allow usage of __iterator__ property.
-       "lastsemic": false, // Don't tolerat missing semicolons when the it is 
omitted for the last statement in a one-line block.
-       "laxbreak": true, // Tolerate unsafe line breaks e.g. `return [\n] x` 
without semicolons.
-       "laxcomma": false, // Don't suppress warnings about comma-first coding 
style.
-       "loopfunc": false, // Don't allow functions to be defined within loops.
-       "multistr": false, // Don't tolerate multi-line strings.
-       "onecase": false, // Don't tolerate switches with just one case.
-       "proto": false, // Don't tolerate __proto__ property. This property is 
deprecated.
-       "regexdash": false, // Don't tolerate unescaped last dash i.e. `[-...]`.
-       "scripturl": false, // Don't tolerate script-targeted URLs.
-       "smarttabs": false, // Don't tolerate mixed tabs and spaces when the 
latter are used for alignmnent only.
-       "shadow": false, // Don't allows re-define variables later in code e.g. 
`var x=1; x=2;`.
-       "sub": false, // Don't tolerate all forms of subscript notation besides 
dot notation e.g. `dict['key']` instead of `dict.key`.
-       "supernew": false, // Don't tolerate `new function () { ... };` and 
`new Object;`.
-       "validthis": false, // Don't tolerate strict violations when the code 
is running in strict mode and you use this in a non-constructor function.
-
-       "browser": true, // Standard browser globals e.g. `window`, `document`.
-
-       "quotmark": false,
-       "maxlen": 100,
-       "maxparams": 7,
-       "maxdepth": 4,
-       "maxstatements": 19,
-       "predef": [
-               "jQuery",
-               "mediaWiki",
-               "util",
-               "wikibase",
-               "JSON"
-       ]
-}
diff --git a/Gruntfile.js b/Gruntfile.js
index b286391..ecc2d8d 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -1,22 +1,13 @@
 /*jshint node:true */
 'use strict';
 module.exports = function ( grunt ) {
-       grunt.loadNpmTasks( 'grunt-contrib-jshint' );
+       grunt.loadNpmTasks( 'grunt-eslint' );
        grunt.loadNpmTasks( 'grunt-jsonlint' );
-       grunt.loadNpmTasks( 'grunt-jscs' );
 
        grunt.initConfig( {
-               jshint: {
-                       options: {
-                               jshintrc: true
-                       },
-                       all: [
-                               '**/*.js'
-                       ]
-               },
-               jscs: {
-                       src: '<%= jshint.all %>'
-               },
+               eslint: {
+                        all: '.'
+                },
                jsonlint: {
                        all: [
                                '**/*.json',
@@ -25,6 +16,6 @@
                }
        } );
 
-       grunt.registerTask( 'test', [ 'jshint', 'jscs', 'jsonlint' ] );
+       grunt.registerTask( 'test', [ 'eslint', 'jsonlint' ] );
        grunt.registerTask( 'default', 'test' );
 };
diff --git a/package.json b/package.json
index e43a88e..20da8ca 100644
--- a/package.json
+++ b/package.json
@@ -4,10 +4,10 @@
     "test": "grunt test"
   },
   "devDependencies": {
+    "eslint-config-wikimedia": "0.4.0",
     "grunt": "0.4.5",
     "grunt-cli": "0.1.13",
-    "grunt-contrib-jshint": "0.12.0",
-    "grunt-jscs": "2.5.0",
+    "grunt-eslint": "19.0.0",
     "grunt-jsonlint": "1.0.7"
   }
 }
diff --git a/src/RepoApi.js b/src/RepoApi.js
index 2ee0300..414cece 100644
--- a/src/RepoApi.js
+++ b/src/RepoApi.js
@@ -851,7 +851,7 @@
                if ( Array.isArray( value ) ) {
                        return value.map( function ( item ) {
                                return '\x1f' + item;
-                       } ).join('');
+                       } ).join( '' );
                }
 
                // We must enforce the alternative separation character, see 
ApiBase.php::explodeMultiValue.
diff --git a/tests/.eslintrc.json b/tests/.eslintrc.json
new file mode 100644
index 0000000..9d1c02c
--- /dev/null
+++ b/tests/.eslintrc.json
@@ -0,0 +1,15 @@
+{
+        "extends": "../.eslintrc.json",
+        "env": {
+                "qunit": true
+        },
+        "globals": {
+                "sinon": false
+        },
+        "rules": {
+               "array-bracket-spacing": "off",
+               "object-curly-spacing": "off",
+               "quotes": "off",
+               "valid-jsdoc": "off"
+        }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5930ac47a1291d2af83eb4181cc2178fbd3e8c4b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikibaseJavaScriptApi
Gerrit-Branch: master
Gerrit-Owner: WMDE-leszek <leszek.mani...@wikimedia.de>

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

Reply via email to