Skip to content

Commit b0412de

Browse files
chuckcarpenterRobbieTheWagner
authored andcommitted
Fix lint issues and ignore build artifacts
- Fix ESLint errors in supabase service (side-effects, unsafe return) - Fix unused vars and unnecessary type assertions - Convert register component to template-only - Add electron-app/ember-test to lint ignore files (build artifacts) - Format files with prettier
1 parent 43a43d5 commit b0412de

12 files changed

Lines changed: 118 additions & 94 deletions

File tree

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# compiled output
55
/dist/
66
/electron-app/dist/
7+
/electron-app/ember-test/
78
/electron-app/magnifier/rust-sampler/target/
89

910
# misc

.stylelintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# compiled output
55
/dist/
6+
/electron-app/ember-test/
67

78
# Rust generated documentation
89
**/target/doc/

app/authenticators/supabase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default class SupabaseAuthenticator extends BaseAuthenticator {
4444
* Restore session from Supabase's persisted storage.
4545
* Called on app startup to check if user is still logged in.
4646
*/
47+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4748
async restore(_data: SupabaseAuthData): Promise<SupabaseAuthData> {
4849
const session = await this.supabase.getSession();
4950

app/components/login.gts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ export default class LoginComponent extends Component {
100100
{{else}}
101101
{{! Email Entry Step }}
102102
<p class="text-menu-text text-sm mb-4">
103-
Enter your email and we'll send you a code to sign in.
104-
No password needed!
103+
Enter your email and we'll send you a code to sign in. No password
104+
needed!
105105
</p>
106106

107107
<div class="mb-6">
@@ -201,8 +201,7 @@ export default class LoginComponent extends Component {
201201

202202
this.router.transitionTo('settings.cloud.profile');
203203
} catch (error: unknown) {
204-
this.errorMessage =
205-
(error as Error).message || 'Invalid or expired code';
204+
this.errorMessage = (error as Error).message || 'Invalid or expired code';
206205
} finally {
207206
this.loading = false;
208207
}

app/components/register.gts

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
11
import { LinkTo } from '@ember/routing';
2-
import Component from '@glimmer/component';
32

43
/**
54
* With OTP authentication, there's no separate registration flow.
65
* New users are automatically created when they verify their email.
76
* This component just redirects users to the login flow.
87
*/
9-
export default class RegisterComponent extends Component {
10-
<template>
11-
<div class="bg-menu p-4 rounded-md w-full">
12-
<div class="pt-4 w-full">
13-
<h2 class="font-bold text-2xl">
14-
Sign Up
15-
</h2>
16-
</div>
8+
<template>
9+
<div class="bg-menu p-4 rounded-md w-full">
10+
<div class="pt-4 w-full">
11+
<h2 class="font-bold text-2xl">
12+
Sign Up
13+
</h2>
14+
</div>
15+
16+
<div class="mt-4">
17+
<p class="text-menu-text text-sm mb-4">
18+
Getting started is easy! Just enter your email address and we'll send
19+
you a code to sign in. No password required.
20+
</p>
1721

18-
<div class="mt-4">
19-
<p class="text-menu-text text-sm mb-4">
20-
Getting started is easy! Just enter your email address and we'll send
21-
you a code to sign in. No password required.
22-
</p>
22+
<p class="text-menu-text text-sm mb-6">
23+
If you're a new user, your account will be created automatically.
24+
</p>
2325

24-
<p class="text-menu-text text-sm mb-6">
25-
If you're a new user, your account will be created automatically.
26-
</p>
26+
<LinkTo
27+
@route="settings.cloud.login"
28+
class="btn btn-primary w-full inline-block text-center"
29+
data-test-register-continue
30+
>
31+
Continue with Email
32+
</LinkTo>
2733

34+
<p class="mt-4 text-center text-menu-text text-sm">
35+
Already have an account?
2836
<LinkTo
2937
@route="settings.cloud.login"
30-
class="btn btn-primary w-full inline-block text-center"
31-
data-test-register-continue
38+
class="font-medium text-alt hover:text-alt-hover"
3239
>
33-
Continue with Email
40+
Sign in
3441
</LinkTo>
35-
36-
<p class="mt-4 text-center text-menu-text text-sm">
37-
Already have an account?
38-
<LinkTo
39-
@route="settings.cloud.login"
40-
class="font-medium text-alt hover:text-alt-hover"
41-
>
42-
Sign in
43-
</LinkTo>
44-
</p>
45-
</div>
42+
</p>
4643
</div>
47-
</template>
48-
}
44+
</div>
45+
</template>

app/data-sources/remote.ts

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ import { getOwner } from '@ember/application';
22

33
import { applyStandardSourceInjections } from 'ember-orbit';
44

5-
import type { RealtimeChannel, SupabaseClient } from '@supabase/supabase-js';
6-
75
import { Orbit } from '@orbit/core';
86
import { Source } from '@orbit/data';
97
import type {
108
InitializedRecord,
119
RecordIdentity,
1210
RecordOperation,
11+
RecordQuery,
1312
RecordSchema,
1413
RecordTransformResult,
1514
} from '@orbit/records';
16-
import type { RecordQuery } from '@orbit/records';
15+
import type { RealtimeChannel, SupabaseClient } from '@supabase/supabase-js';
1716

1817
import type SessionService from '../services/session.ts';
1918
import type SupabaseService from '../services/supabase.ts';
@@ -114,7 +113,7 @@ export class SupabaseSource extends Source {
114113
const records = await this.findRecords(type);
115114
results.push(...records);
116115
} else if (expression.op === 'findRecord') {
117-
const record = expression.record as RecordIdentity;
116+
const record = expression.record;
118117
const result = await this.findRecord(record.type, record.id);
119118
if (result) results.push(result);
120119
}
@@ -139,50 +138,48 @@ export class SupabaseSource extends Source {
139138
for (const op of ops) {
140139
switch (op.op) {
141140
case 'addRecord': {
142-
const record = await this._addRecord(op.record as InitializedRecord);
141+
const record = await this._addRecord(op.record);
143142
results.push(record);
144143
break;
145144
}
146145
case 'updateRecord': {
147-
const record = await this.updateRecord(
148-
op.record as InitializedRecord
149-
);
146+
const record = await this.updateRecord(op.record);
150147
results.push(record);
151148
break;
152149
}
153150
case 'removeRecord': {
154-
await this.removeRecord(op.record as RecordIdentity);
151+
await this.removeRecord(op.record);
155152
break;
156153
}
157154
case 'replaceRelatedRecords': {
158155
await this.replaceRelatedRecords(
159-
op.record as RecordIdentity,
160-
op.relationship as string,
161-
op.relatedRecords as RecordIdentity[]
156+
op.record,
157+
op.relationship,
158+
op.relatedRecords
162159
);
163160
break;
164161
}
165162
case 'replaceRelatedRecord': {
166163
await this.replaceRelatedRecord(
167-
op.record as RecordIdentity,
168-
op.relationship as string,
169-
op.relatedRecord as RecordIdentity | null
164+
op.record,
165+
op.relationship,
166+
op.relatedRecord
170167
);
171168
break;
172169
}
173170
case 'addToRelatedRecords': {
174171
await this.addToRelatedRecords(
175-
op.record as RecordIdentity,
176-
op.relationship as string,
177-
op.relatedRecord as RecordIdentity
172+
op.record,
173+
op.relationship,
174+
op.relatedRecord
178175
);
179176
break;
180177
}
181178
case 'removeFromRelatedRecords': {
182179
await this.removeFromRelatedRecords(
183-
op.record as RecordIdentity,
184-
op.relationship as string,
185-
op.relatedRecord as RecordIdentity
180+
op.record,
181+
op.relationship,
182+
op.relatedRecord
186183
);
187184
break;
188185
}
@@ -215,7 +212,9 @@ export class SupabaseSource extends Source {
215212

216213
if (error) throw new Error(`Supabase query error: ${error.message}`);
217214

218-
return (data as SupabaseColor[]).map((c) => this.transformColorToOrbit(c));
215+
return (data as SupabaseColor[]).map((c) =>
216+
this.transformColorToOrbit(c)
217+
);
219218
}
220219
}
221220

@@ -259,7 +258,9 @@ export class SupabaseSource extends Source {
259258
}
260259

261260
// Add a record (internal implementation)
262-
private async _addRecord(record: InitializedRecord): Promise<InitializedRecord> {
261+
private async _addRecord(
262+
record: InitializedRecord
263+
): Promise<InitializedRecord> {
263264
const tableName = this.getTableName(record.type);
264265
const supabaseRecord = this.transformFromOrbit(record);
265266

@@ -277,7 +278,9 @@ export class SupabaseSource extends Source {
277278
}
278279

279280
// Update a record
280-
private async updateRecord(record: InitializedRecord): Promise<InitializedRecord> {
281+
private async updateRecord(
282+
record: InitializedRecord
283+
): Promise<InitializedRecord> {
281284
const tableName = this.getTableName(record.type);
282285
const supabaseRecord = this.transformFromOrbit(record);
283286

@@ -503,7 +506,9 @@ export class SupabaseSource extends Source {
503506
}
504507

505508
export default {
506-
create(injections: SupabaseSourceInjections = { schema: {} as RecordSchema }) {
509+
create(
510+
injections: SupabaseSourceInjections = { schema: {} as RecordSchema }
511+
) {
507512
applyStandardSourceInjections(injections);
508513

509514
injections.name = 'remote';

app/services/data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { orbit, type Store } from 'ember-orbit';
55

66
import type { Coordinator } from '@orbit/coordinator';
77
import type IndexedDBSource from '@orbit/indexeddb';
8-
import type { InitializedRecord, RecordIdentity } from '@orbit/records';
8+
import type { InitializedRecord } from '@orbit/records';
99

1010
import type Palette from '../data-models/palette.ts';
1111
import type { SupabaseSource } from '../data-sources/remote.ts';

app/services/supabase.ts

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import { createClient } from '@supabase/supabase-js';
1111

1212
import type { EnvironmentConfig } from '../config/environment.ts';
1313

14+
interface Owner {
15+
resolveRegistration(name: string): EnvironmentConfig;
16+
}
17+
1418
export interface SupabaseConfig {
1519
url: string;
1620
anonKey: string;
@@ -21,28 +25,30 @@ export default class SupabaseService extends Service {
2125

2226
get client(): SupabaseClient {
2327
if (!this._client) {
24-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
25-
const config = (getOwner(this) as any)?.resolveRegistration(
26-
'config:environment'
27-
) as EnvironmentConfig;
28-
const supabaseConfig = config.supabase;
29-
30-
if (!supabaseConfig?.url || !supabaseConfig?.anonKey) {
31-
throw new Error(
32-
'Supabase configuration is missing. Please set SUPABASE_URL and SUPABASE_ANON_KEY.'
33-
);
34-
}
28+
this._initializeClient();
29+
}
3530

36-
this._client = createClient(supabaseConfig.url, supabaseConfig.anonKey, {
37-
auth: {
38-
autoRefreshToken: true,
39-
persistSession: true,
40-
detectSessionInUrl: false, // Electron app, no URL detection needed
41-
},
42-
});
31+
return this._client!;
32+
}
33+
34+
private _initializeClient(): void {
35+
const owner = getOwner(this) as Owner | undefined;
36+
const config = owner?.resolveRegistration('config:environment');
37+
const supabaseConfig = config?.supabase;
38+
39+
if (!supabaseConfig?.url || !supabaseConfig?.anonKey) {
40+
throw new Error(
41+
'Supabase configuration is missing. Please set SUPABASE_URL and SUPABASE_ANON_KEY.'
42+
);
4343
}
4444

45-
return this._client;
45+
this._client = createClient(supabaseConfig.url, supabaseConfig.anonKey, {
46+
auth: {
47+
autoRefreshToken: true,
48+
persistSession: true,
49+
detectSessionInUrl: false, // Electron app, no URL detection needed
50+
},
51+
});
4652
}
4753

4854
get auth() {
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
import Register from '../../../components/register.gts';
22

3-
<template>
4-
<Register />
5-
</template>
3+
<template><Register /></template>

0 commit comments

Comments
 (0)