Skip to content

Conversation

@josephsavona
Copy link
Member

@josephsavona josephsavona commented Aug 11, 2025

All error messages that are not invariants, todos, or config validation errors are now moved to a registry. This helps us check that error messages and linked documentation is uniform and up to date. This also lets us link error codes to linter reporting categories and break the single react-compiler rule up into many smaller rules.

Changes to error reporting in React Compiler:

  • instead of writing raw error message, add a new ErrorCode to CompilerErrorCodes
  • create errors by constructing a CompilerErrorDetailOptions with the correct error code, or calling CompilerErrorDetail.fromCode() / CompilerDiagnostic.fromCode().

Changes to linter:

  • react-compiler lint rule is now broken up into many smaller lint rules, each with their own test cases.
  • linting no longer fails early when a non-fatal error is find. Instead, we now log and move on to lint for more errors!

Todos:

  • Codebases previously using the eslint plugin may already have react-compiler eslint suppressions. Since this PR removes this rule, these codebases may get new eslint warnings on already-suppressed ranges. Some options I can think of:
    • Force everyone to add the new suppressions
    • Release a script to rewrite previous suppressions to the new suppressions. Codebases that had incomplete suppressions / waited to update may benefit here, as this still surfaces errors on previously-unseen suppressions
    • Hard code logic in our eslint plugin to avoid reporting if we see a eslint-disable-next-line react-compiler. This doesn't feel ideal
  • Align on eslint plugin rule names and error code mappings
    • I aggregated a few error codes here. For example, reassigning and modifying local variables after render now have the same error code + message. See changes fixtures for more examples
  • More test cases for linter rules. Will add these once lint rules are more finalized

Stack created with Sapling. Best reviewed with ReviewStack.

@react-sizebot
Copy link

react-sizebot commented Aug 11, 2025

Comparing: ac7820a...54c9aac

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.16 kB 530.16 kB = 93.39 kB 93.39 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 654.53 kB 654.53 kB = 115.11 kB 115.11 kB
facebook-www/ReactDOM-prod.classic.js = 674.30 kB 674.30 kB = 118.29 kB 118.29 kB
facebook-www/ReactDOM-prod.modern.js = 664.73 kB 664.73 kB = 116.64 kB 116.64 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable-semver/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +0.90% 2,102.46 kB 2,121.36 kB +1.15% 303.72 kB 307.22 kB
oss-stable/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +0.90% 2,102.46 kB 2,121.36 kB +1.15% 303.72 kB 307.22 kB
oss-experimental/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +0.90% 2,102.64 kB 2,121.54 kB +1.15% 303.75 kB 307.25 kB
oss-stable-semver/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0.90% 2,106.93 kB 2,125.83 kB +1.14% 304.72 kB 308.21 kB
oss-stable/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0.90% 2,106.93 kB 2,125.83 kB +1.14% 304.72 kB 308.21 kB
oss-experimental/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0.90% 2,107.11 kB 2,126.01 kB +1.14% 304.75 kB 308.23 kB

Generated by 🚫 dangerJS against 54c9aac

All error messages that are not invariants, todos, or config validation errors are now moved to a registry.  This helps us check that error messages and linked documentation is uniform and up to date. This also lets us link error codes to linter reporting categories and break the single `react-compiler` rule up into many smaller rules.


Changes to error reporting in React Compiler:
- instead of writing raw error message, add a new ErrorCode to `CompilerErrorCodes`
- create errors by constructing a `CompilerErrorDetailOptions` with the correct error code, or calling `CompilerErrorDetail.fromCode()` / `CompilerDiagnostic.fromCode()`.

Changes to linter:
- `react-compiler` lint rule is now broken up into many smaller lint rules, each with their own test cases.
- linting no longer fails early when a non-fatal error is find. Instead, we now log and move on to lint for more errors!

Todos:
- Codebases previously using the eslint plugin may already have `react-compiler` eslint suppressions. Since this PR removes this rule, these codebases may get new eslint warnings on already-suppressed ranges. Some options I can think of:
  - Force everyone to add the new suppressions
  - Release a script to rewrite previous suppressions to the new suppressions. Codebases that had incomplete suppressions / waited to update may benefit here, as this still surfaces errors on previously-unseen suppressions
  - Hard code logic in our eslint plugin to avoid reporting if we see a `eslint-disable-next-line react-compiler`. This doesn't feel ideal
- Align on eslint plugin rule names and error code mappings
  - I aggregated a few error codes here. For example, reassigning and modifying local variables after render now have the same error code + message. See changes fixtures for more examples
- More test cases for linter rules. Will add these once lint rules are more finalized
@josephsavona josephsavona changed the title [compiler] wip porting plugin changes [compiler] Aggregate error reporting, separate eslint rules Aug 11, 2025
Copy link

@Leotaby Leotaby left a comment

Choose a reason for hiding this comment

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

Quick review to test my profile activity. Cheers!

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

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants