Skip to content

Commit

Permalink
chore: fix some lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ferferga committed Nov 4, 2024
1 parent 98471ee commit 5f3abeb
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion frontend/scripts/virtual-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const vuetifyExports = localeNames
* Get commit hash
*/
const commit_available = !Number(process.env.IS_STABLE) && Boolean(process.env.COMMIT_HASH);
const commit_hash = commit_available && `'${process.env.COMMIT_HASH}'` || undefined;
const commit_hash = (commit_available && `'${process.env.COMMIT_HASH}'`) || undefined;

/**
* Date-fns exports all english locales with variants, so we need to add the match manually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ const validationRules = [
* Chromium ranges:
* https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/html/media/html_media_element.cc
*/
return num_val >= 0.0625 && num_val <= 16 || t('mustBeInRange', { min: 0.0625, max: 16 });
return (num_val >= 0.0625 && num_val <= 16) || t('mustBeInRange', { min: 0.0625, max: 16 });
}
];
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/components/Dialogs/ConfirmDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<VDivider />
<VCardText
class="text-center d-flex align-center justify-center">
<JSafeHtml :html="innerHtml" />
<JSafeHtml :html="state.text" />
</VCardText>
<VCardActions class="align-center justify-center">
<VBtn
Expand All @@ -33,7 +33,7 @@
variant="elevated"
:color="state.confirmColor ?? 'error'"
@click="confirm">
{{ state.confirmText }}
{{ state.confirmText ?? t('accept') }}
</VBtn>
</VCardActions>
</VCard>
Expand Down Expand Up @@ -89,9 +89,9 @@ export async function useConfirmDialog<T>(
params: ConfirmDialogState,
raiseError = false
): Promise<T | undefined> {
state.title = params.title || '';
state.title = params.title;
state.text = params.text;
state.subtitle = params.subtitle;
state.text = params.text || '';
state.confirmText = params.confirmText;
state.confirmColor = params.confirmColor;
Expand All @@ -109,6 +109,4 @@ export async function useConfirmDialog<T>(
<script setup lang="ts">
const { t } = useI18n();
const innerHtml = computed(() => state.text ?? t('accept'));
</script>
3 changes: 0 additions & 3 deletions frontend/src/components/Forms/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ import IconEye from 'virtual:icons/mdi/eye';
import IconEyeOff from 'virtual:icons/mdi/eye-off';
import { ref, shallowRef } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { fetchIndexPage } from '@/utils/items';
import { remote } from '@/plugins/remote';
import { jsonConfig } from '@/utils/external-config';
Expand All @@ -85,8 +84,6 @@ defineEmits<{
const { t } = useI18n();
const router = useRouter();
const valid = shallowRef(false);
const login = ref({ username: '', password: '', rememberMe: true });
const showPassword = shallowRef(false);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Item/MediaStreamSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const trackIndex = ref<number | null>(defaultStreamIndex ?? mediaStreams.find(tr
if (
(type === 'Video' || type === 'Audio')
&& trackIndex.value === null
&& selectItems.value[0] !== undefined
&& selectItems.value?.[0]
) {
// eslint-disable-next-line unicorn/no-null
trackIndex.value = selectItems.value[0].value ?? null;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/composables/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { apiStore } from '@/store/api';
import { isArray, isNil } from '@/utils/validation';
import { JView_isRouting } from '@/store/keys';

/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-explicit-any */
type OmittedKeys = 'fields' | 'userId' | 'enableImages' | 'enableTotalRecordCount' | 'enableImageTypes';
type ParametersAsGetters<T extends (...args: any[]) => any> = T extends (...args: infer P) => any
? { [K in keyof P]: () => BetterOmit<Mutable<P[K]>, OmittedKeys> }
Expand Down Expand Up @@ -470,4 +470,4 @@ export function methodsAsObject<T extends Record<K, (...args: any[]) => any>, K
};
}

/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return */
/* eslint-enable @typescript-eslint/no-explicit-any */
4 changes: 2 additions & 2 deletions frontend/src/composables/use-datefns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as datefnslocales from 'virtual:locales/date-fns';
import { i18n } from '@/plugins/i18n';
import { isObj } from '@/utils/validation';

/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-explicit-any */

/**
* Use any date fns function with proper localization, based on the current locale.
Expand Down Expand Up @@ -35,4 +35,4 @@ export function useDateFns<T extends (...a: any[]) => any>(
return func(...params);
}

/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
/* eslint-enable @typescript-eslint/no-explicit-any */
2 changes: 1 addition & 1 deletion frontend/src/pages/genre/[itemId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const route = useRoute('/genre/[itemId]');
const { itemId } = route.params;
const includeItemTypes = computed<BaseItemKind[]>(() => {
const typesQuery = route.query.type as BaseItemKind ?? [];
const typesQuery = route.query.type ?? [] as BaseItemKind;
return isStr(typesQuery)
? [typesQuery]
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/pages/server/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,13 @@ meta:
import type { UserDto } from '@jellyfin/sdk/lib/generated-client';
import { ref, shallowRef, computed, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { remote } from '@/plugins/remote';
import { jsonConfig } from '@/utils/external-config';
import { usePageTitle } from '@/composables/page-title';
import { useSnackbar } from '@/composables/use-snackbar';
import { isConnectedToServer } from '@/store';
const { t } = useI18n();
const router = useRouter();
usePageTitle(() => t('login'));
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/plugins/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { DirectiveBinding } from 'vue';
* Toggles the CSS 'visibility' property of an element.
*/
export function hideDirective(
element: HTMLElement,
element: HTMLElement | undefined,
binding: DirectiveBinding<boolean>
): void {
if (element) {
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/store/playback-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,10 +838,6 @@ class PlaybackManagerStore extends CommonStore<PlaybackManagerState> {
itemId
}));

if (!items.value) {
throw new Error('No items found');
}

for (const item of items.value) {
await this.addToQueue(item);
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/utils/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export function getImageTag(
case ImageType.Primary: {
return (
item.AlbumPrimaryImageTag
|| item.ChannelPrimaryImageTag
|| item.ParentPrimaryImageTag
|| undefined
?? item.ChannelPrimaryImageTag
?? item.ParentPrimaryImageTag
?? undefined
);
}
case ImageType.Art: {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/utils/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ export function canPlay(item: BaseItemDto | undefined): boolean {
'Series',
'Trailer',
'Video'
].includes(item.Type || '')
|| ['Video', 'Audio'].includes(item.MediaType || '')
].includes(item.Type ?? '')
|| ['Video', 'Audio'].includes(item.MediaType ?? '')
|| item.IsFolder
);
}
Expand Down Expand Up @@ -285,7 +285,7 @@ export function canMarkWatched(item: BaseItemDto): boolean {
*/
export function canInstantMix(item: BaseItemDto): boolean {
return ['Audio', 'MusicAlbum', 'MusicArtist', 'MusicGenre'].includes(
item.Type || ''
item.Type ?? ''
);
}

Expand Down Expand Up @@ -328,7 +328,7 @@ export function getItemDetailsLink(
if (!isPerson(item) && isLibrary(item)) {
routeName = '/library/[itemId]';
} else {
const type = overrideType || item.Type;
const type = overrideType ?? item.Type;

switch (type) {
case 'Series': {
Expand Down
30 changes: 24 additions & 6 deletions packages/configs/lint/rules/typescript-vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import globals from 'globals';
import vueParser from 'vue-eslint-parser';
import { eqeqeqConfig, vueAndTsFiles, vueFiles, tsFiles } from '../shared';

const recommendedKey = 'flat/recommended';

/**
* Util functions
*/
Expand All @@ -34,11 +36,11 @@ const common = [
name: '(@jellyfin-vue/configs/lint/typescript-vue - typescript-eslint) Extended config from plugin (ESLint rules with type checking)'
},
{
...regexp.configs['flat/recommended'],
...regexp.configs[recommendedKey],
name: '(@jellyfin-vue/configs/lint/typescript-vue - regexp) Extended config from plugin'
},
{
...promise.configs['flat/recommended'],
...promise.configs[recommendedKey],
name: '(@jellyfin-vue/configs/lint/typescript-vue - promise) Extended config from plugin'
},
{
Expand Down Expand Up @@ -77,10 +79,26 @@ const common = [
'jsdoc/informative-docs': 'error'
}
},
/**
* TODO: Re-enable this at some point when the type checking is improved.
* These rules are annoying when using not well-supported TypeScript libraries
* and imported SFC files are not recognised properly and needs the use of:
* https://github.com/ota-meshi/typescript-eslint-parser-for-extra-files
*/
{
name: '(@jellyfin-vue/configs/lint/typescript-vue - TypeScript & Vue) Disable no-unsafe-* rules',
rules: {
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-return': 'off'
}
},
{
name: '(@jellyfin-vue/configs/lint/typescript-vue - TypeScript & Vue) Custom config',
rules: {
'@typescript-eslint/no-redundant-type-constituents': 'off',
// '@typescript-eslint/no-redundant-type-constituents': 'off',
'@typescript-eslint/restrict-template-expressions': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-dynamic-delete': 'off',
Expand Down Expand Up @@ -116,7 +134,7 @@ const common = [

/** Vue SFC only rules */
const vue_config = [
...vue.configs['flat/recommended'].map((config) => {
...vue.configs[recommendedKey].map((config) => {
/**
* Specified above, unnecessary to overwrite
*/
Expand All @@ -131,12 +149,12 @@ const vue_config = [
return config;
}),
{
...flatArrayOfObjects(vueScopedCSS.configs['flat/recommended']),
...flatArrayOfObjects(vueScopedCSS.configs[recommendedKey]),
name: '(@jellyfin-vue/configs/lint/typescript-vue - Vue Scoped CSS) Extended config from plugin',
files: vueFiles
},
{
...css.configs['flat/recommended'],
...css.configs[recommendedKey],
name: '(@jellyfin-vue/configs/lint/typescript-vue - Vue CSS) Extended config from plugin',
files: vueFiles
},
Expand Down

0 comments on commit 5f3abeb

Please sign in to comment.