Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@fka/oxfmt-config

npm version License: MIT

Shared, opinionated oxfmt configuration for JavaScript and TypeScript projects.

Features

  • High Performance: Built for oxfmt (powered by Oxc).
  • 📦 Smart Import Sorting: Structured import order (builtinexternalinternalparentsiblingindextypestyle).
  • 🎨 Tailwind CSS & package.json Sorting: Automatically sorts classes and package.json fields.
  • 🛠️ TypeScript Ready: Full type definitions included.

Installation

# 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 oxfmt

Usage

1. Basic Setup

Create an oxfmt.config.ts or oxfmt.config.js in the root of your project:

import config from '@fka/oxfmt-config';

export default config;

2. Extending / Overriding Configuration

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;

3. Add Scripts to package.json

{
  "scripts": {
    "fmt": "oxfmt",
    "fmt:check": "oxfmt --check"
  }
}

Default Configuration

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

Import Sorting Order

Imports are sorted according to the following order:

  1. builtin: Node.js built-in modules (e.g. fs, path, node:*)
  2. external: Third-party packages from node_modules (e.g. react, lodash)
  3. subpath: Package subpath imports (#*)
  4. internal: Internal alias paths (configured with ~/ and @/)
  5. parent: Parent directory relative imports (e.g. ../, ../../../infra)
  6. sibling: Sibling & subdirectory imports (e.g. ./store/comment)
  7. index: Current directory index file imports (e.g. ./)
  8. type: Type-only imports
  9. style: Style files (.css, .scss, .less)
  10. unknown: Other unclassified imports

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages