fix(no-barrel-import): framework-aware wording for React Native targets#796
Merged
Merged
Conversation
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
commit: |
Contributor
|
No React Doctor issues found. 🎉 Reviewed by React Doctor for commit |
Contributor
Author
|
Ran end-to-end CLI testing of the framework-aware wording: built the CLI from this branch and ran
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:This ships extra code in your app bundle & slows startup.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/.nativeextensions → nearestpackage.jsonplatform → projectframeworksetting), 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:Notably,
.web.tsxfiles 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, andApp.web.tsxunderframework: "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-importdiagnostic 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: newclassifyReactNativeFileTargetreturns"react-native" | "web" | "unknown"(same ladder as before: native/web extensions → nearestpackage.json→frameworksetting).isReactNativeFileActiveis now!== "web"so RN rule gating stays conservative on"unknown"while messaging treats"unknown"as web.Adds
no-barrel-import.test.tscovering nextjs, react-native, expo, unknown, andApp.web.tsxunder RN; patch changeset foroxlint-plugin-react-doctor.Reviewed by Cursor Bugbot for commit cdd477b. Bugbot is set up for automated code reviews on this repo. Configure here.