ignite-parse-auth-kit 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CONTRIBUTING.md +0 -0
  2. package/LICENSE +21 -0
  3. package/README.md +492 -0
  4. package/app/app.tsx +116 -0
  5. package/app/components/AlertTongle.tsx +105 -0
  6. package/app/components/AutoImage.tsx +89 -0
  7. package/app/components/Button.tsx +248 -0
  8. package/app/components/Card.tsx +314 -0
  9. package/app/components/EmptyState.tsx +248 -0
  10. package/app/components/Header.tsx +332 -0
  11. package/app/components/Icon.tsx +140 -0
  12. package/app/components/ListItem.tsx +243 -0
  13. package/app/components/ListView.tsx +42 -0
  14. package/app/components/Screen.tsx +305 -0
  15. package/app/components/Text.test.tsx +23 -0
  16. package/app/components/Text.tsx +116 -0
  17. package/app/components/TextField.tsx +292 -0
  18. package/app/components/Toggle/Checkbox.tsx +123 -0
  19. package/app/components/Toggle/Radio.tsx +106 -0
  20. package/app/components/Toggle/Switch.tsx +264 -0
  21. package/app/components/Toggle/Toggle.tsx +285 -0
  22. package/app/components/index copy.ts +15 -0
  23. package/app/components/index.ts +18 -0
  24. package/app/config/config.base.ts +26 -0
  25. package/app/config/config.dev.ts +10 -0
  26. package/app/config/config.prod.ts +10 -0
  27. package/app/config/index.ts +28 -0
  28. package/app/context/AuthContext.tsx +14 -0
  29. package/app/context/EpisodeContext.tsx +136 -0
  30. package/app/context/auth/AuthProvider.tsx +340 -0
  31. package/app/context/auth/hooks.ts +29 -0
  32. package/app/context/auth/index.ts +38 -0
  33. package/app/context/auth/reducer.ts +68 -0
  34. package/app/context/auth/services.ts +394 -0
  35. package/app/context/auth/types.ts +99 -0
  36. package/app/context/auth/validation.ts +45 -0
  37. package/app/devtools/ReactotronClient.ts +9 -0
  38. package/app/devtools/ReactotronClient.web.ts +12 -0
  39. package/app/devtools/ReactotronConfig.ts +139 -0
  40. package/app/i18n/ar.ts +126 -0
  41. package/app/i18n/demo-ar.ts +464 -0
  42. package/app/i18n/demo-en.ts +462 -0
  43. package/app/i18n/demo-es.ts +469 -0
  44. package/app/i18n/demo-fr.ts +471 -0
  45. package/app/i18n/demo-hi.ts +468 -0
  46. package/app/i18n/demo-ja.ts +464 -0
  47. package/app/i18n/demo-ko.ts +457 -0
  48. package/app/i18n/en.ts +146 -0
  49. package/app/i18n/es.ts +132 -0
  50. package/app/i18n/fr.ts +132 -0
  51. package/app/i18n/hi.ts +131 -0
  52. package/app/i18n/index.ts +86 -0
  53. package/app/i18n/ja.ts +130 -0
  54. package/app/i18n/ko.ts +129 -0
  55. package/app/i18n/translate.ts +33 -0
  56. package/app/lib/Parse/index.ts +2 -0
  57. package/app/lib/Parse/parse.ts +62 -0
  58. package/app/navigators/AppNavigator.tsx +145 -0
  59. package/app/navigators/DemoNavigator.tsx +137 -0
  60. package/app/navigators/navigationUtilities.ts +208 -0
  61. package/app/screens/ChooseAuthScreen.tsx +224 -0
  62. package/app/screens/DemoCommunityScreen.tsx +141 -0
  63. package/app/screens/DemoDebugScreen.tsx +192 -0
  64. package/app/screens/DemoPodcastListScreen.tsx +387 -0
  65. package/app/screens/DemoShowroomScreen/DemoDivider.tsx +66 -0
  66. package/app/screens/DemoShowroomScreen/DemoShowroomScreen.tsx +313 -0
  67. package/app/screens/DemoShowroomScreen/DemoUseCase.tsx +52 -0
  68. package/app/screens/DemoShowroomScreen/DrawerIconButton.tsx +120 -0
  69. package/app/screens/DemoShowroomScreen/SectionListWithKeyboardAwareScrollView.tsx +59 -0
  70. package/app/screens/DemoShowroomScreen/demos/DemoAutoImage.tsx +230 -0
  71. package/app/screens/DemoShowroomScreen/demos/DemoButton.tsx +234 -0
  72. package/app/screens/DemoShowroomScreen/demos/DemoCard.tsx +181 -0
  73. package/app/screens/DemoShowroomScreen/demos/DemoEmptyState.tsx +78 -0
  74. package/app/screens/DemoShowroomScreen/demos/DemoHeader.tsx +151 -0
  75. package/app/screens/DemoShowroomScreen/demos/DemoIcon.tsx +115 -0
  76. package/app/screens/DemoShowroomScreen/demos/DemoListItem.tsx +218 -0
  77. package/app/screens/DemoShowroomScreen/demos/DemoText.tsx +144 -0
  78. package/app/screens/DemoShowroomScreen/demos/DemoTextField.tsx +233 -0
  79. package/app/screens/DemoShowroomScreen/demos/DemoToggle.tsx +354 -0
  80. package/app/screens/DemoShowroomScreen/demos/index.ts +12 -0
  81. package/app/screens/ErrorScreen/ErrorBoundary.tsx +76 -0
  82. package/app/screens/ErrorScreen/ErrorDetails.tsx +98 -0
  83. package/app/screens/ForgetPasswordScreen.tsx +180 -0
  84. package/app/screens/LoginScreen.tsx +260 -0
  85. package/app/screens/RegisterScreen.tsx +395 -0
  86. package/app/screens/WelcomeScreen.tsx +114 -0
  87. package/app/services/api/apiProblem.test.ts +73 -0
  88. package/app/services/api/apiProblem.ts +74 -0
  89. package/app/services/api/index.ts +91 -0
  90. package/app/services/api/types.ts +50 -0
  91. package/app/theme/colors.ts +85 -0
  92. package/app/theme/colorsDark.ts +50 -0
  93. package/app/theme/context.tsx +145 -0
  94. package/app/theme/context.utils.ts +25 -0
  95. package/app/theme/spacing.ts +14 -0
  96. package/app/theme/spacingDark.ts +14 -0
  97. package/app/theme/styles.ts +24 -0
  98. package/app/theme/theme.ts +23 -0
  99. package/app/theme/timing.ts +6 -0
  100. package/app/theme/types.ts +64 -0
  101. package/app/theme/typography.ts +71 -0
  102. package/app/utils/crashReporting.ts +62 -0
  103. package/app/utils/delay.ts +6 -0
  104. package/app/utils/formatDate.ts +49 -0
  105. package/app/utils/gestureHandler.native.ts +3 -0
  106. package/app/utils/gestureHandler.ts +6 -0
  107. package/app/utils/hasValidStringProp.ts +11 -0
  108. package/app/utils/openLinkInBrowser.ts +8 -0
  109. package/app/utils/storage/index.ts +82 -0
  110. package/app/utils/storage/storage.test.ts +61 -0
  111. package/app/utils/useHeader.tsx +37 -0
  112. package/app/utils/useIsMounted.ts +18 -0
  113. package/app/utils/useSafeAreaInsetsStyle.ts +46 -0
  114. package/app.config.ts +39 -0
  115. package/app.json +67 -0
  116. package/assets/icons/back.png +0 -0
  117. package/assets/icons/back@2x.png +0 -0
  118. package/assets/icons/back@3x.png +0 -0
  119. package/assets/icons/bell.png +0 -0
  120. package/assets/icons/bell@2x.png +0 -0
  121. package/assets/icons/bell@3x.png +0 -0
  122. package/assets/icons/caretLeft.png +0 -0
  123. package/assets/icons/caretLeft@2x.png +0 -0
  124. package/assets/icons/caretLeft@3x.png +0 -0
  125. package/assets/icons/caretRight.png +0 -0
  126. package/assets/icons/caretRight@2x.png +0 -0
  127. package/assets/icons/caretRight@3x.png +0 -0
  128. package/assets/icons/check.png +0 -0
  129. package/assets/icons/check@2x.png +0 -0
  130. package/assets/icons/check@3x.png +0 -0
  131. package/assets/icons/demo/clap.png +0 -0
  132. package/assets/icons/demo/clap@2x.png +0 -0
  133. package/assets/icons/demo/clap@3x.png +0 -0
  134. package/assets/icons/demo/community.png +0 -0
  135. package/assets/icons/demo/community@2x.png +0 -0
  136. package/assets/icons/demo/community@3x.png +0 -0
  137. package/assets/icons/demo/components.png +0 -0
  138. package/assets/icons/demo/components@2x.png +0 -0
  139. package/assets/icons/demo/components@3x.png +0 -0
  140. package/assets/icons/demo/debug.png +0 -0
  141. package/assets/icons/demo/debug@2x.png +0 -0
  142. package/assets/icons/demo/debug@3x.png +0 -0
  143. package/assets/icons/demo/github.png +0 -0
  144. package/assets/icons/demo/github@2x.png +0 -0
  145. package/assets/icons/demo/github@3x.png +0 -0
  146. package/assets/icons/demo/heart.png +0 -0
  147. package/assets/icons/demo/heart@2x.png +0 -0
  148. package/assets/icons/demo/heart@3x.png +0 -0
  149. package/assets/icons/demo/pin.png +0 -0
  150. package/assets/icons/demo/pin@2x.png +0 -0
  151. package/assets/icons/demo/pin@3x.png +0 -0
  152. package/assets/icons/demo/podcast.png +0 -0
  153. package/assets/icons/demo/podcast@2x.png +0 -0
  154. package/assets/icons/demo/podcast@3x.png +0 -0
  155. package/assets/icons/demo/slack.png +0 -0
  156. package/assets/icons/demo/slack@2x.png +0 -0
  157. package/assets/icons/demo/slack@3x.png +0 -0
  158. package/assets/icons/google.png +0 -0
  159. package/assets/icons/hidden.png +0 -0
  160. package/assets/icons/hidden@2x.png +0 -0
  161. package/assets/icons/hidden@3x.png +0 -0
  162. package/assets/icons/ladybug.png +0 -0
  163. package/assets/icons/ladybug@2x.png +0 -0
  164. package/assets/icons/ladybug@3x.png +0 -0
  165. package/assets/icons/lock.png +0 -0
  166. package/assets/icons/lock@2x.png +0 -0
  167. package/assets/icons/lock@3x.png +0 -0
  168. package/assets/icons/menu.png +0 -0
  169. package/assets/icons/menu@2x.png +0 -0
  170. package/assets/icons/menu@3x.png +0 -0
  171. package/assets/icons/more.png +0 -0
  172. package/assets/icons/more@2x.png +0 -0
  173. package/assets/icons/more@3x.png +0 -0
  174. package/assets/icons/settings.png +0 -0
  175. package/assets/icons/settings@2x.png +0 -0
  176. package/assets/icons/settings@3x.png +0 -0
  177. package/assets/icons/view.png +0 -0
  178. package/assets/icons/view@2x.png +0 -0
  179. package/assets/icons/view@3x.png +0 -0
  180. package/assets/icons/x.png +0 -0
  181. package/assets/icons/x@2x.png +0 -0
  182. package/assets/icons/x@3x.png +0 -0
  183. package/assets/images/app-icon-all.png +0 -0
  184. package/assets/images/app-icon-android-adaptive-background.png +0 -0
  185. package/assets/images/app-icon-android-adaptive-foreground.png +0 -0
  186. package/assets/images/app-icon-android-legacy.png +0 -0
  187. package/assets/images/app-icon-ios.png +0 -0
  188. package/assets/images/app-icon-web-favicon.png +0 -0
  189. package/assets/images/demo/cr-logo.png +0 -0
  190. package/assets/images/demo/cr-logo@2x.png +0 -0
  191. package/assets/images/demo/cr-logo@3x.png +0 -0
  192. package/assets/images/demo/rnl-logo.png +0 -0
  193. package/assets/images/demo/rnl-logo@2x.png +0 -0
  194. package/assets/images/demo/rnl-logo@3x.png +0 -0
  195. package/assets/images/demo/rnn-logo.png +0 -0
  196. package/assets/images/demo/rnn-logo@2x.png +0 -0
  197. package/assets/images/demo/rnn-logo@3x.png +0 -0
  198. package/assets/images/demo/rnr-image-1.png +0 -0
  199. package/assets/images/demo/rnr-image-1@2x.png +0 -0
  200. package/assets/images/demo/rnr-image-1@3x.png +0 -0
  201. package/assets/images/demo/rnr-image-2.png +0 -0
  202. package/assets/images/demo/rnr-image-2@2x.png +0 -0
  203. package/assets/images/demo/rnr-image-2@3x.png +0 -0
  204. package/assets/images/demo/rnr-image-3.png +0 -0
  205. package/assets/images/demo/rnr-image-3@2x.png +0 -0
  206. package/assets/images/demo/rnr-image-3@3x.png +0 -0
  207. package/assets/images/demo/rnr-logo.png +0 -0
  208. package/assets/images/demo/rnr-logo@2x.png +0 -0
  209. package/assets/images/demo/rnr-logo@3x.png +0 -0
  210. package/assets/images/logo.png +0 -0
  211. package/assets/images/logo@2x.png +0 -0
  212. package/assets/images/logo@3x.png +0 -0
  213. package/assets/images/sad-face.png +0 -0
  214. package/assets/images/sad-face@2x.png +0 -0
  215. package/assets/images/sad-face@3x.png +0 -0
  216. package/assets/images/welcome-face.png +0 -0
  217. package/assets/images/welcome-face@2x.png +0 -0
  218. package/assets/images/welcome-face@3x.png +0 -0
  219. package/babel.config.js +7 -0
  220. package/bin/cli.js +196 -0
  221. package/ignite/templates/app-icon/android-adaptive-background.png +0 -0
  222. package/ignite/templates/app-icon/android-adaptive-foreground.png +0 -0
  223. package/ignite/templates/app-icon/android-legacy.png +0 -0
  224. package/ignite/templates/app-icon/ios-universal.png +0 -0
  225. package/ignite/templates/component/NAME.tsx.ejs +39 -0
  226. package/ignite/templates/navigator/NAMENavigator.tsx.ejs +18 -0
  227. package/ignite/templates/screen/NAMEScreen.tsx.ejs +29 -0
  228. package/ignite/templates/splash-screen/logo.png +0 -0
  229. package/index.tsx +9 -0
  230. package/jest.config.js +5 -0
  231. package/metro.config.js +31 -0
  232. package/package.json +166 -0
  233. package/plugins/withSplashScreen.ts +69 -0
  234. package/src/app/_layout.tsx +58 -0
  235. package/src/app/index.tsx +5 -0
  236. package/test/i18n.test.ts +75 -0
  237. package/test/mockFile.ts +6 -0
  238. package/test/setup.ts +58 -0
  239. package/test/test-tsconfig.json +8 -0
  240. package/tsconfig.json +52 -0
  241. package/types/lib.es5.d.ts +25 -0
@@ -0,0 +1,69 @@
1
+ import { ConfigPlugin, withStringsXml, AndroidConfig, withAndroidStyles } from "expo/config-plugins"
2
+
3
+ /**
4
+ *
5
+ * Expo Config Plugin to help address the double splash screen issue with `expo-splash-screen`
6
+ * See more information about this issue here: https://github.com/expo/expo/issues/16084
7
+ *
8
+ * How it works:
9
+ * 1) Replace the default splash screen with a transparent screen
10
+ * 2) Set the splash screen status bar to translucent
11
+ */
12
+ export const withSplashScreen: ConfigPlugin = (config) => {
13
+ config = withAndroidSplashScreen(config)
14
+ return config
15
+ }
16
+
17
+ /**
18
+ * Android implementation of the config plugin - the only platform needed for this plugin.
19
+ * However, it is good practice to break up your config plugins from the exported
20
+ * function into parts by platform. For example, if it was needed, we would also
21
+ * add `withIosSplashScreen` for the iOS implementation.
22
+ */
23
+ const withAndroidSplashScreen: ConfigPlugin = (config) => {
24
+ config = withCustomStylesXml(config)
25
+ config = withCustomStringsXml(config)
26
+ return config
27
+ }
28
+
29
+ /**
30
+ * Modifies the `android/app/src/main/res/values/strings.xml` file to add the following string:
31
+ *
32
+ * <string name="expo_splash_screen_status_bar_translucent" translatable="false">true</string>
33
+ */
34
+ const withCustomStringsXml: ConfigPlugin = (config) =>
35
+ withStringsXml(config, (modConfig) => {
36
+ modConfig.modResults = AndroidConfig.Strings.setStringItem(
37
+ [
38
+ {
39
+ _: "true",
40
+ $: {
41
+ name: "expo_splash_screen_status_bar_translucent",
42
+ translatable: "false",
43
+ },
44
+ },
45
+ ],
46
+ modConfig.modResults,
47
+ )
48
+ return modConfig
49
+ })
50
+
51
+ /**
52
+ * Modifies the `android/app/src/main/res/values/styles.xml` file to append the
53
+ * the following to the Theme.App.SplashScreen style:
54
+ *
55
+ * <item name="android:windowIsTranslucent">true</item>
56
+ */
57
+ const withCustomStylesXml: ConfigPlugin = (config) =>
58
+ withAndroidStyles(config, async (modConfig) => {
59
+ modConfig.modResults = AndroidConfig.Styles.assignStylesValue(modConfig.modResults, {
60
+ add: true,
61
+ name: "android:windowIsTranslucent",
62
+ value: "true",
63
+ parent: {
64
+ name: "Theme.App.SplashScreen",
65
+ parent: "AppTheme",
66
+ },
67
+ })
68
+ return modConfig
69
+ })
@@ -0,0 +1,58 @@
1
+ import { useEffect, useState } from "react"
2
+ import { Slot, SplashScreen } from "expo-router"
3
+ import { useFonts } from "@expo-google-fonts/space-grotesk"
4
+ import { KeyboardProvider } from "react-native-keyboard-controller"
5
+ import { initialWindowMetrics, SafeAreaProvider } from "react-native-safe-area-context"
6
+
7
+ import { initI18n } from "@/i18n"
8
+ import { ThemeProvider } from "@/theme/context"
9
+ import { customFontsToLoad } from "@/theme/typography"
10
+ import { loadDateFnsLocale } from "@/utils/formatDate"
11
+
12
+ SplashScreen.preventAutoHideAsync()
13
+
14
+ if (__DEV__) {
15
+ // Load Reactotron configuration in development. We don't want to
16
+ // include this in our production bundle, so we are using `if (__DEV__)`
17
+ // to only execute this in development.
18
+ require("src/devtools/ReactotronConfig.ts")
19
+ }
20
+
21
+ export { ErrorBoundary } from "@/components/ErrorBoundary/ErrorBoundary"
22
+
23
+ export default function Root() {
24
+ const [fontsLoaded, fontError] = useFonts(customFontsToLoad)
25
+ const [isI18nInitialized, setIsI18nInitialized] = useState(false)
26
+
27
+ useEffect(() => {
28
+ initI18n()
29
+ .then(() => setIsI18nInitialized(true))
30
+ .then(() => loadDateFnsLocale())
31
+ }, [])
32
+
33
+ const loaded = fontsLoaded && isI18nInitialized
34
+
35
+ useEffect(() => {
36
+ if (fontError) throw fontError
37
+ }, [fontError])
38
+
39
+ useEffect(() => {
40
+ if (loaded) {
41
+ SplashScreen.hideAsync()
42
+ }
43
+ }, [loaded])
44
+
45
+ if (!loaded) {
46
+ return null
47
+ }
48
+
49
+ return (
50
+ <SafeAreaProvider initialMetrics={initialWindowMetrics}>
51
+ <ThemeProvider>
52
+ <KeyboardProvider>
53
+ <Slot />
54
+ </KeyboardProvider>
55
+ </ThemeProvider>
56
+ </SafeAreaProvider>
57
+ )
58
+ }
@@ -0,0 +1,5 @@
1
+ import { WelcomeScreen } from '@/screens/WelcomeScreen'
2
+
3
+ export default function Index() {
4
+ return <WelcomeScreen />
5
+ }
@@ -0,0 +1,75 @@
1
+ import { exec } from "child_process"
2
+
3
+ import en from "../app/i18n/en"
4
+
5
+ // Use this array for keys that for whatever reason aren't greppable so they
6
+ // don't hold your test suite hostage by always failing.
7
+ const EXCEPTIONS: string[] = [
8
+ // "welcomeScreen:readyForLaunch",
9
+
10
+ /**
11
+ * This translation key actually shows up in a comment describing the usage of the translate
12
+ * function in the app/i18n/translate.ts file. Because the grep command in the i18n test below
13
+ * doesn't account for commented out code, we must manually exclude it so tests don't fail
14
+ * because of a comment.
15
+ */
16
+ "hello",
17
+ ]
18
+
19
+ function iterate(obj, stack, array) {
20
+ for (const property in obj) {
21
+ if (Object.prototype.hasOwnProperty.call(obj, property)) {
22
+ if (typeof (obj as object)[property] === "object") {
23
+ iterate(obj[property], `${stack}.${property}`, array)
24
+ } else {
25
+ array.push(`${stack.slice(1)}.${property}`)
26
+ }
27
+ }
28
+ }
29
+
30
+ return array
31
+ }
32
+
33
+ /**
34
+ * This tests your codebase for missing i18n strings so you can avoid error strings at render time
35
+ *
36
+ * It was taken from https://gist.github.com/Michaelvilleneuve/8808ba2775536665d95b7577c9d8d5a1
37
+ * and modified slightly to account for our Ignite higher order components,
38
+ * which take 'tx' and 'fooTx' props.
39
+ * The grep command is nasty looking, but it's essentially searching the codebase for a few different things:
40
+ *
41
+ * tx="*"
42
+ * Tx=""
43
+ * tx={""}
44
+ * Tx={""}
45
+ * translate(""
46
+ *
47
+ * and then grabs the i18n key between the double quotes
48
+ *
49
+ * This approach isn't 100% perfect. If you are storing your key string in a variable because you
50
+ * are setting it conditionally, then it won't be picked up.
51
+ *
52
+ */
53
+
54
+ describe("i18n", () => {
55
+ test("There are no missing keys", (done) => {
56
+ // Actual command output:
57
+ // grep "[T\|t]x=[{]\?\"\S*\"[}]\?\|translate(\"\S*\"" -ohr './app' | grep -o "\".*\""
58
+ const command = `grep "[T\\|t]x=[{]\\?\\"\\S*\\"[}]\\?\\|translate(\\"\\S*\\"" -ohr './app' | grep -o "\\".*\\""`
59
+ exec(command, (_, stdout) => {
60
+ const allTranslationsDefinedOld = iterate(en, "", [])
61
+ // Replace first instance of "." because of i18next namespace separator
62
+ const allTranslationsDefined = allTranslationsDefinedOld.map((key) => key.replace(".", ":"))
63
+ const allTranslationsUsed = stdout.replace(/"/g, "").split("\n")
64
+ allTranslationsUsed.splice(-1, 1)
65
+
66
+ for (let i = 0; i < allTranslationsUsed.length; i += 1) {
67
+ if (!EXCEPTIONS.includes(allTranslationsUsed[i])) {
68
+ // You can add keys to EXCEPTIONS (above) if you don't want them included in the test
69
+ expect(allTranslationsDefined).toContainEqual(allTranslationsUsed[i])
70
+ }
71
+ }
72
+ done()
73
+ })
74
+ }, 240000)
75
+ })
@@ -0,0 +1,6 @@
1
+ export default {
2
+ height: 100,
3
+ width: 100,
4
+ scale: 2.0,
5
+ uri: "https://placecats.com/200/200",
6
+ }
package/test/setup.ts ADDED
@@ -0,0 +1,58 @@
1
+ // we always make sure 'react-native' gets included first
2
+ // eslint-disable-next-line no-restricted-imports
3
+ import * as ReactNative from "react-native"
4
+
5
+ import mockFile from "./mockFile"
6
+
7
+ // libraries to mock
8
+ jest.doMock("react-native", () => {
9
+ // Extend ReactNative
10
+ return Object.setPrototypeOf(
11
+ {
12
+ Image: {
13
+ ...ReactNative.Image,
14
+ resolveAssetSource: jest.fn((_source) => mockFile), // eslint-disable-line @typescript-eslint/no-unused-vars
15
+ getSize: jest.fn(
16
+ (
17
+ uri: string, // eslint-disable-line @typescript-eslint/no-unused-vars
18
+ success: (width: number, height: number) => void,
19
+ failure?: (_error: any) => void, // eslint-disable-line @typescript-eslint/no-unused-vars
20
+ ) => success(100, 100),
21
+ ),
22
+ },
23
+ },
24
+ ReactNative,
25
+ )
26
+ })
27
+
28
+ jest.mock("i18next", () => ({
29
+ currentLocale: "en",
30
+ t: (key: string, params: Record<string, string>) => {
31
+ return `${key} ${JSON.stringify(params)}`
32
+ },
33
+ translate: (key: string, params: Record<string, string>) => {
34
+ return `${key} ${JSON.stringify(params)}`
35
+ },
36
+ }))
37
+
38
+ jest.mock("expo-localization", () => ({
39
+ ...jest.requireActual("expo-localization"),
40
+ getLocales: () => [{ languageTag: "en-US", textDirection: "ltr" }],
41
+ }))
42
+
43
+ jest.mock("../app/i18n/index.ts", () => ({
44
+ i18n: {
45
+ isInitialized: true,
46
+ language: "en",
47
+ t: (key: string, params: Record<string, string>) => {
48
+ return `${key} ${JSON.stringify(params)}`
49
+ },
50
+ numberToCurrency: jest.fn(),
51
+ },
52
+ }))
53
+
54
+ declare const tron // eslint-disable-line @typescript-eslint/no-unused-vars
55
+
56
+ declare global {
57
+ let __TEST__: boolean
58
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "noImplicitAny": false,
5
+ "noUnusedLocals": false
6
+ },
7
+ "include": ["**/*.test.ts", "**/*.test.tsx"]
8
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "extends": "expo/tsconfig.base",
3
+ "compilerOptions": {
4
+ "allowJs": false,
5
+ "allowSyntheticDefaultImports": true,
6
+ "experimentalDecorators": true,
7
+ "jsx": "react-native",
8
+ "customConditions": [
9
+ "react-native"
10
+ ],
11
+ "module": "esnext",
12
+ "moduleResolution": "bundler",
13
+ "strict": true,
14
+ "noImplicitAny": true,
15
+ "noImplicitReturns": true,
16
+ "noImplicitThis": true,
17
+ "sourceMap": true,
18
+ "target": "esnext",
19
+ "lib": [
20
+ "esnext",
21
+ "dom"
22
+ ],
23
+ "skipLibCheck": true,
24
+ "resolveJsonModule": true,
25
+ "baseUrl": ".",
26
+ "paths": {
27
+ "@/*": [
28
+ "./app/*"
29
+ ],
30
+ "@assets/*": [
31
+ "./assets/*"
32
+ ]
33
+ },
34
+ "typeRoots": [
35
+ "./node_modules/@types",
36
+ "./types"
37
+ ]
38
+ },
39
+ "ts-node": {
40
+ "compilerOptions": {
41
+ "module": "commonjs"
42
+ }
43
+ },
44
+ "include": [
45
+ "**/*.ts",
46
+ "**/*.tsx"
47
+ ],
48
+ "exclude": [
49
+ "node_modules",
50
+ "test/**/*"
51
+ ]
52
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Fixes https://github.com/microsoft/TypeScript/issues/16655 for `Array.prototype.filter()`
3
+ * For example, using the fix the type of `bar` is `string[]` in the below snippet as it should be.
4
+ *
5
+ * const foo: (string | null | undefined)[] = [];
6
+ * const bar = foo.filter(Boolean);
7
+ *
8
+ * For related definitions, see https://github.com/microsoft/TypeScript/blob/master/src/lib/es5.d.ts
9
+ *
10
+ * Original licenses apply, see
11
+ * - https://github.com/microsoft/TypeScript/blob/master/LICENSE.txt
12
+ * - https://stackoverflow.com/help/licensing
13
+ */
14
+
15
+ /** See https://stackoverflow.com/a/51390763/1470607 */
16
+ type Falsy = false | 0 | "" | null | undefined
17
+
18
+ interface Array<T> {
19
+ /**
20
+ * Returns the elements of an array that meet the condition specified in a callback function.
21
+ * @param predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
22
+ * @param thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
23
+ */
24
+ filter<S extends T>(predicate: BooleanConstructor, thisArg?: any): Exclude<S, Falsy>[]
25
+ }