Install XO
mainInstall XO as a development dependency in your project. Note that XO requires your project to be ESM. You can run it directly using npx xo.
npm install xo --save-devrepository·main·Indexed 27 days ago
https://github.com/xojs/xoAn opinionated, zero-config JavaScript/TypeScript linter that acts as a wrapper around ESLint. It provides strict, readable defaults and includes plugins to eliminate code style discussions. Supports ESM projects and integrates with Astro, React, Svelte, and Vue. Features include automatic TypeScript linting, Prettier integration, and a CLI with options for indentation, semicolons, and automatic fixing.
Install XO as a development dependency in your project. Note that XO requires your project to be ESM. You can run it directly using npx xo.
npm install xo --save-devIf you want to use XO's rules directly in ESLint without using the xo CLI, install eslint-config-xo. This configuration accepts core style options, including Prettier integration.
Note: This replaces the deprecated xoToEslintConfig helper. Use eslintConfigXo() instead.
import eslintConfigXo from 'eslint-config-xo';
export default [
...eslintConfigXo({space: true, prettier: true}),
];To lint React files, install eslint-config-xo-react and spread its recommended config in your xo.config.js.
Note: Until eslint-plugin-react supports ESLint 10 natively, you may need to wrap the config with fixupConfigRules from @eslint/compat.
npm install --save-dev eslint-config-xo-reactimport xoReact from 'eslint-config-xo-react';
const xoConfig = [
...xoReact(),
];
export default xoConfig;XO uses ESLint's Flat Config format. You can create an xo.config.js or xo.config.ts file in your project root, or add an xo field to your package.json. For TypeScript validation of your config, import the provided types.
import {type FlatXoConfig} from 'xo';
const xoConfig: FlatXoConfig = [
// your config
];
export default xoConfig;If you use the xo CLI but your editor only supports the ESLint extension, you can use the xo/eslint-adapter. This adapter reads your xo.config.js and automatically generates a matching ESLint configuration, ensuring your editor displays the same errors as the CLI.
export {default} from 'xo/eslint-adapter';To lint Svelte files, install eslint-plugin-svelte and spread its recommended config in your xo.config.js.
npm install --save-dev eslint-plugin-svelteimport sveltePlugin from 'eslint-plugin-svelte';
const xoConfig = [
...sveltePlugin.configs.recommended,
];
export default xoConfig;To lint Astro files, install eslint-plugin-astro and spread its recommended config in your xo.config.js.
npm install --save-dev eslint-plugin-astroimport astroPlugin from 'eslint-plugin-astro';
const xoConfig = [
...astroPlugin.configs.recommended,
];
export default xoConfig;To lint Vue files, install eslint-plugin-vue and spread its recommended config in your xo.config.js.
npm install --save-dev eslint-plugin-vueimport vuePlugin from 'eslint-plugin-vue';
const xoConfig = [
...vuePlugin.configs['flat/recommended'],
];
export default xoConfig;XO automatically lints TypeScript files (.ts, .mts, .cts, and .tsx) using eslint-config-xo-typescript. It handles the @typescript-eslint/parser project option automatically, even without a tsconfig.json.
To opt out of automatic tsconfig handling, specify your own languageOptions.parserOptions.project, languageOptions.parserOptions.projectService, or languageOptions.parserOptions.tsconfigRootDir in your configuration.
XO respects an eslint-suppressions.json file in your working directory. This allows you to suppress existing violations while enforcing rules on new code.
To generate this file, use the xo/eslint-adapter in an eslint.config.js and run ESLint with the --suppress-all flag:
npx eslint --suppress-allTo use a custom path for the suppressions file, use the --suppressions-location flag with the xo CLI.
Specify which files the config applies to using a glob string or array. Default: **/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,vue,svelte,astro}.
Add paths to be ignored. For global ignores, keep ignores as the only key in the config object. XO supports negated ignores (e.g., !dist/**) to reopen built-in ignored paths.
Enable Prettier formatting by setting prettier: true. Alternatively, set prettier: 'compat' to turn off all XO rules that conflict with Prettier, allowing you to manage formatting via a separate Prettier configuration.
When true, XO applies specific Prettier options: semi (based on your semicolon setting), useTabs (based on your space setting), tabWidth (based on your space setting), singleQuote: true, bracketSpacing: false, bracketSameLine: false, and trailingComma: 'all'.