Commit 83ecc02d authored by Mike Greiling's avatar Mike Greiling

resolve all prefer-const eslint violations

parent 0b3f0049
/* eslint-disable comma-dangle, object-shorthand, func-names, space-before-function-paren, arrow-parens, no-unused-vars, class-methods-use-this, no-var, consistent-return, prefer-const, no-param-reassign, space-in-parens, max-len */ /* eslint-disable comma-dangle, object-shorthand, func-names, space-before-function-paren, arrow-parens, no-unused-vars, class-methods-use-this, no-var, consistent-return, no-param-reassign, space-in-parens, max-len */
((global) => { ((global) => {
class TemplateSelector { class TemplateSelector {
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
if (!file) return; if (!file) return;
const oldValue = this.editor.getValue(); const oldValue = this.editor.getValue();
let newValue = file.content; const newValue = file.content;
this.editor.setValue(newValue, 1); this.editor.setValue(newValue, 1);
if (!skipFocus) this.editor.focus(); if (!skipFocus) this.editor.focus();
......
/* eslint-disable no-unused-vars, no-mixed-operators, prefer-const, comma-dangle */ /* eslint-disable no-unused-vars, no-mixed-operators, comma-dangle */
/* global DocumentTouch */ /* global DocumentTouch */
((w) => { ((w) => {
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
gl.issueBoards.touchEnabled = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch; gl.issueBoards.touchEnabled = ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch;
gl.issueBoards.getBoardSortableDefaultOptions = (obj) => { gl.issueBoards.getBoardSortableDefaultOptions = (obj) => {
let defaultSortOptions = { const defaultSortOptions = {
animation: 200, animation: 200,
forceFallback: true, forceFallback: true,
fallbackClass: 'is-dragging', fallbackClass: 'is-dragging',
......
/* eslint-disable space-before-function-paren, no-underscore-dangle, class-methods-use-this, consistent-return, prefer-const, space-in-parens, no-shadow, no-param-reassign, max-len, no-unused-vars */ /* eslint-disable space-before-function-paren, no-underscore-dangle, class-methods-use-this, consistent-return, space-in-parens, no-shadow, no-param-reassign, max-len, no-unused-vars */
/* global ListIssue */ /* global ListIssue */
/* global ListLabel */ /* global ListLabel */
...@@ -66,7 +66,7 @@ class List { ...@@ -66,7 +66,7 @@ class List {
getIssues (emptyIssues = true) { getIssues (emptyIssues = true) {
const filters = this.filters; const filters = this.filters;
let data = { page: this.page }; const data = { page: this.page };
Object.keys(filters).forEach((key) => { data[key] = filters[key]; }); Object.keys(filters).forEach((key) => { data[key] = filters[key]; });
......
/* eslint-disable space-before-function-paren, comma-dangle, no-param-reassign, camelcase, prefer-const, max-len, no-unused-vars */ /* eslint-disable space-before-function-paren, comma-dangle, no-param-reassign, camelcase, max-len, no-unused-vars */
/* global Vue */ /* global Vue */
class BoardService { class BoardService {
...@@ -47,7 +47,7 @@ class BoardService { ...@@ -47,7 +47,7 @@ class BoardService {
} }
getIssuesForList (id, filter = {}) { getIssuesForList (id, filter = {}) {
let data = { id }; const data = { id };
Object.keys(filter).forEach((key) => { data[key] = filter[key]; }); Object.keys(filter).forEach((key) => { data[key] = filter[key]; });
return this.issues.get(data); return this.issues.get(data);
......
/* eslint-disable object-shorthand, func-names, camelcase, prefer-const, no-restricted-syntax, guard-for-in, comma-dangle, max-len, no-param-reassign */ /* eslint-disable object-shorthand, func-names, camelcase, no-restricted-syntax, guard-for-in, comma-dangle, max-len, no-param-reassign */
/* global Vue */ /* global Vue */
/* global DiscussionModel */ /* global DiscussionModel */
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
} }
}, },
unresolvedDiscussionIds: function () { unresolvedDiscussionIds: function () {
let ids = []; const ids = [];
for (const discussionId in this.state) { for (const discussionId in this.state) {
const discussion = this.state[discussionId]; const discussion = this.state[discussionId];
......
/* eslint-disable wrap-iife, func-names, space-before-function-paren, comma-dangle, prefer-template, consistent-return, class-methods-use-this, arrow-body-style, prefer-const, no-unused-vars, no-underscore-dangle, no-new, max-len, no-sequences, no-unused-expressions, no-param-reassign */ /* eslint-disable wrap-iife, func-names, space-before-function-paren, comma-dangle, prefer-template, consistent-return, class-methods-use-this, arrow-body-style, no-unused-vars, no-underscore-dangle, no-new, max-len, no-sequences, no-unused-expressions, no-param-reassign */
(function(global) { (function(global) {
class DueDateSelect { class DueDateSelect {
......
/* eslint-disable no-param-reassign, func-names, no-var, camelcase, no-unused-vars, object-shorthand, space-before-function-paren, no-return-assign, comma-dangle, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, prefer-arrow-callback, prefer-const, wrap-iife, max-len */ /* eslint-disable no-param-reassign, func-names, no-var, camelcase, no-unused-vars, object-shorthand, space-before-function-paren, no-return-assign, comma-dangle, consistent-return, one-var, one-var-declaration-per-line, quotes, prefer-template, prefer-arrow-callback, wrap-iife, max-len */
/* global Issuable */ /* global Issuable */
/* global Turbolinks */ /* global Turbolinks */
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
this.issuableBulkActions.setOriginalDropdownData(); this.issuableBulkActions.setOriginalDropdownData();
if ($checkedIssues.length > 0) { if ($checkedIssues.length > 0) {
let ids = $.map($checkedIssues, function(value) { const ids = $.map($checkedIssues, function(value) {
return $(value).data('id'); return $(value).data('id');
}); });
$updateIssuesIds.val(ids); $updateIssuesIds.val(ids);
......
/* eslint-disable comma-dangle, quote-props, no-useless-computed-key, object-shorthand, prefer-const, no-new, no-param-reassign, max-len */ /* eslint-disable comma-dangle, quote-props, no-useless-computed-key, object-shorthand, no-new, no-param-reassign, max-len */
/* global Vue */ /* global Vue */
/* global ace */ /* global ace */
/* global Flash */ /* global Flash */
...@@ -50,8 +50,8 @@ ...@@ -50,8 +50,8 @@
$.get(this.file.content_path) $.get(this.file.content_path)
.done((file) => { .done((file) => {
let content = this.$el.querySelector('pre'); const content = this.$el.querySelector('pre');
let fileContent = document.createTextNode(file.content); const fileContent = document.createTextNode(file.content);
content.textContent = fileContent.textContent; content.textContent = fileContent.textContent;
......
/* eslint-disable comma-dangle, object-shorthand, no-param-reassign, camelcase, prefer-const, no-nested-ternary, no-continue, max-len */ /* eslint-disable comma-dangle, object-shorthand, no-param-reassign, camelcase, no-nested-ternary, no-continue, max-len */
/* global Cookies */ /* global Cookies */
/* global Vue */ /* global Vue */
...@@ -251,7 +251,7 @@ ...@@ -251,7 +251,7 @@
}, },
checkLineLengths(linesObj) { checkLineLengths(linesObj) {
let { left, right } = linesObj; const { left, right } = linesObj;
if (left.length !== right.length) { if (left.length !== right.length) {
if (left.length > right.length) { if (left.length > right.length) {
...@@ -316,11 +316,11 @@ ...@@ -316,11 +316,11 @@
let unresolved = 0; let unresolved = 0;
for (let i = 0, l = files.length; i < l; i += 1) { for (let i = 0, l = files.length; i < l; i += 1) {
let file = files[i]; const file = files[i];
if (file.resolveMode === INTERACTIVE_RESOLVE_MODE) { if (file.resolveMode === INTERACTIVE_RESOLVE_MODE) {
let numberConflicts = 0; let numberConflicts = 0;
let resolvedConflicts = Object.keys(file.resolutionData).length; const resolvedConflicts = Object.keys(file.resolutionData).length;
// We only check for conflicts type 'text' // We only check for conflicts type 'text'
// since conflicts `text_editor` can´t be resolved in interactive mode // since conflicts `text_editor` can´t be resolved in interactive mode
...@@ -364,9 +364,7 @@ ...@@ -364,9 +364,7 @@
}; };
this.state.conflictsData.files.forEach((file) => { this.state.conflictsData.files.forEach((file) => {
let addFile; const addFile = {
addFile = {
old_path: file.old_path, old_path: file.old_path,
new_path: file.new_path new_path: file.new_path
}; };
......
/* eslint-disable wrap-iife, func-names, space-before-function-paren, object-shorthand, comma-dangle, one-var, one-var-declaration-per-line, no-restricted-syntax, prefer-const, max-len, no-param-reassign */ /* eslint-disable wrap-iife, func-names, space-before-function-paren, object-shorthand, comma-dangle, one-var, one-var-declaration-per-line, no-restricted-syntax, max-len, no-param-reassign */
(function(global) { (function(global) {
class ProjectLabelSubscription { class ProjectLabelSubscription {
...@@ -38,8 +38,8 @@ ...@@ -38,8 +38,8 @@
this.$buttons.attr('data-status', newStatus); this.$buttons.attr('data-status', newStatus);
this.$buttons.find('> span').text(newAction); this.$buttons.find('> span').text(newAction);
for (let button of this.$buttons) { for (const button of this.$buttons) {
let $button = $(button); const $button = $(button);
if ($button.attr('data-original-title')) { if ($button.attr('data-original-title')) {
$button.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle'); $button.tooltip('hide').attr('data-original-title', newAction).tooltip('fixTitle');
......
/* eslint-disable prefer-const, comma-dangle, max-len, no-useless-return, no-param-reassign, max-len */ /* eslint-disable comma-dangle, max-len, no-useless-return, no-param-reassign, max-len */
/* global Api */ /* global Api */
/*= require ../blob/template_selector */ /*= require ../blob/template_selector */
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
this.issuableType = this.wrapper.data('issuable-type'); this.issuableType = this.wrapper.data('issuable-type');
this.titleInput = $(`#${this.issuableType}_title`); this.titleInput = $(`#${this.issuableType}_title`);
let initialQuery = { const initialQuery = {
name: this.dropdown.data('selected') name: this.dropdown.data('selected')
}; };
......
/* eslint-disable no-new, comma-dangle, class-methods-use-this, prefer-const, no-param-reassign */ /* eslint-disable no-new, comma-dangle, class-methods-use-this, no-param-reassign */
((global) => { ((global) => {
class IssuableTemplateSelectors { class IssuableTemplateSelectors {
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
} }
initEditor() { initEditor() {
let editor = $('.markdown-area'); const editor = $('.markdown-area');
// Proxy ace-editor's .setValue to jQuery's .val // Proxy ace-editor's .setValue to jQuery's .val
editor.setValue = editor.val; editor.setValue = editor.val;
editor.getValue = editor.val; editor.getValue = editor.val;
......
/* eslint-disable no-unused-expressions, prefer-const, no-prototype-builtins, no-new, no-shadow, max-len */ /* eslint-disable no-unused-expressions, no-prototype-builtins, no-new, no-shadow, max-len */
/*= require js.cookie.js */ /*= require js.cookie.js */
/*= require jquery.endless-scroll.js */ /*= require jquery.endless-scroll.js */
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
}]; }];
function getEventName(index) { function getEventName(index) {
let filter = filters[index]; const filter = filters[index];
return filter.hasOwnProperty('name') ? filter.name : filter.id; return filter.hasOwnProperty('name') ? filter.name : filter.id;
} }
function getSelector(index) { function getSelector(index) {
let filter = filters[index]; const filter = filters[index];
return `#${filter.id}_event_filter`; return `#${filter.id}_event_filter`;
} }
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
for (let x = 0; x < filters.length; x += 1) { for (let x = 0; x < filters.length; x += 1) {
((x) => { ((x) => {
let shouldHighlight = i === x; const shouldHighlight = i === x;
let testName = shouldHighlight ? 'should highlight' : 'should not highlight'; const testName = shouldHighlight ? 'should highlight' : 'should not highlight';
it(`${testName} ${getEventName(x)}`, () => { it(`${testName} ${getEventName(x)}`, () => {
expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight); expect($(getSelector(x)).parent().hasClass('active')).toEqual(shouldHighlight);
......
/* eslint-disable comma-dangle, prefer-const, no-param-reassign, no-unused-expressions, max-len */ /* eslint-disable comma-dangle, no-param-reassign, no-unused-expressions, max-len */
/* global Turbolinks */ /* global Turbolinks */
/*= require jquery */ /*= require jquery */
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
let remoteCallback; let remoteCallback;
let navigateWithKeys = function navigateWithKeys(direction, steps, cb, i) { const navigateWithKeys = function navigateWithKeys(direction, steps, cb, i) {
i = i || 0; i = i || 0;
if (!i) direction = direction.toUpperCase(); if (!i) direction = direction.toUpperCase();
$('body').trigger({ $('body').trigger({
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
} }
}; };
let remoteMock = function remoteMock(data, term, callback) { const remoteMock = function remoteMock(data, term, callback) {
remoteCallback = callback.bind({}, data); remoteCallback = callback.bind({}, data);
}; };
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
it('should select a following item on DOWN keypress', () => { it('should select a following item on DOWN keypress', () => {
expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(0); expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(0);
let randomIndex = (Math.floor(Math.random() * (this.projectsData.length - 1)) + 0); const randomIndex = (Math.floor(Math.random() * (this.projectsData.length - 1)) + 0);
navigateWithKeys('down', randomIndex, () => { navigateWithKeys('down', randomIndex, () => {
expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(1); expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(1);
expect($(`${ITEM_SELECTOR}:eq(${randomIndex}) a`, this.$dropdownMenuElement)).toHaveClass('is-focused'); expect($(`${ITEM_SELECTOR}:eq(${randomIndex}) a`, this.$dropdownMenuElement)).toHaveClass('is-focused');
...@@ -100,7 +100,7 @@ ...@@ -100,7 +100,7 @@
expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(0); expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(0);
navigateWithKeys('down', (this.projectsData.length - 1), () => { navigateWithKeys('down', (this.projectsData.length - 1), () => {
expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(1); expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(1);
let randomIndex = (Math.floor(Math.random() * (this.projectsData.length - 2)) + 0); const randomIndex = (Math.floor(Math.random() * (this.projectsData.length - 2)) + 0);
navigateWithKeys('up', randomIndex, () => { navigateWithKeys('up', randomIndex, () => {
expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(1); expect($(FOCUSED_ITEM_SELECTOR, this.$dropdownMenuElement).length).toBe(1);
expect($(`${ITEM_SELECTOR}:eq(${((this.projectsData.length - 2) - randomIndex)}) a`, this.$dropdownMenuElement)).toHaveClass('is-focused'); expect($(`${ITEM_SELECTOR}:eq(${((this.projectsData.length - 2) - randomIndex)}) a`, this.$dropdownMenuElement)).toHaveClass('is-focused');
...@@ -110,14 +110,14 @@ ...@@ -110,14 +110,14 @@
it('should click the selected item on ENTER keypress', () => { it('should click the selected item on ENTER keypress', () => {
expect(this.dropdownContainerElement).toHaveClass('open'); expect(this.dropdownContainerElement).toHaveClass('open');
let randomIndex = Math.floor(Math.random() * (this.projectsData.length - 1)) + 0; const randomIndex = Math.floor(Math.random() * (this.projectsData.length - 1)) + 0;
navigateWithKeys('down', randomIndex, () => { navigateWithKeys('down', randomIndex, () => {
spyOn(Turbolinks, 'visit').and.stub(); spyOn(Turbolinks, 'visit').and.stub();
navigateWithKeys('enter', null, () => { navigateWithKeys('enter', null, () => {
expect(this.dropdownContainerElement).not.toHaveClass('open'); expect(this.dropdownContainerElement).not.toHaveClass('open');
let link = $(`${ITEM_SELECTOR}:eq(${randomIndex}) a`, this.$dropdownMenuElement); const link = $(`${ITEM_SELECTOR}:eq(${randomIndex}) a`, this.$dropdownMenuElement);
expect(link).toHaveClass('is-active'); expect(link).toHaveClass('is-active');
let linkedLocation = link.attr('href'); const linkedLocation = link.attr('href');
if (linkedLocation && linkedLocation !== '#') expect(Turbolinks.visit).toHaveBeenCalledWith(linkedLocation); if (linkedLocation && linkedLocation !== '#') expect(Turbolinks.visit).toHaveBeenCalledWith(linkedLocation);
}); });
}); });
...@@ -171,9 +171,8 @@ ...@@ -171,9 +171,8 @@
}); });
}); });
it('should still have input value on close and restore', () => { it('should still have input value on close and restore', () => {
let $searchInput = $(SEARCH_INPUT_SELECTOR); const $searchInput = $(SEARCH_INPUT_SELECTOR);
initDropDown.call(this, false, true); initDropDown.call(this, false, true);
$searchInput $searchInput
.trigger('focus') .trigger('focus')
......
/* eslint-disable no-new, prefer-const */ /* eslint-disable no-new */
/* global IssuableContext */ /* global IssuableContext */
/* global LabelsSelect */ /* global LabelsSelect */
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
LABELS_DATA.push({ id: i, title: `test ${i}`, color: '#5CB85C' }); LABELS_DATA.push({ id: i, title: `test ${i}`, color: '#5CB85C' });
} }
} else if (req.url === '/root/test/issues/2.json') { } else if (req.url === '/root/test/issues/2.json') {
let tmp = []; const tmp = [];
for (let i = 0; i < saveLabelCount; i += 1) { for (let i = 0; i < saveLabelCount; i += 1) {
tmp.push({ id: i, title: `test ${i}`, color: '#5CB85C' }); tmp.push({ id: i, title: `test ${i}`, color: '#5CB85C' });
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment