[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
printCodeFramefromCompilerErrorand 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
detailsarray (CompilerDiagnosticand the Rust compiler), and - a legacy flat
loc(deprecatedCompilerErrorDetail).
- a
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 --noEmiton both ESLint packages is clean (no new errors vs. baseline).- Verified the detail loop handles the Rust compiler's
detailsarray shape and the legacy flatlocshape.
Comments
No comments yet. Start the discussion.