Shared, opinionated oxfmt configuration for JavaScript and TypeScript projects.
- ⚡ High Performance: Built for
oxfmt(powered by Oxc). - 📦 Smart Import Sorting: Structured import order (
builtin➔external➔internal➔parent➔sibling➔index➔type➔style). - 🎨 Tailwind CSS & package.json Sorting: Automatically sorts classes and
package.jsonfields. - 🛠️ TypeScript Ready: Full type definitions included.
# pnpm
pnpm add -D @fka/oxfmt-config oxfmt
# npm
npm install -D @fka/oxfmt-config oxfmt
# yarn
yarn add -D @fka/oxfmt-config oxfmt
# bun
bun add -d @fka/oxfmt-config oxfmtCreate an oxfmt.config.ts or oxfmt.config.js in the root of your project:
import config from '@fka/oxfmt-config';
export default config;You can easily override or extend any rules:
import baseConfig from '@fka/oxfmt-config';
import type { OxfmtConfig } from 'oxfmt';
const config: OxfmtConfig = {
...baseConfig,
printWidth: 100, // custom override
};
export default config;{
"scripts": {
"fmt": "oxfmt",
"fmt:check": "oxfmt --check"
}
}| Option | Value | Description |
|---|---|---|
printWidth |
120 |
Max line length |
tabWidth |
2 |
Number of spaces per indentation level |
useTabs |
false |
Indent with spaces |
semi |
true |
Print semicolons at the ends of statements |
singleQuote |
true |
Use single quotes instead of double quotes |
jsxSingleQuote |
false |
Use double quotes in JSX |
trailingComma |
'all' |
Print trailing commas wherever possible |
bracketSpacing |
true |
Print spaces between brackets in object literals |
bracketSameLine |
true |
Put the > of multi-line HTML/JSX elements at the end of the last line |
arrowParens |
'avoid' |
Avoid parens when possible in single-argument arrow functions |
endOfLine |
'lf' |
Enforce LF line breaks |
sortPackageJson |
true |
Automatically sort package.json |
sortTailwindcss |
true |
Automatically sort Tailwind CSS classes |
sortImports |
Enabled |
Sort and organize import statements |
Imports are sorted according to the following order:
builtin: Node.js built-in modules (e.g.fs,path,node:*)external: Third-party packages fromnode_modules(e.g.react,lodash)subpath: Package subpath imports (#*)internal: Internal alias paths (configured with~/and@/)parent: Parent directory relative imports (e.g.../,../../../infra)sibling: Sibling & subdirectory imports (e.g../store/comment)index: Current directory index file imports (e.g../)type: Type-only importsstyle: Style files (.css,.scss,.less)unknown: Other unclassified imports