Skip to content

chore: drop unused exports flagged by only-export-components#8130

Merged
itsjavi merged 1 commit into
mainfrom
react-doctor/only-export-components
May 25, 2026
Merged

chore: drop unused exports flagged by only-export-components#8130
itsjavi merged 1 commit into
mainfrom
react-doctor/only-export-components

Conversation

@mattinannt
Copy link
Copy Markdown
Member

Summary

Three component files exported helpers/variants that no callers actually use. The unused export keyword forces Fast Refresh to treat the file as a "mixed exports" boundary and skip HMR for the component on every save during dev.

File Was exported Used externally?
template-tags.tsx getRoleBasedStyling No (only line 70 in same file)
ResponseDataView.tsx formatAddressData, formatContactInfoData, extractResponseData (each marked "// Export for testing") No test file imports them
multi-select/badge.tsx badgeVariants No (only used in the same file's Badge)

Removing the export keyword is the smallest correct fix per react-doctor/only-export-components (Architecture, error).

Why this PR only covers 3 of the 16 findings

The remaining 13 hits in this cluster split into two groups, both intentionally out of scope here:

  1. Source files where the second export is genuinely publicpreview-email-template.tsx (getPreviewEmailTemplateHtml is imported from emailTemplate.tsx), MappingRow.tsx (TMapping / createEmptyMapping used by AddIntegrationModal.tsx), add-filter-modal.tsx (handleAddFilter), ElementsComboBox.tsx (OptionsType enum + types), ResponseTableColumns.tsx. Each requires creating a sibling *.utils.ts or *.types.ts file plus updating all importers — a real refactor that should be its own PR.

  2. Storybook stories files (6 of them: confirmation-modal/stories.tsx, delete-dialog/stories.tsx, dialog/stories.tsx, slider/stories.tsx, tag/stories.tsx, tab-nav/stories.tsx). Storybook ships its own HMR; Fast Refresh's "single-export-per-file" assumption doesn't apply the same way. Worth a project-level config exclusion in react-doctor.config.json rather than touching every file.

Test plan

Verified locally:

  • pnpm --filter @formbricks/web test5166 / 5166 pass

🤖 Generated with Claude Code

Three component files exported helpers/variants that no callers
actually use. The unused `export` keyword causes Fast Refresh to
treat the file as a "mixed exports" boundary and skip HMR for the
component on every save:

- template-tags.tsx: `getRoleBasedStyling` used only locally
- ResponseDataView.tsx: `formatAddressData` / `formatContactInfoData`
  / `extractResponseData` annotated "Export for testing" but no test
  imports them (dead public surface)
- multi-select/badge.tsx: `badgeVariants` referenced only within the
  same file

Removing the `export` keyword is the smallest correct fix per
react-doctor/only-export-components (Architecture, error).

Note: the other 13 hits in this cluster (10 mixed-export source files
+ 3 Storybook stories files) need actual file-creation refactors
(extract helpers to sibling utils/types files), or are arguably
out-of-scope for the rule on Storybook stories which have their own
HMR. They are intentionally left for a follow-up.

Verified via `pnpm --filter @formbricks/web test`: 5166/5166 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mattinannt mattinannt requested a review from itsjavi May 23, 2026 12:55
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Review Change Stack

Walkthrough

This PR reduces the public API surface across three web modules by making internal helper functions private. In ResponseDataView.tsx, three formatting helpers (formatAddressData, formatContactInfoData, extractResponseData) are converted from exported functions to private constants. In template-tags.tsx, the getRoleBasedStyling helper is made private. In badge.tsx, badgeVariants is removed from the named exports, leaving only the Badge component public. All internal logic and component behaviors remain unchanged; only external visibility is restricted.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing unused exports flagged by the only-export-components linter rule across three component files.
Description check ✅ Passed The description provides a clear summary, explains the rationale, documents scope limitations, and includes test results, though it doesn't follow the template's required structure completely.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/app/(app)/workspaces/[workspaceId]/surveys/[surveyId]/(analysis)/responses/components/ResponseDataView.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/web/modules/survey/components/template-list/components/template-tags.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

apps/web/modules/ui/components/multi-select/badge.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.


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
Copy Markdown
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/web/app/`(app)/workspaces/[workspaceId]/surveys/[surveyId]/(analysis)/responses/components/ResponseDataView.tsx:
- Around line 51-52: The variable typing in extractResponseData currently uses
Record<string, any>, which weakens type safety; change the type to avoid any by
using Record<string, unknown> or, preferably, the shared response value type
from `@formbricks/types` (e.g., ResponseValue or equivalent) for responseData and
the function return type, and if possible let TypeScript infer the return type
instead of an explicit annotation; update the signature of
extractResponseData(response: TResponseWithQuotas, survey: TSurvey) and the
local responseData binding to use the chosen safer type.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ac311111-3b50-4af7-84e1-b580162e9c3b

📥 Commits

Reviewing files that changed from the base of the PR and between be5beae and 0c143f3.

📒 Files selected for processing (3)
  • apps/web/app/(app)/workspaces/[workspaceId]/surveys/[surveyId]/(analysis)/responses/components/ResponseDataView.tsx
  • apps/web/modules/survey/components/template-list/components/template-tags.tsx
  • apps/web/modules/ui/components/multi-select/badge.tsx

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Member

@itsjavi itsjavi left a comment

Choose a reason for hiding this comment

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

lgtm

@itsjavi itsjavi added this pull request to the merge queue May 25, 2026
Merged via the queue into main with commit 56f0f98 May 25, 2026
17 checks passed
@itsjavi itsjavi deleted the react-doctor/only-export-components branch May 25, 2026 21:48
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.

2 participants