From 69186f164fdef413666d042ecfa4e2a6c9b0fac8 Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 18 Feb 2026 09:21:48 +0100 Subject: [PATCH 1/2] Refine PERF-11 rule for collection selector edge cases --- .../rules/perf-11-optimize-data-selection.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md b/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md index f6686837e512..d13afd292387 100644 --- a/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md +++ b/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md @@ -124,17 +124,18 @@ const [hasEmptyReports] = useOnyx(ONYXKEYS.COLLECTION.REPORT, { ### Review Metadata -Flag ONLY when ALL of these are true: +Flag ONLY when ANY of these are true: - A component uses `useOnyx` and either: - Subscribes to a broad data structure without selecting specific fields, causing re-renders when unrelated fields change - - Uses a `selector` that returns a large object, full collection, mapped/transformed collection, `Set`, `Map`, or intermediate data structure that is further reduced by the component + - Uses a `selector` whose output is still large or complex (e.g., full collection, large mapped/transformed result, `Set`, `Map`), or returns an intermediate data structure that is further reduced by the component +- A selector on a collection references other large external datasets (e.g., another Onyx collection passed via closure) and iterates over them on every change to the subscribed collection, compounding the computation cost on unrelated updates **DO NOT flag if:** - The selector returns a primitive value (`boolean`, `string`, `number`, `undefined`) - The selector returns a small object with only a few fields picked from a single item (not a collection) -- The selector meaningfully reduces a large dataset to a small result +- The selector meaningfully reduces a large dataset to a small result (e.g., a primitive or a few items) — the `deepEqual` cost on a small result is negligible, regardless of how the selector iterates internally - The `useOnyx` call is on a single-item key (not a collection), and the selector picks specific fields - The data structure is static or the function requires the entire object for valid operations From 387b44723f70ce728274b26dc3e0bb02a6ef288f Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Wed, 18 Feb 2026 10:25:30 +0100 Subject: [PATCH 2/2] Clarify selector iteration exemption scope in PERF-11 --- .../coding-standards/rules/perf-11-optimize-data-selection.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md b/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md index d13afd292387..d76da268091a 100644 --- a/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md +++ b/.claude/skills/coding-standards/rules/perf-11-optimize-data-selection.md @@ -135,7 +135,7 @@ Flag ONLY when ANY of these are true: - The selector returns a primitive value (`boolean`, `string`, `number`, `undefined`) - The selector returns a small object with only a few fields picked from a single item (not a collection) -- The selector meaningfully reduces a large dataset to a small result (e.g., a primitive or a few items) — the `deepEqual` cost on a small result is negligible, regardless of how the selector iterates internally +- The selector meaningfully reduces a large dataset to a small result (e.g., a primitive or a few items) by iterating over the subscribed collection itself — the `deepEqual` cost on a small result is negligible - The `useOnyx` call is on a single-item key (not a collection), and the selector picks specific fields - The data structure is static or the function requires the entire object for valid operations