Skip to content

Commit

Permalink
chore: enable the @typescript-eslint/explicit-function-return-type fo…
Browse files Browse the repository at this point in the history
…r renderer part (podman-desktop#10705)

* fix: eslint config
Signed-off-by: Philippe Martin <[email protected]>

* fix: components
Signed-off-by: Philippe Martin <[email protected]>

* fix: store
Signed-off-by: Philippe Martin <[email protected]>

* fix: window mocks
Signed-off-by: Philippe Martin <[email protected]>

* fix: components 2/x
Signed-off-by: Philippe Martin <[email protected]>

* fix: components 3/x
Signed-off-by: Philippe Martin <[email protected]>

* fix: rebase
Signed-off-by: Philippe Martin <[email protected]>

* fix: components 5/x
Signed-off-by: Philippe Martin <[email protected]>

* fix: components 6/x
Signed-off-by: Philippe Martin <[email protected]>

* fix: typo
Signed-off-by: Philippe Martin <[email protected]>

* fix: rebase
Signed-off-by: Philippe Martin <[email protected]>
  • Loading branch information
feloy authored Jan 20, 2025
1 parent 704bb31 commit bb1c3c0
Show file tree
Hide file tree
Showing 326 changed files with 1,125 additions and 1,146 deletions.
1 change: 0 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ export default [
rules: {
'@typescript-eslint/no-empty-function': 'off',
'no-undef': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'no-self-assign': 'off',
'sonarjs/no-empty-function': 'off',
'sonarjs/sonar-prefer-regexp-exec': 'off',
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ test('opens submenu when a `submenu` menu is opened', async () => {
link: '/tosubmenu',
tooltip: 'With submenu',
type: 'submenu',
get counter() {
get counter(): number {
return 0;
},
items: [{} as NavigationRegistryEntry],
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ window.events?.receive('navigate', (navigationRequest: unknown) => {
<CustomPick />
<CommandPalette />
<MessageBox />
<AppNavigation meta={meta} exitSettingsCallback={() => router.goto(nonSettingsPage)} />
<AppNavigation meta={meta} exitSettingsCallback={(): void => router.goto(nonSettingsPage)} />
{#if meta.url.startsWith('/preferences')}
<PreferencesNavigation meta={meta} />
{/if}
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/AppNavigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function onDidChangeConfigurationCallback(e: Event): void {
<div class="grow"></div>

<div bind:this={outsideWindow}>
<NavItem href="/accounts" tooltip="" bind:meta={meta} onClick={event => authActions?.onButtonClick(event)}>
<NavItem href="/accounts" tooltip="" bind:meta={meta} onClick={(event): void => authActions?.onButtonClick(event)}>
<Tooltip bottomRight tip="Accounts">
<div class="flex flex-col items-center w-full h-full">
<AccountIcon size={iconSize} />
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/Loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { lastPage } from './stores/breadcrumb';
// first, patch window object
const callbacks = new Map<string, any>();
const eventEmitter = {
receive: (message: string, callback: any) => {
receive: (message: string, callback: any): void => {
callbacks.set(message, callback);
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/renderer/src/Loader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ onMount(async () => {
console.error('Unable to check if system is ready', error);
}
const checkRemoteStarted = async () => {
const checkRemoteStarted = async (): Promise<void> => {
const extensionsStarted = await window.extensionSystemIsExtensionsStarted();
if (extensionsStarted) {
window.dispatchEvent(new CustomEvent('extensions-already-started', {}));
Expand All @@ -57,7 +57,7 @@ onDestroy(() => {
// receive events from main process to install a new extension
window.events?.receive('install-extension:from-id', (extensionId: unknown) => {
const action = async () => {
const action = async (): Promise<void> => {
const redirectPage = `/extensions/details/${extensionId}`;
// need to open the extension page
await tick();
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/Route.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const route = createRouteObject({
},
});
function processMetaBreadcrumbs(breadcrumbs?: Array<TinroBreadcrumb>) {
function processMetaBreadcrumbs(breadcrumbs?: Array<TinroBreadcrumb>): void {
if (breadcrumbs) {
const curPage = breadcrumbs[breadcrumbs.length - 1];
if (!curPage) return;
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/SubmenuNavigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (!pages[title]) {
</div>
<div class="h-full overflow-hidden hover:overflow-y-auto" style="margin-bottom:auto">
{#each items ?? [] as item}
<SettingsNavItem title={item.tooltip} href={item.link} selected={meta.url.startsWith(item.link)} onClick={() => pages[title] = item.link}
<SettingsNavItem title={item.tooltip} href={item.link} selected={meta.url.startsWith(item.link)} onClick={(): string => pages[title] = item.link}
></SettingsNavItem>
{/each}
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/renderer/src/TelemetryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class TelemetryService {

private handlerFlusher: NodeJS.Timeout | undefined;

public handlePageOpen(pagePath: string) {
public handlePageOpen(pagePath: string): void {
this.handlePageClose();

this.handlerFlusher = setTimeout(() => {
Expand All @@ -45,7 +45,7 @@ export class TelemetryService {
}

// clear timeout
public handlePageClose() {
public handlePageClose(): void {
if (this.handlerFlusher) {
clearTimeout(this.handlerFlusher);
this.handlerFlusher = undefined;
Expand Down
8 changes: 4 additions & 4 deletions packages/renderer/src/lib/actions/ActionUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ test('Object with single non serializable property', async () => {
});

test('Array with single non serializable property', async () => {
expect(removeNonSerializableProperties([() => {}])).toStrictEqual([]);
expect(removeNonSerializableProperties([(): void => {}])).toStrictEqual([]);
});

test('Array with single non serializable and serializable property', async () => {
expect(removeNonSerializableProperties([() => {}, 'dummy'])).toStrictEqual(['dummy']);
expect(removeNonSerializableProperties([(): void => {}, 'dummy'])).toStrictEqual(['dummy']);
});

test('Object with properties nested in object', async () => {
Expand All @@ -56,7 +56,7 @@ test('Object with properties nested in array', async () => {
removeNonSerializableProperties({
parent: [
{
nonSerializable: () => {},
nonSerializable: (): void => {},
serializable: 'dummy',
},
],
Expand All @@ -75,7 +75,7 @@ test('Object with single non serializable property nested in array', async () =>
removeNonSerializableProperties({
parent: [
{
nonSerializable: () => {},
nonSerializable: (): void => {},
serializable: 'dummy',
},
],
Expand Down
6 changes: 3 additions & 3 deletions packages/renderer/src/lib/actions/ContributionActions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ beforeAll(() => {

(window.events as unknown) = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
receive: (_channel: string, func: any) => {
receive: (_channel: string, func: any): void => {
func();
},
};
Expand Down Expand Up @@ -119,7 +119,7 @@ test('Expect executeCommand to be called with sanitize object', async () => {
render(ContributionActions, {
args: [
{
nonSerializable: () => {},
nonSerializable: (): void => {},
serializable: 'hello',
},
],
Expand All @@ -143,7 +143,7 @@ test('Expect executeCommand to be called with sanitize object nested', async ()
args: [
{
parent: {
nonSerializable: () => {},
nonSerializable: (): void => {},
serializable: 'hello',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async function executeContribution(menu: Menu): Promise<void> {
{#each filteredContributions as menu}
<ListItemButtonIcon
title={menu.title}
onClick={() => executeContribution(menu)}
onClick={(): Promise<void> => executeContribution(menu)}
menu={dropdownMenu}
icon={getIcon(menu)}
detailed={detailed}
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/appearance/IconImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let imgSrc: string | undefined = undefined;
$: getImgSrc(image);
function getImgSrc(image: string | { light: string; dark: string } | undefined) {
function getImgSrc(image: string | { light: string; dark: string } | undefined): void {
new AppearanceUtil()
.getImage(image)
.then(s => (imgSrc = s))
Expand Down
6 changes: 3 additions & 3 deletions packages/renderer/src/lib/authentication/AuthActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ export function onButtonClick(e: MouseEvent): void {
<DropdownMenu.Item
title="Manage authentication"
icon={faKey}
onClick={() => handleNavigation({ page: NavigationPage.AUTHENTICATION })} />
onClick={(): void => handleNavigation({ page: NavigationPage.AUTHENTICATION })} />

{#each $authenticationProviders as provider}
{@const sessionRequests = provider.sessionRequests ?? []}
{#if provider?.accounts?.length > 0}
{#each provider.accounts as account}
<DropdownMenu.Item
title="Sign out of {provider.displayName} ({account.label})"
onClick={() => window.requestAuthenticationProviderSignOut(provider.id, account.id)}
onClick={(): Promise<void> => window.requestAuthenticationProviderSignOut(provider.id, account.id)}
icon={faSignOut} />
{/each}
{/if}

{#each sessionRequests as request}
<DropdownMenu.Item
title="Sign in with {provider.displayName} to use {request.extensionLabel}"
onClick={() => window.requestAuthenticationProviderSignIn(request.id)}
onClick={(): Promise<void> => window.requestAuthenticationProviderSignIn(request.id)}
icon={faSignIn} />
{/each}
{/each}
Expand Down
20 changes: 10 additions & 10 deletions packages/renderer/src/lib/compose/ComposeActions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function handleError(errorMessage: string): void {
onUpdate(compose);
}
async function startCompose() {
async function startCompose(): Promise<void> {
inProgress(true, 'STARTING');
try {
await window.startContainersByLabel(compose.engineId, composeLabel, compose.name);
Expand All @@ -68,7 +68,7 @@ async function startCompose() {
inProgress(false);
}
}
async function stopCompose() {
async function stopCompose(): Promise<void> {
inProgress(true, 'STOPPING');
try {
await window.stopContainersByLabel(compose.engineId, composeLabel, compose.name);
Expand All @@ -79,7 +79,7 @@ async function stopCompose() {
}
}
async function deleteCompose() {
async function deleteCompose(): Promise<void> {
inProgress(true, 'DELETING');
try {
await window.deleteContainersByLabel(compose.engineId, composeLabel, compose.name);
Expand All @@ -90,7 +90,7 @@ async function deleteCompose() {
}
}
async function restartCompose() {
async function restartCompose(): Promise<void> {
inProgress(true, 'RESTARTING');
try {
await window.restartContainersByLabel(compose.engineId, composeLabel, compose.name);
Expand Down Expand Up @@ -121,7 +121,7 @@ if (dropdownMenu) {

<ListItemButtonIcon
title="Start Compose"
onClick={() => startCompose()}
onClick={startCompose}
hidden={compose.status === 'RUNNING' || compose.status === 'STOPPING'}
detailed={detailed}
inProgress={compose.actionInProgress && compose.status === 'STARTING'}
Expand All @@ -130,15 +130,15 @@ if (dropdownMenu) {

<ListItemButtonIcon
title="Stop Compose"
onClick={() => stopCompose()}
onClick={stopCompose}
hidden={!(compose.status === 'RUNNING' || compose.status === 'STOPPING')}
detailed={detailed}
inProgress={compose.actionInProgress && compose.status === 'STOPPING'}
icon={faStop} />

<ListItemButtonIcon
title="Delete Compose"
onClick={() => withConfirmation(deleteCompose, `delete compose ${compose.name}`)}
onClick={(): void => withConfirmation(deleteCompose, `delete compose ${compose.name}`)}
icon={faTrash}
detailed={detailed}
inProgress={compose.actionInProgress && compose.status === 'DELETING'} />
Expand All @@ -148,21 +148,21 @@ if (dropdownMenu) {
{#if !detailed}
<ListItemButtonIcon
title="Generate Kube"
onClick={() => openGenerateKube()}
onClick={openGenerateKube}
menu={dropdownMenu}
detailed={detailed}
icon={faFileCode} />
{/if}
<ListItemButtonIcon
title="Deploy to Kubernetes"
onClick={() => deployToKubernetes()}
onClick={deployToKubernetes}
menu={dropdownMenu}
hidden={compose.engineType !== 'podman'}
detailed={detailed}
icon={faRocket} />
<ListItemButtonIcon
title="Restart Compose"
onClick={() => restartCompose()}
onClick={restartCompose}
menu={dropdownMenu}
detailed={detailed}
icon={faArrowsRotate} />
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/compose/ComposeDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ beforeAll(() => {
onDidUpdateProviderStatusMock.mockImplementation(() => Promise.resolve());

(window.events as unknown) = {
receive: (_channel: string, func: () => void) => {
receive: (_channel: string, func: () => void): void => {
func();
},
};
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/compose/ComposeDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ onDestroy(() => {
<div class="flex items-center w-5">
<div>&nbsp;</div>
</div>
<ComposeActions compose={compose} detailed={true} on:update={() => (compose = compose)} />
<ComposeActions compose={compose} detailed={true} on:update={(): ComposeInfoUI => (compose = compose)} />
</svelte:fragment>
<svelte:fragment slot="tabs">
<Tab title="Summary" selected={isTabSelected($router.path, 'summary')} url={getTabUrl($router.path, 'summary')} />
Expand Down
4 changes: 2 additions & 2 deletions packages/renderer/src/lib/compose/ComposeDetailsLogs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $: {
const colourizedContainerName = new Map<string, string>();
// Callback for logs which will output the logs to the terminal
function callback(name: string, data: string) {
function callback(name: string, data: string): void {
if (name === 'first-message') {
noLogs = false;
} else if (name === 'data') {
Expand Down Expand Up @@ -61,7 +61,7 @@ async function fetchComposeLogs(): Promise<void> {
// in order to add padding to each output / make it look nice.
const promises = compose.containers.map(container => {
// Set a customer callback that will add the container name and padding
const logsCallback = (name: string, data: string) => {
const logsCallback = (name: string, data: string): void => {
const padding = ' '.repeat(maxNameLength - container.name.length);
const colouredName = colourizedContainerName.get(container.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ComposeInfoUI } from './ComposeInfoUI';
export let compose: ComposeInfoUI;
function openContainer(containerID: string) {
function openContainer(containerID: string): void {
handleNavigation({
page: NavigationPage.CONTAINER_LOGS,
parameters: {
Expand Down Expand Up @@ -48,7 +48,7 @@ function openContainer(containerID: string) {
{#each compose.containers as container}
<tr>
<DetailsCell>
<Link on:click={() => openContainer(container.id)}>{container.name}</Link>
<Link on:click={(): void => openContainer(container.id)}>{container.name}</Link>
</DetailsCell>
<DetailsCell>{container.id}</DetailsCell>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ onMount(() => {
});
});
async function loadDetails() {
async function loadDetails(): Promise<void> {
const getKubeConfigMap = await window.kubernetesReadNamespacedConfigMap(configMap.name, namespace);
if (getKubeConfigMap) {
kubeConfigMap = getKubeConfigMap;
Expand All @@ -58,7 +58,7 @@ async function loadDetails() {
<DetailsPage title={configMap.name} subtitle={configMap.namespace} bind:this={detailsPage}>
<StatusIcon slot="icon" icon={ConfigMapIcon} size={24} status={configMap.status} />
<svelte:fragment slot="actions">
<ConfigMapSecretActions configMapSecret={configMap} detailed={true} on:update={() => (configMap = configMap)} />
<ConfigMapSecretActions configMapSecret={configMap} detailed={true} on:update={(): ConfigMapSecretUI => (configMap = configMap)} />
</svelte:fragment>
<div slot="detail" class="flex py-2 w-full justify-end text-sm text-[var(--pd-content-text)]">
<StateChange state={configMap.status} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function deleteConfigMapSecret(): Promise<void> {

<ListItemButtonIcon
title={`Delete ${configmapSecretUtils.isSecret(configMapSecret) ? 'Secret' : 'ConfigMap'}`}
onClick={() =>
onClick={(): void =>
withConfirmation(
deleteConfigMapSecret,
`delete ${configmapSecretUtils.isSecret(configMapSecret) ? 'secret' : 'configmap'} ${configMapSecret.name}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ConfigMapSecretUI } from './ConfigMapSecretUI';
export let object: ConfigMapSecretUI;
function openDetails() {
function openDetails(): void {
const configmapSecretUtils = new ConfigMapSecretUtils();
if (configmapSecretUtils.isSecret(object)) {
router.goto(
Expand All @@ -22,7 +22,7 @@ function openDetails() {
}
</script>

<button class="hover:cursor-pointer flex flex-col max-w-full" on:click={() => openDetails()}>
<button class="hover:cursor-pointer flex flex-col max-w-full" on:click={openDetails}>
<div class="text-sm text-[var(--pd-table-body-text-highlight)] max-w-full overflow-hidden text-ellipsis">
{object.name}
</div>
Expand Down
Loading

0 comments on commit bb1c3c0

Please sign in to comment.