MDL-54944 js: split variable intialisations in multiple lines
authorDan Poltawski <dan@moodle.com>
Wed, 29 Jun 2016 13:51:07 +0000 (14:51 +0100)
committerDan Poltawski <dan@moodle.com>
Thu, 7 Jul 2016 11:11:06 +0000 (12:11 +0100)
To increase code clarity, we don't allow multiple intilisations to be
confused with each other.

Detected by http://eslint.org/docs/rules/one-var-declaration-per-line

admin/tool/lp/amd/src/competencyactions.js
admin/tool/lp/amd/src/competencypicker.js
admin/tool/lp/amd/src/competencypicker_user_plans.js
lib/amd/src/form-course-selector.js
lib/amd/src/localstorage.js
mod/assign/amd/src/grading_navigation.js
mod/assign/amd/src/participant_selector.js

index c0943c0..522e827 100644 (file)
@@ -248,7 +248,8 @@ define(['jquery',
         $.when.apply(null, requests).done(function(competencies, framework) {
 
             // Expand the list of competencies into a tree.
-            var i, competenciestree = [];
+            var i;
+            var competenciestree = [];
             for (i = 0; i < competencies.length; i++) {
                 var onecompetency = competencies[i];
                 if (onecompetency.parentid == "0") {
index 28c4ce3..2ba49ac 100644 (file)
@@ -248,7 +248,8 @@ define(['jquery',
             }
 
             // Expand the list of competencies into a tree.
-            var i, tree = [], comp;
+            var i, comp;
+            var tree = [];
             for (i = 0; i < competencies.length; i++) {
                 comp = competencies[i];
                 if (comp.parentid == "0") { // Loose check for now, because WS returns a string.
index 8046c29..6565ed2 100644 (file)
@@ -100,7 +100,8 @@ define(['jquery',
         ])[0].done(function(competencies) {
 
             // Expand the list of competencies into a fake tree.
-            var i, tree = [], comp;
+            var i, comp;
+            var tree = [];
             for (i = 0; i < competencies.length; i++) {
                 comp = competencies[i].competency;
                 if (comp.shortname.toLowerCase().indexOf(searchText.toLowerCase()) < 0) {
index f34fb3d..0914918 100644 (file)
@@ -29,7 +29,8 @@ define(['core/ajax', 'jquery'], function(ajax, $) {
         // Public variables and functions.
         processResults: function(selector, data) {
             // Mangle the results into an array of objects.
-            var results = [], i = 0;
+            var results = [];
+            var i = 0;
             var excludelist = String($(selector).data('exclude')).split(',');
 
             for (i = 0; i < data.courses.length; i++) {
index 27da8e4..adb2c80 100644 (file)
@@ -106,7 +106,8 @@ define(['core/config'], function(config) {
         // From http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery.
         /* jshint bitwise: false */
         /* eslint no-bitwise: "off" */
-        var hash = 0, i, chr, len;
+        var hash = 0;
+        var i, chr, len;
         if (source.length === 0) {
             return hash;
         }
index b284435..97087e0 100644 (file)
@@ -332,7 +332,8 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
         e.preventDefault();
         var select = this._region.find('[data-action=change-user]');
         var currentUserId = select.attr('data-selected');
-        var i = 0, currentIndex = 0;
+        var i = 0;
+        var currentIndex = 0;
 
         for (i = 0; i < this._filteredUsers.length; i++) {
             if (this._filteredUsers[i].id == currentUserId) {
@@ -361,7 +362,8 @@ define(['jquery', 'core/notification', 'core/str', 'core/form-autocomplete',
         e.preventDefault();
         var select = this._region.find('[data-action=change-user]');
         var currentUserId = select.attr('data-selected');
-        var i = 0, currentIndex = 0;
+        var i = 0;
+        var currentIndex = 0;
 
         for (i = 0; i < this._filteredUsers.length; i++) {
             if (this._filteredUsers[i].id == currentUserId) {
index d8094b7..71312a6 100644 (file)
@@ -35,7 +35,8 @@ define(['core/ajax', 'jquery', 'core/templates'], function(ajax, $, templates) {
          * @return {Array}
          */
         processResults: function(selector, data) {
-            var results = [], i = 0;
+            var results = [];
+            var i = 0;
             for (i = 0; i < data.length; i++) {
                 results[i] = {value: data[i].id, label: data[i].label};
             }