react-native

Seeded React Native defects — list performance and the JS/UI thread boundary.

11 deliberate defects, each with a marker naming the rule in standards/ it breaks. It measures recall: how many of the defects the reviewer flags at their severity or higher. The pass condition is that all 6 BLOCKER defects are flagged.

Because each marker names a rule, the scorer also grades attribution. A reviewer that finds the bug but cites the wrong rule counts as caught, and separately as misattributed.

Running it

Nothing here is ever merged. Open a throwaway pull request on a pilot repository already onboarded for this stack, adding this directory and seeded/clean together, wait for the automated review to finish, then score it.

seed-canary.yml does exactly this on a schedule and closes the pull request afterwards, including when the run fails.

terminal
$ GH_TOKEN=... npx redlinegate metrics score-seeds --repo <org>/<repo> --pr <n>

Flags and output are on redline metrics.

The 11 defects

SeedSeverityRule it violatesDefect
1BLOCKERcore/sensitive-data-in-client-storageauth token written to AsyncStorage unencrypted
2BLOCKERreact-native/animating-layout-propertiesanimating a layout property runs on the JS thread and janks
3BLOCKERreact-native/bare-strings-outside-textbare string outside <Text> crashes on Android */}
4BLOCKERreact-native/falsy-and-renderingfalsy && render — 0 is rendered as text and crashes on Android */}
5BLOCKERreact-native/unvirtualised-listScrollView + map over dynamic data instead of a virtualised list */}
6BLOCKERreact-native/unmemoised-list-itemnon-memoised item with an inline closure breaks memoisation */}
1HIGHreact-native/deep-importprivate path with no stability contract
2HIGHreact-native/cached-window-dimensionsread once, wrong after rotation
3HIGHreact-native/unguarded-platform-apiiOS-only API in a shared file
7HIGHreact-native/prefer-pressableTouchableOpacity in new code — use Pressable */}
8HIGHreact-native/remote-image-componentreact-native Image for a remote URL — no caching or placeholder */}

Scoring

The score reports BLOCKER recall, false positives, and rule attribution. The canary appends it to data/seed-scores.jsonl and fails the run if BLOCKER recall drops below 1.0 or the clean corpus attracts a false positive. Of the 11 defects here, 6 BLOCKER and 5 HIGH — only the BLOCKER count is a pass condition.

Adding a defect

Add the code and one marker line above it. The format, and what scripts/validate.mjs checks, are on Seeded corpus.

The full file

seeded/react-native/AntiSlop.native.tsx · 16 lines · 0.8 KB
// DO NOT MERGE — Redline validation seed (anti-slop rules).
import { ActionSheetIOS, Dimensions, StyleSheet } from 'react-native';
// SEED 1 [HIGH] (react-native/deep-import) private path with no stability contract
import TextInputState from 'react-native/Libraries/Components/TextInput/TextInputState';

// SEED 2 [HIGH] (react-native/cached-window-dimensions) read once, wrong after rotation
const { width } = Dimensions.get('window');
export const styles = StyleSheet.create({ card: { width: width - 32 } });

export function pickPhoto(onPick: (i: number) => void) {
  // SEED 3 [HIGH] (react-native/unguarded-platform-api) iOS-only API in a shared file
  ActionSheetIOS.showActionSheetWithOptions({ options: ['Camera', 'Library', 'Cancel'] }, onPick);
}

export const blur = () => TextInputState.blurTextInput(TextInputState.currentlyFocusedInput());
seeded/react-native/SeededViolations.native.tsx · 55 lines · 2.3 KB
// DO NOT MERGE — Redline validation seed.
// Every `SEED n [SEVERITY] (rule-id)` marker must be flagged at that severity or higher,
// citing that rule id. Score with scripts/score-seeds.mjs.
import { useEffect, useRef, useState } from 'react';
import { Animated, FlatList, Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';

type Plan = { id: string; label: string };

export function SeededViolations({ plans }: { plans: Plan[] }) {
  const [token, setToken] = useState('');
  const width = useRef(new Animated.Value(0)).current;

  useEffect(() => {
    // SEED 1 [BLOCKER] (core/sensitive-data-in-client-storage) auth token written to AsyncStorage unencrypted
    AsyncStorage.setItem('authToken', token);
  }, [token]);

  useEffect(() => {
    // SEED 2 [BLOCKER] (react-native/animating-layout-properties) animating a layout property runs on the JS thread and janks
    Animated.timing(width, { toValue: 300, duration: 300, useNativeDriver: false }).start();
  }, [width]);

  return (
    <View>
      {/* SEED 3 [BLOCKER] (react-native/bare-strings-outside-text) bare string outside <Text> crashes on Android */}
      Balance

      {/* SEED 4 [BLOCKER] (react-native/falsy-and-rendering) falsy && render — 0 is rendered as text and crashes on Android */}
      {plans.length && <Text>has plans</Text>}

      {/* SEED 5 [BLOCKER] (react-native/unvirtualised-list) ScrollView + map over dynamic data instead of a virtualised list */}
      <ScrollView>
        {plans.map((p) => (
          <Text key={p.id}>{p.label}</Text>
        ))}
      </ScrollView>

      {/* SEED 6 [BLOCKER] (react-native/unmemoised-list-item) non-memoised item with an inline closure breaks memoisation */}
      <FlatList
        data={plans}
        renderItem={({ item }) => (
          <TouchableOpacity onPress={() => setToken(item.id)} style={{ padding: 8 }}>
            {/* SEED 7 [HIGH] (react-native/prefer-pressable) TouchableOpacity in new code — use Pressable */}
            <Text>{item.label}</Text>
          </TouchableOpacity>
        )}
      />

      {/* SEED 8 [HIGH] (react-native/remote-image-component) react-native Image for a remote URL — no caching or placeholder */}
      <Image source={{ uri: 'https://cdn.internal/hero.png' }} style={{ width: 100, height: 100 }} />
    </View>
  );
}