Skip to main content

CLI Usage

Oxc provides two command-line tools: oxlint for linting JavaScript and TypeScript code, and oxfmt for formatting.

oxlint CLI

The oxlint CLI provides fast, parallel linting with configurable rules, plugins, and output formats.

Basic Usage

# Lint current directory
oxlint

# Lint specific files or directories
oxlint src/
oxlint file1.js file2.ts

# Lint with configuration file
oxlint -c .oxlintrc.json src/

Core Options

-c, --config
string
default:".oxlintrc.json"
Path to configuration file. Supports .json, .jsonc, and experimental .ts/.js files (requires Node.js runtime).
oxlint -c custom-config.json src/
--tsconfig
string
default:"./tsconfig.json"
TypeScript configuration file for path aliases and project references (used by import plugin).
oxlint --tsconfig tsconfig.build.json src/
--init
boolean
Initialize a new .oxlintrc.json configuration file with default values.
oxlint --init

Rule Configuration

Control which rules are enabled using command-line flags:
# Deny specific rules or categories
oxlint -D correctness -D suspicious src/

# Allow specific rules
oxlint -D all -A no-debugger src/

# Mix deny and allow
oxlint -D correctness -A no-debugger -W no-console src/
Available Categories:
  • correctness - Code that is outright wrong or useless (default)
  • suspicious - Code that is most likely wrong or useless
  • pedantic - Strict lints with occasional false positives
  • perf - Code that could be more performant
  • style - Code that should be more idiomatic
  • restriction - Lints preventing specific language features
  • nursery - New lints under development
  • all - All categories except nursery

Plugin Options

oxlint includes multiple plugin systems. Some plugins are enabled by default.
# Enable optional plugins
oxlint --react-plugin src/
oxlint --import-plugin --tsconfig tsconfig.json src/
oxlint --jest-plugin tests/
oxlint --vitest-plugin tests/

# Enable multiple plugins
oxlint --react-plugin --jsx-a11y-plugin src/
Default Plugins (always enabled):
  • oxc - Oxc-specific rules
  • typescript - TypeScript rules
  • unicorn - Unicorn plugin rules
Optional Plugins:
  • --react-plugin - React rules
  • --import-plugin - Import/export validation (requires --tsconfig)
  • --jsdoc-plugin - JSDoc comment validation
  • --jest-plugin - Jest testing rules
  • --vitest-plugin - Vitest testing rules (auto-enables jest)
  • --jsx-a11y-plugin - JSX accessibility rules
  • --nextjs-plugin - Next.js specific rules
  • --react-perf-plugin - React performance rules
  • --promise-plugin - Promise usage rules
  • --node-plugin - Node.js rules
  • --vue-plugin - Vue.js rules

Fix Options

--fix
boolean
Automatically fix safe issues. Only unfixed issues are reported.
oxlint --fix src/
--fix-suggestions
boolean
Apply auto-fixable suggestions. May change program behavior.
oxlint --fix-suggestions src/
--fix-dangerously
boolean
Apply dangerous fixes and suggestions. Use with caution.
oxlint --fix-dangerously src/

Ignore Options

--ignore-path
string
default:".eslintignore"
Specify the ignore file to use.
oxlint --ignore-path .gitignore src/
--ignore-pattern
string
Specify patterns to ignore (can be used multiple times).
oxlint --ignore-pattern "**/*.test.js" --ignore-pattern "dist/**" src/
--no-ignore
boolean
Disable all ignore patterns and files.
oxlint --no-ignore src/

Warning Options

--quiet
boolean
Disable reporting warnings, only show errors.
oxlint --quiet src/
--deny-warnings
boolean
Treat warnings as errors (non-zero exit code).
oxlint --deny-warnings src/
--max-warnings
number
Exit with error if warnings exceed threshold.
oxlint --max-warnings 10 src/

Output Options

-f, --format
string
default:"default"
Output format for diagnostics.Available formats:
  • default - Human-readable format
  • stylish - Stylish format
  • json - JSON output
  • unix - Unix-style format
  • checkstyle - Checkstyle XML format
  • github - GitHub Actions format
  • gitlab - GitLab CI format
  • junit - JUnit XML format
oxlint --format json src/ > results.json
oxlint --format github src/  # Auto-enabled in GitHub Actions

Advanced Options

--type-aware
boolean
Enable rules that require type information.
oxlint --type-aware --tsconfig tsconfig.json src/
--type-check
boolean
Enable experimental TypeScript compiler diagnostics.
oxlint --type-check --tsconfig tsconfig.json src/
--disable-nested-config
boolean
Disable automatic loading of nested configuration files.
oxlint --disable-nested-config src/
--report-unused-disable-directives
boolean
Report directive comments like // oxlint-disable-line when no errors would have been reported.
oxlint --report-unused-disable-directives src/
--report-unused-disable-directives-severity
string
Same as above but specify severity: warn, error, or off.
oxlint --report-unused-disable-directives-severity=warn src/

Miscellaneous Options

--threads
number
Number of threads to use. Set to 1 for single-threaded execution.
oxlint --threads 4 src/
--silent
boolean
Do not display any diagnostics.
oxlint --silent src/
--print-config
boolean
Output the resolved configuration. No linting is performed.
oxlint --print-config src/main.ts
--rules
boolean
List all available rules.
oxlint --rules
--lsp
boolean
Start the Language Server Protocol server.
oxlint --lsp

oxfmt CLI

The oxfmt CLI provides fast code formatting with Prettier-compatible options.

Basic Usage

# Format files in place
oxfmt src/

# Format specific files
oxfmt file1.js file2.ts

# Format with configuration
oxfmt -c .oxfmtrc.jsonc src/

# Format using glob patterns (quote to prevent shell expansion)
oxfmt 'src/**/*.{js,ts}'

Mode Options

Format and write files in place:
oxfmt src/
# or explicitly
oxfmt --write src/

Configuration Options

-c, --config
string
Path to configuration file (.oxfmtrc.json or .oxfmtrc.jsonc).
oxfmt -c .oxfmtrc.jsonc src/

Ignore Options

--ignore-path
string
Path to ignore file(s). Can be specified multiple times. Defaults to .gitignore and .prettierignore.
oxfmt --ignore-path .customignore src/
--with-node-modules
boolean
Format code in node_modules directory (skipped by default).
oxfmt --with-node-modules src/

Runtime Options

--threads
number
Number of threads to use. Set to 1 for single-threaded execution.
oxfmt --threads 4 src/
--no-error-on-unmatched-pattern
boolean
Do not exit with error when a pattern has no matches.
oxfmt --no-error-on-unmatched-pattern 'src/**/*.vue'

Special Modes

--init
boolean
Initialize .oxfmtrc.json with default values.
oxfmt --init
--migrate
string
Migrate configuration from another formatter. Sources: prettier, biome.
oxfmt --migrate prettier
oxfmt --migrate biome
--lsp
boolean
Start the Language Server Protocol server.
oxfmt --lsp

Path Specifications

PATH
string
Single file, path, or list of paths. Glob patterns and exclude patterns (with ! prefix) are supported.
# Single file
oxfmt src/main.ts

# Multiple paths
oxfmt src/ tests/

# Glob patterns (quote to prevent shell expansion)
oxfmt 'src/**/*.ts' '!src/**/*.test.ts'

# Exclude patterns
oxfmt 'src/**/*.js' '!**/node_modules/**'

Examples

# Format entire project
oxfmt .

# Format with check in CI
oxfmt --check src/

Terminal Output

$ oxfmt src/
src/utils.ts 123ms
src/main.ts 45ms
Formatted 2 files in 168ms

Integration Examples

CI/CD Pipeline

name: Lint and Format
on: [push, pull_request]

jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install oxlint
        run: npm install -g oxlint
      - name: Run oxlint
        run: oxlint --deny-warnings --format github src/
      
      - name: Install oxfmt
        run: npm install -g oxfmt
      - name: Check formatting
        run: oxfmt --check src/

Package.json Scripts

package.json
{
  "scripts": {
    "lint": "oxlint src/",
    "lint:fix": "oxlint --fix src/",
    "format": "oxfmt src/",
    "format:check": "oxfmt --check src/",
    "check": "npm run lint && npm run format:check"
  }
}

See Also

Build docs developers (and LLMs) love