Properly fix no-unused-vars warning

This commit is contained in:
Antoine Bartuccio 2024-10-03 14:25:39 +02:00
parent c57d2ece9c
commit ee965008d1
3 changed files with 12 additions and 12 deletions

View File

@ -39,21 +39,21 @@ $(function () {
}) })
}) })
function createQuickNotif (msg) { // eslint-disable-line no-unused-vars export function createQuickNotif (msg) {
const el = document.createElement('li') const el = document.createElement('li')
el.textContent = msg el.textContent = msg
el.addEventListener('click', () => el.parentNode.removeChild(el)) el.addEventListener('click', () => el.parentNode.removeChild(el))
document.getElementById('quick_notif').appendChild(el) document.getElementById('quick_notif').appendChild(el)
} }
function deleteQuickNotifs () { // eslint-disable-line no-unused-vars export function deleteQuickNotifs () {
const el = document.getElementById('quick_notif') const el = document.getElementById('quick_notif')
while (el.firstChild) { while (el.firstChild) {
el.removeChild(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') $('#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 // 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 // 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 // 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() 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 * @readonly
@ -85,7 +85,7 @@ const History = {
* @param {History} action * @param {History} action
* @param {URL | null} url * @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) { if (!url) {
url = new URL(window.location.href) 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 * @param {string} url The paginated endpoint to fetch
* @return {Promise<Object[]>} * @return {Promise<Object[]>}
*/ */
async function fetch_paginated (url) { // eslint-disable-line no-unused-vars export async function fetch_paginated (url) {
const max_per_page = 199 const max_per_page = 199
const paginated_url = new URL(url, document.location.origin) const paginated_url = new URL(url, document.location.origin)
paginated_url.searchParams.set('page_size', max_per_page.toString()) paginated_url.searchParams.set('page_size', max_per_page.toString())

View File

@ -158,7 +158,7 @@
/** /**
* @param {Select2Options} options * @param {Select2Options} options
*/ */
function sithSelect2 (options) { // eslint-disable-line no-unused-vars export function sithSelect2 (options) {
const elem = $(options.element) const elem = $(options.element)
return elem.select2({ return elem.select2({
theme: elem[0].multiple ? 'classic' : 'default', 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 {Select2Object[]} source The array containing the data
* @param {RemoteSourceOptions} options * @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) { if (options.excluded) {
const ids = options.excluded() const ids = options.excluded()
return { data: source.filter((i) => !ids.includes(i.id)) } 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 {string} source The url of the endpoint
* @param {RemoteSourceOptions} options * @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 jQuery.ajaxSettings.traditional = true
const params = { const params = {
url: source, url: source,
@ -231,7 +231,7 @@ function remote_data_source (source, options) { // eslint-disable-line no-unused
return { ajax: params } return { ajax: params }
} }
function item_formatter (user) { // eslint-disable-line no-unused-vars export function item_formatter (user) {
if (user.loading) { if (user.loading) {
return user.text return user.text
} }

View File

@ -1,6 +1,6 @@
/* eslint-disable camelcase */ /* eslint-disable camelcase */
/* global DataTransfer */ /* global DataTransfer */
function alpine_webcam_builder ( // eslint-disable-line no-unused-vars export function alpine_webcam_builder (
default_picture, default_picture,
delete_url, delete_url,
can_delete_picture can_delete_picture