Skip to content

Commit

Permalink
chore: resolve lint errors and warnings
Browse files Browse the repository at this point in the history
Signed-off-by: David Dal Busco <[email protected]>
  • Loading branch information
peterpeterparker committed Nov 6, 2023
1 parent e605bbb commit 36b4355
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 15 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
caughtErrorsIgnorePattern: '^_'
}
],
'no-underscore-dangle': 'off'
'no-underscore-dangle': 'off',
'svelte/no-at-html-tags': 'off'
}
};
11 changes: 10 additions & 1 deletion src/frontend/src/lib/components/core/Busy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { busy } from '$lib/stores/busy.store';
import Spinner from '$lib/components/ui/Spinner.svelte';
import { isNullish, nonNullish } from '$lib/utils/utils';
import { handleKeyPress } from '$lib/utils/keyboard.utils';
const close = () => {
if (isNullish($busy) || !$busy.close) {
Expand All @@ -15,7 +16,15 @@
</script>

{#if nonNullish($busy)}
<div transition:fade on:click={close} class:close={$busy.close}>
<div
role="button"
tabindex="-1"
aria-label={$i18n.core.close}
transition:fade
on:click={close}
class:close={$busy.close}
on:keypress={($event) => handleKeyPress({ $event, callback: close })}
>
<div class="content">
{#if $busy.spinner}
<div class="spinner">
Expand Down
7 changes: 2 additions & 5 deletions src/frontend/src/lib/components/docs/DocForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { busy } from '$lib/stores/busy.store';
import { toasts } from '$lib/stores/toasts.store';
import { RULES_CONTEXT_KEY, type RulesContext } from '$lib/types/rules.context';
import type { Principal } from '@dfinity/principal';
import { createEventDispatcher, getContext } from 'svelte';
import { isNullish } from '$lib/utils/utils';
import { i18n } from '$lib/stores/i18n.store';
Expand All @@ -22,12 +21,10 @@
let action: DataStoreAction | undefined;
$: action = $docsStore?.action;
let collection: string | undefined;
$: collection = $store.rule?.[0];
let satelliteId: Principal;
$: satelliteId = $store.satelliteId;
let key: string | undefined;
$: key = $docsStore?.key;
Expand Down Expand Up @@ -109,7 +106,7 @@
<form on:submit|preventDefault={onSubmit}>
<div>
<div>
<label>{$i18n.document.field_doc_id_label}</label>
<label for="doc-id">{$i18n.document.field_doc_id_label}</label>
<div class="form-doc-id">
<input
id="doc-id"
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/lib/components/docs/DocFormField.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="form-field">
<div class="form-field-item">
<label>{$i18n.document.field_name_label}</label>
<label for="field_name">{$i18n.document.field_name_label}</label>
<input
id="field_name"
type="text"
Expand All @@ -22,7 +22,7 @@
/>
</div>
<div class="form-field-item">
<label>{$i18n.document.field_type_label}</label>
<label for="field_type">{$i18n.document.field_type_label}</label>
<select id="field_type" name="field_type" bind:value={fieldType}>
<option value={DocFieldTypeEnum.BOOLEAN}>{$i18n.document.field_type_boolean}</option>
<option value={DocFieldTypeEnum.STRING}>{$i18n.document.field_type_string}</option>
Expand All @@ -31,7 +31,7 @@
</div>
<div class="form-field-item">
<div>
<label>{$i18n.document.field_value_label}</label>
<label for="value">{$i18n.document.field_value_label}</label>
<div class="value-input-wrapper">
{#if fieldType === DocFieldTypeEnum.NUMBER || fieldType === DocFieldTypeEnum.STRING}
<input
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { missionControlStore } from '$lib/stores/mission-control.store';
import { nonNullish } from '$lib/utils/utils';
import CanisterTopUpModal from '$lib/components/modals/CanisterTopUpModal.svelte';
import { i18nFormat } from '$lib/utils/i18n.utils';
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/src/lib/components/ui/Json.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { isHash, stringifyJson, isPrincipal } from '$lib/utils/json.utils';
import { i18n } from '$lib/stores/i18n.store';
import { handleKeyPress } from '$lib/utils/keyboard.utils';
export let json: unknown | undefined = undefined;
export let defaultExpandedLevel = Infinity;
Expand Down Expand Up @@ -74,6 +75,7 @@
role="button"
aria-label={$i18n.core.toggle}
tabindex="0"
on:keypress={($event) => handleKeyPress({ $event, callback: toggle })}
on:click|stopPropagation={toggle}
>{keyLabel}
<span class="bracket">{openBracket} ... {closeBracket}</span>
Expand All @@ -90,6 +92,7 @@
role="button"
aria-label={$i18n.core.toggle}
tabindex="0"
on:keypress={($event) => handleKeyPress({ $event, callback: toggle })}
on:click|stopPropagation={toggle}
>{keyLabel}<span class="bracket open">{openBracket}</span></span
>
Expand Down
8 changes: 7 additions & 1 deletion src/frontend/src/lib/components/ui/Menu.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<script lang="ts">
import { layoutMenuOpen } from '$lib/stores/layout.store';
import Logo from '$lib/components/presentation/Logo.svelte';
import { handleKeyPress } from '$lib/utils/keyboard.utils';
const close = () => layoutMenuOpen.set(false);
</script>

<div role="menu">
<div
class="inner"
data-tid="menu-inner"
class:open={$layoutMenuOpen}
on:click={() => layoutMenuOpen.set(false)}
on:keypress={($event) => handleKeyPress({ $event, callback: close })}
on:click={close}
role="button"
tabindex="-1"
>
<div class="logo">
<Logo color="white" />
Expand Down
9 changes: 8 additions & 1 deletion src/frontend/src/lib/components/ui/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import IconClose from '$lib/components/icons/IconClose.svelte';
import { createEventDispatcher } from 'svelte';
import { isBusy } from '$lib/stores/busy.store';
import { handleKeyPress } from '$lib/utils/keyboard.utils';
let visible = true;
Expand Down Expand Up @@ -32,7 +33,13 @@
aria-describedby="modalContent"
on:introend
>
<div class="backdrop" on:click|stopPropagation={close} />
<div
class="backdrop"
on:click|stopPropagation={close}
on:keypress={($event) => handleKeyPress({ $event, callback: close })}
role="button"
tabindex="-1"
/>
<div
transition:scale={{ delay: 25, duration: 150, easing: quintOut }}
class="wrapper"
Expand Down
10 changes: 8 additions & 2 deletions src/frontend/src/lib/components/ui/Popover.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { quintOut } from 'svelte/easing';
import { i18n } from '$lib/stores/i18n.store';
import IconClose from '$lib/components/icons/IconClose.svelte';
import { handleKeyPress } from '$lib/utils/keyboard.utils';
export let anchor: HTMLElement | undefined = undefined;
export let visible = false;
Expand Down Expand Up @@ -41,10 +42,15 @@
? `--popover-right: ${innerWidth - right}px;`
: `--popover-left: ${left}px;`
}`}
on:click|stopPropagation
on:introend
>
<div class="backdrop" on:click|stopPropagation={() => (visible = false)} />
<div
class="backdrop"
on:click|stopPropagation={close}
on:keypress={($event) => handleKeyPress({ $event, callback: close })}
role="button"
tabindex="-1"
/>
<div
transition:scale={{ delay: 25, duration: 150, easing: quintOut }}
class="wrapper"
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/lib/constants/wallet.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ export const MEMO_CANISTER_CREATE = BigInt(0x41455243); // == 'CREA'
/// At least for topup, it has to be exactly the memo used by the IC
export const MEMO_CANISTER_TOP_UP = BigInt(0x50555054); // == 'TPUP'

// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
export const MEMO_SATELLITE_CREATE_REFUND = BigInt(0x44464552544153); // == 'SATREFD'
// eslint-disable-next-line @typescript-eslint/no-loss-of-precision
export const MEMO_ORBITER_CREATE_REFUND = BigInt(0x4446455242524f); // == 'ORBREFD'
13 changes: 13 additions & 0 deletions src/frontend/src/lib/utils/keyboard.utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const handleKeyPress = ({
$event: { code },
callback
}: {
$event: KeyboardEvent;
callback: () => void;
}) => {
if (!['Enter', 'Space'].includes(code)) {
return;
}

callback();
};

0 comments on commit 36b4355

Please sign in to comment.