Configuration
Oxfmt works out of the box, but most teams commit a configuration file to keep formatting consistent across local runs, editors, and CI.
This page focuses on project configuration: formatting options, ignore patterns, and experimental features.
Create a config file
To generate a starter config in the current directory:
sh
oxfmt --initmy-repo/ ├── oxfmt.config.ts # default for the whole repo ├── src/ │ └── app.ts # uses root config └── packages/ └── fancy-app/ ├── .oxfmtrc.json # overrides for this package └── index.ts # uses packages/fancy-app/.oxfmtrc.json
sh
oxfmt -c path/to/yourconfig.json
``````json [.oxfmtrc.json]
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"printWidth": 80
}
``````ts [oxfmt.config.ts]
import { defineConfig } from "oxfmt";
export default defineConfig({
printWidth: 80,
});
``````json [.oxfmtrc.json]
{
"$schema": "./node_modules/oxfmt/configuration_schema.json"
}[*] indent_size = 4
[*.{js,ts}] indent_size = 2
json
{
"printWidth": 100,
"overrides": [
{
"files": ["*.test.js", "*.spec.ts"],
"options": {
"printWidth": 120
}
},
{
"files": ["*.md", "*.html"],
"excludeFiles": ["*.min.js"],
"options": {
"tabWidth": 4
}
}
]
}
``````ts [oxfmt.config.ts]
import { defineConfig } from "oxfmt";
export default defineConfig({
printWidth: 100,
overrides: [
{
files: ["*.test.js", "*.spec.ts"],
options: {
printWidth: 120,
},
},
{
files: ["*.md", "*.html"],
excludeFiles: ["*.min.js"],
options: {
tabWidth: 4,
},
},
],
});
``````json [.oxfmtrc.json]
{
"printWidth": 80
}
``````ts [oxfmt.config.ts]
import { defineConfig } from "oxfmt";
export default defineConfig({
printWidth: 80,
});
```