Skip to content

Commit

Permalink
chore: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
yamashita-kenngo committed Jun 1, 2024
1 parent dcdf6e2 commit ee455ed
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 42 deletions.
4 changes: 2 additions & 2 deletions app/src/pages/403.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const test = suite<ReturnType<typeof render>>("<Page403 />");

test.before.each((context) => {
const returnValue = render(() => <Page403 />);
Object.getOwnPropertyNames(returnValue).forEach((name) => {
for (const name of Object.getOwnPropertyNames(returnValue)) {
// @ts-expect-error
context[name] = returnValue[name];
});
}
});

test.after.each(({ unmount }) => unmount());
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/account/addAccount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const test = suite<ReturnType<typeof render>>("<AddAccount />");

test.before.each((context) => {
const returnValue = render(() => <AddAccount />);
Object.getOwnPropertyNames(returnValue).forEach((name) => {
for (const name of Object.getOwnPropertyNames(returnValue)) {
// @ts-expect-error
context[name] = returnValue[name];
});
}
});

test.after.each(({ unmount }) => unmount());
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/dashboard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const test = suite<ReturnType<typeof render>>("<Dashboard />");

test.before.each((context) => {
const returnValue = render(() => <Dashboard />);
Object.getOwnPropertyNames(returnValue).forEach((name) => {
for (const name of Object.getOwnPropertyNames(returnValue)) {
// @ts-expect-error
context[name] = returnValue[name];
});
}
});

test.after.each(({ unmount }) => unmount());
Expand Down
14 changes: 7 additions & 7 deletions app/src/pages/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getCurrentUser } from "../service/auth";
import { QueryObj, getDocumentsWithQuery } from "../service/firestore";
import { DocumentData } from "firebase/firestore";
import { getDocumentsWithQuery, firestore }from "../service/firestore";
import type { QueryObj } from "../service/firestore";
import type { DocumentData } from "firebase/firestore";

const Dashboard = () => {
return (
Expand All @@ -12,21 +13,20 @@ const Dashboard = () => {
</h1>
<div class="flex items-center justify-end">
<div class="ml-4 flex items-center md:ml-6">
{/* pulldown menu select */}
<select class="block appearance-none bg-white border border-gray-400 hover:border-gray-500 px-4 py-2 pr-8 rounded shadow leading-tight focus:outline-none focus:shadow-outline">
<option>🏘️Tenant Info</option>
<option>🪪Account Info</option>
<option>🛫Product Info</option>
<option>⚙️Settings</option>
</select>
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 mx-2 rounded">
<button type="button" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 mx-2 rounded">
Logout
</button>
</div>
</div>
</div>
</header>
<div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
<div class="max-w-7xl mx-auto my-2 py-6 sm:px-6 lg:px-8">
<div class="px-4 py-6 sm:px-0">
<div class="border-4 border-dashed border-gray-200 rounded-lg h-96">
<div class="flex flex-col items-center justify-center h-full">
Expand All @@ -35,7 +35,7 @@ const Dashboard = () => {
</h2>
<a
href="/tenant/add"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 mx-2 rounded"
class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 mx-2 my-2 rounded"
>
Register Tenant
</a>
Expand All @@ -58,7 +58,7 @@ async function getAccountInfo(): Promise<DocumentData | null> {
operator: "==",
value: uid,
};
const result = await getDocumentsWithQuery(collectionName, queryObj);
const result = await getDocumentsWithQuery(firestore, collectionName, queryObj);
if (result instanceof Error) {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const test = suite<ReturnType<typeof render>>("<Login />");

test.before.each((context) => {
const returnValue = render(() => <Login />);
Object.getOwnPropertyNames(returnValue).forEach((name) => {
for (const name of Object.getOwnPropertyNames(returnValue)) {
// @ts-expect-error
context[name] = returnValue[name];
});
}
});

test.after.each(({ unmount }) => unmount());
Expand Down
2 changes: 1 addition & 1 deletion app/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const Login = () => {
type="password"
autocomplete="current-password"
required
class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
class="block w-full rounded-md border-0 px-2 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
onChange={(e) => handlePasswordChange(e)}
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/tenant/addTenant.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const test = suite<ReturnType<typeof render>>("<AddTenant />");

test.before.each((context) => {
const returnValue = render(() => <AddTenant />);
Object.getOwnPropertyNames(returnValue).forEach((name) => {
for (const name of Object.getOwnPropertyNames(returnValue)) {
// @ts-expect-error
context[name] = returnValue[name];
});
}
});

test.after.each(({ unmount }) => unmount());
Expand Down
4 changes: 2 additions & 2 deletions app/src/service/firestore.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test } from "uvu";
import * as assert from "uvu/assert";
import fs from "node:fs";
import {
initializeTestEnvironment,
import type {
RulesTestEnvironment,
} from "@firebase/rules-unit-testing";
import { initializeTestEnvironment } from "@firebase/rules-unit-testing";

import { getAllDocumentsWithCollectionName } from "./firestore";
import type { Firestore } from "firebase/firestore";
Expand Down
30 changes: 8 additions & 22 deletions app/src/service/firestore.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import { firebaseApp } from "./firebase";
import {
import { getFirestore, collection, getDocs,getDoc, setDoc, doc, addDoc, updateDoc, deleteDoc, query,where } from "firebase/firestore";
import type {
CollectionReference,
DocumentData,
Firestore,
query,
Query,
addDoc,
collection,
collectionGroup,
deleteDoc,
doc,
getDoc,
getFirestore,
setDoc,
updateDoc,
getDocs,
where,
QuerySnapshot,
} from "firebase/firestore";

export const firestore: Firestore = getFirestore(firebaseApp);
Expand Down Expand Up @@ -46,7 +33,7 @@ export async function getAllDocumentsWithCollectionName(
}
return documents;
} catch (error) {
return new Error("Error getting documents: " + error);
return new Error(`Error getting documents: ${error}`);
}
}

Expand All @@ -62,7 +49,7 @@ export async function addNewDocument(
return null;
})
.catch((error) => {
return new Error("Error adding document: " + error);
return new Error(`Error adding document: ${error}`);
});
}

Expand All @@ -78,7 +65,7 @@ export async function addNewDocumentWithAutoId(
return null;
})
.catch((error) => {
return new Error("Error adding document: " + error);
return new Error(`Error adding document: ${error}`);
});
}

Expand All @@ -91,9 +78,8 @@ export async function getDocumentById(
const documentSnapshot = await getDoc(documentRef);
if (documentSnapshot.exists()) {
return documentSnapshot.data();
} else {
return null;
}
return null;
}

export async function updateDocument(
Expand All @@ -108,7 +94,7 @@ export async function updateDocument(
return null;
})
.catch((error) => {
return new Error("Error updating document: " + error);
return new Error(`Error updating document: ${error}`);
});
}

Expand All @@ -123,7 +109,7 @@ export async function deleteDocument(
return null;
})
.catch((error) => {
return new Error("Error deleting document: " + error);
return new Error(`Error deleting document: ${error}`);
});
}

Expand Down

0 comments on commit ee455ed

Please sign in to comment.