Bases: LSPServerInfo
Oxlint (oxc) linter with JSON diagnostic parsing.
Source code in src/anyenv/lsp_servers/_servers/js_ts_lsps.py
| @dataclass
class OxlintServer(LSPServerInfo):
"""Oxlint (oxc) linter with JSON diagnostic parsing."""
def _parse_json_diagnostics(self, output: str) -> list[Diagnostic]:
"""Parse oxlint JSON output."""
import anyenv
diagnostics: list[Diagnostic] = []
try:
data = anyenv.load_json(output, return_type=dict)
for diag in data.get("diagnostics", []):
# Get location from labels
labels = diag.get("labels", [])
if labels:
span = labels[0].get("span", {})
line = span.get("line", 1)
column = span.get("column", 1)
else:
line, column = 1, 1
diagnostics.append(
Diagnostic(
file=diag.get("filename", ""),
line=line,
column=column,
severity=severity_from_string(diag.get("severity", "warning")),
message=diag.get("message", ""),
code=diag.get("code"),
source=self.id,
)
)
except anyenv.JsonLoadError:
pass
return diagnostics
|