Skip to content

Commit 5ed579a

Browse files
committed
fix: resolve all ESLint errors and warnings
- Fix React hooks rules violations by moving all hooks to top level - Fix unescaped entities in JSX (apostrophes and quotes) - Replace <img> tags with Next.js <Image /> components - Fix ESLint config anonymous default export warning All files now pass ESLint with 0 errors and 0 warnings
1 parent 0202e5c commit 5ed579a

12 files changed

Lines changed: 51 additions & 28 deletions

File tree

apps/web/eslint.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ const compat = new FlatCompat({
99
baseDirectory: __dirname,
1010
});
1111

12-
export default [
12+
const config = [
1313
{
1414
ignores: ['**/node_modules/**', '.next/**'],
1515
},
1616
...compat.extends('next/core-web-vitals'),
1717
];
18+
19+
export default config;

apps/web/src/app/booking/confirmation/[bookingId]/page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ export default function BookingConfirmationPageRoute() {
2525
// Improve type safety for route parameters
2626
const bookingId = Array.isArray(params.bookingId) ? params.bookingId[0] : params.bookingId;
2727

28+
// Always call hooks at the top level - before any conditional returns
29+
const { bookingData, loading, error } = useBookingDetails(bookingId || '');
30+
2831
if (!bookingId) {
2932
// Handle missing bookingId case
3033
router.push('/');
3134
return null;
3235
}
3336

34-
const { bookingData, loading, error } = useBookingDetails(bookingId);
35-
3637
if (loading) {
3738
return (
3839
<BookingPageLayout>

apps/web/src/app/dashboard/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export default function DashboardPage() {
4444
<div className="flex flex-col items-center justify-center min-h-screen text-center">
4545
<h1 className="text-2xl font-bold mb-4">Welcome, Host!</h1>
4646
<p className="mb-4">
47-
You don't have any properties yet. Please create a property to access the host dashboard.
47+
You don&apos;t have any properties yet. Please create a property to access the host dashboard.
4848
</p>
4949
<Link
5050
href="/add-property"

apps/web/src/components/blockchain/BlockchainStatusBadge.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ export function BlockchainStatusBadge({
2525
const [status, setStatus] = useState<PropertyBlockchainStatus | null>(null);
2626
const [isLoading, setIsLoading] = useState(false);
2727

28-
// Don't render if blockchain features are disabled
29-
if (!isBlockchainEnabled()) {
30-
return null;
31-
}
32-
28+
// Always call hooks at the top level - before any conditional returns
3329
const loadStatus = useCallback(async () => {
30+
if (!isBlockchainEnabled()) return;
31+
3432
setIsLoading(true);
3533
try {
3634
const blockchainStatus = await getPropertyBlockchainStatus(propertyId);
@@ -47,11 +45,16 @@ export function BlockchainStatusBadge({
4745
}, [propertyId]);
4846

4947
useEffect(() => {
50-
if (propertyId) {
48+
if (propertyId && isBlockchainEnabled()) {
5149
loadStatus();
5250
}
5351
}, [propertyId, loadStatus]);
5452

53+
// Don't render if blockchain features are disabled
54+
if (!isBlockchainEnabled()) {
55+
return null;
56+
}
57+
5558
if (isLoading) {
5659
return (
5760
<Badge variant="outline" className={`${className} ${getSizeClasses(size)}`}>
@@ -128,11 +131,10 @@ export function BlockchainStatusIcon({
128131
}) {
129132
const [status, setStatus] = useState<PropertyBlockchainStatus | null>(null);
130133

131-
if (!isBlockchainEnabled()) {
132-
return null;
133-
}
134-
134+
// Always call hooks at the top level - before any conditional returns
135135
useEffect(() => {
136+
if (!isBlockchainEnabled()) return;
137+
136138
const loadStatus = async () => {
137139
try {
138140
const blockchainStatus = await getPropertyBlockchainStatus(propertyId);
@@ -147,6 +149,10 @@ export function BlockchainStatusIcon({
147149
}
148150
}, [propertyId]);
149151

152+
if (!isBlockchainEnabled()) {
153+
return null;
154+
}
155+
150156
if (!status) {
151157
return (
152158
<Shield

apps/web/src/components/blockchain/BlockchainVerification.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ export function BlockchainVerification({ propertyId, className }: BlockchainVeri
3535
const [isLoading, setIsLoading] = useState(false);
3636
const [isVerifying, setIsVerifying] = useState(false);
3737

38-
// Don't render if blockchain features are disabled
39-
if (!isBlockchainEnabled()) {
40-
return null;
41-
}
42-
38+
// Always call hooks at the top level - before any conditional returns
4339
const loadStatus = useCallback(async () => {
40+
if (!isBlockchainEnabled()) return;
41+
4442
setIsLoading(true);
4543
try {
4644
const blockchainStatus = await getPropertyBlockchainStatus(propertyId);
@@ -57,6 +55,8 @@ export function BlockchainVerification({ propertyId, className }: BlockchainVeri
5755
}, [propertyId]);
5856

5957
const handleVerify = async () => {
58+
if (!isBlockchainEnabled()) return;
59+
6060
setIsVerifying(true);
6161
try {
6262
const blockchainStatus = await getPropertyBlockchainStatus(propertyId);
@@ -106,9 +106,16 @@ export function BlockchainVerification({ propertyId, className }: BlockchainVeri
106106
};
107107

108108
useEffect(() => {
109-
loadStatus();
109+
if (isBlockchainEnabled()) {
110+
loadStatus();
111+
}
110112
}, [loadStatus]);
111113

114+
// Don't render if blockchain features are disabled
115+
if (!isBlockchainEnabled()) {
116+
return null;
117+
}
118+
112119
if (isLoading && !status) {
113120
return (
114121
<Card className={`p-4 ${className}`}>

apps/web/src/components/booking/BookingForm.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Calendar } from '@/components/ui/calendar';
44
import { Card } from '@/components/ui/card';
55
import { useWallet } from '@/hooks/useWallet';
66
import { format } from 'date-fns';
7+
import Image from 'next/image';
78
import { useState } from 'react';
89
import type { DateRange } from 'react-day-picker';
910
import { toast } from 'react-hot-toast';
@@ -86,10 +87,11 @@ export function BookingForm({ onSubmit, propertyId }: BookingFormProps) {
8687
<Card className="p-6">
8788
<h1 className="mb-4 text-2xl font-bold">{property.title}</h1>
8889
<div className="relative mb-4 aspect-video rounded-lg overflow-hidden">
89-
<img
90+
<Image
9091
src={property.image || '/placeholder.svg'}
9192
alt={property.title}
92-
className="h-full w-full object-cover"
93+
fill
94+
className="object-cover"
9395
/>
9496
</div>
9597
<div className="space-y-4">

apps/web/src/components/booking/confirmation/BookingDetailsCard.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Card, CardHeader } from '@/components/ui/card';
44
import type { BookingData } from '@/types/booking';
55
import { format } from 'date-fns';
6+
import Image from 'next/image';
67
import { Calendar, DollarSign, MapPin, Users } from 'lucide-react';
78

89
interface BookingDetailsCardProps {
@@ -25,9 +26,11 @@ export function BookingDetailsCard({ bookingData }: BookingDetailsCardProps) {
2526
<div className="flex items-start space-x-4">
2627
<div className="w-20 h-20 rounded-lg bg-muted flex items-center justify-center overflow-hidden">
2728
{property.image ? (
28-
<img
29+
<Image
2930
src={property.image}
3031
alt={property.title}
32+
width={80}
33+
height={80}
3134
className="w-full h-full object-cover"
3235
/>
3336
) : (

apps/web/src/components/booking/confirmation/EscrowStatusCard.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export function EscrowStatusCard({
1919
totalAmount,
2020
bookingId,
2121
}: EscrowStatusCardProps) {
22+
// Always call hooks at the top level - before any conditional returns
23+
const { escrowData } = useEscrowStatus(bookingId || '', initialStatus);
24+
2225
if (!bookingId) {
2326
return (
2427
<Card className="overflow-hidden">
@@ -29,7 +32,6 @@ export function EscrowStatusCard({
2932
</Card>
3033
);
3134
}
32-
const { escrowData } = useEscrowStatus(bookingId, initialStatus);
3335

3436
const currentStatus = escrowData?.status || initialStatus;
3537
const lastUpdated = escrowData?.lastUpdated || new Date();

apps/web/src/components/dashboard/BookingHistory.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ const BookingHistory: React.FC<BookingHistoryProps> = ({
452452
<AlertCircle className="w-5 h-5 text-yellow-600 mt-0.5 mr-2" />
453453
<div className="text-sm text-yellow-800 dark:text-yellow-200">
454454
<p className="font-medium">Cancellation Policy</p>
455-
<p>You may be charged a cancellation fee depending on the property's policy.</p>
455+
<p>You may be charged a cancellation fee depending on the property&apos;s policy.</p>
456456
</div>
457457
</div>
458458
</div>

apps/web/src/components/escrows/exampleInitializeContract.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useInitializeContract } from '~/hooks/escrows/useInitializeContract';
22

3-
export const exampleInitializeContract = () => {
3+
export function ExampleInitializeContract() {
44
const { handleSubmit } = useInitializeContract();
55

66
// Mock payload MultiRelease escrow

0 commit comments

Comments
 (0)