npm distribution of dprint-plugin-ruff which is an adapter plugin for Ruff.
Use this with @dprint/formatter or just use @dprint/formatter and download the dprint-plugin-ruff Wasm file.
import { createFromBuffer } from "@dprint/formatter";
import { getBuffer } from "@dprint/ruff";
const formatter = createFromBuffer(getBuffer());
console.log(
formatter.formatText("test.py", `print( "Hi!")`),
);