[compiler] Restore code frames in ESLint compiler error messages (#36…
GitHub Commits - Example: React

[compiler] Restore code frames in ESLint compiler error messages (#36…

Summary

The Rust port (#36173) changed CompileError LoggerEvents to carry plain serialized detail objects instead of CompilerError/CompilerDiagnostic class instances. As a result, the ESLint integrations could no longer call detail.printErrorMessage(source, {eslint: true}) and were given a replacement printErrorMessage() helper that only emitted the reason and description.

This regressed error printing: the source code frame(s) and file:line:column location that used to appear for each error detail were dropped from lint output.

This PR restores the previous behaviour:

  • Export printCodeFrame from CompilerError and reuse it from both ESLint integrations instead of duplicating it.
  • Rebuild the full message (reason, description, per-detail code frames, and hints) in printErrorMessage.
  • Handle both detail shapes that flow through LoggerEvents:
    • a details array (CompilerDiagnostic and the Rust compiler), and
    • a legacy flat loc (deprecated CompilerErrorDetail).

formatDetailForLogging emits one or the other, so the previous unconditional iteration over error.details would have thrown TypeError: not iterable on the flat-loc path. Normalizing to a list fixes that and keeps the code working with both the TypeScript and Rust compilers.

Test plan

  • tsc --noEmit on both ESLint packages is clean (no new errors vs. baseline).
  • Verified the detail loop handles the Rust compiler's details array shape and the legacy flat loc shape.

Comments

No comments yet. Start the discussion.