diff options
author | gfyoung <gfyoung17@gmail.com> | 2018-06-21 17:50:34 +0300 |
---|---|---|
committer | Clement Ho <clemmakesapps@gmail.com> | 2018-06-21 17:50:34 +0300 |
commit | f5cbb44d0bd466b32d16bf8a15b0996eaa42e0e4 (patch) | |
tree | 719feceae3065730e97a7e89860ae59411dc8264 /app | |
parent | 94ac31e28b5de11b86a60e8dd56c472c777234a4 (diff) |
Follow-up to !19808: Split up for-loop initializations
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/line_highlighter.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/network/branch_graph.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/profile/gl_crop.js | 7 | ||||
-rw-r--r-- | app/assets/javascripts/project_find_file.js | 3 | ||||
-rw-r--r-- | app/assets/javascripts/users_select.js | 6 |
5 files changed, 12 insertions, 18 deletions
diff --git a/app/assets/javascripts/line_highlighter.js b/app/assets/javascripts/line_highlighter.js index 815b13f7bf5..291655235d5 100644 --- a/app/assets/javascripts/line_highlighter.js +++ b/app/assets/javascripts/line_highlighter.js @@ -142,14 +142,14 @@ LineHighlighter.prototype.highlightLine = function(lineNumber) { // // range - Array containing the starting and ending line numbers LineHighlighter.prototype.highlightRange = function(range) { - var i, lineNumber, ref, ref1, results; if (range[1]) { - results = []; + const results = []; + const ref = range[0] <= range[1] ? range : range.reverse(); - // eslint-disable-next-line no-multi-assign - for (lineNumber = i = ref = range[0], ref1 = range[1]; ref <= ref1 ? i <= ref1 : i >= ref1; lineNumber = ref <= ref1 ? (i += 1) : (i -= 1)) { + for (let lineNumber = range[0]; lineNumber <= ref[1]; lineNumber += 1) { results.push(this.highlightLine(lineNumber)); } + return results; } else { return this.highlightLine(range[0]); diff --git a/app/assets/javascripts/network/branch_graph.js b/app/assets/javascripts/network/branch_graph.js index 7787849f7a8..6a8591692f1 100644 --- a/app/assets/javascripts/network/branch_graph.js +++ b/app/assets/javascripts/network/branch_graph.js @@ -113,8 +113,7 @@ export default (function() { }); ref = this.days; - // eslint-disable-next-line no-multi-assign - for (mm = j = 0, len = ref.length; j < len; mm = (j += 1)) { + for (mm = 0, len = ref.length; mm < len; mm += 1) { day = ref[mm]; if (cuday !== day[0] || cumonth !== day[1]) { // Dates @@ -288,8 +287,7 @@ export default (function() { ref = commit.parents; results = []; - // eslint-disable-next-line no-multi-assign - for (i = j = 0, len = ref.length; j < len; i = (j += 1)) { + for (i = 0, len = ref.length; i < len; i += 1) { parent = ref[i]; parentCommit = this.preparedCommits[parent[0]]; parentY = this.offsetY + this.unitTime * parentCommit.time; diff --git a/app/assets/javascripts/profile/gl_crop.js b/app/assets/javascripts/profile/gl_crop.js index 40ec3208b58..c6d809d84a6 100644 --- a/app/assets/javascripts/profile/gl_crop.js +++ b/app/assets/javascripts/profile/gl_crop.js @@ -140,10 +140,9 @@ import _ from 'underscore'; binary = atob(dataURL.split(',')[1]); array = []; - // eslint-disable-next-line no-multi-assign - for (k = i = 0, len = binary.length; i < len; k = (i += 1)) { - v = binary[k]; - array.push(binary.charCodeAt(k)); + for (i = 0, len = binary.length; i < len; i += 1) { + v = binary[i]; + array.push(binary.charCodeAt(i)); } return new Blob([new Uint8Array(array)], { type: 'image/png' diff --git a/app/assets/javascripts/project_find_file.js b/app/assets/javascripts/project_find_file.js index f53c95205af..bcdb3f739fe 100644 --- a/app/assets/javascripts/project_find_file.js +++ b/app/assets/javascripts/project_find_file.js @@ -92,8 +92,7 @@ export default class ProjectFindFile { this.element.find(".tree-table > tbody").empty(); results = []; - // eslint-disable-next-line no-multi-assign - for (i = j = 0, len = filePaths.length; j < len; i = (j += 1)) { + for (i = 0, len = filePaths.length; i < len; i += 1) { filePath = filePaths[i]; if (i === 20) { break; diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index 277a7656b8e..7abe7a6be5f 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -259,8 +259,7 @@ function UsersSelect(currentUser, els, options = {}) { showDivider = 0; if (firstUser) { // Move current user to the front of the list - // eslint-disable-next-line no-multi-assign - for (index = j = 0, len = users.length; j < len; index = (j += 1)) { + for (index = 0, len = users.length; index < len; index += 1) { obj = users[index]; if (obj.username === firstUser) { users.splice(index, 1); @@ -563,8 +562,7 @@ function UsersSelect(currentUser, els, options = {}) { // Move current user to the front of the list ref = data.results; - // eslint-disable-next-line no-multi-assign - for (index = j = 0, len = ref.length; j < len; index = (j += 1)) { + for (index = 0, len = ref.length; index < len; index += 1) { obj = ref[index]; if (obj.username === firstUser) { data.results.splice(index, 1); |