Package Exports
- @configurajs/vite-plus
Readme
@configurajs/vite-plus
Opinionated Oxlint + Oxfmt configuration preset for Vite+ projects.
Features
- TypeScript (enabled by default)
- Vue 3 (enabled by default)
- React (opt-in)
- Vitest (enabled by default)
- Oxfmt formatting with import sorting and Tailwind CSS class sorting
- Lint-staged preset out of the box
Install
pnpm add -D @configurajs/vite-plusUsage
Oxc Configuration File
Create oxlint.config.ts in your project root:
// oxlint.config.ts
import { lint } from '@configurajs/vite-plus'
export default lint()Create oxfmt.config.ts in your project root:
// oxfmt.config.ts
import { fmt } from '@configurajs/vite-plus'
export default fmt()Vite+ Configuration File
If you are using Vite+, you can configure lint, fmt and staged in vite.config.ts directly:
// vite.config.ts
import { defineConfig } from 'vite-plus'
import { lint, fmt, staged } from '@configurajs/vite-plus'
export default defineConfig({
lint: lint(),
fmt: fmt(),
staged: staged(),
})Lint Options
lint({
// Enable TypeScript support (default: true)
ts: true,
// Enable Vue support, version 3 by default (default: true)
vue: true, // or { version: 2 }
// Enable React support (default: false)
react: false,
// Enable Vitest support (default: true)
vitest: true,
// Custom rules
rules: {
'no-console': 'error',
},
// Ignore file patterns
ignores: ['**/generated/**'],
// Additional overrides
overrides: [
{
files: ['scripts/**'],
rules: { 'no-console': 'off' },
},
],
})Fmt Options
fmt({
// Ignore file patterns
ignores: ['**/generated/**'],
})Staged
staged() returns a preset lint-staged configuration:
staged()
// Equivalent to:
// {
// '*.{js,jsx,ts,tsx,vue}': ['vp fmt --no-error-on-unmatched-pattern', 'vp lint --fix'],
// '*.{md,json,yaml,yml,html,css,scss,less}': 'vp fmt --no-error-on-unmatched-pattern',
// }js / jsx / ts / tsx / vue— Format and lint fixmd / json / yaml / yml / html / css / scss / less— Format only
VSCode Settings
Add the following to .vscode/settings.json:
{
"prettier.enable": false,
"eslint.enable": false,
"editor.defaultFormatter": "oxc.oxc-vscode",
}License
MIT