Skip to content

False positive: "Raw text outside <Text>" rule doesn't recognize custom components that handle text correctly #100

@saileshbro

Description

@saileshbro

Description

Problem

The react-native/no-raw-text lint rule triggers errors for valid code when using custom components that correctly handle text rendering, even though these components are not <Text> components. This is common in:

  1. Expo Router components - Like <Stack.Screen.Title>
  2. Native Tabs components - Like <NativeTabs.Trigger.Label>
  3. Custom UI library components - That wrap text internally

Examples of False Positives

// ❌ Reported as error, but works correctly with expo-router
<Stack.Screen.Title>Oops!</Stack.Screen.Title>

// ❌ Reported as error, but NativeTabs.Trigger.Label handles text correctly
<NativeTabs.Trigger.Label>Home</NativeTabs.Trigger.Label>
<NativeTabs.Trigger.Label>Sources</NativeTabs.Trigger.Label>
<NativeTabs.Trigger.Label>Transactions</NativeTabs.Trigger.Label>
<NativeTabs.Trigger.Label>Search</NativeTabs.Trigger.Label>

Current Behavior

React Doctor flags these as errors:

✗ Raw "Oops!" outside a <Text> component — this will crash on React Native (17)
✗ Raw "Home" outside a <Text> component — this will crash on React Native (17)
✗ Raw "Sources" outside a <Text> component — this will crash on React Native (17)
✗ Raw "Transactions" outside a <Text> component — this will crash on React Native (17)

Expected Behavior

The rule should recognize that custom components like NativeTabs.Trigger.Label and Stack.Screen.Title correctly handle text rendering, even though they're not <Text> components.

Recommendation

Option 1 is the quickest fix - make ignore.rules work for this rule.


This issue was generated with assistance from an AI coding agent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions