@ashtrath/oxc-config
v0.1.0
Published
Ashtrath's OXC (oxlint + oxfmt) config
Readme
@ashtrath/oxc-config
Opinionated Oxlint and Oxfmt configuration factories for TypeScript projects, with an interactive setup wizard and automatic preset composition.
The factory architecture follows the composable design popularized by Anthony Fu in @antfu/eslint-config, adapted for native Oxlint and Oxfmt toolchains.
Quick start
Run the interactive CLI wizard in your project root:
# Bun
bunx @ashtrath/oxc-config
# pnpm
pnpm dlx @ashtrath/oxc-config
# npm
npx @ashtrath/oxc-configThe wizard:
- Detects your package manager from lockfiles.
- Identifies project frameworks (React, Next.js, Tailwind CSS).
- Writes
oxlint.config.tsandoxfmt.config.ts. - Adds
lint,lint:fix, andfmtscripts topackage.json. - Configures
.vscode/settings.jsonfor format-on-save.
Manual installation
Install @ashtrath/oxc-config and peer dependencies:
# Bun
bun add -D @ashtrath/oxc-config oxlint oxfmt
# pnpm
pnpm add -D @ashtrath/oxc-config oxlint oxfmt
# npm
npm i -D @ashtrath/oxc-config oxlint oxfmtOptional peer dependencies for framework support:
# Tailwind CSS sorting and lint rules
bun add -D oxlint-tailwindcss
# React Doctor inspection rules
bun add -D oxlint-plugin-react-doctor
# Anti-slop heuristic rules
bun add -D @ashtrath/oxlint-plugin-slopConfiguration
Linter (oxlint.config.ts)
Export the result of ashtrathLint:
import ashtrathLint from '@ashtrath/oxc-config/lint'
export default ashtrathLint({
// Project type: 'app' (default) or 'lib'
type: 'app',
// Framework toggles (auto-detected by CLI)
react: true,
nextjs: false,
// Tailwind CSS configuration
tailwindcss: {
entryPoint: 'src/index.css',
},
// Anti-slop heuristic checks
antislop: true,
// Ignore patterns
ignorePatterns: ['dist/**', 'coverage/**'],
})You can pass extra Oxlint configuration items or overrides as trailing arguments:
import ashtrathLint from '@ashtrath/oxc-config/lint'
export default ashtrathLint(
{ type: 'lib' },
{
rules: {
'no-console': 'warn',
},
},
)Formatter (oxfmt.config.ts)
Export the result of ashtrathFmt:
import ashtrathFmt from '@ashtrath/oxc-config/fmt'
export default ashtrathFmt({
// Default options: 2 spaces, single quotes, no semicolons, trailing commas, print width 100
sortImports: true,
sortPackageJson: true,
sortTailwindcss: true,
jsdoc: true,
})Custom file override objects pass directly as trailing arguments:
import ashtrathFmt from '@ashtrath/oxc-config/fmt'
export default ashtrathFmt(
{},
{
files: ['**/*.md'],
tabWidth: 4,
},
)Presets
ashtrathLint packages these presets:
| Preset | Target | Description |
| --------------- | ---------------------- | ------------------------------------------------------------------ |
| javascript | All files | Base syntax checks, modern idiom enforcement, and console controls |
| typescript | *.ts, *.tsx | TypeScript strictness, type assertions, and app vs lib rules |
| perfectionist | All files | Natural sorting for imports, exports, and object keys |
| antislop | All files | AST heuristic rules from @ashtrath/oxlint-plugin-slop |
| react | JSX / TSX | React hooks and React Doctor diagnostics |
| nextjs | Next.js projects | Routing rules and framework conventions |
| tailwindcss | Class attributes | Class sorting and duplicate class detection |
| vitest | *.test.*, *.spec.* | Test assertions and suite structure |
| e18e | All files | Ecosystem cleanup and package dependency hygiene |
| unicorn | All files | Modern standard library patterns |
| node | Node scripts | Node runtime globals and process controls |
| regexp | Regex literals | Regular expression correctness and backtracking checks |
| comments | Directives | Suppression comments and unused disable reporting |
VS Code settings
Install the Oxc VS Code extension.
Add these settings to .vscode/settings.json:
{
"prettier.enable": false,
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file",
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "explicit",
"source.organizeImports": "never"
},
"[javascript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[javascriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[typescript]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[typescriptreact]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[json]": { "editor.defaultFormatter": "oxc.oxc-vscode" },
"[jsonc]": { "editor.defaultFormatter": "oxc.oxc-vscode" }
}Scripts
Add standard scripts to package.json:
{
"scripts": {
"lint": "oxlint",
"lint:fix": "oxlint --fix",
"fmt": "oxfmt --write --no-error-on-unmatched-pattern"
}
}Acknowledgements
- Factory pattern and composable API design inspired by Anthony Fu's @antfu/eslint-config.
