Skip to content

Commit

Permalink
chore: no-explicit-any
Browse files Browse the repository at this point in the history
Enable no-explicit-any linting rule and fix issues.

Part of #1245.

Signed-off-by: Tim deBoer <[email protected]>
  • Loading branch information
deboer-tim committed Jan 29, 2025
1 parent f3e5e8f commit 2b40663
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 44 deletions.
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
9 changes: 4 additions & 5 deletions packages/frontend/src/Build.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ async function buildBootcImage() {
kernel: {
append: buildConfigKernelArguments,
},
}) as BuildConfig;
});
const buildOptions: BootcBuildInfo = {
id: buildID,
Expand Down Expand Up @@ -366,18 +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[]): BuildConfig {
if (Array.isArray(obj)) {
return obj.map(removeEmptyStrings); // Recurse for each item in arrays
} else if (obj && typeof obj === 'object') {
} else {
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);
}, {} as unknown);
}
return obj;
}
onMount(async () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/Examples.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ 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: { id: string }) => [category.id, category]),
);
const output: Map<Category, Example[]> = new Map();
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/lib/BootcStatusIcon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StarIcon } from '@podman-desktop/ui-svelte/icons';
// 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: unknown = undefined;
export let size = 20;
$: solid =
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/lib/dashboard/Dashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Button, NavPage } from '@podman-desktop/ui-svelte';
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
15 changes: 3 additions & 12 deletions packages/frontend/src/lib/disk-image/DiskImageDetailsBuild.spec.ts
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,7 +145,7 @@ 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) => {
logsTerminal.onKey((e: object) => {
e = e.key;
if (socket !== undefined) {
const encoder = new TextEncoder();
Expand Down

0 comments on commit 2b40663

Please sign in to comment.