1
0
mirror of https://github.com/jellyfin/jellyfin-web.git synced 2025-04-18 20:24:10 +03:00

Fix unused var and pseudorandom warnings

This commit is contained in:
Bill Thornton 2025-03-27 12:15:56 -04:00
parent 9077782c17
commit ad2472e90e
19 changed files with 31 additions and 30 deletions

View File

@ -367,7 +367,6 @@ export default tseslint.config(
rules: {
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/no-unused-vars': 'warn',
'sonarjs/public-static-readonly': 'off',

View File

@ -484,7 +484,7 @@ function getAirTimeText(item, showAirDateTime, showAirEndTime) {
airTimeText += ' - ' + datetime.getDisplayTime(date);
}
} catch (e) {
console.error('error parsing date: ' + item.StartDate);
console.error('error parsing date: ' + item.StartDate, e);
}
}
@ -617,7 +617,7 @@ function getCardFooterText(item, apiClient, options, footerClass, progressHtml,
datetime.parseISO8601Date(item.PremiereDate),
{ weekday: 'long', month: 'long', day: 'numeric' }
));
} catch (err) {
} catch {
lines.push('');
}
} else {

View File

@ -678,6 +678,7 @@ describe('getDefaultBackgroundClass', () => {
});
test('randomization string provided', () => {
// eslint-disable-next-line sonarjs/pseudo-random
const generateRandomString = (stringLength: number): string => (Math.random() + 1).toString(36).substring(stringLength);
for (let i = 0; i < 100; i++) {

View File

@ -358,7 +358,7 @@ function Guide(options) {
if ((typeof date).toString().toLowerCase() === 'string') {
try {
date = datetime.parseISO8601Date(date, { toLocal: true });
} catch (err) {
} catch {
return date;
}
}
@ -392,7 +392,7 @@ function Guide(options) {
try {
program.StartDateLocal = datetime.parseISO8601Date(program.StartDate, { toLocal: true });
} catch (err) {
console.error('error parsing timestamp for start date');
console.error('error parsing timestamp for start date', err);
}
}
@ -400,7 +400,7 @@ function Guide(options) {
try {
program.EndDateLocal = datetime.parseISO8601Date(program.EndDate, { toLocal: true });
} catch (err) {
console.error('error parsing timestamp for end date');
console.error('error parsing timestamp for end date', err);
}
}

View File

@ -60,7 +60,7 @@ function getProgramInfoHtml(item, options) {
miscInfo.push(text);
} catch (e) {
console.error('error parsing date:', item.StartDate);
console.error('error parsing date:', item.StartDate, e);
}
}
@ -140,7 +140,7 @@ export function getMediaInfoHtml(item, options = {}) {
text = datetime.toLocaleDateString(date);
miscInfo.push(text);
} catch (e) {
console.error('error parsing date:', item.PremiereDate);
console.error('error parsing date:', item.PremiereDate, e);
}
}
@ -170,7 +170,7 @@ export function getMediaInfoHtml(item, options = {}) {
miscInfo.push(text);
}
} catch (e) {
console.error('error parsing date:', item.StartDate);
console.error('error parsing date:', item.StartDate, e);
}
}
@ -188,7 +188,7 @@ export function getMediaInfoHtml(item, options = {}) {
text += ` - ${endYear}`;
}
} catch (e) {
console.error('error parsing date:', item.EndDate);
console.error('error parsing date:', item.EndDate, e);
}
}
@ -238,7 +238,7 @@ export function getMediaInfoHtml(item, options = {}) {
text = globalize.translate('OriginalAirDateValue', datetime.toLocaleDateString(date));
miscInfo.push(text);
} catch (e) {
console.error('error parsing date:', program.PremiereDate);
console.error('error parsing date:', program.PremiereDate, e);
}
} else if (program.ProductionYear && options.year !== false ) {
miscInfo.push(program.ProductionYear);
@ -255,7 +255,7 @@ export function getMediaInfoHtml(item, options = {}) {
text = datetime.toLocaleString(datetime.parseISO8601Date(item.PremiereDate).getFullYear(), { useGrouping: false });
miscInfo.push(text);
} catch (e) {
console.error('error parsing date:', item.PremiereDate);
console.error('error parsing date:', item.PremiereDate, e);
}
}
}

View File

@ -821,7 +821,7 @@ function fillItemInfo(context, item, parentalRatingOptions) {
date = datetime.parseISO8601Date(item.DateCreated, true);
context.querySelector('#txtDateAdded').value = date.toISOString().slice(0, 10);
} catch (e) {
} catch {
context.querySelector('#txtDateAdded').value = '';
}
} else {
@ -833,7 +833,7 @@ function fillItemInfo(context, item, parentalRatingOptions) {
date = datetime.parseISO8601Date(item.PremiereDate, true);
context.querySelector('#txtPremiereDate').value = date.toISOString().slice(0, 10);
} catch (e) {
} catch {
context.querySelector('#txtPremiereDate').value = '';
}
} else {
@ -845,7 +845,7 @@ function fillItemInfo(context, item, parentalRatingOptions) {
date = datetime.parseISO8601Date(item.EndDate, true);
context.querySelector('#txtEndDate').value = date.toISOString().slice(0, 10);
} catch (e) {
} catch {
context.querySelector('#txtEndDate').value = '';
}
} else {

View File

@ -265,7 +265,7 @@ export default function (view) {
document.addEventListener('keydown', onKeyDown);
try {
onLoad();
} catch (e) {
} catch {
appRouter.goHome();
}
});

View File

@ -713,7 +713,7 @@ export default function (view) {
}, state);
}
} catch (e) {
console.error('error parsing date: ' + program.EndDate);
console.error('error parsing date: ' + program.EndDate, e);
}
}
}
@ -1712,7 +1712,7 @@ export default function (view) {
if (browser.firefox || browser.edge) {
dom.addEventListener(document, 'click', onClickCapture, { capture: true });
}
} catch (e) {
} catch {
setBackdropTransparency(TRANSPARENCY_LEVEL.None); // reset state set in viewbeforeshow
appRouter.goHome();
}

View File

@ -61,7 +61,7 @@ function renderUpcoming(elem, items) {
day: 'numeric'
});
} catch (err) {
console.error('error parsing timestamp for upcoming tv shows');
console.error('error parsing timestamp for upcoming tv shows', err);
}
}

View File

@ -79,7 +79,7 @@ export function updateCurrentCulture() {
let culture;
try {
culture = userSettings.language();
} catch (err) {
} catch {
console.error('no language set in user settings');
}
culture = culture || getDefaultLanguage();
@ -92,7 +92,7 @@ export function updateCurrentCulture() {
let dateTimeCulture;
try {
dateTimeCulture = userSettings.dateTimeLocale();
} catch (err) {
} catch {
console.error('no date format set in user settings');
}

View File

@ -22,7 +22,7 @@
// text/html parsing is natively supported
return;
}
} catch (ex) { /* noop */ }
} catch { /* noop */ }
DOMParserPrototype.parseFromString = function (markup, type) {
if (/^\s*text\/html\s*(?:;|$)/i.test(type)) {

View File

@ -8,7 +8,7 @@
try {
new window.KeyboardEvent('event', { bubbles: true, cancelable: true });
} catch (e) {
} catch {
// We can't use `KeyboardEvent` in old WebKit because `initKeyboardEvent`
// doesn't seem to populate some properties (`keyCode`, `which`) that
// are read-only.

View File

@ -13,7 +13,7 @@
if (window.Headers) {
try {
new window.Headers(undefined);
} catch (_) {
} catch {
console.debug('patch \'Headers\' to accept \'undefined\'');
const _Headers = window.Headers;

View File

@ -1512,7 +1512,7 @@ export class HtmlVideoPlayer {
trackElement.removeCue(trackElement.cues[0]);
}
} catch (e) {
console.error('error removing cue from textTrack');
console.error('error removing cue from textTrack', e);
}
trackElement.mode = 'disabled';

View File

@ -211,7 +211,7 @@ export function getDisplayDateTime(date) {
if (typeof date === 'string') {
try {
date = parseISO8601Date(date, true);
} catch (err) {
} catch {
return date;
}
}
@ -227,7 +227,7 @@ export function getDisplayTime(date) {
if (typeof date === 'string') {
try {
date = parseISO8601Date(date, true);
} catch (err) {
} catch {
return date;
}
}

View File

@ -64,7 +64,7 @@ let hasFieldKey = false;
try {
hasFieldKey = 'key' in new KeyboardEvent('keydown');
} catch (e) {
console.error("error checking 'key' field");
console.error("error checking 'key' field", e);
}
if (!hasFieldKey) {

View File

@ -31,7 +31,7 @@ function getScreensaverPlugin(isLoggedIn) {
let option;
try {
option = userSettings.get('screensaver', false);
} catch (err) {
} catch {
option = isLoggedIn ? 'backdropscreensaver' : 'logoscreensaver';
}

View File

@ -61,7 +61,7 @@ export async function serverAddress() {
let config;
try {
config = await resp.json();
} catch (err) {
} catch {
return;
}

View File

@ -9,6 +9,7 @@ function toLocaleStringSupportsOptions() {
* @returns {number} Randomly generated number.
*/
export function randomInt(min: number, max: number): number {
// eslint-disable-next-line sonarjs/pseudo-random
return Math.floor(Math.random() * (max - min + 1)) + min;
}