From 830f90058a2d16243f234097010c590379b92016 Mon Sep 17 00:00:00 2001 From: Marcel van Remmerden Date: Tue, 9 Jan 2024 02:42:15 +0000 Subject: [PATCH] Fix all eslint errors --- example/components/StyledFirebaseAuth.tsx | 69 ++++++++++++----------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/example/components/StyledFirebaseAuth.tsx b/example/components/StyledFirebaseAuth.tsx index f86dfd32..cc4ad49b 100644 --- a/example/components/StyledFirebaseAuth.tsx +++ b/example/components/StyledFirebaseAuth.tsx @@ -1,66 +1,69 @@ import { useEffect, useRef, useState } from 'react' import { onAuthStateChanged } from 'firebase/auth' import 'firebaseui/dist/firebaseui.css' -import {auth} from "firebaseui" +import { auth } from 'firebaseui' interface Props { // The Firebase UI Web UI Config object. // See: https://github.com/firebase/firebaseui-web#configuration - uiConfig: auth.Config; + uiConfig: auth.Config // Callback that will be passed the FirebaseUi instance before it is // started. This allows access to certain configuration options such as // disableAutoSignIn(). - uiCallback?(ui: auth.AuthUI): void; + uiCallback?(ui: auth.AuthUI): void // The Firebase App auth instance to use. - firebaseAuth: any; // As firebaseui-web - className?: string; + firebaseAuth: any // As firebaseui-web + className?: string } - -const StyledFirebaseAuth = ({uiConfig, firebaseAuth, className, uiCallback}: Props) => { - const [firebaseui, setFirebaseui] = useState(null); - const [userSignedIn, setUserSignedIn] = useState(false); - const elementRef = useRef(null); +const StyledFirebaseAuth = ({ + uiConfig, + firebaseAuth, + className, + uiCallback, +}: Props) => { + const [firebaseui, setFirebaseui] = useState< + typeof import('firebaseui') | null + >(null) + const [userSignedIn, setUserSignedIn] = useState(false) + const elementRef = useRef(null) useEffect(() => { // Firebase UI only works on the Client. So we're loading the package only after // the component has mounted, so that this works when doing server-side rendering. - setFirebaseui(require('firebaseui')); - }, []); - + setFirebaseui(require('firebaseui')) + }, []) useEffect(() => { - if (firebaseui === null ) - return; + if (firebaseui === null) return // Get or Create a firebaseUI instance. - const firebaseUiWidget = firebaseui.auth.AuthUI.getInstance() || new firebaseui.auth.AuthUI(firebaseAuth); - if (uiConfig.signInFlow === 'popup') - firebaseUiWidget.reset(); + const firebaseUiWidget = + firebaseui.auth.AuthUI.getInstance() || + new firebaseui.auth.AuthUI(firebaseAuth) + if (uiConfig.signInFlow === 'popup') firebaseUiWidget.reset() // We track the auth state to reset firebaseUi if the user signs out. - const unregisterAuthObserver = onAuthStateChanged(firebaseAuth, user => { - if (!user && userSignedIn) - firebaseUiWidget.reset(); - setUserSignedIn(!!user); - }); + const unregisterAuthObserver = onAuthStateChanged(firebaseAuth, (user) => { + if (!user && userSignedIn) firebaseUiWidget.reset() + setUserSignedIn(!!user) + }) // Trigger the callback if any was set. - if (uiCallback) - uiCallback(firebaseUiWidget); + if (uiCallback) uiCallback(firebaseUiWidget) // Render the firebaseUi Widget. // @ts-ignore - firebaseUiWidget.start(elementRef.current, uiConfig); + firebaseUiWidget.start(elementRef.current, uiConfig) return () => { - unregisterAuthObserver(); - firebaseUiWidget.reset(); - }; + unregisterAuthObserver() + firebaseUiWidget.reset() + } // eslint-disable-next-line react-hooks/exhaustive-deps - }, [firebaseui, uiConfig]); + }, [firebaseui, uiConfig]) - return
; -}; + return
+} -export default StyledFirebaseAuth; \ No newline at end of file +export default StyledFirebaseAuth