Errors and lint findings as Elixir Code.diagnostic/1 maps.
Every OXC error and lint finding uses this shape:
%{
file: "app.ts",
severity: :error,
message: "Unexpected token",
position: {2, 11},
span: {2, 12},
source: nil,
stacktrace: []
}position is the 1-based {line, column} where the problem starts and span
is where it ends, with columns counted in characters. Diagnostics without a
source location use position: 0 and span: nil, as Elixir does.
Some diagnostics carry extra keys:
:details— help text suggesting a fix:rule— the lint rule that reported the finding:labels— secondary locations, each with:position,:span, and:message:fixes— lint fixes asOXC.patch/0maps, ready forOXC.patch_string/2:suggestions— alternative type-aware fixes, each with a:messageand:fixes
Summary
Types
A native error: message, help, and byte-range labels with the primary label first.
Functions
Format a diagnostic as file:line:column: message, like Elixir compiler output.
Build diagnostics from native errors reported for source in file.
Types
@type position() :: {line :: pos_integer(), column :: pos_integer()}
@type raw() :: %{ :message => String.t(), optional(:help) => String.t() | nil, optional(:labels) => [ {non_neg_integer(), non_neg_integer(), String.t() | nil} ], optional(:severity) => :error | :warning, optional(:rule) => String.t(), optional(:fixes) => [{non_neg_integer(), non_neg_integer(), String.t()}], optional(:suggestions) => [ %{ message: String.t(), fixes: [{non_neg_integer(), non_neg_integer(), String.t()}] } ], optional(atom()) => term() }
A native error: message, help, and byte-range labels with the primary label first.
@type t() :: Code.diagnostic(:error | :warning)
Functions
Format a diagnostic as file:line:column: message, like Elixir compiler output.
Build diagnostics from native errors reported for source in file.
Pass nil for source when the errors do not refer to a single source text.