Commit 57961bbd authored by Lukas Eipert's avatar Lukas Eipert

Fix eslint prefer-arrow-callback rule

This fixes all disabled lints for the `prefer-arrow-callback` rule:
https://eslint.org/docs/rules/prefer-arrow-callback
parent c12f6cdf
/* eslint-disable func-names, no-var, prefer-arrow-callback */ /* eslint-disable func-names, no-var */
import $ from 'jquery'; import $ from 'jquery';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -45,26 +45,22 @@ MarkdownPreview.prototype.showPreview = function($form) { ...@@ -45,26 +45,22 @@ MarkdownPreview.prototype.showPreview = function($form) {
this.hideReferencedUsers($form); this.hideReferencedUsers($form);
} else { } else {
preview.addClass('md-preview-loading').text(__('Loading...')); preview.addClass('md-preview-loading').text(__('Loading...'));
this.fetchMarkdownPreview( this.fetchMarkdownPreview(mdText, url, response => {
mdText, var body;
url, if (response.body.length > 0) {
function(response) { ({ body } = response);
var body; } else {
if (response.body.length > 0) { body = this.emptyMessage;
({ body } = response); }
} else {
body = this.emptyMessage; preview.removeClass('md-preview-loading').html(body);
} preview.renderGFM();
this.renderReferencedUsers(response.references.users, $form);
preview.removeClass('md-preview-loading').html(body);
preview.renderGFM(); if (response.references.commands) {
this.renderReferencedUsers(response.references.users, $form); this.renderReferencedCommands(response.references.commands, $form);
}
if (response.references.commands) { });
this.renderReferencedCommands(response.references.commands, $form);
}
}.bind(this),
);
} }
}; };
...@@ -132,12 +128,12 @@ const markdownToolbar = $('.md-header-toolbar'); ...@@ -132,12 +128,12 @@ const markdownToolbar = $('.md-header-toolbar');
$.fn.setupMarkdownPreview = function() { $.fn.setupMarkdownPreview = function() {
var $form = $(this); var $form = $(this);
$form.find('textarea.markdown-area').on('input', function() { $form.find('textarea.markdown-area').on('input', () => {
markdownPreview.hideReferencedUsers($form); markdownPreview.hideReferencedUsers($form);
}); });
}; };
$(document).on('markdown-preview:show', function(e, $form) { $(document).on('markdown-preview:show', (e, $form) => {
if (!$form) { if (!$form) {
return; return;
} }
...@@ -162,7 +158,7 @@ $(document).on('markdown-preview:show', function(e, $form) { ...@@ -162,7 +158,7 @@ $(document).on('markdown-preview:show', function(e, $form) {
markdownPreview.showPreview($form); markdownPreview.showPreview($form);
}); });
$(document).on('markdown-preview:hide', function(e, $form) { $(document).on('markdown-preview:hide', (e, $form) => {
if (!$form) { if (!$form) {
return; return;
} }
...@@ -191,7 +187,7 @@ $(document).on('markdown-preview:hide', function(e, $form) { ...@@ -191,7 +187,7 @@ $(document).on('markdown-preview:hide', function(e, $form) {
markdownPreview.hideReferencedCommands($form); markdownPreview.hideReferencedCommands($form);
}); });
$(document).on('markdown-preview:toggle', function(e, keyboardEvent) { $(document).on('markdown-preview:toggle', (e, keyboardEvent) => {
var $target; var $target;
$target = $(keyboardEvent.target); $target = $(keyboardEvent.target);
if ($target.is('textarea.markdown-area')) { if ($target.is('textarea.markdown-area')) {
......
/* eslint-disable func-names, prefer-arrow-callback */ /* eslint-disable func-names */
import $ from 'jquery'; import $ from 'jquery';
import Dropzone from 'dropzone'; import Dropzone from 'dropzone';
...@@ -43,18 +43,18 @@ export default class BlobFileDropzone { ...@@ -43,18 +43,18 @@ export default class BlobFileDropzone {
previewsContainer: '.dropzone-previews', previewsContainer: '.dropzone-previews',
headers: csrf.headers, headers: csrf.headers,
init() { init() {
this.on('addedfile', function() { this.on('addedfile', () => {
toggleLoading(submitButton, submitButtonLoadingIcon, false); toggleLoading(submitButton, submitButtonLoadingIcon, false);
dropzoneMessage.addClass(HIDDEN_CLASS); dropzoneMessage.addClass(HIDDEN_CLASS);
$('.dropzone-alerts') $('.dropzone-alerts')
.html('') .html('')
.hide(); .hide();
}); });
this.on('removedfile', function() { this.on('removedfile', () => {
toggleLoading(submitButton, submitButtonLoadingIcon, false); toggleLoading(submitButton, submitButtonLoadingIcon, false);
dropzoneMessage.removeClass(HIDDEN_CLASS); dropzoneMessage.removeClass(HIDDEN_CLASS);
}); });
this.on('success', function(header, response) { this.on('success', (header, response) => {
$('#modal-upload-blob').modal('hide'); $('#modal-upload-blob').modal('hide');
visitUrl(response.filePath); visitUrl(response.filePath);
}); });
...@@ -62,7 +62,7 @@ export default class BlobFileDropzone { ...@@ -62,7 +62,7 @@ export default class BlobFileDropzone {
dropzoneMessage.addClass(HIDDEN_CLASS); dropzoneMessage.addClass(HIDDEN_CLASS);
this.removeFile(file); this.removeFile(file);
}); });
this.on('sending', function(file, xhr, formData) { this.on('sending', (file, xhr, formData) => {
formData.append('branch_name', form.find('.js-branch-name').val()); formData.append('branch_name', form.find('.js-branch-name').val());
formData.append('create_merge_request', form.find('.js-create-merge-request').val()); formData.append('create_merge_request', form.find('.js-create-merge-request').val());
formData.append('commit_message', form.find('.js-commit-message').val()); formData.append('commit_message', form.find('.js-commit-message').val());
......
/* eslint-disable func-names, prefer-arrow-callback */ /* eslint-disable func-names */
import $ from 'jquery'; import $ from 'jquery';
import { visitUrl } from './lib/utils/url_utility'; import { visitUrl } from './lib/utils/url_utility';
...@@ -12,11 +12,11 @@ export default class BuildArtifacts { ...@@ -12,11 +12,11 @@ export default class BuildArtifacts {
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
disablePropagation() { disablePropagation() {
$('.top-block').on('click', '.download', function(e) { $('.top-block').on('click', '.download', e => {
return e.stopPropagation(); e.stopPropagation();
}); });
return $('.tree-holder').on('click', 'tr[data-link] a', function(e) { return $('.tree-holder').on('click', 'tr[data-link] a', e => {
return e.stopImmediatePropagation(); e.stopImmediatePropagation();
}); });
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
......
/* eslint-disable func-names, no-var, prefer-arrow-callback, no-else-return, consistent-return, prefer-template, one-var, no-return-assign, no-unused-expressions, no-sequences */ /* eslint-disable func-names, no-var, no-else-return, consistent-return, prefer-template, one-var, no-return-assign, no-unused-expressions, no-sequences */
import $ from 'jquery'; import $ from 'jquery';
...@@ -13,14 +13,14 @@ export default class ImageFile { ...@@ -13,14 +13,14 @@ export default class ImageFile {
$('.two-up.view .frame.deleted img', this.file), $('.two-up.view .frame.deleted img', this.file),
(function(_this) { (function(_this) {
return function() { return function() {
return _this.requestImageInfo($('.two-up.view .frame.added img', _this.file), function() { return _this.requestImageInfo($('.two-up.view .frame.added img', _this.file), () => {
_this.initViewModes(); _this.initViewModes();
// Load two-up view after images are loaded // Load two-up view after images are loaded
// so that we can display the correct width and height information // so that we can display the correct width and height information
const $images = $('.two-up.view img', _this.file); const $images = $('.two-up.view img', _this.file);
$images.waitForImages(function() { $images.waitForImages(() => {
_this.initView('two-up'); _this.initView('two-up');
}); });
}); });
...@@ -138,7 +138,7 @@ export default class ImageFile { ...@@ -138,7 +138,7 @@ export default class ImageFile {
return $(this).width(availWidth / 2); return $(this).width(availWidth / 2);
} }
}); });
return _this.requestImageInfo($('img', wrap), function(width, height) { return _this.requestImageInfo($('img', wrap), (width, height) => {
$('.image-info .meta-width', wrap).text(width + 'px'); $('.image-info .meta-width', wrap).text(width + 'px');
$('.image-info .meta-height', wrap).text(height + 'px'); $('.image-info .meta-height', wrap).text(height + 'px');
return $('.image-info', wrap).removeClass('hide'); return $('.image-info', wrap).removeClass('hide');
...@@ -175,7 +175,7 @@ export default class ImageFile { ...@@ -175,7 +175,7 @@ export default class ImageFile {
wrapPadding = parseInt($swipeWrap.css('right').replace('px', ''), 10); wrapPadding = parseInt($swipeWrap.css('right').replace('px', ''), 10);
_this.initDraggable($swipeBar, wrapPadding, function(e, left) { _this.initDraggable($swipeBar, wrapPadding, (e, left) => {
if (left > 0 && left < $swipeFrame.width() - wrapPadding * 2) { if (left > 0 && left < $swipeFrame.width() - wrapPadding * 2) {
$swipeWrap.width(maxWidth + 1 - left); $swipeWrap.width(maxWidth + 1 - left);
$swipeBar.css('left', left); $swipeBar.css('left', left);
...@@ -215,7 +215,7 @@ export default class ImageFile { ...@@ -215,7 +215,7 @@ export default class ImageFile {
$frameAdded.css('opacity', 1); $frameAdded.css('opacity', 1);
framePadding = parseInt($frameAdded.css('right').replace('px', ''), 10); framePadding = parseInt($frameAdded.css('right').replace('px', ''), 10);
_this.initDraggable($dragger, framePadding, function(e, left) { _this.initDraggable($dragger, framePadding, (e, left) => {
var opacity = left / dragTrackWidth; var opacity = left / dragTrackWidth;
if (opacity >= 0 && opacity <= 1) { if (opacity >= 0 && opacity <= 1) {
......
/* eslint-disable func-names, prefer-arrow-callback */ /* eslint-disable func-names */
import $ from 'jquery'; import $ from 'jquery';
import Api from './api'; import Api from './api';
...@@ -50,7 +50,7 @@ export default class CreateLabelDropdown { ...@@ -50,7 +50,7 @@ export default class CreateLabelDropdown {
this.$dropdownBack.on('click', this.resetForm.bind(this)); this.$dropdownBack.on('click', this.resetForm.bind(this));
this.$cancelButton.on('click', function(e) { this.$cancelButton.on('click', e => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
......
/* eslint-disable func-names, no-underscore-dangle, no-var, one-var, vars-on-top, no-shadow, no-cond-assign, prefer-arrow-callback, no-return-assign, no-else-return, camelcase, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func */ /* eslint-disable func-names, no-underscore-dangle, no-var, one-var, vars-on-top, no-shadow, no-cond-assign, no-return-assign, no-else-return, camelcase, no-lonely-if, guard-for-in, no-restricted-syntax, consistent-return, prefer-template, no-param-reassign, no-loop-func */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -35,13 +35,13 @@ GitLabDropdownInput = (function() { ...@@ -35,13 +35,13 @@ GitLabDropdownInput = (function() {
); );
this.input this.input
.on('keydown', function(e) { .on('keydown', e => {
var keyCode = e.which; var keyCode = e.which;
if (keyCode === 13 && !options.elIsInput) { if (keyCode === 13 && !options.elIsInput) {
e.preventDefault(); e.preventDefault();
} }
}) })
.on('input', function(e) { .on('input', e => {
var val = e.currentTarget.value || _this.options.inputFieldName; var val = e.currentTarget.value || _this.options.inputFieldName;
val = val val = val
.split(' ') .split(' ')
...@@ -95,42 +95,33 @@ GitLabDropdownFilter = (function() { ...@@ -95,42 +95,33 @@ GitLabDropdownFilter = (function() {
// Key events // Key events
timeout = ''; timeout = '';
this.input this.input
.on('keydown', function(e) { .on('keydown', e => {
var keyCode = e.which; var keyCode = e.which;
if (keyCode === 13 && !options.elIsInput) { if (keyCode === 13 && !options.elIsInput) {
e.preventDefault(); e.preventDefault();
} }
}) })
.on( .on('input', () => {
'input', if (this.input.val() !== '' && !$inputContainer.hasClass(HAS_VALUE_CLASS)) {
function() { $inputContainer.addClass(HAS_VALUE_CLASS);
if (this.input.val() !== '' && !$inputContainer.hasClass(HAS_VALUE_CLASS)) { } else if (this.input.val() === '' && $inputContainer.hasClass(HAS_VALUE_CLASS)) {
$inputContainer.addClass(HAS_VALUE_CLASS); $inputContainer.removeClass(HAS_VALUE_CLASS);
} else if (this.input.val() === '' && $inputContainer.hasClass(HAS_VALUE_CLASS)) { }
$inputContainer.removeClass(HAS_VALUE_CLASS); // Only filter asynchronously only if option remote is set
} if (this.options.remote) {
// Only filter asynchronously only if option remote is set clearTimeout(timeout);
if (this.options.remote) { return (timeout = setTimeout(() => {
clearTimeout(timeout); $inputContainer.parent().addClass('is-loading');
return (timeout = setTimeout(
function() { return this.options.query(this.input.val(), data => {
$inputContainer.parent().addClass('is-loading'); $inputContainer.parent().removeClass('is-loading');
return this.options.callback(data);
return this.options.query( });
this.input.val(), }, 250));
function(data) { } else {
$inputContainer.parent().removeClass('is-loading'); return this.filter(this.input.val());
return this.options.callback(data); }
}.bind(this), });
);
}.bind(this),
250,
));
} else {
return this.filter(this.input.val());
}
}.bind(this),
);
} }
GitLabDropdownFilter.prototype.shouldBlur = function(keyCode) { GitLabDropdownFilter.prototype.shouldBlur = function(keyCode) {
...@@ -175,9 +166,7 @@ GitLabDropdownFilter = (function() { ...@@ -175,9 +166,7 @@ GitLabDropdownFilter = (function() {
key: this.options.keys, key: this.options.keys,
}); });
if (tmp.length) { if (tmp.length) {
results[key] = tmp.map(function(item) { results[key] = tmp.map(item => item);
return item;
});
} }
} }
} }
...@@ -453,32 +442,28 @@ GitLabDropdown = (function() { ...@@ -453,32 +442,28 @@ GitLabDropdown = (function() {
if (this.dropdown.find('.dropdown-toggle-page').length) { if (this.dropdown.find('.dropdown-toggle-page').length) {
selector = '.dropdown-page-one .dropdown-content a'; selector = '.dropdown-page-one .dropdown-content a';
} }
this.dropdown.on( this.dropdown.on('click', selector, e => {
'click', var $el, selected, selectedObj, isMarking;
selector, $el = $(e.currentTarget);
function(e) { selected = self.rowClicked($el);
var $el, selected, selectedObj, isMarking; selectedObj = selected ? selected[0] : null;
$el = $(e.currentTarget); isMarking = selected ? selected[1] : null;
selected = self.rowClicked($el); if (this.options.clicked) {
selectedObj = selected ? selected[0] : null; this.options.clicked.call(this, {
isMarking = selected ? selected[1] : null; selectedObj,
if (this.options.clicked) { $el,
this.options.clicked.call(this, { e,
selectedObj, isMarking,
$el, });
e, }
isMarking,
});
}
// Update label right after all modifications in dropdown has been done // Update label right after all modifications in dropdown has been done
if (this.options.toggleLabel) { if (this.options.toggleLabel) {
this.updateLabel(selectedObj, $el, this); this.updateLabel(selectedObj, $el, this);
} }
$el.trigger('blur'); $el.trigger('blur');
}.bind(this), });
);
} }
} }
...@@ -525,9 +510,7 @@ GitLabDropdown = (function() { ...@@ -525,9 +510,7 @@ GitLabDropdown = (function() {
name, name,
), ),
); );
this.renderData(groupData, name).map(function(item) { this.renderData(groupData, name).map(item => html.push(item));
return html.push(item);
});
} }
} else { } else {
// Render each row // Render each row
...@@ -708,7 +691,7 @@ GitLabDropdown = (function() { ...@@ -708,7 +691,7 @@ GitLabDropdown = (function() {
return text return text
.split('') .split('')
.map(function(character, i) { .map((character, i) => {
if (indexOf.call(occurrences, i) !== -1) { if (indexOf.call(occurrences, i) !== -1) {
return '<b>' + character + '</b>'; return '<b>' + character + '</b>';
} else { } else {
......
/* eslint-disable consistent-return, func-names, array-callback-return, prefer-arrow-callback */ /* eslint-disable consistent-return, func-names, array-callback-return */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -45,7 +45,7 @@ export default { ...@@ -45,7 +45,7 @@ export default {
this.getSelectedIssues().map(function() { this.getSelectedIssues().map(function() {
const labelsData = $(this).data('labels'); const labelsData = $(this).data('labels');
if (labelsData) { if (labelsData) {
return labelsData.map(function(labelId) { return labelsData.map(labelId => {
if (labels.indexOf(labelId) === -1) { if (labels.indexOf(labelId) === -1) {
return labels.push(labelId); return labels.push(labelId);
} }
......
/* eslint-disable no-useless-return, func-names, no-var, no-underscore-dangle, prefer-arrow-callback, one-var, prefer-template, no-new, consistent-return, no-shadow, no-param-reassign, vars-on-top, no-lonely-if, no-else-return, dot-notation, no-empty */ /* eslint-disable no-useless-return, func-names, no-var, no-underscore-dangle, one-var, prefer-template, no-new, consistent-return, no-shadow, no-param-reassign, vars-on-top, no-lonely-if, no-else-return, dot-notation, no-empty */
/* global Issuable */ /* global Issuable */
/* global ListLabel */ /* global ListLabel */
...@@ -24,7 +24,7 @@ export default class LabelsSelect { ...@@ -24,7 +24,7 @@ export default class LabelsSelect {
$els = $('.js-label-select'); $els = $('.js-label-select');
} }
$els.each(function(i, dropdown) { $els.each((i, dropdown) => {
var $block, var $block,
$dropdown, $dropdown,
$form, $form,
...@@ -172,9 +172,7 @@ export default class LabelsSelect { ...@@ -172,9 +172,7 @@ export default class LabelsSelect {
$sidebarCollapsedValue.text(labelCount); $sidebarCollapsedValue.text(labelCount);
if (data.labels.length) { if (data.labels.length) {
labelTitles = data.labels.map(function(label) { labelTitles = data.labels.map(label => label.title);
return label.title;
});
if (labelTitles.length > 5) { if (labelTitles.length > 5) {
labelTitles = labelTitles.slice(0, 5); labelTitles = labelTitles.slice(0, 5);
...@@ -456,9 +454,7 @@ export default class LabelsSelect { ...@@ -456,9 +454,7 @@ export default class LabelsSelect {
); );
} else { } else {
var { labels } = boardsStore.detail.issue; var { labels } = boardsStore.detail.issue;
labels = labels.filter(function(selectedLabel) { labels = labels.filter(selectedLabel => selectedLabel.id !== label.id);
return selectedLabel.id !== label.id;
});
boardsStore.detail.issue.labels = labels; boardsStore.detail.issue.labels = labels;
} }
......
/* eslint-disable func-names, no-var, consistent-return, prefer-arrow-callback, no-return-assign */ /* eslint-disable no-var, consistent-return, no-return-assign */
function notificationGranted(message, opts, onclick) { function notificationGranted(message, opts, onclick) {
var notification; var notification;
notification = new Notification(message, opts); notification = new Notification(message, opts);
setTimeout(function() { setTimeout(
// Hide the notification after X amount of seconds () =>
return notification.close(); // Hide the notification after X amount of seconds
}, 8000); notification.close(),
8000,
);
return (notification.onclick = onclick || notification.close); return (notification.onclick = onclick || notification.close);
} }
...@@ -32,7 +34,7 @@ function notifyMe(message, body, icon, onclick) { ...@@ -32,7 +34,7 @@ function notifyMe(message, body, icon, onclick) {
// If it's okay let's create a notification // If it's okay let's create a notification
return notificationGranted(message, opts, onclick); return notificationGranted(message, opts, onclick);
} else if (Notification.permission !== 'denied') { } else if (Notification.permission !== 'denied') {
return Notification.requestPermission(function(permission) { return Notification.requestPermission(permission => {
// If the user accepts, let's create a notification // If the user accepts, let's create a notification
if (permission === 'granted') { if (permission === 'granted') {
return notificationGranted(message, opts, onclick); return notificationGranted(message, opts, onclick);
......
/* eslint-disable func-names, no-var, no-param-reassign, one-var, operator-assignment, no-else-return, prefer-template, prefer-arrow-callback, consistent-return */ /* eslint-disable func-names, no-var, no-param-reassign, one-var, operator-assignment, no-else-return, prefer-template, consistent-return */
import $ from 'jquery'; import $ from 'jquery';
import { insertText } from '~/lib/utils/common_utils'; import { insertText } from '~/lib/utils/common_utils';
...@@ -218,7 +218,7 @@ export function insertMarkdownText({ ...@@ -218,7 +218,7 @@ export function insertMarkdownText({
: blockTagText(text, textArea, blockTag, selected); : blockTagText(text, textArea, blockTag, selected);
} else { } else {
textToInsert = selectedSplit textToInsert = selectedSplit
.map(function(val) { .map(val => {
if (tag.indexOf(textPlaceholder) > -1) { if (tag.indexOf(textPlaceholder) > -1) {
return tag.replace(textPlaceholder, val); return tag.replace(textPlaceholder, val);
} }
...@@ -301,7 +301,7 @@ export function addMarkdownListeners(form) { ...@@ -301,7 +301,7 @@ export function addMarkdownListeners(form) {
export function addEditorMarkdownListeners(editor) { export function addEditorMarkdownListeners(editor) {
$('.js-md') $('.js-md')
.off('click') .off('click')
.on('click', function(e) { .on('click', e => {
const { mdTag, mdBlock, mdPrepend, mdSelect } = $(e.currentTarget).data(); const { mdTag, mdBlock, mdPrepend, mdSelect } = $(e.currentTarget).data();
insertMarkdownText({ insertMarkdownText({
......
/* eslint-disable func-names, no-var, no-underscore-dangle, one-var, consistent-return, prefer-arrow-callback */ /* eslint-disable func-names, no-var, no-underscore-dangle, one-var, consistent-return */
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -105,7 +105,7 @@ MergeRequest.prototype.submitNoteForm = function(form, $button) { ...@@ -105,7 +105,7 @@ MergeRequest.prototype.submitNoteForm = function(form, $button) {
}; };
MergeRequest.prototype.initCommitMessageListeners = function() { MergeRequest.prototype.initCommitMessageListeners = function() {
$(document).on('click', 'a.js-with-description-link', function(e) { $(document).on('click', 'a.js-with-description-link', e => {
var textarea = $('textarea.js-commit-message'); var textarea = $('textarea.js-commit-message');
e.preventDefault(); e.preventDefault();
...@@ -114,7 +114,7 @@ MergeRequest.prototype.initCommitMessageListeners = function() { ...@@ -114,7 +114,7 @@ MergeRequest.prototype.initCommitMessageListeners = function() {
$('.js-without-description-hint').show(); $('.js-without-description-hint').show();
}); });
$(document).on('click', 'a.js-without-description-link', function(e) { $(document).on('click', 'a.js-without-description-link', e => {
var textarea = $('textarea.js-commit-message'); var textarea = $('textarea.js-commit-message');
e.preventDefault(); e.preventDefault();
......
/* eslint-disable func-names, no-else-return, prefer-template, prefer-arrow-callback */ /* eslint-disable no-else-return, prefer-template */
import $ from 'jquery'; import $ from 'jquery';
import Api from './api'; import Api from './api';
...@@ -27,7 +27,7 @@ export default class NamespaceSelect { ...@@ -27,7 +27,7 @@ export default class NamespaceSelect {
} }
}, },
data(term, dataCallback) { data(term, dataCallback) {
return Api.namespaces(term, function(namespaces) { return Api.namespaces(term, namespaces => {
if (isFilter) { if (isFilter) {
const anyNamespace = { const anyNamespace = {
text: __('Any namespace'), text: __('Any namespace'),
......
/* eslint-disable func-names, no-var, one-var, no-loop-func, consistent-return, prefer-template, prefer-arrow-callback, camelcase */ /* eslint-disable func-names, no-var, one-var, no-loop-func, consistent-return, prefer-template, camelcase */
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '../locale'; import { __ } from '../locale';
...@@ -259,9 +259,7 @@ export default (function() { ...@@ -259,9 +259,7 @@ export default (function() {
opacity: 0, opacity: 0,
cursor: 'pointer', cursor: 'pointer',
}) })
.click(function() { .click(() => window.open(options.commit_url.replace('%s', commit.id), '_blank'))
return window.open(options.commit_url.replace('%s', commit.id), '_blank');
})
.hover( .hover(
function() { function() {
this.tooltip = r.commitTooltip(x + 5, y, commit); this.tooltip = r.commitTooltip(x + 5, y, commit);
......
/* eslint-disable func-names, no-var, one-var, consistent-return, no-return-assign, prefer-arrow-callback, prefer-template, no-shadow, no-else-return, @gitlab/i18n/no-non-i18n-strings */ /* eslint-disable func-names, no-var, one-var, consistent-return, no-return-assign, prefer-template, no-shadow, no-else-return, @gitlab/i18n/no-non-i18n-strings */
import $ from 'jquery'; import $ from 'jquery';
import RefSelectDropdown from './ref_select_dropdown'; import RefSelectDropdown from './ref_select_dropdown';
...@@ -63,7 +63,7 @@ export default class NewBranchForm { ...@@ -63,7 +63,7 @@ export default class NewBranchForm {
}; };
formatter = function(values, restriction) { formatter = function(values, restriction) {
var formatted; var formatted;
formatted = values.map(function(value) { formatted = values.map(value => {
switch (false) { switch (false) {
case !/\s/.test(value): case !/\s/.test(value):
return 'spaces'; return 'spaces';
......
/* eslint-disable no-restricted-properties, func-names, no-var, camelcase, /* eslint-disable no-restricted-properties, func-names, no-var, camelcase,
no-unused-expressions, one-var, default-case, no-unused-expressions, one-var, default-case,
prefer-template, consistent-return, no-alert, no-return-assign, prefer-template, consistent-return, no-alert, no-return-assign,
no-param-reassign, prefer-arrow-callback, no-else-return, vars-on-top, no-param-reassign, no-else-return, vars-on-top,
no-shadow, no-useless-escape, class-methods-use-this */ no-shadow, no-useless-escape, class-methods-use-this */
/* global ResolveService */ /* global ResolveService */
...@@ -1370,7 +1370,7 @@ export default class Notes { ...@@ -1370,7 +1370,7 @@ export default class Notes {
.find('li.system-note') .find('li.system-note')
.has('ul'); .has('ul');
$.each(systemNotes, function(index, systemNote) { $.each(systemNotes, (index, systemNote) => {
const $systemNote = $(systemNote); const $systemNote = $(systemNote);
const headerMessage = $systemNote const headerMessage = $systemNote
.find('.note-text') .find('.note-text')
......
/* eslint-disable func-names, no-restricted-syntax, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, no-return-assign, prefer-arrow-callback, prefer-template, no-else-return, no-shadow */ /* eslint-disable func-names, no-restricted-syntax, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, no-return-assign, prefer-template, no-else-return, no-shadow */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -69,24 +69,18 @@ export const ContributorsGraph = (function() { ...@@ -69,24 +69,18 @@ export const ContributorsGraph = (function() {
ContributorsGraph.set_y_domain = function(data) { ContributorsGraph.set_y_domain = function(data) {
return (ContributorsGraph.prototype.y_domain = [ return (ContributorsGraph.prototype.y_domain = [
0, 0,
d3.max(data, function(d) { d3.max(data, d => (d.commits = d.commits || d.additions || d.deletions)),
return (d.commits = d.commits || d.additions || d.deletions);
}),
]); ]);
}; };
ContributorsGraph.init_x_domain = function(data) { ContributorsGraph.init_x_domain = function(data) {
return (ContributorsGraph.prototype.x_domain = d3.extent(data, function(d) { return (ContributorsGraph.prototype.x_domain = d3.extent(data, d => d.date));
return d.date;
}));
}; };
ContributorsGraph.init_y_domain = function(data) { ContributorsGraph.init_y_domain = function(data) {
return (ContributorsGraph.prototype.y_domain = [ return (ContributorsGraph.prototype.y_domain = [
0, 0,
d3.max(data, function(d) { d3.max(data, d => (d.commits = d.commits || d.additions || d.deletions)),
return (d.commits = d.commits || d.additions || d.deletions);
}),
]); ]);
}; };
...@@ -180,9 +174,7 @@ export const ContributorsMasterGraph = (function(superClass) { ...@@ -180,9 +174,7 @@ export const ContributorsMasterGraph = (function(superClass) {
ContributorsMasterGraph.prototype.parse_dates = function(data) { ContributorsMasterGraph.prototype.parse_dates = function(data) {
const parseDate = d3.timeParse('%Y-%m-%d'); const parseDate = d3.timeParse('%Y-%m-%d');
return data.forEach(function(d) { return data.forEach(d => (d.date = parseDate(d.date)));
return (d.date = parseDate(d.date));
});
}; };
ContributorsMasterGraph.prototype.create_scale = function() { ContributorsMasterGraph.prototype.create_scale = function() {
...@@ -216,11 +208,9 @@ export const ContributorsMasterGraph = (function(superClass) { ...@@ -216,11 +208,9 @@ export const ContributorsMasterGraph = (function(superClass) {
ContributorsMasterGraph.prototype.create_area = function(x, y) { ContributorsMasterGraph.prototype.create_area = function(x, y) {
return (this.area = d3 return (this.area = d3
.area() .area()
.x(function(d) { .x(d => x(d.date))
return x(d.date);
})
.y0(this.height) .y0(this.height)
.y1(function(d) { .y1(d => {
d.commits = d.commits || d.additions || d.deletions; d.commits = d.commits || d.additions || d.deletions;
return y(d.commits); return y(d.commits);
})); }));
...@@ -330,7 +320,7 @@ export const ContributorsAuthorGraph = (function(superClass) { ...@@ -330,7 +320,7 @@ export const ContributorsAuthorGraph = (function(superClass) {
ContributorsAuthorGraph.prototype.create_area = function(x, y) { ContributorsAuthorGraph.prototype.create_area = function(x, y) {
return (this.area = d3 return (this.area = d3
.area() .area()
.x(function(d) { .x(d => {
const parseDate = d3.timeParse('%Y-%m-%d'); const parseDate = d3.timeParse('%Y-%m-%d');
return x(parseDate(d)); return x(parseDate(d));
}) })
......
/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign, prefer-arrow-callback, consistent-return, no-cond-assign, no-else-return */ /* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign, consistent-return, no-cond-assign, no-else-return */
import _ from 'underscore'; import _ from 'underscore';
export default { export default {
...@@ -76,16 +76,12 @@ export default { ...@@ -76,16 +76,12 @@ export default {
var log, total_data; var log, total_data;
log = parsed_log.total; log = parsed_log.total;
total_data = this.pick_field(log, field); total_data = this.pick_field(log, field);
return _.sortBy(total_data, function(d) { return _.sortBy(total_data, d => d.date);
return d.date;
});
}, },
pick_field(log, field) { pick_field(log, field) {
var total_data; var total_data;
total_data = []; total_data = [];
_.each(log, function(d) { _.each(log, d => total_data.push(_.pick(d, [field, 'date'])));
return total_data.push(_.pick(d, [field, 'date']));
});
return total_data; return total_data;
}, },
get_author_data(parsed_log, field, date_range) { get_author_data(parsed_log, field, date_range) {
...@@ -107,9 +103,7 @@ export default { ...@@ -107,9 +103,7 @@ export default {
}; };
})(this), })(this),
); );
return _.sortBy(author_data, function(d) { return _.sortBy(author_data, d => d[field]).reverse();
return d[field];
}).reverse();
}, },
parse_log_entry(log_entry, field, date_range) { parse_log_entry(log_entry, field, date_range) {
var parsed_entry; var parsed_entry;
......
/* eslint-disable func-names, prefer-arrow-callback, consistent-return, */ /* eslint-disable consistent-return */
import $ from 'jquery'; import $ from 'jquery';
import { __ } from './locale'; import { __ } from './locale';
...@@ -40,12 +40,9 @@ export default class SingleFileDiff { ...@@ -40,12 +40,9 @@ export default class SingleFileDiff {
this.$toggleIcon.addClass('fa-caret-down'); this.$toggleIcon.addClass('fa-caret-down');
} }
$('.js-file-title, .click-to-expand', this.file).on( $('.js-file-title, .click-to-expand', this.file).on('click', e => {
'click', this.toggleDiff($(e.target));
function(e) { });
this.toggleDiff($(e.target));
}.bind(this),
);
} }
toggleDiff($target, cb) { toggleDiff($target, cb) {
......
/* eslint-disable func-names, consistent-return, no-var, one-var, no-else-return, prefer-arrow-callback, class-methods-use-this */ /* eslint-disable func-names, consistent-return, no-var, one-var, no-else-return, class-methods-use-this */
import $ from 'jquery'; import $ from 'jquery';
import { visitUrl } from './lib/utils/url_utility'; import { visitUrl } from './lib/utils/url_utility';
...@@ -29,7 +29,7 @@ export default class TreeView { ...@@ -29,7 +29,7 @@ export default class TreeView {
var li, liSelected; var li, liSelected;
li = $('tr.tree-item'); li = $('tr.tree-item');
liSelected = null; liSelected = null;
return $('body').keydown(function(e) { return $('body').keydown(e => {
var next, path; var next, path;
if ($('input:focus').length > 0 && (e.which === 38 || e.which === 40)) { if ($('input:focus').length > 0 && (e.which === 38 || e.which === 40)) {
return false; return false;
......
/* eslint-disable func-names, one-var, no-var, prefer-rest-params, vars-on-top, prefer-arrow-callback, consistent-return, no-shadow, no-else-return, no-self-compare, prefer-template, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */ /* eslint-disable func-names, one-var, no-var, prefer-rest-params, vars-on-top, consistent-return, no-shadow, no-else-return, no-self-compare, prefer-template, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */
/* global Issuable */ /* global Issuable */
/* global emitSidebarEvent */ /* global emitSidebarEvent */
...@@ -250,16 +250,12 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -250,16 +250,12 @@ function UsersSelect(currentUser, els, options = {}) {
return $dropdown.glDropdown({ return $dropdown.glDropdown({
showMenuAbove, showMenuAbove,
data(term, callback) { data(term, callback) {
return _this.users( return _this.users(term, options, users => {
term, // GitLabDropdownFilter returns this.instance
options, // GitLabDropdownRemote returns this.options.instance
function(users) { const glDropdown = this.instance || this.options.instance;
// GitLabDropdownFilter returns this.instance glDropdown.options.processData(term, users, callback);
// GitLabDropdownRemote returns this.options.instance });
const glDropdown = this.instance || this.options.instance;
glDropdown.options.processData(term, users, callback);
}.bind(this),
);
}, },
processData(term, data, callback) { processData(term, data, callback) {
let users = data; let users = data;
...@@ -606,7 +602,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -606,7 +602,7 @@ function UsersSelect(currentUser, els, options = {}) {
multiple: $(select).hasClass('multiselect'), multiple: $(select).hasClass('multiselect'),
minimumInputLength: 0, minimumInputLength: 0,
query(query) { query(query) {
return _this.users(query.term, options, function(users) { return _this.users(query.term, options, users => {
var anyUser, data, emailUser, index, len, name, nullUser, obj, ref; var anyUser, data, emailUser, index, len, name, nullUser, obj, ref;
data = { data = {
results: users, results: users,
......
/* eslint-disable func-names, prefer-arrow-callback, consistent-return, camelcase, class-methods-use-this */ /* eslint-disable func-names, consistent-return, camelcase, class-methods-use-this */
// Zen Mode (full screen) textarea // Zen Mode (full screen) textarea
// //
...@@ -39,11 +39,11 @@ export default class ZenMode { ...@@ -39,11 +39,11 @@ export default class ZenMode {
constructor() { constructor() {
this.active_backdrop = null; this.active_backdrop = null;
this.active_textarea = null; this.active_textarea = null;
$(document).on('click', '.js-zen-enter', function(e) { $(document).on('click', '.js-zen-enter', e => {
e.preventDefault(); e.preventDefault();
return $(e.currentTarget).trigger('zen_mode:enter'); return $(e.currentTarget).trigger('zen_mode:enter');
}); });
$(document).on('click', '.js-zen-leave', function(e) { $(document).on('click', '.js-zen-leave', e => {
e.preventDefault(); e.preventDefault();
return $(e.currentTarget).trigger('zen_mode:leave'); return $(e.currentTarget).trigger('zen_mode:leave');
}); });
...@@ -67,7 +67,7 @@ export default class ZenMode { ...@@ -67,7 +67,7 @@ export default class ZenMode {
}; };
})(this), })(this),
); );
$(document).on('keydown', function(e) { $(document).on('keydown', e => {
// Esc // Esc
if (e.keyCode === 27) { if (e.keyCode === 27) {
e.preventDefault(); e.preventDefault();
......
/* eslint-disable prefer-arrow-callback, no-var, one-var, consistent-return, func-names */ /* eslint-disable no-var, one-var, consistent-return, func-names */
import $ from 'jquery'; import $ from 'jquery';
import Api from 'ee/api'; import Api from 'ee/api';
...@@ -14,8 +14,8 @@ export default function initLDAPGroupsSelect() { ...@@ -14,8 +14,8 @@ export default function initLDAPGroupsSelect() {
}; };
import(/* webpackChunkName: 'select2' */ 'select2/select2') import(/* webpackChunkName: 'select2' */ 'select2/select2')
.then(() => { .then(() => {
$('.ajax-ldap-groups-select').each(function(i, select) { $('.ajax-ldap-groups-select').each((i, select) => {
return $(select).select2({ $(select).select2({
id(group) { id(group) {
return group.cn; return group.cn;
}, },
...@@ -24,7 +24,7 @@ export default function initLDAPGroupsSelect() { ...@@ -24,7 +24,7 @@ export default function initLDAPGroupsSelect() {
query(query) { query(query) {
var provider; var provider;
provider = $('#ldap_group_link_provider').val(); provider = $('#ldap_group_link_provider').val();
return Api.ldapGroups(query.term, provider, function(groups) { return Api.ldapGroups(query.term, provider, groups => {
var data; var data;
data = { data = {
results: groups, results: groups,
...@@ -52,7 +52,7 @@ export default function initLDAPGroupsSelect() { ...@@ -52,7 +52,7 @@ export default function initLDAPGroupsSelect() {
}) })
.catch(() => {}); .catch(() => {});
return $('#ldap_group_link_provider').on('change', function() { $('#ldap_group_link_provider').on('change', () => {
return $('.ajax-ldap-groups-select').select2('data', null); $('.ajax-ldap-groups-select').select2('data', null);
}); });
} }
/* eslint-disable no-var, func-names, one-var, prefer-arrow-callback, prefer-template, no-else-return */ /* eslint-disable no-var, func-names, one-var, prefer-template, no-else-return */
import $ from 'jquery'; import $ from 'jquery';
import Api from '~/api'; import Api from '~/api';
...@@ -20,7 +20,7 @@ function AdminEmailSelect() { ...@@ -20,7 +20,7 @@ function AdminEmailSelect() {
order_by: 'id', order_by: 'id',
membership: false, membership: false,
}); });
return Promise.all([projectsFetch, groupsFetch]).then(function([projects, groups]) { return Promise.all([projectsFetch, groupsFetch]).then(([projects, groups]) => {
var all, data; var all, data;
all = { all = {
id: 'all', id: 'all',
......
/* eslint-disable prefer-arrow-callback, one-var, no-var, no-shadow, no-else-return, func-names */ /* eslint-disable one-var, no-var, no-shadow, no-else-return */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import '~/gl_dropdown';
...@@ -6,7 +6,7 @@ import '~/gl_dropdown'; ...@@ -6,7 +6,7 @@ import '~/gl_dropdown';
function WeightSelect(els, options = {}) { function WeightSelect(els, options = {}) {
const $els = $(els || '.js-weight-select'); const $els = $(els || '.js-weight-select');
$els.each(function(i, dropdown) { $els.each((i, dropdown) => {
var $block, $dropdown, $selectbox, $value; var $block, $dropdown, $selectbox, $value;
$dropdown = $(dropdown); $dropdown = $(dropdown);
$selectbox = $dropdown.closest('.selectbox'); $selectbox = $dropdown.closest('.selectbox');
......
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