Commit 60404418 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'justin_ho-fix-no-else-return' into 'master'

Fix no-else-return eslint rule

See merge request gitlab-org/gitlab!30454
parents 632ce4dd 9c96399c
......@@ -22,17 +22,17 @@ rules:
- allow:
- __
- _links
# Disabled for now, to make the airbnb-base 12.1.0 -> 13.1.0 update smoother
no-else-return:
- error
- allowElseIf: true
import/no-unresolved:
- error
- ignore:
# https://gitlab.com/gitlab-org/gitlab/issues/38226
- '^ee_component/'
import/no-useless-path-segments: off
import/order: off
# Disabled for now, to make the airbnb-base 12.1.0 -> 13.1.0 update smoother
no-else-return:
- error
- allowElseIf: true
import/no-useless-path-segments: off
lines-between-class-members: off
# Disabled for now, to make the plugin-vue 4.5 -> 5.0 update smoother
vue/no-confusing-v-for-v-if: error
......
/* eslint-disable func-names, no-else-return, consistent-return, one-var, no-return-assign */
/* eslint-disable func-names, consistent-return, one-var, no-return-assign */
import $ from 'jquery';
......@@ -201,9 +201,8 @@ export default class ImageFile {
if (domImg) {
if (domImg.complete) {
return callback.call(this, domImg.naturalWidth, domImg.naturalHeight);
} else {
return img.on('load', () => callback.call(this, domImg.naturalWidth, domImg.naturalHeight));
}
return img.on('load', () => callback.call(this, domImg.naturalWidth, domImg.naturalHeight));
}
}
}
/* eslint-disable func-names, no-else-return */
/* eslint-disable func-names */
import $ from 'jquery';
import { __ } from './locale';
......@@ -52,9 +52,8 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
return $('<li />')
.addClass('dropdown-header')
.text(ref.header);
} else {
return $('<li />').append(link);
}
return $('<li />').append(link);
},
id(obj, $el) {
return $el.attr('data-ref');
......
/* eslint-disable no-else-return, no-lonely-if */
/* global CommentsStore */
import $ from 'jquery';
......@@ -22,27 +21,19 @@ const CommentAndResolveBtn = Vue.extend({
showButton() {
if (this.discussion) {
return this.discussion.isResolvable();
} else {
return false;
}
return false;
},
isDiscussionResolved() {
return this.discussion.isResolved();
},
buttonText() {
if (this.isDiscussionResolved) {
if (this.textareaIsEmpty) {
return __('Unresolve thread');
} else {
return __('Comment & unresolve thread');
}
} else {
if (this.textareaIsEmpty) {
return __('Resolve thread');
} else {
return __('Comment & resolve thread');
}
return this.isDiscussionResolved ? __('Unresolve thread') : __('Resolve thread');
}
return this.isDiscussionResolved
? __('Comment & unresolve thread')
: __('Comment & resolve thread');
},
},
created() {
......
/* eslint-disable func-names, no-else-return, guard-for-in, no-restricted-syntax, no-lonely-if, no-continue */
/* eslint-disable func-names, guard-for-in, no-restricted-syntax, no-lonely-if, no-continue */
/* global CommentsStore */
import $ from 'jquery';
......@@ -25,9 +25,8 @@ const JumpToDiscussion = Vue.extend({
buttonText() {
if (this.discussionId) {
return __('Jump to next unresolved thread');
} else {
return __('Jump to first unresolved thread');
}
return __('Jump to first unresolved thread');
},
allResolved() {
return this.unresolvedDiscussionCount === 0;
......@@ -36,12 +35,10 @@ const JumpToDiscussion = Vue.extend({
if (this.discussionId) {
if (this.unresolvedDiscussionCount > 1) {
return true;
} else {
}
return this.discussionId !== this.lastResolvedId;
}
} else {
return this.unresolvedDiscussionCount >= 1;
}
},
lastResolvedId() {
let lastId;
......
/* eslint-disable no-useless-return, func-names, no-underscore-dangle, no-new, consistent-return, no-shadow, no-param-reassign, no-lonely-if, no-else-return, dot-notation, no-empty */
/* eslint-disable no-useless-return, func-names, no-underscore-dangle, no-new, consistent-return, no-shadow, no-param-reassign, no-lonely-if, dot-notation, no-empty */
/* global Issuable */
/* global ListLabel */
......@@ -311,9 +311,8 @@ export default class LabelsSelect {
firstLabel: selectedLabels[0],
labelCount: selectedLabels.length - 1,
});
} else {
return defaultLabel;
}
return defaultLabel;
},
fieldName: $dropdown.data('fieldName'),
id(label) {
......@@ -325,9 +324,8 @@ export default class LabelsSelect {
if ($dropdown.hasClass('js-filter-submit') && label.isAny == null) {
return label.title;
} else {
return label.id;
}
return label.id;
},
hidden() {
const page = $('body').attr('data-page');
......
/* eslint-disable func-names, no-param-reassign, operator-assignment, no-else-return, consistent-return */
/* eslint-disable func-names, no-param-reassign, operator-assignment, consistent-return */
import $ from 'jquery';
import { insertText } from '~/lib/utils/common_utils';
......@@ -217,9 +217,8 @@ export function insertMarkdownText({
}
if (val.indexOf(tag) === 0) {
return String(val.replace(tag, ''));
} else {
return String(tag) + val;
}
return String(tag) + val;
})
.join('\n');
}
......
/* eslint-disable func-names, no-underscore-dangle, no-param-reassign, consistent-return, no-else-return */
/* eslint-disable func-names, no-underscore-dangle, no-param-reassign, consistent-return */
import $ from 'jquery';
......@@ -128,9 +128,8 @@ LineHighlighter.prototype.hashToRange = function(hash) {
const first = parseInt(matches[1], 10);
const last = matches[2] ? parseInt(matches[2], 10) : null;
return [first, last];
} else {
return [null, null];
}
return [null, null];
};
// Highlight a single line
......@@ -153,9 +152,8 @@ LineHighlighter.prototype.highlightRange = function(range) {
}
return results;
} else {
return this.highlightLine(range[0]);
}
return this.highlightLine(range[0]);
};
// Set the URL hash string
......
/* eslint-disable one-var, no-else-return, no-self-compare, consistent-return, no-param-reassign, no-shadow */
/* eslint-disable one-var, no-self-compare, consistent-return, no-param-reassign, no-shadow */
/* global Issuable */
/* global ListMilestone */
......@@ -123,9 +123,8 @@ export default class MilestoneSelect {
toggleLabel: (selected, el) => {
if (selected && 'id' in selected && $(el).hasClass('is-active')) {
return selected.title;
} else {
return defaultLabel;
}
return defaultLabel;
},
defaultLabel,
fieldName: $dropdown.data('fieldName'),
......@@ -133,9 +132,8 @@ export default class MilestoneSelect {
id: milestone => {
if (!useId && !$dropdown.is('.js-issuable-form-dropdown')) {
return milestone.name;
} else {
return milestone.id;
}
return milestone.id;
},
hidden: () => {
$selectBox.hide();
......@@ -244,13 +242,12 @@ export default class MilestoneSelect {
)
.find('span')
.text(data.milestone.title);
} else {
}
$value.html(milestoneLinkNoneTemplate);
return $sidebarCollapsedValue
.attr('data-original-title', __('Milestone'))
.find('span')
.text(__('None'));
}
})
.catch(() => {
// eslint-disable-next-line no-jquery/no-fade
......
/* eslint-disable no-else-return */
import $ from 'jquery';
import '~/gl_dropdown';
import Api from './api';
......@@ -23,9 +21,8 @@ export default class NamespaceSelect {
toggleLabel(selected) {
if (selected.id == null) {
return selected.text;
} else {
return `${selected.kind}: ${selected.full_path}`;
}
return `${selected.kind}: ${selected.full_path}`;
},
data(term, dataCallback) {
return Api.namespaces(term, namespaces => {
......@@ -43,9 +40,8 @@ export default class NamespaceSelect {
text(namespace) {
if (namespace.id == null) {
return namespace.text;
} else {
return `${namespace.kind}: ${namespace.full_path}`;
}
return `${namespace.kind}: ${namespace.full_path}`;
},
renderRow: this.renderRow,
clicked(options) {
......
/* eslint-disable func-names, consistent-return, no-return-assign, no-else-return, @gitlab/require-i18n-strings */
/* eslint-disable func-names, consistent-return, no-return-assign, @gitlab/require-i18n-strings */
import $ from 'jquery';
import RefSelectDropdown from './ref_select_dropdown';
......@@ -76,9 +76,8 @@ export default class NewBranchForm {
const matched = this.name.val().match(restriction.pattern);
if (matched) {
return errors.concat(formatter(matched.reduce(unique, []), restriction));
} else {
return errors;
}
return errors;
};
const errors = this.restrictions.reduce(validator, []);
if (errors.length > 0) {
......
/* eslint-disable no-restricted-properties, babel/camelcase,
no-unused-expressions, default-case,
consistent-return, no-alert, no-param-reassign, no-else-return,
consistent-return, no-alert, no-param-reassign,
no-shadow, no-useless-escape,
class-methods-use-this */
......@@ -1123,11 +1123,10 @@ export default class Notes {
if (row.is('.js-temp-notes-holder')) {
// remove temporary row for diff lines
return row.remove();
} else {
}
// only remove the form
return form.remove();
}
}
cancelDiscussionForm(e) {
e.preventDefault();
......
/* eslint-disable func-names, no-else-return */
/* eslint-disable func-names */
import $ from 'jquery';
import Api from './api';
......@@ -74,7 +74,7 @@ const projectSelect = () => {
},
projectsCallback,
);
} else {
}
return Api.projects(
query.term,
{
......@@ -85,7 +85,6 @@ const projectSelect = () => {
},
projectsCallback,
);
}
},
id(project) {
if (simpleFilter) return project.id;
......
/* eslint-disable consistent-return, no-else-return */
/* eslint-disable consistent-return */
import $ from 'jquery';
......@@ -16,11 +16,10 @@ export default function syntaxHighlight(el) {
if ($(el).hasClass('js-syntax-highlight')) {
// Given the element itself, apply highlighting
return $(el).addClass(gon.user_color_scheme);
} else {
}
// Given a parent element, recurse to any of its applicable children
const $children = $(el).find('.js-syntax-highlight');
if ($children.length) {
return syntaxHighlight($children);
}
}
}
/* eslint-disable func-names, consistent-return, one-var, no-else-return, class-methods-use-this */
/* eslint-disable func-names, consistent-return, one-var, class-methods-use-this */
import $ from 'jquery';
import { visitUrl } from './lib/utils/url_utility';
......@@ -15,9 +15,8 @@ export default class TreeView {
if (e.metaKey || e.which === 2) {
e.preventDefault();
return window.open(path, '_blank');
} else {
return visitUrl(path);
}
return visitUrl(path);
}
});
// Show the "Loading commit data" for only the first element
......
/* eslint-disable func-names, prefer-rest-params, consistent-return, no-shadow, no-else-return, no-self-compare, no-unused-expressions, yoda, prefer-spread, babel/camelcase, no-param-reassign */
/* eslint-disable func-names, prefer-rest-params, consistent-return, no-shadow, no-self-compare, no-unused-expressions, yoda, prefer-spread, babel/camelcase, no-param-reassign */
/* global Issuable */
/* global emitSidebarEvent */
......@@ -148,12 +148,11 @@ function UsersSelect(currentUser, els, options = {}) {
name: selectedUser.name,
length: otherSelected.length,
});
} else {
}
return sprintf(s__('UsersSelect|%{name} + %{length} more'), {
name: firstUser.name,
length: selectedUsers.length - 1,
});
}
};
$('.assign-to-me-link').on('click', e => {
......@@ -375,13 +374,11 @@ function UsersSelect(currentUser, els, options = {}) {
$dropdown.find('.dropdown-toggle-text').removeClass('is-default');
if (selected.text) {
return selected.text;
} else {
}
return selected.name;
}
} else {
$dropdown.find('.dropdown-toggle-text').addClass('is-default');
return defaultLabel;
}
},
defaultLabel,
hidden() {
......
/* eslint-disable no-shadow, no-else-return */
/* eslint-disable no-shadow */
import $ from 'jquery';
import '~/gl_dropdown';
......@@ -33,9 +33,8 @@ function WeightSelect(els, options = {}) {
id(obj, el) {
if ($(el).data('none') == null) {
return $(el).data('id');
} else {
return '';
}
return '';
},
clicked(glDropdownEvt) {
const { e } = glDropdownEvt;
......
/* eslint-disable no-else-return, dot-notation, no-return-assign, no-new, no-underscore-dangle */
/* eslint-disable dot-notation, no-return-assign, no-new, no-underscore-dangle */
import $ from 'jquery';
import LineHighlighter from '~/line_highlighter';
......@@ -8,10 +8,9 @@ describe('LineHighlighter', function() {
const clickLine = function(number, eventData = {}) {
if ($.isEmptyObject(eventData)) {
return $(`#L${number}`).click();
} else {
}
const e = $.Event('click', eventData);
return $(`#L${number}`).trigger(e);
}
};
beforeEach(function() {
loadFixtures('static/line_highlighter.html');
......
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