Fix sonarjs no-small-switch

This commit is contained in:
Bill Thornton 2022-10-08 03:18:30 -04:00
parent 762573bef8
commit 76ed503c81
8 changed files with 29 additions and 46 deletions

View file

@ -77,7 +77,6 @@ module.exports = {
// TODO: Enable the following rules and fix issues
'sonarjs/no-duplicate-string': ['off'],
'sonarjs/no-redundant-jump': ['off'],
'sonarjs/no-small-switch': ['off'],
'sonarjs/prefer-object-literal': ['off'],
'sonarjs/prefer-single-boolean-return': ['off']
},

View file

@ -273,28 +273,23 @@ import { Events } from 'jellyfin-apiclient';
hls.on(Hls.Events.ERROR, function (event, data) {
console.error('HLS Error: Type: ' + data.type + ' Details: ' + (data.details || '') + ' Fatal: ' + (data.fatal || false));
switch (data.type) {
case Hls.ErrorTypes.NETWORK_ERROR:
// try to recover network error
if (data.response && data.response.code && data.response.code >= 400) {
console.debug('hls.js response error code: ' + data.response.code);
// try to recover network error
if (data.type === Hls.ErrorTypes.NETWORK_ERROR
&& data.response?.code && data.response.code >= 400
) {
console.debug('hls.js response error code: ' + data.response.code);
// Trigger failure differently depending on whether this is prior to start of playback, or after
hls.destroy();
// Trigger failure differently depending on whether this is prior to start of playback, or after
hls.destroy();
if (reject) {
reject('servererror');
reject = null;
} else {
onErrorInternal(instance, 'servererror');
}
if (reject) {
reject('servererror');
reject = null;
} else {
onErrorInternal(instance, 'servererror');
}
return;
}
break;
default:
break;
return;
}
if (data.fatal) {

View file

@ -334,12 +334,8 @@ function showDownloadOptions(button, context, subtitleId) {
positionTo: button
}).then(function (id) {
switch (id) {
case 'download':
downloadRemoteSubtitles(context, subtitleId);
break;
default:
break;
if (id === 'download') {
downloadRemoteSubtitles(context, subtitleId);
}
});
});

View file

@ -66,11 +66,9 @@ function renderRecordingFolders(context, promise) {
function onMoreClick() {
const type = this.getAttribute('data-type');
const serverId = ApiClient.serverId();
switch (type) {
case 'latest':
Dashboard.navigate('list.html?type=Recordings&serverId=' + serverId);
if (type === 'latest') {
Dashboard.navigate('list.html?type=Recordings&serverId=' + ApiClient.serverId());
}
}

View file

@ -374,10 +374,9 @@ import Dashboard from '../../utils/dashboard';
}
function onInputCommand(e) {
switch (e.detail.command) {
case 'search':
e.preventDefault();
Dashboard.navigate('search.html?collectionType=movies&parentId=' + params.topParentId);
if (e.detail.command === 'search') {
e.preventDefault();
Dashboard.navigate('search.html?collectionType=movies&parentId=' + params.topParentId);
}
}

View file

@ -348,10 +348,9 @@ import Dashboard from '../../utils/dashboard';
}
function onInputCommand(e) {
switch (e.detail.command) {
case 'search':
e.preventDefault();
Dashboard.navigate('search.html?collectionType=music&parentId=' + params.topParentId);
if (e.detail.command === 'search') {
e.preventDefault();
Dashboard.navigate('search.html?collectionType=music&parentId=' + params.topParentId);
}
}

View file

@ -333,10 +333,9 @@ import autoFocuser from '../../components/autoFocuser';
}
function onInputCommand(e) {
switch (e.detail.command) {
case 'search':
e.preventDefault();
Dashboard.navigate('search.html?collectionType=tv&parentId=' + params.topParentId);
if (e.detail.command === 'search') {
e.preventDefault();
Dashboard.navigate('search.html?collectionType=tv&parentId=' + params.topParentId);
}
}

View file

@ -172,10 +172,8 @@ export class ComicsPlayer {
onWindowKeyUp(e) {
const key = keyboardnavigation.getKeyName(e);
switch (key) {
case 'Escape':
this.stop();
break;
if (key === 'Escape') {
this.stop();
}
}