Skip to content

Commit c143a46

Browse files
committed
add svelte-check
1 parent baea2a0 commit c143a46

File tree

7 files changed

+65
-36
lines changed

7 files changed

+65
-36
lines changed

bun.lockb

1.64 KB
Binary file not shown.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
"format:check": "prettier --check --plugin prettier-plugin-svelte.",
1616
"lint": "eslint --max-warnings=0 packages/**",
1717
"lint:fix": "eslint --max-warnings=0 --fix packages/**",
18+
"svelte-check": "svelte-check --compiler-warnings \"unused-export-let:ignore\"",
1819
"types": "tsc -p \"./tsconfig.types.json\"",
19-
"check": "bun run format:check && bun run lint && bun run tsc && bun run test",
20-
"check:fix": "bun run format && bun run lint:fix && bun run tsc && bun run test",
20+
"check": "bun run format:check && bun run tsc && bun run svelte-check && bun run lint && bun run test",
21+
"check:fix": "bun run format && bun run tsc && bun run svelte-check && bun run lint:fix && bun run test",
2122
"pack:i": "bun run automation/installScript.ts",
2223
"release": "bun run automation/release.ts",
2324
"serve-publish": "bun --watch automation/publishServer.ts",
@@ -45,6 +46,7 @@
4546
"prettier": "^3.2.5",
4647
"prettier-plugin-svelte": "^3.2.1",
4748
"string-argv": "^0.3.2",
49+
"svelte-check": "^3.6.4",
4850
"svelte-preprocess": "^5.1.3",
4951
"tslib": "2.6.2",
5052
"typescript": "^5.3.3"

packages/core/src/fields/inputFields/fields/ImageSuggester/ImageSuggesterCard.svelte

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
</div>
2525

2626
<style>
27-
.image-card {
28-
}
29-
3027
.image-card-image {
3128
width: 100%;
3229
height: fit-content;

packages/core/src/modals/modalContents/ButtonBuilderModalComponent.svelte

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
2-
import { ButtonBuilderModal } from 'packages/core/src/modals/modalContents/ButtonBuilderModal.ts';
2+
import { ButtonBuilderModal } from 'packages/core/src/modals/modalContents/ButtonBuilderModal';
33
import {
4+
ButtonAction,
45
ButtonActionType,
56
ButtonConfig,
67
ButtonStyleType,
@@ -9,20 +10,21 @@
910
} from 'packages/core/src/config/ButtonConfig';
1011
import SettingComponent from 'packages/core/src/utils/components/SettingComponent.svelte';
1112
import { onDestroy } from 'svelte';
12-
import { getUUID } from 'packages/core/src/utils/Utils';
13+
import { DomHelpers } from 'packages/core/src/utils/Utils';
1314
import Button from 'packages/core/src/utils/components/Button.svelte';
1415
import Icon from 'packages/core/src/utils/components/Icon.svelte';
1516
import ModalButtonGroup from 'packages/core/src/utils/components/ModalButtonGroup.svelte';
1617
import Toggle from 'packages/core/src/utils/components/Toggle.svelte';
17-
import { ButtonBase } from 'packages/core/src/fields/button/ButtonBase';
1818
import { IPlugin } from 'packages/core/src/IPlugin';
19+
import { ButtonField } from 'packages/core/src/fields/button/ButtonField';
20+
import { Command } from 'packages/core/src/api/InternalAPI';
1921
2022
export let plugin: IPlugin;
2123
export let modal: ButtonBuilderModal;
2224
export let buttonConfig: ButtonConfig;
2325
2426
let buttonEl: HTMLElement;
25-
let buttonBase: ButtonBase;
27+
let buttonBase: ButtonField;
2628
let addActionType: ButtonActionType;
2729
2830
$: updatePreviewButton(buttonConfig, buttonEl);
@@ -34,8 +36,8 @@
3436
function updatePreviewButton(config: ButtonConfig, el: HTMLElement) {
3537
buttonBase?.unmount();
3638
if (el) {
37-
el.empty();
38-
buttonBase = new ButtonBase(plugin, getUUID(), '', plugin.internal.stringifyYaml(config), true);
39+
DomHelpers.empty(el);
40+
buttonBase = new ButtonField(plugin, config, '', false, true);
3941
buttonBase.mount(el);
4042
}
4143
}
@@ -47,25 +49,37 @@
4749
}
4850
4951
function removeAction(id: number) {
50-
buttonConfig.actions.splice(id, 1);
52+
buttonConfig.actions?.splice(id, 1);
5153
buttonConfig.actions = buttonConfig.actions;
5254
}
5355
54-
function commandActionChangeCommand(action: CommandButtonAction) {
56+
function commandActionChangeCommand(action: ButtonAction) {
57+
if (action.type !== ButtonActionType.COMMAND) {
58+
return;
59+
}
60+
5561
plugin.internal.openCommandSelectModal((command: Command) => {
5662
action.command = command.id;
5763
buttonConfig.actions = buttonConfig.actions;
5864
});
5965
}
6066
61-
function templaterCreateNoteActionChangeTemplateFile(action: TemplaterCreateNoteButtonAction) {
67+
function templaterCreateNoteActionChangeTemplateFile(action: ButtonAction) {
68+
if (action.type !== ButtonActionType.TEMPLATER_CREATE_NOTE) {
69+
return;
70+
}
71+
6272
plugin.internal.openFileSelectModal((file: string) => {
6373
action.templateFile = file;
6474
buttonConfig.actions = buttonConfig.actions;
6575
});
6676
}
6777
68-
function templaterCreateNoteActionChangeFolderPath(action: TemplaterCreateNoteButtonAction) {
78+
function templaterCreateNoteActionChangeFolderPath(action: ButtonAction) {
79+
if (action.type !== ButtonActionType.TEMPLATER_CREATE_NOTE) {
80+
return;
81+
}
82+
6983
plugin.internal.openFolderSelectModal((folder: string) => {
7084
action.folderPath = folder;
7185
buttonConfig.actions = buttonConfig.actions;
@@ -139,18 +153,19 @@ Add action of type
139153
{/each}
140154
</select>
141155

142-
<Button variant="primary" on:click={() => addAction()}>Add Action</Button>
156+
<Button variant={ButtonStyleType.PRIMARY} on:click={() => addAction()}>Add Action</Button>
143157

144-
{#each buttonConfig.actions as action, i (i)}
158+
{#each buttonConfig.actions ?? [] as action, i (i)}
145159
<h5>{getActionLabel(action.type)}</h5>
146160

147161
{#if action.type === ButtonActionType.COMMAND}
148162
<SettingComponent
149163
name="Command: {action.command || 'none'}"
150164
description="The command to execute when this action runs."
151165
>
152-
<Button variant="primary" on:click={() => commandActionChangeCommand(action)}>Change</Button>
153-
<Button variant="destructive" on:click={() => removeAction(i)}>
166+
<Button variant={ButtonStyleType.PRIMARY} on:click={() => commandActionChangeCommand(action)}>Change</Button
167+
>
168+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>
154169
<Icon plugin={modal.plugin} iconName="x"></Icon>
155170
</Button>
156171
</SettingComponent>
@@ -159,7 +174,7 @@ Add action of type
159174
{#if action.type === ButtonActionType.OPEN}
160175
<SettingComponent name="Link" description="The link to open.">
161176
<input type="text" bind:value={action.link} placeholder="[[Some Note]] or https://www.example.com" />
162-
<Button variant="destructive" on:click={() => removeAction(i)}>
177+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>
163178
<Icon plugin={modal.plugin} iconName="x"></Icon>
164179
</Button>
165180
</SettingComponent>
@@ -168,7 +183,7 @@ Add action of type
168183
{#if action.type === ButtonActionType.JS}
169184
<SettingComponent name="JS File" description="The JavaScript file to run.">
170185
<input type="text" bind:value={action.file} placeholder="someJsFile.js" />
171-
<Button variant="destructive" on:click={() => removeAction(i)}>
186+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>
172187
<Icon plugin={modal.plugin} iconName="x"></Icon>
173188
</Button>
174189
</SettingComponent>
@@ -177,7 +192,7 @@ Add action of type
177192
{#if action.type === ButtonActionType.INPUT}
178193
<SettingComponent name="Text" description="The text to input at the cursor.">
179194
<input type="text" bind:value={action.str} placeholder="some text" />
180-
<Button variant="destructive" on:click={() => removeAction(i)}>
195+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>
181196
<Icon plugin={modal.plugin} iconName="x"></Icon>
182197
</Button>
183198
</SettingComponent>
@@ -186,20 +201,22 @@ Add action of type
186201
{#if action.type === ButtonActionType.SLEEP}
187202
<SettingComponent name="Sleep Time" description="The time to sleep in milliseconds.">
188203
<input type="number" bind:value={action.ms} placeholder="100 ms" />
189-
<Button variant="destructive" on:click={() => removeAction(i)}>
204+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>
190205
<Icon plugin={modal.plugin} iconName="x"></Icon>
191206
</Button>
192207
</SettingComponent>
193208
{/if}
194209

195210
{#if action.type === ButtonActionType.TEMPLATER_CREATE_NOTE}
196-
<Button variant="destructive" on:click={() => removeAction(i)}>Remove Action</Button>
211+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>Remove Action</Button>
197212

198213
<SettingComponent
199214
name="Template File: {action.templateFile || 'none'}"
200215
description="The template file to create a new note of."
201216
>
202-
<Button variant="primary" on:click={() => templaterCreateNoteActionChangeTemplateFile(action)}
217+
<Button
218+
variant={ButtonStyleType.PRIMARY}
219+
on:click={() => templaterCreateNoteActionChangeTemplateFile(action)}
203220
>Change
204221
</Button>
205222
</SettingComponent>
@@ -208,7 +225,9 @@ Add action of type
208225
name="Folder: {action.folderPath || 'none'}"
209226
description="The folder to create a new note in."
210227
>
211-
<Button variant="primary" on:click={() => templaterCreateNoteActionChangeFolderPath(action)}>Change</Button>
228+
<Button variant={ButtonStyleType.PRIMARY} on:click={() => templaterCreateNoteActionChangeFolderPath(action)}
229+
>Change</Button
230+
>
212231
</SettingComponent>
213232

214233
<SettingComponent name="File Name: {action.fileName || 'default'}" description="The file name of the new note.">
@@ -221,7 +240,7 @@ Add action of type
221240
{/if}
222241

223242
{#if action.type === ButtonActionType.UPDATE_METADATA}
224-
<Button variant="destructive" on:click={() => removeAction(i)}>Remove Action</Button>
243+
<Button variant={ButtonStyleType.DESTRUCTIVE} on:click={() => removeAction(i)}>Remove Action</Button>
225244

226245
<SettingComponent name="Metadata Property" description="The metadata property in form of a bind target.">
227246
<input type="text" bind:value={action.bindTarget} placeholder="some value" />
@@ -242,6 +261,8 @@ Add action of type
242261
<div bind:this={buttonEl}></div>
243262

244263
<ModalButtonGroup>
245-
<Button variant="primary" on:click={() => modal.okay(buttonConfig)}>{modal.options.submitText}</Button>
246-
<Button variant="default" on:click={() => modal.cancel()}>Cancel</Button>
264+
<Button variant={ButtonStyleType.PRIMARY} on:click={() => modal.okay(buttonConfig)}
265+
>{modal.options.submitText}</Button
266+
>
267+
<Button variant={ButtonStyleType.DEFAULT} on:click={() => modal.cancel()}>Cancel</Button>
247268
</ModalButtonGroup>

packages/core/src/utils/components/ListWrapper.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script lang="ts">
2-
export let elements: unknown[] = [];
2+
type T = $$Generic;
3+
4+
export let elements: T[] = [];
35
</script>
46

57
{#each elements.slice(0, elements.length - 1) as element}

packages/core/src/utils/components/LiteralRenderComponent.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
import { stringifyAndLinkUnknown } from 'packages/core/src/utils/Literal';
33
import LinkComponent from 'packages/core/src/utils/components/LinkComponent.svelte';
44
import ListWrapper from 'packages/core/src/utils/components/ListWrapper.svelte';
5+
import { MarkdownLink } from 'packages/core/src/parsers/MarkdownLinkParser';
56
6-
export let value = undefined;
7+
export let value: unknown = undefined;
8+
let parsedValue: string | MarkdownLink | (string | MarkdownLink)[];
79
8-
$: parsedValue = stringifyAndLinkUnknown(value);
10+
$: parsedValue = stringifyAndLinkUnknown(value, false);
911
</script>
1012

1113
{#if typeof parsedValue === 'string'}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<script lang="ts">
2-
export let checked: boolean;
2+
export let checked: boolean | undefined;
33
</script>
44

55
<div
66
class="checkbox-container"
7-
class:is-enabled={checked}
7+
class:is-enabled={checked ?? false}
88
role="switch"
99
tabindex="0"
10-
aria-checked={checked}
10+
aria-checked={checked ?? false}
1111
on:click={() => (checked = !checked)}
12+
on:keydown={e => {
13+
if (e.key === ' ') {
14+
checked = !checked;
15+
}
16+
}}
1217
>
13-
<input type="checkbox" tabindex="-1" checked={checked} />
18+
<input type="checkbox" tabindex="-1" checked={checked ?? false} />
1419
</div>

0 commit comments

Comments
 (0)