Quality Standards
Code quality tooling with oxlint, oxfmt, Husky, and TypeScript type safety.
Overview
BetterStarter enforces high code quality through automated tooling and checks that run before every commit.
oxlint
oxlint is a blazing-fast JavaScript/TypeScript linter written in Rust. It replaces ESLint for the majority of linting needs.
Commands
# Lint the codebase
pnpm lint
# Lint and auto-fix issues
pnpm lint:fixConfiguration
oxlint config is in .oxlintrc.json:
{
"plugins": ["react", "typescript", "oxc"],
"categories": {
"correctness": "error",
"suspicious": "warn"
},
"rules": {
"react/no-array-index-key": "warn"
}
}oxfmt
oxfmt is a fast TypeScript/JavaScript formatter built on the OXC toolchain. It replaces Prettier.
Commands
# Check formatting
pnpm format
# Format and write changes
pnpm format:fixRun Both Together
# Lint + format check
pnpm lint-format
# Fix lint + format issues
pnpm lint-format:fixTypeScript
Full type safety is enforced. All code must pass TypeScript compilation without casting.
Type Checking
# Check types without building
pnpm tsc --noEmitBest Practices
- Never use
asor type assertions unless absolutely necessary - Infer types from schemas and function returns
- Use generics with
Tprefix:TData,TReturn,TArgs - Fix type errors at the source, not at the point of use
Husky & lint-staged
Pre-commit hooks automatically run quality checks:
What Happens on Commit
- Staged files are automatically linted with oxlint and formatted with oxfmt
- Syntax errors prevent commits
- Type errors must be fixed before pushing
Git Hooks
Located in .husky/:
pre-commit: Runs oxlint and oxfmt on staged files- Prevents committing code with linting errors
Pre-commit Workflow
Example: Making a Change
# Edit files
$ vim src/MyComponent.tsx
# Stage changes
$ git add src/MyComponent.tsx
# Commit (triggers pre-commit hook)
$ git commit -m "Add MyComponent"
# → oxfmt automatically formats your code
# → oxlint catches syntax and style errors
# → Errors fail the commitIf you have linting or formatting issues:
# Fix all issues automatically
pnpm lint-format:fix
# Then re-stage and commit
git add .
git commit -m "Add MyComponent"Continuous Integration
In CI environments, all checks run:
pnpm lint-format # Verify linting and formatting
pnpm tsc --noEmit # Type checking
pnpm build # Production buildFailing CI prevents merging to main.
Standards Summary
| Tool | Purpose | When It Runs |
|---|---|---|
| oxlint | Linting | Pre-commit, CI |
| oxfmt | Formatting | Pre-commit, CI |
| TypeScript | Type safety | Pre-commit, CI, IDE |
| Husky | Git hooks | Before commit |
| lint-staged | Selective file checking | Pre-commit |
Overriding Rules
To disable an oxlint rule for a specific line:
// oxlint-disable-next-line no-async-promise-executor
const x = new Promise(async () => {})For TypeScript:
// @ts-ignore
const x: string = 123Avoid overrides unless absolutely necessary—they're a code smell.