Skip to content

Conversation

@pandeymangg
Copy link
Contributor

Adds eslint 9 support for the js package and removes the vercel style guide package

@pandeymangg pandeymangg requested a review from Dhruwang October 7, 2025 08:37
@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Walkthrough

Adds a root clean npm script that runs turbo clean and rimraf, and adds rimraf as a devDependency; updates engines.node to >=18.18.0. Adds a clean task to turbo.json. Removes packages/js/.eslintrc.cjs and adds packages/js/eslint.config.mjs; packages/js/package.json is updated to use modern ESLint packages/plugins and adjusts the lint script. Strengthens TypeScript typings: proxy handler keys use keyof TFormbricks, global formbricks typed as TFormbricks & Record<string, (...args: unknown[]) => unknown>, and processQueuedFunctions now accepts TFormbricks. Tests and helpers updated to use typed calls and typed globals; minor formatting changes.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the main change of introducing ESLint 9 configuration to the js package without extraneous detail or ambiguity, aligning with the primary intent of the pull request.
Description Check ✅ Passed The description accurately reflects the key changes by noting the addition of ESLint 9 support and the removal of the Vercel style guide, directly aligning with the content of the changeset.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ee2052 and 5f32407.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • package.json (1 hunks)
  • packages/js/.eslintrc.cjs (0 hunks)
  • packages/js/eslint.config.mjs (1 hunks)
  • packages/js/package.json (1 hunks)
  • packages/js/src/index.test.ts (13 hunks)
  • packages/js/src/index.ts (1 hunks)
  • packages/js/src/lib/load-formbricks.test.ts (14 hunks)
  • packages/js/src/lib/load-formbricks.ts (4 hunks)
  • packages/js/src/types/formbricks.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • packages/js/.eslintrc.cjs
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-09-24T17:04:00.743Z
Learnt from: pandeymangg
PR: formbricks/js#6
File: packages/js/src/lib/load-formbricks.test.ts:96-114
Timestamp: 2025-09-24T17:04:00.743Z
Learning: The formbricks/js project uses happy-dom as the test environment in Vitest configuration, not jsdom. This is configured in packages/js/vite.config.ts and works well for DOM-dependent tests.

Applied to files:

  • packages/js/src/lib/load-formbricks.test.ts
📚 Learning: 2025-09-24T17:04:00.743Z
Learnt from: pandeymangg
PR: formbricks/js#6
File: packages/js/src/lib/load-formbricks.test.ts:96-114
Timestamp: 2025-09-24T17:04:00.743Z
Learning: The formbricks/js project uses happy-dom as the test environment in Vitest configuration (packages/js/vite.config.ts), not jsdom. This configuration works well for DOM-dependent tests and is faster than jsdom.

Applied to files:

  • packages/js/src/lib/load-formbricks.test.ts
📚 Learning: 2025-09-24T17:03:14.148Z
Learnt from: pandeymangg
PR: formbricks/js#6
File: packages/js/src/index.test.ts:27-103
Timestamp: 2025-09-24T17:03:14.148Z
Learning: In packages/js/src/index.test.ts, the maintainer prefers individual test functions for proxy-forwarding tests rather than table-driven tests, valuing explicit and independently readable test cases.

Applied to files:

  • packages/js/src/index.test.ts
🧬 Code graph analysis (4)
packages/js/src/lib/load-formbricks.test.ts (2)
packages/js/src/lib/load-formbricks.ts (1)
  • loadFormbricksToProxy (133-147)
packages/js/src/types/formbricks.ts (1)
  • TFormbricks (1-35)
packages/js/src/index.ts (2)
packages/js/src/lib/load-formbricks.ts (1)
  • loadFormbricksToProxy (133-147)
packages/js/src/types/formbricks.ts (1)
  • TFormbricks (1-35)
packages/js/src/index.test.ts (1)
packages/js/src/types/formbricks.ts (1)
  • TFormbricks (1-35)
packages/js/src/lib/load-formbricks.ts (1)
packages/js/src/types/formbricks.ts (1)
  • TFormbricks (1-35)
🔇 Additional comments (10)
packages/js/src/index.ts (1)

17-17: LGTM: Type narrowing improves safety.

Casting prop to keyof TFormbricks strengthens type checking at the proxy boundary, ensuring only valid TFormbricks method names are forwarded to loadFormbricksToProxy.

packages/js/src/types/formbricks.ts (1)

29-29: LGTM: Formatting consistency.

The trailing comma aligns with the coding style used throughout the PR.

packages/js/src/lib/load-formbricks.test.ts (3)

5-8: LGTM: Strengthened test type safety.

Constraining loadFormbricksToProxy to accept keyof TFormbricks aligns the test helper with the typed proxy implementation and catches invalid method names at compile time.


23-24: LGTM: Cleaner global access.

The typedGlobalThis alias eliminates repeated type assertions and improves readability throughout the test file.


82-89: Verify the @ts-expect-error is still needed.

The inline implementation with @ts-expect-error suggests a type mismatch between the mock signature and Node's actual setTimeout. Since this is test-only code and the mock works correctly, the suppression is acceptable, but ensure it remains necessary as TypeScript or Vitest types evolve.

packages/js/src/index.test.ts (2)

10-10: LGTM: Type import supports stronger testing.

Importing TFormbricks enables the typed customMethod test and better compile-time validation of proxy method calls.


151-155: LGTM: Typed custom method test.

Using keyof TFormbricks and accessing args[0] properly constrains the test to valid method names while avoiding arbitrary argument spreading.

packages/js/src/lib/load-formbricks.ts (3)

4-5: LGTM: Typed global declaration.

Changing to const with TFormbricks & Record<string, (...args: unknown[]) => unknown> improves type safety while allowing the SDK to expose additional methods beyond the core interface.


71-85: LGTM: Strengthened parameter type.

Changing formbricksInstance from any to TFormbricks improves type safety and makes the method validation check (lines 73-77) more explicit.


108-109: LGTM: Appropriate suppression for dynamic dispatch.

The @ts-expect-error and eslint-disable comments are necessary for runtime dynamic method invocation, which cannot be fully type-checked statically.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 7, 2025

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
packages/js/package.json (1)

52-53: Add Prettier to satisfy eslint-plugin-prettier’s peer dependency.
This was flagged earlier and still applies: without a local prettier dependency, pnpm will error when resolving eslint-plugin-prettier@5. Please add it here.

     "eslint-plugin-prettier": "5.5.4",
+    "prettier": "3.6.2",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9679a1 and 1e2dc79.

📒 Files selected for processing (6)
  • apps/playground/package.json (1 hunks)
  • package.json (1 hunks)
  • packages/js/eslint.config.mjs (1 hunks)
  • packages/js/package.json (1 hunks)
  • packages/js/src/index.test.ts (13 hunks)
  • turbo.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-24T16:57:19.813Z
Learnt from: pandeymangg
PR: formbricks/js#6
File: turbo.json:20-23
Timestamp: 2025-09-24T16:57:19.813Z
Learning: Package-scoped task names like "formbricks/js:test" are valid and functional syntax in Turborepo's root turbo.json configuration, contrary to previous understanding that task keys must be plain task names.

Applied to files:

  • turbo.json
🧬 Code graph analysis (1)
packages/js/src/index.test.ts (1)
packages/js/src/types/formbricks.ts (1)
  • TFormbricks (1-35)
🔇 Additional comments (4)
packages/js/src/index.test.ts (4)

10-10: Good addition for type safety.

The TFormbricks import enables type-safe dynamic method invocation in the test at line 150, replacing previous any casts with proper type constraints.


140-140: Past review comment addressed.

The stale comment about casting to any has been removed as requested in the previous review.


150-153: Type safety improvement looks good.

Replacing the previous any cast with keyof TFormbricks constraint provides compile-time safety while still testing dynamic method invocation through the proxy.


163-163: Appropriate mock type cast.

The as unknown as void cast is necessary here because loadFormbricksToProxy returns Promise<void>, but this test verifies that the proxy correctly propagates non-void return values. The double cast is the correct way to override TypeScript's type checking for testing purposes.

Copy link
Member

@Dhruwang Dhruwang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🚀✅

@pandeymangg pandeymangg added this pull request to the merge queue Oct 7, 2025
Merged via the queue into main with commit a80c59f Oct 7, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants