feat: label test/story file context on diagnostic sites#795
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 |
Co-Authored-By: Aiden Bai <aiden.bai05@gmail.com>
Contributor
Author
Makes the file-context classifier the single owner of the test/story path heuristics so the label and test-noise suppression agree by construction. Also strips the new fileContext field from the Score API payload, folds the per-rule summary's context tags into the single site-grouping pass, drops a dead guard in the pipeline stamping, and counts test/story diagnostics for the run event in one pass.
This was referenced Jun 12, 2026
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
A finding in a spec or story file doesn't mean users crash — but the report framed every site identically, so
rn-no-raw-text-style findings in non-shipping code read as production impact. This adds file-context labels driven by the same path heuristics that already power test-noise auto-suppression (isTestFilePath), so the label and the suppression can never disagree.classifyFileContext(relativePath): "test" | "story" | "production"in core —.stories.*/.story.*suffix wins asstory, everything elseisTestFilePathmatches istest.buildDiagnosticPipelinestampsfileContext?: "test" | "story"on surviving diagnostics (omitted for production, so the JSON report shape is purely additive —Diagnosticschema gainsfileContext: Schema.optional(Schema.Literals(["test", "story"])), noschemaVersionbump). The pipeline's oldisTestcache is now the context cache; auto-suppression behavior is unchanged.src/utils/foo.spec.tsx:3 (test file)in the terminal cluster locations and the per-ruleFiles:text dumps.diagnosticsInTestFiles/diagnosticsInStoryFilescounts on the run wide event, so the next Lorenzo-style eval can check whether labeled findings change behavior before judging if the scheme reduces confusion.Product-thinking note: no new flag/config — the label is unconditional, additive output on an existing surface. The classification half is fully tested; whether the labeling reduces confusion is the eval's call.
Tests:
classify-file-context.test.ts(classification incl. fixture-project and Windows paths), pipeline stamping + "rn-no-raw-text in a spec never shows" infilter-diagnostics.test.ts, and renderer tagging inrender-file-context-tag.test.ts. Changeset:react-doctorminor.Link to Devin session: https://app.devin.ai/sessions/92feef39863a4c84a5a105959d757c84
Requested by: @aidenybai
Note
Low Risk
Additive reporting and a refactor of existing test-path heuristics; suppression behavior stays aligned via a single classifier, with broad test coverage and no Score API shape change.
Overview
Adds file-context labeling so diagnostics in non-shipping files are clearly distinguished from production code.
Core: New
classifyFileContextcentralizes path heuristics (.stories.*→"story", test/spec/fixture suffixes and test dirs →"test", else"production").isTestFilePathnow delegates to it so test-noise auto-suppression and labels always use the same rules. The diagnostic pipeline stamps optionalfileContext: "test" | "story"on survivors; the JSONDiagnosticschema gains the same optional field (additive, no schema version bump). Score API requests still strip local path-derived fields viastripLocalFileFields.CLI: Terminal cluster locations and per-rule
Files:dumps append dim(test file)/(story file)tags. Run telemetry addsdiagnosticsInTestFilesanddiagnosticsInStoryFilescounts.Tests cover classification (including fixture projects and Windows paths), pipeline stamping, and renderer output.
Reviewed by Cursor Bugbot for commit 190df5c. Bugbot is set up for automated code reviews on this repo. Configure here.