diff --git a/.eslintrc.js b/.eslintrc.js index 4ca7e38..a9d7815 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -10,7 +10,14 @@ module.exports = { '@typescript-eslint/no-unsafe-assignment': 'off', '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-argument': 'off', - '@typescript-eslint/no-namespace': 'off' + '@typescript-eslint/no-namespace': 'off', + '@typescript-eslint/no-floating-promises': 'off', + '@typescript-eslint/await-thenable': 'off', + '@typescript-eslint/no-unsafe-call': 'off', + '@typescript-eslint/no-unsafe-enum-comparison': 'off', + '@typescript-eslint/no-var-requires': 'off', + 'no-restricted-syntax': 'off', + 'promise/always-return': 'off' } } ] diff --git a/src/components/GoogleReCaptchaCheckbox.tsx b/src/components/GoogleReCaptchaCheckbox.tsx index 3bf2831..78c9b0d 100644 --- a/src/components/GoogleReCaptchaCheckbox.tsx +++ b/src/components/GoogleReCaptchaCheckbox.tsx @@ -10,7 +10,7 @@ export interface GoogleReCaptchaCheckboxProps extends Omit action?: string; className?: string; container?: ContainerId | HTMLElement; - callback?: () => void; + callback?: (token: string) => void; errorCallback?: () => void; expiredCallback?: () => void; language?: GoogleReCaptcha.Language; diff --git a/src/context/GoogleReCaptchaContext.ts b/src/context/GoogleReCaptchaContext.ts index d4d27c2..3d83752 100644 --- a/src/context/GoogleReCaptchaContext.ts +++ b/src/context/GoogleReCaptchaContext.ts @@ -18,35 +18,28 @@ export interface GoogleReCaptchaContextProps { ) => void; } +const contextError = + 'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider'; + export const GoogleReCaptchaContext = createContext({ googleReCaptcha: {}, siteKey: '', language: '', isLoading: true, executeV3: () => { - throw Error( - 'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider' - ); + throw Error(contextError); }, executeV2Invisible: () => { - throw Error( - 'GoogleReCaptchaContext has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider' - ); + throw Error(contextError); }, reset: () => { - throw Error( - 'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider' - ); + throw Error(contextError); }, getResponse: () => { - throw Error( - 'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider' - ); + throw Error(contextError); }, render: () => { - throw Error( - 'GoogleReCaptcha Context has not yet been implemented, if you are using useGoogleReCaptcha hook, make sure the hook is called inside component wrapped by GoogleRecaptchaProvider' - ); + throw Error(contextError); } }); diff --git a/src/context/GoogleReCaptchaProvider.test.tsx b/src/context/GoogleReCaptchaProvider.test.tsx index 5c4eeb5..fb38fca 100644 --- a/src/context/GoogleReCaptchaProvider.test.tsx +++ b/src/context/GoogleReCaptchaProvider.test.tsx @@ -1,5 +1,5 @@ -import { render } from '@testing-library/react'; import React from 'react'; +import { render } from '@testing-library/react'; import type { GoogleReCaptchaProviderProps } from './GoogleReCaptchaProvider'; import { GoogleReCaptchaProvider } from './GoogleReCaptchaProvider'; diff --git a/src/context/GoogleReCaptchaProvider.tsx b/src/context/GoogleReCaptchaProvider.tsx index 0e131db..37231a5 100644 --- a/src/context/GoogleReCaptchaProvider.tsx +++ b/src/context/GoogleReCaptchaProvider.tsx @@ -1,13 +1,13 @@ import React from 'react'; -import type { GoogleReCaptcha, ContainerId } from '../utils'; +import type { ContainerId, GoogleReCaptcha } from '../utils'; import { - removeGoogleReCaptchaScript, - injectGoogleReCaptchaScript, + checkGoogleReCaptchaInjected, hideGoogleReCaptchaBadge, - removeGoogleReCaptchaContainer, + injectGoogleReCaptchaScript, removeGoogleReCaptchaBadge, - checkGoogleReCaptchaInjected + removeGoogleReCaptchaContainer, + removeGoogleReCaptchaScript } from '../utils'; import { GoogleReCaptchaContextProvider } from './GoogleReCaptchaContext'; diff --git a/src/context/withGoogleReCaptcha.tsx b/src/context/withGoogleReCaptcha.tsx index 50424d2..7eee5b6 100644 --- a/src/context/withGoogleReCaptcha.tsx +++ b/src/context/withGoogleReCaptcha.tsx @@ -7,7 +7,7 @@ export interface WithGoogleReCaptchaParams { googleReCaptcha: GoogleReCaptchaContextProps; } -export const withGoogleReCaptcha = ( +export const withGoogleReCaptcha = ( Component: React.ComponentType ) => { const WithGoogleReCaptchaComponent = (props: OwnProps & Partial) => (