Quickstart
Recommended setup and common workflows.
Install
Install oxfmt as a dev dependency:
sh
$ npm add -D oxfmt
``````sh [pnpm]
$ pnpm add -D oxfmt
``````sh [yarn]
$ yarn add -D oxfmt
``````sh [bun]
$ bun add -D oxfmt
``````json [package.json]
{
"scripts": {
"fmt": "oxfmt",
"fmt:check": "oxfmt --check"
}
}
``````sh [npm]
npm run fmt
``````sh [pnpm]
pnpm run fmt
``````sh [yarn]
yarn run fmt
``````sh [bun]
bun run fmt
``````sh [npm]
npm run fmt:check
``````sh [pnpm]
pnpm run fmt:check
``````sh [yarn]
yarn run fmt:check
``````sh [bun]
bun run fmt:check
``````sh
oxfmt [OPTIONS] [PATH]...
``````json [package.json]
{
"lint-staged": {
"*": "oxfmt --no-error-on-unmatched-pattern"
}
}
``````sh
oxfmt --init
``````sh
oxfmt --migrate prettier
``````sh
oxfmt --list-different
``````sh
echo 'const x = 1' | oxfmt --stdin-filepath test.ts
``````ts
import { format, type FormatOptions } from "oxfmt";
const input = `let a=42;`;
const options: FormatOptions = {
semi: false,
};
const { code } = await format("a.js", input, options);
console.log(code); // "let a = 42"