diff --git a/web_src/js/components/DiffCommitSelector.vue b/web_src/js/components/DiffCommitSelector.vue
index d58337e09..cbb1f2087 100644
--- a/web_src/js/components/DiffCommitSelector.vue
+++ b/web_src/js/components/DiffCommitSelector.vue
@@ -103,7 +103,7 @@ export default {
this.menuVisible = !this.menuVisible;
// load our commits when the menu is not yet visible (it'll be toggled after loading)
// and we got no commits
- if (this.commits.length === 0 && this.menuVisible && !this.isLoading) {
+ if (!this.commits.length && this.menuVisible && !this.isLoading) {
this.isLoading = true;
try {
await this.fetchCommits();
@@ -216,7 +216,7 @@ export default {
diff --git a/web_src/js/components/RepoActionView.vue b/web_src/js/components/RepoActionView.vue
index 9a1a04a24..8174189f4 100644
--- a/web_src/js/components/RepoActionView.vue
+++ b/web_src/js/components/RepoActionView.vue
@@ -462,7 +462,7 @@ export function initRepositoryActionView() {
{{ locale.showFullScreen }}
-
+
{{ locale.downloadLogs }}
diff --git a/web_src/js/components/RepoBranchTagSelector.vue b/web_src/js/components/RepoBranchTagSelector.vue
index d297503b2..4e977ab18 100644
--- a/web_src/js/components/RepoBranchTagSelector.vue
+++ b/web_src/js/components/RepoBranchTagSelector.vue
@@ -19,17 +19,19 @@ const sfc = {
});
// TODO: fix this anti-pattern: side-effects-in-computed-properties
- this.active = (items.length === 0 && this.showCreateNewBranch ? 0 : -1);
+ this.active = !items.length && this.showCreateNewBranch ? 0 : -1;
return items;
},
showNoResults() {
- return this.filteredItems.length === 0 && !this.showCreateNewBranch;
+ return !this.filteredItems.length && !this.showCreateNewBranch;
},
showCreateNewBranch() {
if (this.disableCreateBranch || !this.searchTerm) {
return false;
}
- return this.items.filter((item) => item.name.toLowerCase() === this.searchTerm.toLowerCase()).length === 0;
+ return !this.items.filter((item) => {
+ return item.name.toLowerCase() === this.searchTerm.toLowerCase();
+ }).length;
},
formActionUrl() {
return `${this.repoLink}/branches/_new/${this.branchNameSubURL}`;
diff --git a/web_src/js/features/admin/common.js b/web_src/js/features/admin/common.js
index 3c485d67a..4e64bff33 100644
--- a/web_src/js/features/admin/common.js
+++ b/web_src/js/features/admin/common.js
@@ -6,9 +6,7 @@ import {POST} from '../../modules/fetch.js';
const {appSubUrl} = window.config;
export function initAdminCommon() {
- if ($('.page-content.admin').length === 0) {
- return;
- }
+ if (!$('.page-content.admin').length) return;
// check whether appUrl(ROOT_URL) is correct, if not, show an error message
checkAppUrl();
diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js
index e2ce01eb4..18849ba7c 100644
--- a/web_src/js/features/common-global.js
+++ b/web_src/js/features/common-global.js
@@ -19,7 +19,7 @@ const {appUrl, appSubUrl, csrfToken, i18n} = window.config;
export function initGlobalFormDirtyLeaveConfirm() {
// Warn users that try to leave a page after entering data into a form.
// Except on sign-in pages, and for forms marked as 'ignore-dirty'.
- if ($('.user.signin').length === 0) {
+ if (!$('.user.signin').length) {
$('form:not(.ignore-dirty)').areYouSure();
}
}
diff --git a/web_src/js/features/comp/SearchUserBox.js b/web_src/js/features/comp/SearchUserBox.js
index 83d7044f1..081c47425 100644
--- a/web_src/js/features/comp/SearchUserBox.js
+++ b/web_src/js/features/comp/SearchUserBox.js
@@ -34,7 +34,7 @@ export function initCompSearchUserBox() {
}
});
- if (allowEmailInput && items.length === 0 && looksLikeEmailAddressCheck.test(searchQuery)) {
+ if (allowEmailInput && !items.length && looksLikeEmailAddressCheck.test(searchQuery)) {
const resultItem = {
title: searchQuery,
description: allowEmailDescription,
diff --git a/web_src/js/features/repo-diff.js b/web_src/js/features/repo-diff.js
index a3e36dd8f..b704e91bd 100644
--- a/web_src/js/features/repo-diff.js
+++ b/web_src/js/features/repo-diff.js
@@ -214,8 +214,7 @@ function initRepoDiffShowMore() {
export function initRepoDiffView() {
initRepoDiffConversationForm();
- const $diffFileList = $('#diff-file-list');
- if ($diffFileList.length === 0) return;
+ if (!$('#diff-file-list').length) return;
initDiffFileTree();
initDiffCommitSelect();
initRepoDiffShowMore();
diff --git a/web_src/js/features/repo-editor.js b/web_src/js/features/repo-editor.js
index 1ab0a5786..da3bda8c1 100644
--- a/web_src/js/features/repo-editor.js
+++ b/web_src/js/features/repo-editor.js
@@ -39,11 +39,9 @@ function initEditPreviewTab($form) {
}
function initEditorForm() {
- if ($('.repository .edit.form').length === 0) {
- return;
- }
-
- initEditPreviewTab($('.repository .edit.form'));
+ const $form = $('.repository .edit.form');
+ if (!$form) return;
+ initEditPreviewTab($form);
}
function getCursorPosition($e) {
@@ -165,7 +163,7 @@ export function initRepoEditor() {
commitButton?.addEventListener('click', (e) => {
// A modal which asks if an empty file should be committed
- if ($editArea.val().length === 0) {
+ if (!$editArea.val()) {
$('#edit-empty-content-modal').modal({
onApprove() {
$('.edit.form').trigger('submit');
diff --git a/web_src/js/features/repo-findfile.js b/web_src/js/features/repo-findfile.js
index 0411b51f9..cff5068a1 100644
--- a/web_src/js/features/repo-findfile.js
+++ b/web_src/js/features/repo-findfile.js
@@ -77,7 +77,7 @@ function filterRepoFiles(filter) {
const filterResult = filterRepoFilesWeighted(files, filter);
- toggleElem(repoFindFileNoResult, filterResult.length === 0);
+ toggleElem(repoFindFileNoResult, !filterResult.length);
for (const r of filterResult) {
const row = document.createElement('tr');
const cell = document.createElement('td');
diff --git a/web_src/js/features/repo-home.js b/web_src/js/features/repo-home.js
index 2b0e38f08..e195c23c3 100644
--- a/web_src/js/features/repo-home.js
+++ b/web_src/js/features/repo-home.js
@@ -153,11 +153,11 @@ export function initRepoTopicBar() {
$.fn.form.settings.rules.validateTopic = function (_values, regExp) {
const $topics = $topicDropdown.children('a.ui.label');
- const status = $topics.length === 0 || $topics.last()[0].getAttribute('data-value').match(regExp);
+ const status = !$topics.length || $topics.last()[0].getAttribute('data-value').match(regExp);
if (!status) {
$topics.last().removeClass('green').addClass('red');
}
- return status && $topicDropdown.children('a.ui.label.red').length === 0;
+ return status && !$topicDropdown.children('a.ui.label.red').length;
};
$topicForm.form({
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index 492428b32..20a854fb4 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -362,7 +362,7 @@ export async function updateIssuesMeta(url, action, issue_ids, id) {
}
export function initRepoIssueComments() {
- if ($('.repository.view.issue .timeline').length === 0) return;
+ if (!$('.repository.view.issue .timeline').length) return;
$('.re-request-review').on('click', async function (e) {
e.preventDefault();
@@ -377,7 +377,7 @@ export function initRepoIssueComments() {
$(document).on('click', (event) => {
const $urlTarget = $(':target');
- if ($urlTarget.length === 0) return;
+ if (!$urlTarget.length) return;
const urlTargetId = $urlTarget.attr('id');
if (!urlTargetId) return;
@@ -385,7 +385,7 @@ export function initRepoIssueComments() {
const $target = $(event.target);
- if ($target.closest(`#${urlTargetId}`).length === 0) {
+ if (!$target.closest(`#${urlTargetId}`).length) {
const scrollPosition = $(window).scrollTop();
window.location.hash = '';
$(window).scrollTop(scrollPosition);
@@ -478,9 +478,7 @@ export function initRepoPullRequestReview() {
}
// The following part is only for diff views
- if ($('.repository.pull.diff').length === 0) {
- return;
- }
+ if (!$('.repository.pull.diff').length) return;
const $reviewBtn = $('.js-btn-review');
const $panel = $reviewBtn.parent().find('.review-box-panel');
@@ -529,7 +527,7 @@ export function initRepoPullRequestReview() {
const $td = $ntr.find(`.add-comment-${side}`);
const $commentCloud = $td.find('.comment-code-cloud');
- if ($commentCloud.length === 0 && !$ntr.find('button[name="pending_review"]').length) {
+ if (!$commentCloud.length && !$ntr.find('button[name="pending_review"]').length) {
try {
const response = await GET($(this).closest('[data-new-comment-url]').attr('data-new-comment-url'));
const html = await response.text();
@@ -626,7 +624,7 @@ export function initRepoIssueTitleEdit() {
};
const pullrequest_target_update_url = $(this).attr('data-target-update-url');
- if ($editInput.val().length === 0 || $editInput.val() === $issueTitle.text()) {
+ if (!$editInput.val().length || $editInput.val() === $issueTitle.text()) {
$editInput.val($issueTitle.text());
await pullrequest_targetbranch_change(pullrequest_target_update_url);
} else {
diff --git a/web_src/js/features/repo-legacy.js b/web_src/js/features/repo-legacy.js
index 897a00b49..73364cd5b 100644
--- a/web_src/js/features/repo-legacy.js
+++ b/web_src/js/features/repo-legacy.js
@@ -50,9 +50,7 @@ function reloadConfirmDraftComment() {
export function initRepoCommentForm() {
const $commentForm = $('.comment.form');
- if ($commentForm.length === 0) {
- return;
- }
+ if (!$commentForm.length) return;
if ($commentForm.find('.field.combo-editor-dropzone').length) {
// at the moment, if a form has multiple combo-markdown-editors, it must be an issue template form
@@ -202,7 +200,7 @@ export function initRepoCommentForm() {
$($(this).data('id-selector')).addClass('tw-hidden');
}
});
- if (listIds.length === 0) {
+ if (!listIds.length) {
$noSelect.removeClass('tw-hidden');
} else {
$noSelect.addClass('tw-hidden');
@@ -329,7 +327,7 @@ async function onEditContent(event) {
let comboMarkdownEditor;
const setupDropzone = async ($dropzone) => {
- if ($dropzone.length === 0) return null;
+ if (!$dropzone.length) return null;
let disableRemovedfileEvent = false; // when resetting the dropzone (removeAllFiles), disable the "removedfile" event
let fileUuidDict = {}; // to record: if a comment has been saved, then the uploaded files won't be deleted from server when clicking the Remove in the dropzone
@@ -485,9 +483,7 @@ async function onEditContent(event) {
}
export function initRepository() {
- if ($('.page-content.repository').length === 0) {
- return;
- }
+ if (!$('.page-content.repository').length) return;
initRepoBranchTagSelector('.js-branch-tag-selector');
diff --git a/web_src/js/features/repo-settings.js b/web_src/js/features/repo-settings.js
index dc1db8ab2..0ea44130d 100644
--- a/web_src/js/features/repo-settings.js
+++ b/web_src/js/features/repo-settings.js
@@ -71,7 +71,7 @@ export function initRepoSettingSearchTeamBox() {
}
export function initRepoSettingGitHook() {
- if ($('.edit.githook').length === 0) return;
+ if (!$('.edit.githook').length) return;
const filename = document.querySelector('.hook-filename').textContent;
const _promise = createMonaco($('#content')[0], filename, {language: 'shell'});
}
diff --git a/web_src/js/features/user-settings.js b/web_src/js/features/user-settings.js
index 0dd908f34..2d8c53e45 100644
--- a/web_src/js/features/user-settings.js
+++ b/web_src/js/features/user-settings.js
@@ -1,7 +1,7 @@
import {hideElem, showElem} from '../utils/dom.js';
export function initUserSettings() {
- if (document.querySelectorAll('.user.settings.profile').length === 0) return;
+ if (!document.querySelectorAll('.user.settings.profile').length) return;
const usernameInput = document.getElementById('username');
if (!usernameInput) return;