1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Fix lint errors

This commit is contained in:
Bill Thornton 2025-02-20 12:51:59 -05:00
parent 7d9acf30b6
commit 4730a30c3d
29 changed files with 53 additions and 23 deletions

View file

@ -17,6 +17,7 @@ const GenresItemsContainer: FC<GenresItemsContainerProps> = ({
parentId,
collectionType,
itemType
// eslint-disable-next-line sonarjs/function-return-type
}) => {
const { isLoading, data: genresResult } = useGetGenres(itemType, parentId);

View file

@ -6,6 +6,7 @@ import SectionContainer from 'components/common/SectionContainer';
import { CardShape } from 'utils/card';
import type { LibraryViewProps } from 'types/library';
// eslint-disable-next-line sonarjs/function-return-type
const UpcomingView: FC<LibraryViewProps> = ({ parentId }) => {
const { isLoading, data: groupsUpcomingEpisodes } =
useGetGroupsUpcomingEpisodes(parentId);

View file

@ -17,6 +17,7 @@ export interface MovedItem {
playlistItemId: string
}
// eslint-disable-next-line sonarjs/redundant-type-aliases
export type PlayerErrorCode = string;
export interface PlayerStopInfo {

View file

@ -16,6 +16,7 @@ const MarkdownBox: FC<MarkdownBoxProps> = ({
<Box
dangerouslySetInnerHTML={
markdown ?
// eslint-disable-next-line sonarjs/disabled-auto-escaping
{ __html: DOMPurify.sanitize(markdownIt({ html: true }).render(markdown)) } :
undefined
}

View file

@ -9,6 +9,7 @@ interface CardTextProps {
const CardText: FC<CardTextProps> = ({ className, textLine }) => {
const { title, titleAction } = textLine;
// eslint-disable-next-line sonarjs/function-return-type
const renderCardText = () => {
if (titleAction) {
return (

View file

@ -323,7 +323,7 @@ function shouldShowMediaTitle(
}
function shouldShowExtraType(itemExtraType: NullableString) {
return itemExtraType && itemExtraType !== 'Unknown';
return !!(itemExtraType && itemExtraType !== 'Unknown');
}
function shouldShowSeriesYearOrYear(
@ -351,7 +351,7 @@ function shouldShowPersonRoleOrType(
showPersonRoleOrType: boolean | undefined,
item: ItemDto
) {
return showPersonRoleOrType && (item as BaseItemPerson).Role;
return !!(showPersonRoleOrType && (item as BaseItemPerson).Role);
}
function shouldShowParentTitle(

View file

@ -195,6 +195,7 @@ function buildCardsHtmlInternal(items, options) {
if (isVertical) {
html += '</div>';
}
// eslint-disable-next-line sonarjs/no-dead-store
hasOpenSection = false;
}
@ -215,6 +216,7 @@ function buildCardsHtmlInternal(items, options) {
if (options.rows && itemsInRow === 0) {
if (hasOpenRow) {
html += '</div>';
// eslint-disable-next-line sonarjs/no-dead-store
hasOpenRow = false;
}

View file

@ -4,7 +4,7 @@ import globalize from '../../../lib/globalize';
import IconButtonElement from '../../../elements/IconButtonElement';
type AccessScheduleListProps = {
index: number;
index?: number;
DayOfWeek?: string;
StartHour?: number ;
EndHour?: number;

View file

@ -3,7 +3,6 @@ import globalize from 'lib/globalize';
import { getBackdropShape, getPortraitShape, getSquareShape } from 'utils/card';
import { getParameterByName } from 'utils/url';
import { appHost } from './apphost';
import cardBuilder from './cardbuilder/cardBuilder';
import imageLoader from './images/imageLoader';
import layoutManager from './layoutManager';
@ -160,8 +159,10 @@ function loadSection(elem, userId, topParentId, section, isSingleSection) {
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-wrap padded-left padded-right">';
}
let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
cardLayout = false;
// NOTE: Why is card layout always disabled?
// let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
const cardLayout = false;
html += cardBuilder.getCardsHtml(result.Items, {
preferThumb: section.preferThumb,
shape: section.shape,

View file

@ -74,6 +74,7 @@ function fetchWithTimeout(url, options, timeoutMs) {
*/
function paramsToString(params) {
return Object.entries(params)
// eslint-disable-next-line sonarjs/different-types-comparison
.filter(([, v]) => v !== null && v !== undefined && v !== '')
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
.join('&');

View file

@ -389,6 +389,7 @@ function intersectsInternal(a1, a2, b1, b2) {
}
function intersects(a1, a2, b1, b2) {
// eslint-disable-next-line sonarjs/arguments-order
return intersectsInternal(a1, a2, b1, b2) || intersectsInternal(b1, b2, a1, a2);
}

View file

@ -80,7 +80,7 @@ export function handleHlsJsMediaError(instance, reject) {
let now = Date.now();
if (window.performance?.now) {
now = performance.now(); // eslint-disable-line compat/compat
now = performance.now();
}
if (!recoverDecodingErrorDate || (now - recoverDecodingErrorDate) > 3000) {
@ -373,6 +373,7 @@ export function getBufferedRanges(instance, elem) {
start = 0;
}
if (!isValidDuration(end)) {
// eslint-disable-next-line sonarjs/no-dead-store
end = 0;
continue;
}

View file

@ -417,6 +417,7 @@ export function getListViewHtml(options) {
}
if (enableOverview && item.Overview) {
// eslint-disable-next-line sonarjs/disabled-auto-escaping
const overview = DOMPurify.sanitize(markdownIt({ html: true }).render(item.Overview || ''));
html += '<div class="secondary listItem-overview listItemBodyText">';
html += '<bdi>' + overview + '</bdi>';

View file

@ -13,6 +13,7 @@ interface MediaInfoItemProps {
const MediaInfoItem: FC<MediaInfoItemProps> = ({ className, miscInfo }) => {
const { text, textAction, cssClass, type } = miscInfo;
// eslint-disable-next-line sonarjs/function-return-type
const renderText = () => {
if (textAction) {
return (

View file

@ -208,6 +208,7 @@ function getMimeType(type, container) {
}
function getParam(name, url) {
// eslint-disable-next-line sonarjs/single-char-in-character-classes
name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');
const regexS = '[\\?&]' + name + '=([^&#]*)';
const regex = new RegExp(regexS, 'i');
@ -2115,6 +2116,7 @@ export class PlaybackManager {
if (!state) {
playerStates[player.name] = {};
// eslint-disable-next-line sonarjs/no-dead-store
state = playerStates[player.name];
}

View file

@ -90,6 +90,7 @@ class SkipSegment extends PlaybackSubscriber {
elem.classList.remove('no-transition');
}
// eslint-disable-next-line sonarjs/void-use
void elem.offsetWidth;
const hasFocus = document.activeElement && focusManager.isCurrentlyFocusable(document.activeElement);
@ -111,6 +112,7 @@ class SkipSegment extends PlaybackSubscriber {
const elem = this.skipElement;
if (elem) {
elem.classList.remove('no-transition');
// eslint-disable-next-line sonarjs/void-use
void elem.offsetWidth;
requestAnimationFrame(() => {

View file

@ -1,11 +1,14 @@
// TODO: Check if needed and move to external dependency
// From https://github.com/parshap/node-sanitize-filename
// eslint-disable-next-line sonarjs/duplicates-in-character-class
const illegalRe = /[/?<>\\:*|":]/g;
// eslint-disable-next-line no-control-regex
// eslint-disable-next-line no-control-regex, sonarjs/no-control-regex
const controlRe = /[\x00-\x1f\x80-\x9f]/g;
const reservedRe = /^\.+$/;
// eslint-disable-next-line sonarjs/concise-regex
const windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
// eslint-disable-next-line sonarjs/slow-regex
const windowsTrailingRe = /[. ]+$/;
function isHighSurrogate(codePoint) {
@ -64,6 +67,7 @@ function truncate(string, byteLength) {
segment = string[i];
if (isHighSurrogate(codePoint) && isLowSurrogate(string.charCodeAt(i + 1))) {
// eslint-disable-next-line sonarjs/updated-loop-counter
i += 1;
segment += string[i];
}

View file

@ -1,4 +1,3 @@
import { appHost } from 'components/apphost';
import cardBuilder from 'components/cardbuilder/cardBuilder';
import focusManager from 'components/focusManager';
import layoutManager from 'components/layoutManager';
@ -202,8 +201,9 @@ function getRouteUrl(section, serverId) {
function getItemsHtmlFn(section) {
return function (items) {
let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
cardLayout = false;
// NOTE: Why is card layout always disabled?
// let cardLayout = appHost.preferVisualCards && section.autoCardLayout && section.showTitle;
const cardLayout = false;
const serverId = this.apiClient.serverId();
const leadingButtons = layoutManager.tv ? [{
name: globalize.translate('All'),

View file

@ -877,6 +877,7 @@ function renderOverview(page, item) {
const overviewElements = page.querySelectorAll('.overview');
if (overviewElements.length > 0) {
// eslint-disable-next-line sonarjs/disabled-auto-escaping
const overview = DOMPurify.sanitize(markdownIt({ html: true }).render(item.Overview || ''));
if (overview) {
@ -1378,6 +1379,7 @@ function renderChildren(page, item) {
if (item.Type == 'MusicAlbum') {
let showArtist = false;
for (const track of result.Items) {
// eslint-disable-next-line sonarjs/no-alphabetical-sort
if (!isEqual(track.ArtistItems.map(x => x.Id).sort(), track.AlbumArtists.map(x => x.Id).sort())) {
showArtist = true;
break;

View file

@ -36,6 +36,7 @@ function handleConnectionResult(page, result) {
function submitServer(page) {
loading.show();
// eslint-disable-next-line sonarjs/slow-regex
const host = page.querySelector('#txtServerHost').value.replace(/\/+$/, '');
ServerConnections.connectToAddress(host, {
enableAutoLogin: appSettings.enableAutoLogin()

View file

@ -292,6 +292,7 @@ export default function (view, params) {
apiClient.getJSON(apiClient.getUrl('Branding/Configuration')).then(function (options) {
const loginDisclaimer = view.querySelector('.loginDisclaimer');
// eslint-disable-next-line sonarjs/disabled-auto-escaping
loginDisclaimer.innerHTML = DOMPurify.sanitize(markdownIt({ html: true }).render(options.LoginDisclaimer || ''));
for (const elem of loginDisclaimer.querySelectorAll('a')) {

View file

@ -13,7 +13,8 @@ function slideDownToShow(button, elem) {
elem.style.height = '0';
// trigger reflow
// TODO: Find a better way to do this
const newHeight = elem.offsetHeight; /* eslint-disable-line no-unused-vars */
// eslint-disable-next-line @typescript-eslint/no-unused-vars, sonarjs/no-unused-vars, sonarjs/no-dead-store
const newHeight = elem.offsetHeight;
elem.style.height = height;
setTimeout(function () {
@ -35,7 +36,8 @@ function slideUpToHide(button, elem) {
elem.style.height = elem.offsetHeight + 'px';
// trigger reflow
// TODO: Find a better way to do this
const newHeight = elem.offsetHeight; /* eslint-disable-line no-unused-vars */
// eslint-disable-next-line @typescript-eslint/no-unused-vars, sonarjs/no-unused-vars, sonarjs/no-dead-store
const newHeight = elem.offsetHeight;
elem.classList.remove('expanded');
elem.style.height = '0';

View file

@ -161,6 +161,7 @@ function updateValues(isValueSet) {
if (!!isValueSet && !supportsValueAutoSnap) {
const value = snapValue(this, parseFloat(this.value)).toString();
// eslint-disable-next-line sonarjs/different-types-comparison
if (this.value !== value) {
this.value = value;

View file

@ -11,6 +11,7 @@
const realPlay = HTMLMediaElementPrototype.play;
HTMLMediaElementPrototype.play = function () {
// eslint-disable-next-line sonarjs/no-try-promise
try {
const promise = realPlay.apply(this, arguments);

View file

@ -24,6 +24,7 @@ function type(value) {
}
if (typeof value === 'object' || typeof value === 'function') {
// eslint-disable-next-line sonarjs/prefer-regexp-exec
return Object.prototype.toString.call(value).match(/\s([a-z]+)/i)[1].toLowerCase() || 'object';
}

View file

@ -86,7 +86,7 @@ function iOSversion() {
/Version\/(\d+)/
];
for (const test of tests) {
const matches = (navigator.appVersion).match(test);
const matches = RegExp(test).exec(navigator.appVersion);
if (matches) {
return [
parseInt(matches[1], 10),
@ -163,6 +163,7 @@ function supportsCssAnimation(allowPrefix) {
const domPrefixes = ['Webkit', 'O', 'Moz'];
const elm = document.createElement('div');
// eslint-disable-next-line sonarjs/different-types-comparison
if (elm.style.animationName !== undefined) {
animation = true;
}
@ -298,7 +299,7 @@ if (browser.web0s) {
delete browser.chrome;
delete browser.safari;
} else if (browser.tizen) {
const v = (navigator.appVersion).match(/Tizen (\d+).(\d+)/);
const v = RegExp(/Tizen (\d+).(\d+)/).exec(navigator.appVersion);
browser.tizenVersion = parseInt(v[1], 10);
// UserAgent string contains 'Chrome' and 'Safari', but we only want 'tizen' to be true
@ -319,7 +320,6 @@ if (browser.mobile || browser.tv) {
browser.slow = true;
}
/* eslint-disable-next-line compat/compat */
if (typeof document !== 'undefined' && ('ontouchstart' in window) || (navigator.maxTouchPoints > 0)) {
browser.touch = true;
}

View file

@ -230,7 +230,8 @@ function supportsVc1(videoTestElement) {
}
function supportsHdr10(options) {
return options.supportsHdr10 ?? (false // eslint-disable-line sonarjs/no-redundant-boolean
// eslint-disable-next-line no-constant-binary-expression, sonarjs/no-redundant-boolean
return options.supportsHdr10 ?? (false
|| browser.vidaa
|| browser.tizen
|| browser.web0s
@ -253,7 +254,8 @@ function supportsHlg(options) {
}
function supportsDolbyVision(options) {
return options.supportsDolbyVision ?? (false // eslint-disable-line sonarjs/no-redundant-boolean
// eslint-disable-next-line no-constant-binary-expression, sonarjs/no-redundant-boolean
return options.supportsDolbyVision ?? (false
|| browser.safari && ((browser.iOS && browser.iOSVersion >= 13) || browser.osx)
);
}
@ -512,10 +514,8 @@ export default function (options) {
}
}
/* eslint-disable compat/compat */
let maxVideoWidth = browser.xboxOne ? window.screen?.width : null;
/* eslint-enable compat/compat */
if (options.maxVideoWidth) {
maxVideoWidth = options.maxVideoWidth;
}

View file

@ -33,7 +33,7 @@ function textAreaCopy(text) {
} else {
ret = Promise.reject();
}
} catch (_) {
} catch {
ret = Promise.reject();
}
@ -48,11 +48,10 @@ function textAreaCopy(text) {
* @returns {Promise<void>} Promise.
*/
export function copy(text) {
/* eslint-disable-next-line compat/compat */
// eslint-disable-next-line sonarjs/different-types-comparison
if (navigator.clipboard === undefined) {
return textAreaCopy(text);
} else {
/* eslint-disable-next-line compat/compat */
return navigator.clipboard.writeText(text).catch(() => {
return textAreaCopy(text);
});

View file

@ -23,6 +23,7 @@ const DEV_MODE = process.env.NODE_ENV !== 'production';
let COMMIT_SHA = '';
try {
COMMIT_SHA = require('child_process')
// eslint-disable-next-line sonarjs/no-os-command-from-path
.execSync('git describe --always --dirty')
.toString()
.trim();