XO Linter

2.0.2 · active · verified Tue Apr 21

XO is an opinionated JavaScript and TypeScript linter that wraps ESLint, providing a zero-configuration setup with strict, readable code defaults. It aims to streamline code style enforcement and eliminate style-related discussions in pull requests. The current stable version is 2.0.2, with a relatively active release cadence to incorporate updates and maintain compatibility with its underlying dependencies. Key differentiators include its batteries-included approach, which bundles many useful ESLint plugins (e.g., `unicorn`, `import-x`, `n`), automatic caching for performance, first-class TypeScript support, and flexible integration options, including optional Prettier usage. It mandates an ESM-only project structure for optimal functionality.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to install XO as a dev dependency, configure it in `package.json`, and run it from the command line, including using the `--fix` flag to automatically resolve issues.

{
  "name": "my-project",
  "version": "1.0.0",
  "type": "module",
  "devDependencies": {
    "xo": "^2.0.0"
  },
  "scripts": {
    "lint": "xo",
    "lint:fix": "xo --fix"
  }
}

// src/index.js
const myVar =  'hello' ;  // Linting issue: extra space, single quotes

function MyComponent(props) { // Linting issue: function-style component for React
  return (<div>{props.message}</div>);
}

console.log(myVar, MyComponent);

// To run:
// npm install
// npm run lint
// npm run lint:fix

view raw JSON →