Skip to content
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

fix: eslint monorepo svelte 5 setup #5246

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ build
package
!.env.example
vite.config.ts.timestamp-*
tsconfig.tsbuildinfo

# Written to disk when using `act`
.pnpm-store
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/lib/ai/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ describe.concurrent('buildDiff', () => {
const expectedOutput2 = `${hunk2.filePath} - ${hunk2.diff}\n${hunk1.filePath} - ${hunk1.diff}`;

const outputMatchesExpectedValue = [expectedOutput1, expectedOutput2].includes(
buildDiff([hunk1, hunk1], 10000)
buildDiff([hunk1, hunk2], 10000)
);

expect(outputMatchesExpectedValue).toBeTruthy;
expect(outputMatchesExpectedValue).toBeTruthy();
});
});
8 changes: 5 additions & 3 deletions apps/desktop/src/lib/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export function initAnalyticsIfEnabled() {
appNonAnonMetricsEnabled()
.onDisk()
.then((enabled) => {
enabled
? posthog.capture('nonAnonMetricsEnabled')
: posthog.capture('nonAnonMetricsDisabled');
if (enabled) {
posthog.capture('nonAnonMetricsEnabled');
} else {
posthog.capture('nonAnonMetricsDisabled');
}
});
}
});
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/lib/commit/CommitList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
// Force the "base" commit lines to update when $branch updates.
let tsKey = $state<number | undefined>(undefined);
$effect(() => {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
$branch;
tsKey = Date.now();
});
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/lib/components/ProjectNotFound.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
deleteProject: {
try {
await projectsService.deleteProject(id);
} catch (e) {
} catch {
deleteSucceeded = false;
break deleteProject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@

export function close() {
isVisible = false;
onclose && onclose();
if (onclose) {
onclose();
}
}

export function open(e?: MouseEvent, newItem?: any) {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/lib/config/appSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function persisted<T>(initial: T, key: string): Writable<T> & { onDisk: () => Pr
async function storeValueWithDefault<T>(initial: T, key: string): Promise<T> {
try {
await store.load();
} catch (e) {
} catch {
// If file does not exist, reset it
store.reset();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/lib/file/FileContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

return item.files.some((f: unknown) => {
if (!isAnyFile(f)) return false;
computeFileStatus(f) === 'D';
return computeFileStatus(f) === 'D';
});
}

Expand Down
4 changes: 3 additions & 1 deletion apps/desktop/src/lib/history/History.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@

<svelte:window
on:keydown={(e) => {
e.key === 'Escape' && dispatch('hide');
if (e.key === 'Escape') {
dispatch('hide');
}
}}
/>

Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/lib/hunk/HunkContextMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@
<ContextMenuItem
label="Open in {$userSettings.defaultCodeEditor.displayName}"
onclick={() => {
projectPath &&
if (projectPath) {
openExternalUrl(
`${$userSettings.defaultCodeEditor.schemeIdentifer}://file${projectPath}/${filePath}:${item.lineNumber}`
);
}
contextMenu?.close();
}}
/>
Expand Down
12 changes: 9 additions & 3 deletions apps/desktop/src/lib/hunk/HunkDiff.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@
class:is-before={side === CountColumnSide.Before}
class:selected={isSelected}
onclick={() => {
selectable && handleSelected(hunk, !isSelected);
if (selectable) {
handleSelected(hunk, !isSelected);
}
}}
>
{side === CountColumnSide.Before ? row.beforeLineNumber : row.afterLineNumber}
Expand All @@ -348,7 +350,9 @@
<thead class="table__title" class:draggable={!draggingDisabled}>
<tr
onclick={() => {
selectable && handleSelected(hunk, !isSelected);
if (selectable) {
handleSelected(hunk, !isSelected);
}
}}
>
<th
Expand All @@ -364,7 +368,9 @@
checked={isSelected}
small
onclick={() => {
selectable && handleSelected(hunk, !isSelected);
if (selectable) {
handleSelected(hunk, !isSelected);
}
}}
/>
{/if}
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/src/lib/navigation/ChunkyList.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<script lang="ts" module>
type T = any;
</script>

<script lang="ts" generics="T">
/**
* Lazily renders a list of many many items. This is intended to be used
Expand Down
2 changes: 2 additions & 0 deletions apps/desktop/src/lib/select/Select.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script lang="ts" module>
type T = string;

export type SelectItem<T extends string = string> = {
label: string;
value: T;
Expand Down
5 changes: 4 additions & 1 deletion apps/desktop/src/lib/stores/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ export class UserService {
this.user.set(undefined);
}
readonly accessToken$ = derived(this.user, (user) => {
user?.github_access_token;
if (user?.github_access_token) {
return user.github_access_token;
}
return undefined;
});

constructor(
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/lib/components/Navigation.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
<button
class="nav__right--button"
onclick={() => {
$token ? logout() : login();
if ($token) {
logout();
} else {
login();
}
}}
>
{$token ? 'Log Out' : 'Log In'}
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/lib/user/userService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setSentryUser } from '$lib/analytics/sentry';
import { writable } from 'svelte/store';
import { writable, type Writable } from 'svelte/store';
import type { HttpClient } from '@gitbutler/shared/httpClient';

export interface User {
Expand All @@ -12,7 +12,7 @@ export interface User {
}

export class UserService {
user = writable<User | undefined>(undefined, (set) => {
user: Writable<User | undefined> = writable<User | undefined>(undefined, (set) => {
this.fetchUser()
.then((data) => {
this.error.set(undefined);
Expand Down
5 changes: 4 additions & 1 deletion apps/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"experimentalDecorators": true
"experimentalDecorators": true,
"declaration": true,
"composite": true,
"declarationMap": true
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
Expand Down
Loading