Skip to content

Commit 11bcee4

Browse files
fix: resolve eslint errors in AuthContext and test file
1 parent c406281 commit 11bcee4

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

frontend/src/context/AuthContext.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
2424
const [token, setToken] = useState<string | null>(
2525
localStorage.getItem("token"),
2626
);
27-
const [loading, setLoading] = useState(true);
27+
const [loading, setLoading] = useState(!!token);
2828

2929
useEffect(() => {
3030
if (token) {
@@ -37,8 +37,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
3737
setToken(null);
3838
})
3939
.finally(() => setLoading(false));
40-
} else {
41-
setLoading(false);
4240
}
4341
}, [token]);
4442

@@ -78,6 +76,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
7876
);
7977
}
8078

79+
// eslint-disable-next-line react-refresh/only-export-components
8180
export function useAuth() {
8281
const context = useContext(AuthContext);
8382
if (!context) throw new Error("useAuth must be used within AuthProvider");

frontend/src/test/ProtectedRoute.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe("ProtectedRoute", () => {
88
it("redirects to login when not authenticated", () => {
99
// Clear any token
1010
localStorage.removeItem("token");
11-
const { container } = render(
11+
render(
1212
<MemoryRouter initialEntries={["/dashboard"]}>
1313
<AuthProvider>
1414
<ProtectedRoute>

0 commit comments

Comments
 (0)