Skip to content

OxlintServer

Base classes

Name Children Inherits
LSPServerInfo
anyenv.lsp_servers._base
Static configuration for an LSP server.

⋔ Inheritance diagram

graph TD
  2364417477["js_ts_lsps.OxlintServer"]
  514706066["_base.LSPServerInfo"]
  2751680898["builtins.object"]
  514706066 --> 2364417477
  2751680898 --> 514706066

🛈 DocStrings

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

:fa-brands-github: Show source on GitHub