Files
Boshen 63ff8ef0a1 perf(linter): outline diagnostic construction (#25762)
Diagnostic reporting is a cold path, but `LintContext::diagnostic` was explicitly inlined into hundreds of rule bodies. This also duplicated `Message::new`, its primary-label search, and generic diagnostic builders.

Mark these paths `#[cold]` and `#[inline(never)]` so call sites share a few outlined implementations instead of embedding the construction code.

This reduces the stripped aarch64 macOS `oxlint` binary by 224.9 KiB (1.66%; `__text` by 224.3 KiB).

Validated with `just ready` and a release fat-LTO size comparison.

AI assistance: Codex was used to implement and validate this change.
2026-08-17 05:17:33 +00:00
..

Oxc Diagnostics

Error reporting and diagnostic utilities for JavaScript and TypeScript tooling.

Overview

This crate provides comprehensive error handling and diagnostic reporting capabilities for JavaScript and TypeScript tooling.

Key Features

  • Rich diagnostics: Detailed error messages with source context
  • Source highlighting: Syntax-highlighted error locations
  • Multiple error support: Collect and report multiple errors at once
  • Built-in renderers: Graphical terminal and machine-readable JSON output
  • Severity levels: Support for errors, warnings, and informational messages

Architecture

Diagnostic Components

  • Message: Primary error/warning description
  • Labels: Highlight specific source locations
  • Help text: Suggestions for fixing the issue
  • Source context: Display relevant source code sections

Error Flow

  1. Creation: Tools create OxcDiagnostic instances for problems
  2. Collection: DiagnosticService aggregates diagnostics
  3. Formatting: Rich terminal output with colors and context
  4. Reporting: Display to users in IDE, CLI, or other interfaces

The diagnostic system ensures consistent, high-quality error reporting across all oxc tools.