Skip to content

fix(no-barrel-import): framework-aware wording for React Native targets#796

Merged
aidenybai merged 1 commit into
mainfrom
devin/1781246357-no-barrel-import-rn-wording
Jun 12, 2026
Merged

fix(no-barrel-import): framework-aware wording for React Native targets#796
aidenybai merged 1 commit into
mainfrom
devin/1781246357-no-barrel-import-rn-wording

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

no-barrel-import's message says the barrel import "slows page load" — meaningless for React Native, which has no page. The message lead sentence now branches on the file's platform target:

  • RN/Expo target → This ships extra code in your app bundle & slows startup.
  • web (or unknown) target → existing This ships extra code to your users & slows page load.

The branch condition is the testable part: it reuses the exact decision ladder behind isReactNativeFileActive (native .ios/.android/.native extensions → nearest package.json platform → project framework setting), now exposed as a three-way classifier so wording can default to web on "unknown" while RN rule gating keeps its conservative "unknown → active" behavior:

classifyReactNativeFileTarget(context): "react-native" | "web" | "unknown"
isReactNativeFileActive = (context) => classifyReactNativeFileTarget(context) !== "web"

Notably, .web.tsx files inside an RN monorepo still get the page-load wording, and projects with no discoverable framework keep the existing wording (no behavior change for any existing web diagnostics — the source-resolution fallback message is framework-neutral and unchanged).

Unit tests cover each branch: nextjs → page-load, react-native/expo → app-startup, unknown → page-load, and App.web.tsx under framework: "react-native" → page-load.

The "is this wording better" editorial half (e.g. the React 19 caveat phrasing) is intentionally left out of this PR.

Link to Devin session: https://app.devin.ai/sessions/5ebb159406b24bf0bd4f4d515b3cfbf8
Requested by: @aidenybai


Note

Low Risk
User-facing lint message text only; RN rule activation behavior is preserved via isReactNativeFileActive !== "web".

Overview
no-barrel-import diagnostic copy now depends on the file’s platform target instead of always mentioning page load. React Native / Expo targets get “ships extra code in your app bundle & slows startup”; web, unknown framework, and .web.* files in RN monorepos keep the existing “slows page load” wording.

Platform detection is centralized by refactoring is-react-native-file: new classifyReactNativeFileTarget returns "react-native" | "web" | "unknown" (same ladder as before: native/web extensions → nearest package.jsonframework setting). isReactNativeFileActive is now !== "web" so RN rule gating stays conservative on "unknown" while messaging treats "unknown" as web.

Adds no-barrel-import.test.ts covering nextjs, react-native, expo, unknown, and App.web.tsx under RN; patch changeset for oxlint-plugin-react-doctor.

Reviewed by Cursor Bugbot for commit cdd477b. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@796
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@796
npm i https://pkg.pr.new/react-doctor@796

commit: cdd477b

@github-actions

Copy link
Copy Markdown
Contributor

No React Doctor issues found. 🎉

Reviewed by React Doctor for commit cdd477b.

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

Ran end-to-end CLI testing of the framework-aware wording: built the CLI from this branch and ran react-doctor --json --no-score --no-dead-code against two minimal fixture projects with identical barrel-import source, differing only in package.json deps.

  • RN project (react-native dep) → app-startup wording — passed
  • Web project (react-dom/vite deps) → existing page-load wording — passed (regression)
  • src/Other.web.tsx inside the RN project → page-load wording while App.tsx keeps app-startup wording in the same run — passed
RN project output (the change)
{ "f": "src/App.tsx",
  "m": "This ships extra code in your app bundle & slows startup. Import directly from \"./components/Button\"." }
Web project output (regression — unchanged)
{ "f": "src/App.tsx",
  "m": "This ships extra code to your users & slows page load. Import directly from \"./components/Button\"." }
Mixed run: .web.tsx inside RN project
[
  { "f": "src/App.tsx",       "m": "This ships extra code in your app bundle & slows startup. Import directly from \"./components/Button\"." },
  { "f": "src/Other.web.tsx", "m": "This ships extra code to your users & slows page load. Import directly from \"./components/Button\"." }
]

Testing was CLI/shell-only, so evidence is JSON output rather than screenshots. Devin session

@aidenybai aidenybai merged commit fee3fc4 into main Jun 12, 2026
20 checks passed
@aidenybai aidenybai deleted the devin/1781246357-no-barrel-import-rn-wording branch June 12, 2026 07:29
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.

1 participant