Skip to content

chore: no-explicit-any #1248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export default [
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', caughtErrors: 'none' }],
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-misused-promises': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/Build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ test('Check that preselecting an image works', async () => {
expect(select.children[1].textContent).toEqual('image2:latest');

// Expect the one we passed in to be selected
const selectedImage = select.value as unknown as any[];
const selectedImage = select.value;
expect(selectedImage).toBeDefined();
expect(selectedImage).toEqual('image2:latest');
});
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/Build.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -366,16 +366,17 @@ function deleteFilesystem(index: number) {
// Remove any empty strings in the object before passing it in to the backend
// this is useful as we are using "bind:input" with groups / form fields and the first entry will always be blank when submitting
// this will remove any empty strings from the object before passing it in.
function removeEmptyStrings(obj: any): any {
function removeEmptyStrings(obj: object): object {
if (Array.isArray(obj)) {
return obj.map(removeEmptyStrings); // Recurse for each item in arrays
} else if (obj && typeof obj === 'object') {
let initial: { [key: string]: object } = {};
return Object.entries(obj)
.filter(([_, value]) => value !== '' && value !== undefined) // Filter out entries with empty string or undefined values
.reduce((acc, [key, value]) => {
acc[key] = removeEmptyStrings(value); // Recurse for nested objects/arrays
return acc;
}, {} as any);
}, initial);
}
return obj;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/Examples.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ onMount(async () => {
// onmount get the examples
let examples = await bootcClient.getExamples();

const categoryDict = Object.fromEntries(examples.categories.map((category: { id: any }) => [category.id, category]));
const categoryDict = Object.fromEntries(examples.categories.map((category: Category) => [category.id, category]));

const output: Map<Category, Example[]> = new Map();

Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/lib/BootcStatusIcon.svelte
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<script lang="ts">
import { Spinner } from '@podman-desktop/ui-svelte';
import { StarIcon } from '@podman-desktop/ui-svelte/icons';
import type { Component } from 'svelte';

// status: one of running, success, error
// any other status will result in a standard outlined box
export let status = '';
export let icon: any = undefined;
export let icon: Component | string | undefined = undefined;
export let size = 20;

$: solid =
Expand Down
5 changes: 3 additions & 2 deletions packages/frontend/src/lib/dashboard/Dashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import { bootcClient, rpcBrowser } from '../../api/client';
import { Messages } from '/@shared/src/messages/Messages';
import { router } from 'tinro';
import { Button, NavPage } from '@podman-desktop/ui-svelte';
import type { ImageInfo } from '@podman-desktop/api';

let pullInProgress = false;
let imageExists = false;
let displayDisclaimer = false;
let bootcAvailableImages: any[] = [];
let bootcAvailableImages: ImageInfo[] = [];

const exampleImage = 'quay.io/bootc-extension/httpd:latest';
const bootcImageBuilderSite = 'https://github.com/osbuild/bootc-image-builder';
Expand Down Expand Up @@ -60,7 +61,7 @@ onMount(async () => {

// Each time bootcAvailableImages updates, check if 'quay.io/bootc-extension/httpd' is in RepoTags
$: {
if (bootcAvailableImages?.some(image => image.RepoTags.includes(exampleImage))) {
if (bootcAvailableImages?.some(image => image.RepoTags?.includes(exampleImage))) {
imageExists = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (C) 2024 Red Hat, Inc.
* Copyright (C) 2024-2025 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,12 +35,9 @@ vi.mock('/@/api/client', async () => ({
}));

beforeAll(() => {
(window as any).ResizeObserver = ResizeObserver;
(window as any).getConfigurationValue = vi.fn().mockResolvedValue(undefined);
(window as any).matchMedia = vi.fn().mockReturnValue({
addListener: vi.fn(),
Object.defineProperty(window, 'ResizeObserver', {
value: vi.fn().mockReturnValue({ observe: vi.fn(), unobserve: vi.fn() }),
});

Object.defineProperty(window, 'matchMedia', {
value: () => {
return {
Expand All @@ -52,12 +49,6 @@ beforeAll(() => {
});
});

class ResizeObserver {
observe = vi.fn();
disconnect = vi.fn();
unobserve = vi.fn();
}

const mockLogs = `Build log line 1
Build log line 2
Build log line 3`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**********************************************************************
* Copyright (C) 2024 Red Hat, Inc.
* Copyright (C) 2024-2025 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,29 +43,11 @@ vi.mock('/@/api/client', async () => {
});

beforeAll(() => {
(window as any).ResizeObserver = ResizeObserver;
(window as any).getConfigurationValue = vi.fn().mockResolvedValue(undefined);
(window as any).matchMedia = vi.fn().mockReturnValue({
addListener: vi.fn(),
});

Object.defineProperty(window, 'matchMedia', {
value: () => {
return {
matches: false,
addListener: () => {},
removeListener: () => {},
};
},
Object.defineProperty(window, 'ResizeObserver', {
value: vi.fn().mockReturnValue({ observe: vi.fn(), unobserve: vi.fn() }),
});
});

class ResizeObserver {
observe = vi.fn();
disconnect = vi.fn();
unobserve = vi.fn();
}

test('Render virtual machine terminal window', async () => {
vi.mocked(bootcClient.getConfigurationValue).mockResolvedValue(14);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,10 @@ async function initTerminal() {
logsTerminal.loadAddon(attachAddon);

// This is required for keyboard input to work since we are using the attach addon
logsTerminal.onKey((e: any) => {
e = e.key;
logsTerminal.onKey((e: { key: string }) => {
if (socket !== undefined) {
const encoder = new TextEncoder();
const binaryData = encoder.encode(e);
const binaryData = encoder.encode(e.key);
socket.send(binaryData.buffer);
}
});
Expand Down