Skip to content

Conversation

@jorge-cab
Copy link
Contributor

@jorge-cab jorge-cab commented Nov 26, 2025

Summary:
These validations are not essential for compilation, with this we only run that logic when outputMode is 'lint'

Test Plan:
Update fixtures and run tests

@meta-cla meta-cla bot added the CLA Signed label Nov 26, 2025
Summary:
These validations are not essential for compilation, with this we only run that logic when outputMode is 'lint'

Test Plan:
Update fixtures and run tests

```javascript
import { c as _c } from "react/compiler-runtime"; // @validateNoSetStateInEffects @enableAllowSetStateFromRefsInEffects
// @validateNoSetStateInEffects @enableAllowSetStateFromRefsInEffects @outputMode:"lint"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file compiles w/o error, why do we need to change the output mode here? I would expect that we'd only set the outputMode explicitly for fixtures that break w/o it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then the test would not be checking anything right? Because the code that could trigger the error doesn't run.

Like if some change in ValidateNoSetStateInEffects suddenly made this test error out we wouldn't notice

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

etc

Copy link
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for putting this up! Should save a bit of time on compilation since the no-derived-computations-in-effects rule is fairly complex.

For the fixtures, let's only change them to outputMode:"lint" if strictly necessary, ie to show that problematic code does report an error? Or were you thinking that we want to use lint mode anyway to test that the file doesn't error?

This might be an indication that our tests should do what we do in playground: compile in both modes and show a combined view of the output. I'm curious for @mofeiZ's take.

@jorge-cab
Copy link
Contributor Author

Or were you thinking that we want to use lint mode anyway to test that the file doesn't error?

Yeah, that's why I also changed the files that don't error

Comment on lines 287 to 288
} else if (env.config.validateNoDerivedComputationsInEffects) {
validateNoDerivedComputationsInEffects(hir);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change this mode to work similarly? do we want to keep this version of the validation around?

Copy link
Member

@josephsavona josephsavona left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense. As a follow-up, I do think we should seriously consider updating snap to work like playground, ie run both normal build mode and lint mode for each fixture, unless the fixture opts into special behavior. That way we don't need to have multiple versions of the same input to test build vs lint behavior (which i've already done in a few places)

But this makes sense to land, thanks for working on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants