Commit 38d450d8 authored by Lukas Eipert's avatar Lukas Eipert

Fix remaining lints for prefer-template

This fixes all disabled lints for the `prefer-template` rule:
https://eslint.org/docs/rules/prefer-template
parent 64274626
/* eslint-disable no-param-reassign, prefer-template, no-void, consistent-return */ /* eslint-disable no-param-reassign, no-void, consistent-return */
import AccessorUtilities from './lib/utils/accessor'; import AccessorUtilities from './lib/utils/accessor';
...@@ -10,7 +10,7 @@ export default class Autosave { ...@@ -10,7 +10,7 @@ export default class Autosave {
if (key.join != null) { if (key.join != null) {
key = key.join('/'); key = key.join('/');
} }
this.key = 'autosave/' + key; this.key = `autosave/${key}`;
this.field.data('autosave', this); this.field.data('autosave', this);
this.restore(); this.restore();
this.field.on('input', () => this.save()); this.field.on('input', () => this.save());
......
/* eslint-disable func-names, no-var, 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, one-var, no-return-assign, no-unused-expressions, no-sequences */
import $ from 'jquery'; import $ from 'jquery';
...@@ -49,13 +49,13 @@ export default class ImageFile { ...@@ -49,13 +49,13 @@ export default class ImageFile {
activateViewMode(viewMode) { activateViewMode(viewMode) {
$('.view-modes-menu li', this.file) $('.view-modes-menu li', this.file)
.removeClass('active') .removeClass('active')
.filter('.' + viewMode) .filter(`.${viewMode}`)
.addClass('active'); .addClass('active');
return $('.view:visible:not(.' + viewMode + ')', this.file).fadeOut( return $(`.view:visible:not(.${viewMode})`, this.file).fadeOut(
200, 200,
(function(_this) { (function(_this) {
return function() { return function() {
$('.view.' + viewMode, _this.file).fadeIn(200); $(`.view.${viewMode}`, _this.file).fadeIn(200);
return _this.initView(viewMode); return _this.initView(viewMode);
}; };
})(this), })(this),
...@@ -139,8 +139,8 @@ export default class ImageFile { ...@@ -139,8 +139,8 @@ export default class ImageFile {
} }
}); });
return _this.requestImageInfo($('img', wrap), (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');
}); });
}; };
......
/* 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 */ /* 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, no-param-reassign, no-loop-func */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -272,7 +272,7 @@ GitLabDropdown = (function() { ...@@ -272,7 +272,7 @@ GitLabDropdown = (function() {
NON_SELECTABLE_CLASSES = '.divider, .separator, .dropdown-header, .dropdown-menu-empty-item'; NON_SELECTABLE_CLASSES = '.divider, .separator, .dropdown-header, .dropdown-menu-empty-item';
SELECTABLE_CLASSES = '.dropdown-content li:not(' + NON_SELECTABLE_CLASSES + ', .option-hidden)'; SELECTABLE_CLASSES = `.dropdown-content li:not(${NON_SELECTABLE_CLASSES}, .option-hidden)`;
CURSOR_SELECT_SCROLL_PADDING = 5; CURSOR_SELECT_SCROLL_PADDING = 5;
...@@ -359,9 +359,9 @@ GitLabDropdown = (function() { ...@@ -359,9 +359,9 @@ GitLabDropdown = (function() {
instance: this, instance: this,
elements: (function(_this) { elements: (function(_this) {
return function() { return function() {
selector = '.dropdown-content li:not(' + NON_SELECTABLE_CLASSES + ')'; selector = `.dropdown-content li:not(${NON_SELECTABLE_CLASSES})`;
if (_this.dropdown.find('.dropdown-toggle-page').length) { if (_this.dropdown.find('.dropdown-toggle-page').length) {
selector = '.dropdown-page-one ' + selector; selector = `.dropdown-page-one ${selector}`;
} }
return $(selector, this.instance.dropdown); return $(selector, this.instance.dropdown);
}; };
...@@ -377,7 +377,7 @@ GitLabDropdown = (function() { ...@@ -377,7 +377,7 @@ GitLabDropdown = (function() {
if (_this.filterInput.val() !== '') { if (_this.filterInput.val() !== '') {
selector = SELECTABLE_CLASSES; selector = SELECTABLE_CLASSES;
if (_this.dropdown.find('.dropdown-toggle-page').length) { if (_this.dropdown.find('.dropdown-toggle-page').length) {
selector = '.dropdown-page-one ' + selector; selector = `.dropdown-page-one ${selector}`;
} }
if ($(_this.el).is('input')) { if ($(_this.el).is('input')) {
currentIndex = -1; currentIndex = -1;
...@@ -693,7 +693,7 @@ GitLabDropdown = (function() { ...@@ -693,7 +693,7 @@ GitLabDropdown = (function() {
.split('') .split('')
.map((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 {
return character; return character;
} }
...@@ -738,9 +738,7 @@ GitLabDropdown = (function() { ...@@ -738,9 +738,7 @@ GitLabDropdown = (function() {
} else if (value != null) { } else if (value != null) {
field = this.dropdown field = this.dropdown
.parent() .parent()
.find( .find(`input[name='${fieldName}'][value='${value.toString().replace(/'/g, "\\'")}']`);
"input[name='" + fieldName + "'][value='" + value.toString().replace(/'/g, "\\'") + "']",
);
} }
if (this.options.isSelectable && !this.options.isSelectable(selectedObject, el)) { if (this.options.isSelectable && !this.options.isSelectable(selectedObject, el)) {
...@@ -766,11 +764,11 @@ GitLabDropdown = (function() { ...@@ -766,11 +764,11 @@ GitLabDropdown = (function() {
} else { } else {
isMarking = true; isMarking = true;
if (!this.options.multiSelect || el.hasClass('dropdown-clear-active')) { if (!this.options.multiSelect || el.hasClass('dropdown-clear-active')) {
this.dropdown.find('.' + ACTIVE_CLASS).removeClass(ACTIVE_CLASS); this.dropdown.find(`.${ACTIVE_CLASS}`).removeClass(ACTIVE_CLASS);
if (!isInput) { if (!isInput) {
this.dropdown this.dropdown
.parent() .parent()
.find("input[name='" + fieldName + "']") .find(`input[name='${fieldName}']`)
.remove(); .remove();
} }
} }
...@@ -809,7 +807,7 @@ GitLabDropdown = (function() { ...@@ -809,7 +807,7 @@ GitLabDropdown = (function() {
var $input; var $input;
// Create hidden input for form // Create hidden input for form
if (single) { if (single) {
$('input[name="' + fieldName + '"]').remove(); $(`input[name="${fieldName}"]`).remove();
} }
$input = $('<input>') $input = $('<input>')
...@@ -837,12 +835,12 @@ GitLabDropdown = (function() { ...@@ -837,12 +835,12 @@ GitLabDropdown = (function() {
var $el, selector; var $el, selector;
// If we pass an option index // If we pass an option index
if (typeof index !== 'undefined') { if (typeof index !== 'undefined') {
selector = SELECTABLE_CLASSES + ':eq(' + index + ') a'; selector = `${SELECTABLE_CLASSES}:eq(${index}) a`;
} else { } else {
selector = '.dropdown-content .is-focused'; selector = '.dropdown-content .is-focused';
} }
if (this.dropdown.find('.dropdown-toggle-page').length) { if (this.dropdown.find('.dropdown-toggle-page').length) {
selector = '.dropdown-page-one ' + selector; selector = `.dropdown-page-one ${selector}`;
} }
// simulate a click on the first link // simulate a click on the first link
$el = $(selector, this.dropdown); $el = $(selector, this.dropdown);
...@@ -861,7 +859,7 @@ GitLabDropdown = (function() { ...@@ -861,7 +859,7 @@ GitLabDropdown = (function() {
ARROW_KEY_CODES = [38, 40]; ARROW_KEY_CODES = [38, 40];
selector = SELECTABLE_CLASSES; selector = SELECTABLE_CLASSES;
if (this.dropdown.find('.dropdown-toggle-page').length) { if (this.dropdown.find('.dropdown-toggle-page').length) {
selector = '.dropdown-page-one ' + selector; selector = `.dropdown-page-one ${selector}`;
} }
return $('body').on( return $('body').on(
'keydown', 'keydown',
......
/* 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 */ /* eslint-disable no-useless-return, func-names, no-var, no-underscore-dangle, one-var, 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 */
...@@ -70,7 +70,7 @@ export default class LabelsSelect { ...@@ -70,7 +70,7 @@ export default class LabelsSelect {
$loading = $block.find('.block-loading').fadeOut(); $loading = $block.find('.block-loading').fadeOut();
fieldName = $dropdown.data('fieldName'); fieldName = $dropdown.data('fieldName');
initialSelected = $selectbox initialSelected = $selectbox
.find('input[name="' + $dropdown.data('fieldName') + '"]') .find(`input[name="${$dropdown.data('fieldName')}"]`)
.map(function() { .map(function() {
return this.value; return this.value;
}) })
...@@ -92,7 +92,7 @@ export default class LabelsSelect { ...@@ -92,7 +92,7 @@ export default class LabelsSelect {
var data, selected; var data, selected;
selected = $dropdown selected = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find("input[name='" + fieldName + "']") .find(`input[name='${fieldName}']`)
.map(function() { .map(function() {
return this.value; return this.value;
}) })
...@@ -267,11 +267,7 @@ export default class LabelsSelect { ...@@ -267,11 +267,7 @@ export default class LabelsSelect {
if ( if (
$form.find( $form.find(
"input[type='hidden'][name='" + `input[type='hidden'][name='${this.fieldName}'][value='${dropdownValue}']`,
this.fieldName +
"'][value='" +
dropdownValue +
"']",
).length ).length
) { ) {
selectedClass.push('is-active'); selectedClass.push('is-active');
...@@ -284,8 +280,7 @@ export default class LabelsSelect { ...@@ -284,8 +280,7 @@ export default class LabelsSelect {
} }
if (label.color) { if (label.color) {
colorEl = colorEl = `<span class='dropdown-label-box' style='background: ${label.color}'></span>`;
"<span class='dropdown-label-box' style='background: " + label.color + "'></span>";
} else { } else {
colorEl = ''; colorEl = '';
} }
......
/* eslint-disable func-names, no-var, no-param-reassign, one-var, operator-assignment, no-else-return, prefer-template, consistent-return */ /* eslint-disable func-names, no-var, no-param-reassign, one-var, operator-assignment, no-else-return, consistent-return */
import $ from 'jquery'; import $ from 'jquery';
import { insertText } from '~/lib/utils/common_utils'; import { insertText } from '~/lib/utils/common_utils';
...@@ -237,7 +237,7 @@ export function insertMarkdownText({ ...@@ -237,7 +237,7 @@ export function insertMarkdownText({
} }
if (removedFirstNewLine) { if (removedFirstNewLine) {
textToInsert = '\n' + textToInsert; textToInsert = `\n${textToInsert}`;
} }
if (removedLastNewLine) { if (removedLastNewLine) {
......
/* eslint-disable func-names, no-var, no-underscore-dangle, no-param-reassign, prefer-template, consistent-return, one-var, no-else-return */ /* eslint-disable func-names, no-var, no-underscore-dangle, no-param-reassign, consistent-return, one-var, no-else-return */
import $ from 'jquery'; import $ from 'jquery';
...@@ -106,7 +106,7 @@ LineHighlighter.prototype.clickHandler = function(event) { ...@@ -106,7 +106,7 @@ LineHighlighter.prototype.clickHandler = function(event) {
}; };
LineHighlighter.prototype.clearHighlight = function() { LineHighlighter.prototype.clearHighlight = function() {
return $('.' + this.highlightLineClass).removeClass(this.highlightLineClass); return $(`.${this.highlightLineClass}`).removeClass(this.highlightLineClass);
}; };
// Convert a URL hash String into line numbers // Convert a URL hash String into line numbers
...@@ -137,7 +137,7 @@ LineHighlighter.prototype.hashToRange = function(hash) { ...@@ -137,7 +137,7 @@ LineHighlighter.prototype.hashToRange = function(hash) {
// //
// lineNumber - Line number to highlight // lineNumber - Line number to highlight
LineHighlighter.prototype.highlightLine = function(lineNumber) { LineHighlighter.prototype.highlightLine = function(lineNumber) {
return $('#LC' + lineNumber).addClass(this.highlightLineClass); return $(`#LC${lineNumber}`).addClass(this.highlightLineClass);
}; };
// Highlight all lines within a range // Highlight all lines within a range
...@@ -162,9 +162,9 @@ LineHighlighter.prototype.highlightRange = function(range) { ...@@ -162,9 +162,9 @@ LineHighlighter.prototype.highlightRange = function(range) {
LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) { LineHighlighter.prototype.setHash = function(firstLineNumber, lastLineNumber) {
var hash; var hash;
if (lastLineNumber) { if (lastLineNumber) {
hash = '#L' + firstLineNumber + '-' + lastLineNumber; hash = `#L${firstLineNumber}-${lastLineNumber}`;
} else { } else {
hash = '#L' + firstLineNumber; hash = `#L${firstLineNumber}`;
} }
this._hash = hash; this._hash = hash;
return this.__setLocationHash__(hash); return this.__setLocationHash__(hash);
......
/* eslint-disable no-else-return, prefer-template */ /* eslint-disable no-else-return */
import $ from 'jquery'; import $ from 'jquery';
import '~/gl_dropdown'; import '~/gl_dropdown';
...@@ -24,7 +24,7 @@ export default class NamespaceSelect { ...@@ -24,7 +24,7 @@ export default class NamespaceSelect {
if (selected.id == null) { if (selected.id == null) {
return selected.text; return selected.text;
} else { } else {
return selected.kind + ': ' + selected.full_path; return `${selected.kind}: ${selected.full_path}`;
} }
}, },
data(term, dataCallback) { data(term, dataCallback) {
...@@ -44,7 +44,7 @@ export default class NamespaceSelect { ...@@ -44,7 +44,7 @@ export default class NamespaceSelect {
if (namespace.id == null) { if (namespace.id == null) {
return namespace.text; return namespace.text;
} else { } else {
return namespace.kind + ': ' + namespace.full_path; return `${namespace.kind}: ${namespace.full_path}`;
} }
}, },
renderRow: this.renderRow, renderRow: this.renderRow,
......
/* eslint-disable func-names, no-var, one-var, no-loop-func, consistent-return, prefer-template, camelcase */ /* eslint-disable func-names, no-var, one-var, no-loop-func, consistent-return, camelcase */
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '../locale'; import { __ } from '../locale';
...@@ -223,7 +223,7 @@ export default (function() { ...@@ -223,7 +223,7 @@ export default (function() {
shortrefs = commit.refs; shortrefs = commit.refs;
// Truncate if longer than 15 chars // Truncate if longer than 15 chars
if (shortrefs.length > 17) { if (shortrefs.length > 17) {
shortrefs = shortrefs.substr(0, 15) + ''; shortrefs = `${shortrefs.substr(0, 15)}…`;
} }
text = r.text(x + 4, y, shortrefs).attr({ text = r.text(x + 4, y, shortrefs).attr({
'text-anchor': 'start', 'text-anchor': 'start',
......
/* 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 */ /* eslint-disable func-names, no-var, one-var, consistent-return, no-return-assign, 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';
...@@ -70,10 +70,10 @@ export default class NewBranchForm { ...@@ -70,10 +70,10 @@ export default class NewBranchForm {
case !/\/{2,}/g.test(value): case !/\/{2,}/g.test(value):
return 'consecutive slashes'; return 'consecutive slashes';
default: default:
return "'" + value + "'"; return `'${value}'`;
} }
}); });
return restriction.prefix + ' ' + formatted.join(restriction.conjunction); return `${restriction.prefix} ${formatted.join(restriction.conjunction)}`;
}; };
validator = (function(_this) { validator = (function(_this) {
return function(errors, restriction) { return function(errors, restriction) {
......
/* 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, consistent-return, no-alert, no-return-assign,
no-param-reassign, 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 */
...@@ -490,7 +490,7 @@ export default class Notes { ...@@ -490,7 +490,7 @@ export default class Notes {
diffAvatarContainer = row diffAvatarContainer = row
.prevAll('.line_holder') .prevAll('.line_holder')
.first() .first()
.find('.js-avatar-container.' + lineType + '_line'); .find(`.js-avatar-container.${lineType}_line`);
// is this the first note of discussion? // is this the first note of discussion?
discussionContainer = $(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`); discussionContainer = $(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`);
if (!discussionContainer.length) { if (!discussionContainer.length) {
...@@ -506,16 +506,14 @@ export default class Notes { ...@@ -506,16 +506,14 @@ export default class Notes {
} else { } else {
// Merge new discussion HTML in // Merge new discussion HTML in
var $notes = $discussion.find(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`); var $notes = $discussion.find(`.notes[data-discussion-id="${noteEntity.discussion_id}"]`);
var contentContainerClass = var contentContainerClass = $notes
'.' + .closest('.notes-content')
$notes .attr('class')
.closest('.notes-content') .split(' ')
.attr('class') .join('.');
.split(' ')
.join('.');
row row
.find(contentContainerClass + ' .content') .find(`.${contentContainerClass} .content`)
.append($notes.closest('.content').children()); .append($notes.closest('.content').children());
} }
} else { } else {
...@@ -722,7 +720,7 @@ export default class Notes { ...@@ -722,7 +720,7 @@ export default class Notes {
this.revertNoteEditForm($targetNote); this.revertNoteEditForm($targetNote);
$noteEntityEl.renderGFM(); $noteEntityEl.renderGFM();
// Find the note's `li` element by ID and replace it with the updated HTML // Find the note's `li` element by ID and replace it with the updated HTML
$note_li = $('.note-row-' + noteEntity.id); $note_li = $(`.note-row-${noteEntity.id}`);
$note_li.replaceWith($noteEntityEl); $note_li.replaceWith($noteEntityEl);
this.setupNewNote($noteEntityEl); this.setupNewNote($noteEntityEl);
......
/* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, prefer-template, no-return-assign */ /* eslint-disable func-names, no-var, one-var, camelcase, no-param-reassign, no-return-assign */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -66,8 +66,8 @@ export default (function() { ...@@ -66,8 +66,8 @@ export default (function() {
class: 'person', class: 'person',
style: 'display: block;', style: 'display: block;',
}); });
author_name = $('<h4>' + author.author_name + '</h4>'); author_name = $(`<h4>${author.author_name}</h4>`);
author_email = $('<p class="graph-author-email">' + author.author_email + '</p>'); author_email = $(`<p class="graph-author-email">${author.author_email}</p>`);
author_commit_info_span = $('<span/>', { author_commit_info_span = $('<span/>', {
class: 'commits', class: 'commits',
}); });
......
/* 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 */ /* eslint-disable func-names, no-restricted-syntax, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, no-return-assign, no-else-return, no-shadow */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -118,14 +118,11 @@ export const ContributorsGraph = (function() { ...@@ -118,14 +118,11 @@ export const ContributorsGraph = (function() {
}; };
ContributorsGraph.prototype.draw_x_axis = function() { ContributorsGraph.prototype.draw_x_axis = function() {
return ( return this.svg
this.svg .append('g')
.append('g') .attr('class', 'x axis')
.attr('class', 'x axis') .attr('transform', `translate(0, ${this.height})`)
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .call(this.x_axis);
.attr('transform', 'translate(0, ' + this.height + ')')
.call(this.x_axis)
);
}; };
ContributorsGraph.prototype.draw_y_axis = function() { ContributorsGraph.prototype.draw_y_axis = function() {
...@@ -200,8 +197,7 @@ export const ContributorsMasterGraph = (function(superClass) { ...@@ -200,8 +197,7 @@ export const ContributorsMasterGraph = (function(superClass) {
.attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom)
.attr('class', 'tint-box') .attr('class', 'tint-box')
.append('g') .append('g')
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .attr('transform', `translate(${this.MARGIN.left},${this.MARGIN.top})`);
.attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')');
return this.svg; return this.svg;
}; };
...@@ -348,8 +344,7 @@ export const ContributorsAuthorGraph = (function(superClass) { ...@@ -348,8 +344,7 @@ export const ContributorsAuthorGraph = (function(superClass) {
.attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom)
.attr('class', 'spark') .attr('class', 'spark')
.append('g') .append('g')
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .attr('transform', `translate(${this.MARGIN.left},${this.MARGIN.top})`);
.attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')');
return this.svg; return this.svg;
}; };
......
/* eslint-disable func-names, no-var, prefer-template */ /* eslint-disable func-names, no-var */
import $ from 'jquery'; import $ from 'jquery';
import BranchGraph from '../../../network/branch_graph'; import BranchGraph from '../../../network/branch_graph';
...@@ -14,7 +14,7 @@ export default (function() { ...@@ -14,7 +14,7 @@ export default (function() {
this.branch_graph = new BranchGraph($('.network-graph'), opts); this.branch_graph = new BranchGraph($('.network-graph'), opts);
vph = $(window).height() - 250; vph = $(window).height() - 250;
$('.network-graph').css({ $('.network-graph').css({
height: vph + 'px', height: `${vph}px`,
}); });
} }
......
/* eslint-disable func-names, no-var, consistent-return, one-var, no-cond-assign, prefer-template, no-return-assign */ /* eslint-disable func-names, no-var, consistent-return, one-var, no-cond-assign, no-return-assign */
import $ from 'jquery'; import $ from 'jquery';
import fuzzaldrinPlus from 'fuzzaldrin-plus'; import fuzzaldrinPlus from 'fuzzaldrin-plus';
...@@ -112,7 +112,7 @@ export default class ProjectFindFile { ...@@ -112,7 +112,7 @@ export default class ProjectFindFile {
if (searchText) { if (searchText) {
matches = fuzzaldrinPlus.match(filePath, searchText); matches = fuzzaldrinPlus.match(filePath, searchText);
} }
blobItemUrl = this.options.blobUrlTemplate + '/' + encodeURIComponent(filePath); blobItemUrl = `${this.options.blobUrlTemplate}/${encodeURIComponent(filePath)}`;
html = ProjectFindFile.makeHtml(filePath, matches, blobItemUrl); html = ProjectFindFile.makeHtml(filePath, matches, blobItemUrl);
results.push(this.element.find('.tree-table > tbody').append(html)); results.push(this.element.find('.tree-table > tbody').append(html));
} }
......
/* eslint-disable func-names, no-var, consistent-return, one-var, prefer-template, no-else-return, no-param-reassign */ /* eslint-disable func-names, no-var, consistent-return, one-var, no-else-return, no-param-reassign */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
...@@ -247,7 +247,7 @@ Sidebar.prototype.isOpen = function() { ...@@ -247,7 +247,7 @@ Sidebar.prototype.isOpen = function() {
}; };
Sidebar.prototype.getBlock = function(name) { Sidebar.prototype.getBlock = function(name) {
return this.sidebar.find('.block.' + name); return this.sidebar.find(`.block.${name}`);
}; };
export default Sidebar; export default Sidebar;
/* eslint-disable no-return-assign, one-var, no-var, consistent-return, prefer-template, class-methods-use-this, no-lonely-if, vars-on-top */ /* eslint-disable no-return-assign, one-var, no-var, consistent-return, class-methods-use-this, no-lonely-if, vars-on-top */
import $ from 'jquery'; import $ from 'jquery';
import { escape, throttle } from 'underscore'; import { escape, throttle } from 'underscore';
...@@ -416,7 +416,7 @@ export class SearchAutocomplete { ...@@ -416,7 +416,7 @@ export class SearchAutocomplete {
inputs = Object.keys(this.originalState); inputs = Object.keys(this.originalState);
for (i = 0, len = inputs.length; i < len; i += 1) { for (i = 0, len = inputs.length; i < len; i += 1) {
input = inputs[i]; input = inputs[i];
this.getElement('#' + input).val(this.originalState[input]); this.getElement(`#${input}`).val(this.originalState[input]);
} }
} }
...@@ -426,7 +426,7 @@ export class SearchAutocomplete { ...@@ -426,7 +426,7 @@ export class SearchAutocomplete {
results = []; results = [];
for (i = 0, len = inputs.length; i < len; i += 1) { for (i = 0, len = inputs.length; i < len; i += 1) {
input = inputs[i]; input = inputs[i];
results.push(this.getElement('#' + input).val('')); results.push(this.getElement(`#${input}`).val(''));
} }
return results; return results;
} }
......
/* 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 */ /* eslint-disable func-names, one-var, no-var, prefer-rest-params, vars-on-top, consistent-return, no-shadow, no-else-return, no-self-compare, no-unused-expressions, yoda, prefer-spread, camelcase, no-param-reassign */
/* global Issuable */ /* global Issuable */
/* global emitSidebarEvent */ /* global emitSidebarEvent */
...@@ -428,8 +428,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -428,8 +428,7 @@ function UsersSelect(currentUser, els, options = {}) {
const isActive = $el.hasClass('is-active'); const isActive = $el.hasClass('is-active');
const previouslySelected = $dropdown const previouslySelected = $dropdown
.closest('.selectbox') .closest('.selectbox')
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .find(`input[name='${$dropdown.data('fieldName')}'][value!=0]`);
.find("input[name='" + $dropdown.data('fieldName') + "'][value!=0]");
// Enables support for limiting the number of users selected // Enables support for limiting the number of users selected
// Automatically removes the first on the list if more users are selected // Automatically removes the first on the list if more users are selected
...@@ -448,7 +447,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -448,7 +447,7 @@ function UsersSelect(currentUser, els, options = {}) {
// Remove unassigned selection (if it was previously selected) // Remove unassigned selection (if it was previously selected)
const unassignedSelected = $dropdown const unassignedSelected = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find("input[name='" + $dropdown.data('fieldName') + "'][value=0]"); .find(`input[name='${$dropdown.data('fieldName')}'][value=0]`);
if (unassignedSelected) { if (unassignedSelected) {
unassignedSelected.remove(); unassignedSelected.remove();
...@@ -502,7 +501,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -502,7 +501,7 @@ function UsersSelect(currentUser, els, options = {}) {
} else if (!$dropdown.hasClass('js-multiselect')) { } else if (!$dropdown.hasClass('js-multiselect')) {
selected = $dropdown selected = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find("input[name='" + $dropdown.data('fieldName') + "']") .find(`input[name='${$dropdown.data('fieldName')}']`)
.val(); .val();
return assignTo(selected); return assignTo(selected);
} }
...@@ -544,7 +543,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -544,7 +543,7 @@ function UsersSelect(currentUser, els, options = {}) {
updateLabel: $dropdown.data('dropdownTitle'), updateLabel: $dropdown.data('dropdownTitle'),
renderRow(user) { renderRow(user) {
var avatar, img, username; var avatar, img, username;
username = user.username ? '@' + user.username : ''; username = user.username ? `@${user.username}` : '';
avatar = user.avatar_url ? user.avatar_url : gon.default_avatar_url; avatar = user.avatar_url ? user.avatar_url : gon.default_avatar_url;
let selected = false; let selected = false;
...@@ -555,7 +554,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -555,7 +554,7 @@ function UsersSelect(currentUser, els, options = {}) {
const { fieldName } = this; const { fieldName } = this;
const field = $dropdown const field = $dropdown
.closest('.selectbox') .closest('.selectbox')
.find("input[name='" + fieldName + "'][value='" + user.id + "']"); .find(`input[name='${fieldName}'][value='${user.id}']`);
if (field.length) { if (field.length) {
selected = true; selected = true;
...@@ -571,7 +570,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -571,7 +570,7 @@ function UsersSelect(currentUser, els, options = {}) {
)}</a></li>`; )}</a></li>`;
} else { } else {
// 0 margin, because it's now handled by a wrapper // 0 margin, because it's now handled by a wrapper
img = "<img src='" + avatar + "' class='avatar avatar-inline m-0' width='32' />"; img = `<img src='${avatar}' class='avatar avatar-inline m-0' width='32' />`;
} }
return _this.renderRow(options.issuableType, user, selected, username, img); return _this.renderRow(options.issuableType, user, selected, username, img);
...@@ -715,7 +714,7 @@ UsersSelect.prototype.formatResult = function(user) { ...@@ -715,7 +714,7 @@ UsersSelect.prototype.formatResult = function(user) {
${_.escape(user.name)} ${_.escape(user.name)}
</div> </div>
<div class='user-username dropdown-menu-user-username text-secondary'> <div class='user-username dropdown-menu-user-username text-secondary'>
${!user.invite ? '@' + _.escape(user.username) : ''} ${!user.invite ? `@${_.escape(user.username)}` : ''}
</div> </div>
</div> </div>
</div> </div>
......
/* eslint-disable no-var, func-names, one-var, prefer-template, no-else-return */ /* eslint-disable no-var, func-names, one-var, no-else-return */
import $ from 'jquery'; import $ from 'jquery';
import Api from '~/api'; import Api from '~/api';
...@@ -33,9 +33,9 @@ function AdminEmailSelect() { ...@@ -33,9 +33,9 @@ function AdminEmailSelect() {
}, },
id(object) { id(object) {
if (object.path_with_namespace) { if (object.path_with_namespace) {
return 'project-' + object.id; return `project-${object.id}`;
} else if (object.path) { } else if (object.path) {
return 'group-' + object.id; return `group-${object.id}`;
} else { } else {
return 'all'; return 'all';
} }
...@@ -60,21 +60,9 @@ function AdminEmailSelect() { ...@@ -60,21 +60,9 @@ function AdminEmailSelect() {
AdminEmailSelect.prototype.formatResult = function(object) { AdminEmailSelect.prototype.formatResult = function(object) {
if (object.path_with_namespace) { if (object.path_with_namespace) {
return ( return `<div class='project-result'> <div class='project-name'>${object.name}</div> <div class='project-path'>${object.path_with_namespace}</div> </div>`;
"<div class='project-result'> <div class='project-name'>" +
object.name +
"</div> <div class='project-path'>" +
object.path_with_namespace +
'</div> </div>'
);
} else if (object.path) { } else if (object.path) {
return ( return `<div class='group-result'> <div class='group-name'>${object.name}</div> <div class='group-path'>${object.path}</div> </div>`;
"<div class='group-result'> <div class='group-name'>" +
object.name +
"</div> <div class='group-path'>" +
object.path +
'</div> </div>'
);
} else { } else {
return `<div class='group-result'> <div class='group-name'>${__( return `<div class='group-result'> <div class='group-name'>${__(
'All', 'All',
......
/* eslint-disable no-var, prefer-template, no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */ /* eslint-disable no-var, no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */
import $ from 'jquery'; import $ from 'jquery';
import LineHighlighter from '~/line_highlighter'; import LineHighlighter from '~/line_highlighter';
...@@ -8,10 +8,10 @@ describe('LineHighlighter', function() { ...@@ -8,10 +8,10 @@ describe('LineHighlighter', function() {
preloadFixtures('static/line_highlighter.html'); preloadFixtures('static/line_highlighter.html');
clickLine = function(number, eventData = {}) { clickLine = function(number, eventData = {}) {
if ($.isEmptyObject(eventData)) { if ($.isEmptyObject(eventData)) {
return $('#L' + number).click(); return $(`#L${number}`).click();
} else { } else {
const e = $.Event('click', eventData); const e = $.Event('click', eventData);
return $('#L' + number).trigger(e); return $(`#L${number}`).trigger(e);
} }
}; };
beforeEach(function() { beforeEach(function() {
...@@ -42,9 +42,9 @@ describe('LineHighlighter', function() { ...@@ -42,9 +42,9 @@ describe('LineHighlighter', function() {
var line; var line;
new LineHighlighter({ hash: '#L5-25' }); new LineHighlighter({ hash: '#L5-25' });
expect($('.' + this.css).length).toBe(21); expect($(`.${this.css}`).length).toBe(21);
for (line = 5; line <= 25; line += 1) { for (line = 5; line <= 25; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css); expect($(`#LC${line}`)).toHaveClass(this.css);
} }
}); });
...@@ -130,7 +130,7 @@ describe('LineHighlighter', function() { ...@@ -130,7 +130,7 @@ describe('LineHighlighter', function() {
}); });
expect($('#LC13')).toHaveClass(this.css); expect($('#LC13')).toHaveClass(this.css);
expect($('.' + this.css).length).toBe(1); expect($(`.${this.css}`).length).toBe(1);
}); });
it('sets the hash', function() { it('sets the hash', function() {
...@@ -152,9 +152,9 @@ describe('LineHighlighter', function() { ...@@ -152,9 +152,9 @@ describe('LineHighlighter', function() {
shiftKey: true, shiftKey: true,
}); });
expect($('.' + this.css).length).toBe(6); expect($(`.${this.css}`).length).toBe(6);
for (line = 15; line <= 20; line += 1) { for (line = 15; line <= 20; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css); expect($(`#LC${line}`)).toHaveClass(this.css);
} }
}); });
...@@ -165,9 +165,9 @@ describe('LineHighlighter', function() { ...@@ -165,9 +165,9 @@ describe('LineHighlighter', function() {
shiftKey: true, shiftKey: true,
}); });
expect($('.' + this.css).length).toBe(6); expect($(`.${this.css}`).length).toBe(6);
for (line = 5; line <= 10; line += 1) { for (line = 5; line <= 10; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css); expect($(`#LC${line}`)).toHaveClass(this.css);
} }
}); });
}); });
...@@ -188,9 +188,9 @@ describe('LineHighlighter', function() { ...@@ -188,9 +188,9 @@ describe('LineHighlighter', function() {
shiftKey: true, shiftKey: true,
}); });
expect($('.' + this.css).length).toBe(6); expect($(`.${this.css}`).length).toBe(6);
for (line = 5; line <= 10; line += 1) { for (line = 5; line <= 10; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css); expect($(`#LC${line}`)).toHaveClass(this.css);
} }
}); });
...@@ -200,9 +200,9 @@ describe('LineHighlighter', function() { ...@@ -200,9 +200,9 @@ describe('LineHighlighter', function() {
shiftKey: true, shiftKey: true,
}); });
expect($('.' + this.css).length).toBe(6); expect($(`.${this.css}`).length).toBe(6);
for (line = 10; line <= 15; line += 1) { for (line = 10; line <= 15; line += 1) {
expect($('#LC' + line)).toHaveClass(this.css); expect($(`#LC${line}`)).toHaveClass(this.css);
} }
}); });
}); });
......
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