Some eslint suggestions

This commit is contained in:
Jaifroid 2023-12-04 09:59:13 +00:00
parent 16f5f75309
commit d2271e472c
3 changed files with 18 additions and 16 deletions

View File

@ -1,6 +1,6 @@
'use strict';
/* global params */
/* global params, assetsCache */
/* eslint-disable indent */
import uiUtil from './uiUtil.js';
@ -223,7 +223,7 @@ var settingsStore = {
return null;
}
if (params.storeType !== 'local_storage') {
return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[-.+*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
return decodeURIComponent(document.cookie.replace(new RegExp('(?:(?:^|.*;)\\s*' + encodeURIComponent(sKey).replace(/[-.+*]/g, '\\$&') + '\\s*\\=\\s*([^;]*).*$)|^.*$'), '$1')) || null;
} else {
return localStorage.getItem(keyPrefix + sKey);
}
@ -233,21 +233,21 @@ var settingsStore = {
if (!sKey || /^(?:expires|max-age|path|domain|secure)$/i.test(sKey)) {
return false;
}
var sExpires = "";
var sExpires = '';
if (vEnd) {
switch (vEnd.constructor) {
case Number:
sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
sExpires = vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : '; max-age=' + vEnd;
break;
case String:
sExpires = "; expires=" + vEnd;
sExpires = '; expires=' + vEnd;
break;
case Date:
sExpires = "; expires=" + vEnd.toUTCString();
sExpires = '; expires=' + vEnd.toUTCString();
break;
}
}
document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
document.cookie = encodeURIComponent(sKey) + '=' + encodeURIComponent(sValue) + sExpires + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '') + (bSecure ? '; secure' : '');
} else {
localStorage.setItem(keyPrefix + sKey, sValue);
}
@ -258,7 +258,7 @@ var settingsStore = {
return false;
}
if (params.storeType !== 'local_storage') {
document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
document.cookie = encodeURIComponent(sKey) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT' + (sDomain ? '; domain=' + sDomain : '') + (sPath ? '; path=' + sPath : '');
} else {
localStorage.removeItem(keyPrefix + sKey);
}
@ -269,12 +269,14 @@ var settingsStore = {
return false;
}
if (params.storeType !== 'local_storage') {
return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[-.+*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
return (new RegExp('(?:^|;\\s*)' + encodeURIComponent(sKey).replace(/[-.+*]/g, '\\$&') + '\\s*\\=')).test(document.cookie);
} else {
return localStorage.getItem(keyPrefix + sKey) !== null;
}
},
_cookieKeys: function () {
// Disabling linter check because this is library code
// eslint-disable-next-line no-useless-backreference
var aKeys = document.cookie.replace(/((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:=[^;]*)?(?:\1|$)/g, '').split(/\s*(?:=[^;]*)?;\s*/);
for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) {
aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);

View File

@ -1149,7 +1149,7 @@ function reportSearchProviderToAPIStatusPanel (provider) {
}
/**
* Warn the user that he/she clicked on an external link, and open it in a new tab
* Warn the user that they clicked on an external link, and open it in a new tab
*
* @param {Event} event The click event (on an anchor) to handle (optional, but if not provided, clickedAnchor must be provided)
* @param {Element} clickedAnchor The DOM anchor that has been clicked (optional, defaults to event.target)