From ee965008d1016a4cb481c17aca11f146ca748745 Mon Sep 17 00:00:00 2001 From: Sli Date: Thu, 3 Oct 2024 14:25:39 +0200 Subject: [PATCH] Properly fix no-unused-vars warning --- core/static/core/js/script.js | 14 +++++++------- core/static/core/js/sith-select2.js | 8 ++++---- core/static/user/js/user_edit.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/static/core/js/script.js b/core/static/core/js/script.js index 501a801a..775707a3 100644 --- a/core/static/core/js/script.js +++ b/core/static/core/js/script.js @@ -39,21 +39,21 @@ $(function () { }) }) -function createQuickNotif (msg) { // eslint-disable-line no-unused-vars +export function createQuickNotif (msg) { const el = document.createElement('li') el.textContent = msg el.addEventListener('click', () => el.parentNode.removeChild(el)) document.getElementById('quick_notif').appendChild(el) } -function deleteQuickNotifs () { // eslint-disable-line no-unused-vars +export function deleteQuickNotifs () { const el = document.getElementById('quick_notif') while (el.firstChild) { el.removeChild(el.firstChild) } } -function display_notif () { // eslint-disable-line no-unused-vars +export function display_notif () { $('#header_notif').toggle().parent().toggleClass('white') } @@ -63,11 +63,11 @@ function display_notif () { // eslint-disable-line no-unused-vars // Sadly, getting the cookie is not possible with CSRF_COOKIE_HTTPONLY or CSRF_USE_SESSIONS is True // So, the true workaround is to get the token from the dom // https://docs.djangoproject.com/en/2.0/ref/csrf/#acquiring-the-token-if-csrf-use-sessions-is-true -function getCSRFToken () { // eslint-disable-line no-unused-vars +export function getCSRFToken () { return $('[name=csrfmiddlewaretoken]').val() } -const initialUrlParams = new URLSearchParams(window.location.search) // eslint-disable-line no-unused-vars +export const initialUrlParams = new URLSearchParams(window.location.search) /** * @readonly @@ -85,7 +85,7 @@ const History = { * @param {History} action * @param {URL | null} url */ -function update_query_string (key, value, action = History.REPLACE, url = null) { // eslint-disable-line no-unused-vars +export function update_query_string (key, value, action = History.REPLACE, url = null) { if (!url) { url = new URL(window.location.href) } @@ -116,7 +116,7 @@ function update_query_string (key, value, action = History.REPLACE, url = null) * @param {string} url The paginated endpoint to fetch * @return {Promise} */ -async function fetch_paginated (url) { // eslint-disable-line no-unused-vars +export async function fetch_paginated (url) { const max_per_page = 199 const paginated_url = new URL(url, document.location.origin) paginated_url.searchParams.set('page_size', max_per_page.toString()) diff --git a/core/static/core/js/sith-select2.js b/core/static/core/js/sith-select2.js index 7ba0e142..1c25a5ee 100644 --- a/core/static/core/js/sith-select2.js +++ b/core/static/core/js/sith-select2.js @@ -158,7 +158,7 @@ /** * @param {Select2Options} options */ -function sithSelect2 (options) { // eslint-disable-line no-unused-vars +export function sithSelect2 (options) { const elem = $(options.element) return elem.select2({ theme: elem[0].multiple ? 'classic' : 'default', @@ -180,7 +180,7 @@ function sithSelect2 (options) { // eslint-disable-line no-unused-vars * @param {Select2Object[]} source The array containing the data * @param {RemoteSourceOptions} options */ -function local_data_source (source, options) { // eslint-disable-line no-unused-vars +export function local_data_source (source, options) { if (options.excluded) { const ids = options.excluded() return { data: source.filter((i) => !ids.includes(i.id)) } @@ -203,7 +203,7 @@ function local_data_source (source, options) { // eslint-disable-line no-unused- * @param {string} source The url of the endpoint * @param {RemoteSourceOptions} options */ -function remote_data_source (source, options) { // eslint-disable-line no-unused-vars +export function remote_data_source (source, options) { jQuery.ajaxSettings.traditional = true const params = { url: source, @@ -231,7 +231,7 @@ function remote_data_source (source, options) { // eslint-disable-line no-unused return { ajax: params } } -function item_formatter (user) { // eslint-disable-line no-unused-vars +export function item_formatter (user) { if (user.loading) { return user.text } diff --git a/core/static/user/js/user_edit.js b/core/static/user/js/user_edit.js index d6ee2d28..ca14c4c4 100644 --- a/core/static/user/js/user_edit.js +++ b/core/static/user/js/user_edit.js @@ -1,6 +1,6 @@ /* eslint-disable camelcase */ /* global DataTransfer */ -function alpine_webcam_builder ( // eslint-disable-line no-unused-vars +export function alpine_webcam_builder ( default_picture, delete_url, can_delete_picture