Skip to content

Commit 2e3fee9

Browse files
authored
Enforce exact dependency versions (#56)
* Enforce exact dependency versions * Fix react-native package lint issues * Fix ApiClient constructor mocks in tests * Add coverage for setup and event listeners * Fix setup test error typing * Address PR review feedback
1 parent bfce8a0 commit 2e3fee9

36 files changed

+754
-246
lines changed

.ncurc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"removeRange": true
3+
}

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

apps/playground/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node-linker=hoisted
2+
save-exact=true

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44
"scripts": {
55
"build": "turbo run build",
66
"dev": "turbo run dev",
7-
"lint": "turbo run lint",
7+
"lint": "node scripts/check-exact-deps.mjs && turbo run lint",
88
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
99
"check-types": "turbo run check-types",
1010
"test": "turbo run test --no-cache",
1111
"test:coverage": "turbo run test:coverage --no-cache"
1212
},
1313
"devDependencies": {
14-
"prettier": "^3.8.1",
15-
"turbo": "^2.8.8",
14+
"prettier": "3.8.1",
15+
"turbo": "2.8.20",
1616
"typescript": "5.9.3",
17-
"rimraf": "6.1.2"
17+
"rimraf": "6.1.3"
1818
},
19-
"packageManager": "pnpm@10.29.3",
19+
"packageManager": "pnpm@10.32.1",
2020
"engines": {
21-
"node": ">=20"
21+
"node": ">=20.19.0"
2222
},
2323
"pnpm": {
2424
"overrides": {
25-
"on-headers": ">=1.1.0",
26-
"glob": ">=11.1.0",
27-
"node-forge": ">=1.3.2",
28-
"js-yaml": ">=4.1.1",
25+
"on-headers": "1.1.0",
26+
"glob": "13.0.4",
27+
"node-forge": "1.3.3",
28+
"js-yaml": "4.1.1",
2929
"tar": "7.5.12"
3030
}
3131
}

packages/react-native/.eslintrc.cjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
const project = "tsconfig.json";
2+
13
module.exports = {
24
extends: [
35
"@vercel/style-guide/eslint/browser",
46
"@vercel/style-guide/eslint/typescript",
57
"@vercel/style-guide/eslint/react",
68
].map(require.resolve),
79
parserOptions: {
8-
project: "tsconfig.json",
10+
project,
911
tsconfigRootDir: __dirname,
1012
},
1113
globals: {

packages/react-native/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"devDependencies": {
4848
"@types/react": "19.2.14",
4949
"@vercel/style-guide": "6.0.0",
50+
"@vitest/eslint-plugin": "1.6.12",
5051
"@vitest/coverage-v8": "4.0.18",
5152
"react": "19.2.4",
5253
"react-native": "0.84.0",

packages/react-native/src/components/formbricks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import React, { useCallback, useEffect, useSyncExternalStore } from "react";
2+
import { View } from "react-native";
13
import { SurveyWebView } from "@/components/survey-web-view";
24
import { Logger } from "@/lib/common/logger";
35
import { setup } from "@/lib/common/setup";
46
import { SurveyStore } from "@/lib/survey/store";
5-
import React, { useCallback, useEffect, useSyncExternalStore } from "react";
6-
import { View } from "react-native";
77

88
interface FormbricksProps {
99
appUrl: string;

packages/react-native/src/components/survey-web-view.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable no-console -- debugging*/
2+
import React, { type JSX, useEffect, useRef, useState } from "react";
3+
import { KeyboardAvoidingView, Modal, View, StyleSheet } from "react-native";
4+
import { WebView, type WebViewMessageEvent } from "react-native-webview";
25
import { RNConfig } from "@/lib/common/config";
36
import { Logger } from "@/lib/common/logger";
47
import { filterSurveys, getLanguageCode, getStyling } from "@/lib/common/utils";
58
import { SurveyStore } from "@/lib/survey/store";
69
import { type TUserState, ZJsRNWebViewOnMessageData } from "@/types/config";
710
import type { TSurvey, SurveyContainerProps } from "@/types/survey";
8-
import React, { type JSX, useEffect, useRef, useState } from "react";
9-
import { KeyboardAvoidingView, Modal, View, StyleSheet } from "react-native";
10-
import { WebView, type WebViewMessageEvent } from "react-native-webview";
1111

1212
const logger = Logger.getInstance();
1313
logger.configure({ logLevel: "debug" });
@@ -21,15 +21,15 @@ interface SurveyWebViewProps {
2121

2222
export function SurveyWebView(
2323
props: SurveyWebViewProps
24-
): JSX.Element | undefined {
24+
): JSX.Element | null {
2525
const webViewRef = useRef(null);
2626
const [isSurveyRunning, setIsSurveyRunning] = useState(false);
2727
const [showSurvey, setShowSurvey] = useState(false);
2828
const [appConfig, setAppConfig] = useState<RNConfig | null>(null);
2929
const [languageCode, setLanguageCode] = useState("default");
3030

3131
useEffect(() => {
32-
const fetchConfig = async () => {
32+
const fetchConfig = async (): Promise<void> => {
3333
const config = await RNConfig.getInstance();
3434
setAppConfig(config);
3535
};
@@ -87,7 +87,7 @@ export function SurveyWebView(
8787
}, [props.survey.delay, isSurveyRunning, props.survey.name]);
8888

8989
if (!appConfig) {
90-
return;
90+
return null;
9191
}
9292

9393
const project = appConfig.get().environment.data.project;

packages/react-native/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ export const logout = async (): Promise<void> => {
3838
await queue.wait();
3939
};
4040

41+
export { Formbricks } from "@/components/formbricks";
42+
// eslint-disable-next-line import/no-default-export -- preserve the public SDK default export
4143
export { Formbricks as default } from "@/components/formbricks";

packages/react-native/src/lib/common/api.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { wrapThrowsAsync } from "@/lib/common/utils";
22
import {
3-
ApiResponse,
4-
ApiSuccessResponse,
5-
CreateOrUpdateUserResponse,
3+
type ApiResponse,
4+
type ApiSuccessResponse,
5+
type CreateOrUpdateUserResponse,
66
} from "@/types/api";
7-
import { TEnvironmentState } from "@/types/config";
8-
import { ApiErrorResponse, Result, err, ok } from "@/types/error";
7+
import { type TEnvironmentState } from "@/types/config";
8+
import { type ApiErrorResponse, type Result, err, ok } from "@/types/error";
99

1010
export const makeRequest = async <T>(
1111
appUrl: string,

0 commit comments

Comments
 (0)