JavaScript/TypeScript linter (ESLint wrapper) with great defaults
XO provides a comprehensive command-line interface for linting JavaScript and TypeScript projects with zero configuration required.
# Lint all supported files in current directory
xo
# Lint specific files or patterns
xo index.js src/*.ts test/**/*.js
# Lint with glob patterns
xo "src/**/*.{js,ts}" "test/**/*.spec.*"Automatically fix linting issues where possible.
# Fix all fixable issues
xo --fix
# Fix specific files
xo --fix src/index.js
# Combine with other options
xo --fix --space --react src/Control code style and formatting preferences.
# Use spaces instead of tabs (default: 2 spaces)
xo --space
# Use specific number of spaces
xo --space 4
# Force tab indentation
xo --space false
# Control semicolon usage
xo --semicolon # Require semicolons (default)
xo --no-semicolon # Disallow semicolonsEnable Prettier formatting integration.
# Format with Prettier
xo --prettier
# Prettier compatibility mode (disable conflicting rules)
xo --prettier=compatEnable React-specific linting rules.
# Enable React support
xo --react
# Combine with other options
xo --react --prettier --space 2Specify custom configuration files and working directories.
# Use custom config file
xo --config ./custom-xo.config.js
# Set working directory
xo --cwd /path/to/project
# Combine configuration options
xo --config ./xo.config.js --cwd ./srcControl what gets displayed in the output.
# Show only errors (hide warnings)
xo --quiet
# Use specific reporter
xo --reporter json
xo --reporter compact
xo --reporter unix
# Print effective ESLint config for a file
xo --print-config=src/index.jsSpecify files and directories to ignore.
# Ignore specific patterns
xo --ignore "dist/**" --ignore "*.min.js"
# Multiple ignore patterns
xo --ignore "node_modules/**" --ignore "coverage/**" --ignore "build/**"Open files with issues directly in your editor.
# Open files with issues in editor
xo --open
# Combine with other options
xo --open --quietLint code from standard input.
# Lint from stdin
echo "console.log('hello')" | xo --stdin
# Specify filename for context
echo "const x: string = 'test'" | xo --stdin --stdin-filename="test.ts"
# Fix stdin input
echo "console.log( 'hello' )" | xo --stdin --fix# Show XO version
xo --versioninterface CliFlags {
/** Automatically fix issues (default: false) */
fix: boolean;
/** Reporter to use for output formatting */
reporter?: string;
/** Space indentation configuration (string that gets parsed) */
space?: string;
/** Path to XO configuration file */
configPath?: string;
/** Show only errors, not warnings */
quiet?: boolean;
/** Use semicolons at end of statements */
semicolon?: boolean;
/** Enable Prettier integration */
prettier?: boolean;
/** Enable React-specific rules (default: false) */
react: boolean;
/** Working directory for files (default: process.cwd()) */
cwd: string;
/** Print effective ESLint config for file */
printConfig?: string;
/** Show version information */
version?: boolean;
/** Read code from stdin */
stdin?: boolean;
/** Filename for stdin input (default: "stdin.js") */
stdinFilename: string;
/** Open files with issues in editor */
open?: boolean;
/** Ignore pattern globs (can be specified multiple times) */
ignore: string[];
}XO uses standard exit codes to indicate the result of linting:
# Standard development setup
xo --fix --space 2 --react
# Pre-commit hook setup
xo --quiet --reporter=compact
# CI/CD pipeline
xo --reporter=junit --quiet
# Debug configuration
xo --print-config=src/index.ts# Custom ignore patterns for build artifacts
xo --ignore "dist/**" --ignore "build/**" --ignore "*.generated.*"
# TypeScript project with custom config
xo --config ./tsconfig.eslint.json --cwd ./src "**/*.{ts,tsx}"
# Multi-project monorepo
xo --cwd ./packages/frontend --react --prettier
xo --cwd ./packages/backend --space 4# Package.json script
"scripts": {
"lint": "xo",
"lint:fix": "xo --fix",
"lint:ci": "xo --quiet --reporter=junit"
}
# Git pre-commit hook
#!/bin/sh
xo --fix --quiet && git add .
# VS Code task
{
"type": "shell",
"command": "xo",
"args": ["--fix", "--open"],
"group": "build"
}XO provides clear error messages and suggestions:
# Configuration errors
$ xo --print-config=""
Error: The `--print-config` flag must be used with exactly one filename
# Invalid options
$ xo --invalid-option
Error: Unknown option: --invalid-option
# File access errors
$ xo --config ./missing-config.js
Error: Config file not found: ./missing-config.jsXO respects certain environment variables:
# GitHub Actions integration (automatically enables quiet mode)
GITHUB_ACTIONS=true xo
# Node.js options
NODE_OPTIONS="--max-old-space-size=8192" xo large-project/XO supports multiple built-in reporters:
stylish (default): Human-readable format with colorscompact: Compact format for CI environmentsjson: Machine-readable JSON outputjunit: JUnit XML format for CI integrationcheckstyle: Checkstyle XML formattap: TAP (Test Anything Protocol) formatunix: Unix-style format# Examples of different reporters
xo --reporter=json > lint-results.json
xo --reporter=junit > junit-results.xml
xo --reporter=compact --quietInstall with Tessl CLI
npx tessl i tessl/npm-xo