Skip to content

Commit 3bb6100

Browse files
Merge pull request #71 from PlotSenseAI/feature/test/cicd
fix: resolve ESLint errors in web frontend
2 parents 13c0d61 + f501683 commit 3bb6100

7 files changed

Lines changed: 19 additions & 17 deletions

File tree

web/src/components/ui/card.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ describe('Card Components', () => {
3030
})
3131

3232
it('should forward ref', () => {
33-
const ref = { current: null }
34-
render(<Card ref={ref as any}>Content</Card>)
33+
const ref = { current: null as HTMLDivElement | null }
34+
render(<Card ref={ref}>Content</Card>)
3535
expect(ref.current).toBeTruthy()
3636
})
3737

web/src/components/ui/input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { forwardRef } from 'react';
22
import { cn } from '@/lib/utils';
33

4-
export interface InputProps
5-
extends React.InputHTMLAttributes<HTMLInputElement> {}
4+
// InputProps extends React.InputHTMLAttributes to allow all standard input attributes
5+
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>;
66

77
const Input = forwardRef<HTMLInputElement, InputProps>(
88
({ className, type, ...props }, ref) => {

web/src/hooks/use-api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from 'react';
1+
import { useState, useEffect, useCallback } from 'react';
22
import { apiClient } from '@/utils/api';
33
import type { ApiResponse } from '@/types';
44

@@ -14,7 +14,7 @@ export const useApi = <T>(
1414
const [loading, setLoading] = useState(false);
1515
const [error, setError] = useState<string | null>(null);
1616

17-
const execute = async (): Promise<ApiResponse<T>> => {
17+
const execute = useCallback(async (): Promise<ApiResponse<T>> => {
1818
setLoading(true);
1919
setError(null);
2020

@@ -40,13 +40,13 @@ export const useApi = <T>(
4040
} finally {
4141
setLoading(false);
4242
}
43-
};
43+
}, [endpoint]);
4444

4545
useEffect(() => {
4646
if (options.immediate) {
4747
execute();
4848
}
49-
}, [endpoint, options.immediate]);
49+
}, [execute, options.immediate]);
5050

5151
return {
5252
data,

web/src/main.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ createRoot(document.getElementById('root')!).render(
1212
)
1313

1414
// initialize analytics after app mounts
15-
initAnalytics((import.meta as any).env?.VITE_GA_ID || (env as any).analytics?.gaId || import.meta.env.VITE_GA_ID)
15+
const gaId = import.meta.env.VITE_GA_ID ||
16+
(typeof env === 'object' && env !== null && 'analytics' in env &&
17+
typeof env.analytics === 'object' && env.analytics !== null &&
18+
'gaId' in env.analytics ? env.analytics.gaId : undefined);
19+
initAnalytics(gaId as string | undefined);

web/src/test/setup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import '@testing-library/jest-dom'
8-
import { expect, afterEach, vi } from 'vitest'
8+
import { afterEach, vi } from 'vitest'
99
import { cleanup } from '@testing-library/react'
1010

1111
// Cleanup after each test case (e.g., clearing jsdom)
@@ -28,7 +28,7 @@ global.IntersectionObserver = class IntersectionObserver {
2828
return []
2929
}
3030
unobserve() {}
31-
} as any
31+
} as unknown as typeof global.IntersectionObserver
3232

3333
// Mock window.matchMedia (for responsive components)
3434
Object.defineProperty(window, 'matchMedia', {

web/src/test/test-utils.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* for testing React components with common providers and setup.
66
*/
77

8-
import { ReactElement } from 'react'
9-
import { render, RenderOptions } from '@testing-library/react'
8+
import type { ReactElement } from 'react'
9+
import { render, type RenderOptions } from '@testing-library/react'
1010

1111
/**
1212
* Custom render function that wraps components with common providers
@@ -21,7 +21,7 @@ import { render, RenderOptions } from '@testing-library/react'
2121
* })
2222
* ```
2323
*/
24-
interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
24+
type CustomRenderOptions = Omit<RenderOptions, 'wrapper'> & {
2525
// Add custom options here as needed
2626
}
2727

@@ -44,5 +44,6 @@ export function renderWithProviders(
4444
}
4545

4646
// Re-export everything from testing library
47+
// eslint-disable-next-line react-refresh/only-export-components
4748
export * from '@testing-library/react'
4849
export { renderWithProviders as render }

web/src/utils/analytics.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const initAnalytics = async (measurementId: string | undefined): Promise<
3939
window.gtag('js', new Date());
4040
window.gtag('config', measurementId, { send_page_view: false, debug_mode: import.meta.env.DEV });
4141
if (import.meta.env.DEV) {
42-
// eslint-disable-next-line no-console
4342
console.info('[analytics] config sent for', measurementId);
4443
}
4544
trackPageView();
@@ -48,7 +47,6 @@ export const initAnalytics = async (measurementId: string | undefined): Promise<
4847
// no-op; failed to load analytics
4948
// You can log to console for debugging in dev
5049
if (import.meta.env.DEV) {
51-
// eslint-disable-next-line no-console
5250
console.warn('[analytics] failed to initialize', error);
5351
}
5452
}
@@ -64,7 +62,6 @@ export const trackPageView = (): void => {
6462
page_path: window.location.pathname,
6563
});
6664
if (import.meta.env.DEV) {
67-
// eslint-disable-next-line no-console
6865
console.info('[analytics] page_view', { page_location: pageLocation });
6966
}
7067
} catch {

0 commit comments

Comments
 (0)