Skip to content

Commit

Permalink
fix: handle ESLint rule @typescript-eslint/prefer-nullish-coalescing (#…
Browse files Browse the repository at this point in the history
…1718)

Fixes #1701

Signed-off-by: Jeff MAURY <[email protected]>
  • Loading branch information
jeffmaury authored Sep 14, 2024
1 parent bfb2357 commit ea02986
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 14 deletions.
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ export default [
],

// disabled as code in this project is not yet compliant:
'@typescript-eslint/prefer-nullish-coalescing': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'svelte/valid-compile': 'off',
'no-undef': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/utils/inferenceUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export async function withDefaultConfiguration(
return {
port: options.port ?? (await getFreeRandomPort('0.0.0.0')),
image: options.image,
labels: options.labels || {},
labels: options.labels ?? {},
modelsInfo: options.modelsInfo,
connection: options.connection,
inferenceProvider: options.inferenceProvider,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/workers/provider/LlamaCppPython.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export class LlamaCppPython extends InferenceProvider {
status: 'running',
models: config.modelsInfo,
type: InferenceType.LLAMA_CPP,
labels: containerCreateOptions.Labels || {},
labels: containerCreateOptions.Labels ?? {},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function openDetails(): void {
aria-label="Model Name">
{object.name}
</div>
{#if object.registry || object.license}
{#if object.registry ?? object.license}
<span class="text-sm text-[var(--pd-table-body-text)]" aria-label="Model Info"
>{object.registry} - {object.license}</span>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/CreateService.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const processTasks = (tasks: Task[]): void => {
// hint: we do not need to display them as the TasksProgress component will
error = trackedTasks.find(task => task.error)?.error !== undefined;
const task: Task | undefined = trackedTasks.find(task => 'containerId' in (task.labels || {}));
const task: Task | undefined = trackedTasks.find(task => 'containerId' in (task.labels ?? {}));
if (task === undefined) return;
containerId = task.labels?.['containerId'];
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/InferenceServerDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let selectedLanguage: string = 'curl';
$: selectedLanguage;
let variants: LanguageVariant[] = [];
$: variants = $snippetLanguages.find(language => language.key === selectedLanguage)?.variants || [];
$: variants = $snippetLanguages.find(language => language.key === selectedLanguage)?.variants ?? [];
let selectedVariant: string = 'cURL';
$: selectedVariant;
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/Model.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export function goToUpPage(): void {
</script>

<DetailsPage
title={model?.name || ''}
title={model?.name ?? ''}
breadcrumbLeftPart="Models"
breadcrumbRightPart={model?.name || ''}
breadcrumbRightPart={model?.name ?? ''}
breadcrumbTitle="Go back to Models"
onclose={goToUpPage}
onbreadcrumbClick={goToUpPage}>
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/pages/Recipe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ function getFilter(items: ApplicationState[]): ApplicationState[] {
</script>

<DetailsPage
title={recipe?.name || ''}
title={recipe?.name ?? ''}
breadcrumbLeftPart="Recipes"
breadcrumbRightPart={recipe?.name || ''}
breadcrumbRightPart={recipe?.name ?? ''}
breadcrumbTitle="Go back to Recipes"
onclose={goToUpPage}
onbreadcrumbClick={goToUpPage}>
Expand Down Expand Up @@ -88,9 +88,9 @@ function getFilter(items: ApplicationState[]): ApplicationState[] {
</svelte:fragment>
<svelte:fragment slot="subtitle">
<div class="mt-2">
{#each recipe?.categories || [] as categoryId}
{#each recipe?.categories ?? [] as categoryId}
<Card
title={categories.find(category => category.id === categoryId)?.name || '?'}
title={categories.find(category => category.id === categoryId)?.name ?? '?'}
classes="bg-[var(--pd-label-bg)] p-1 text-xs w-fit" />
{/each}
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/shared/src/messages/MessageProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export class RpcBrowser {
return;
}

const { resolve, reject } = this.promises.get(message.id) || {};
const { resolve, reject } = this.promises.get(message.id) ?? {};

if (message.status === 'error') {
reject?.(message.error);
Expand Down Expand Up @@ -205,7 +205,7 @@ export class RpcBrowser {
// Add some timeout
if (!noTimeoutChannels.includes(channel)) {
setTimeout(() => {
const { reject } = this.promises.get(requestId) || {};
const { reject } = this.promises.get(requestId) ?? {};
if (!reject) return;
reject(new Error('Timeout'));
this.promises.delete(requestId);
Expand Down

0 comments on commit ea02986

Please sign in to comment.