{"id":15289,"library":"xo","title":"XO Linter","description":"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.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/xojs/xo","tags":["javascript","cli-app","cli","xo","xoxo","happy","happiness","code","quality"],"install":[{"cmd":"npm install xo","lang":"bash","label":"npm"},{"cmd":"yarn add xo","lang":"bash","label":"yarn"},{"cmd":"pnpm add xo","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"XO is a wrapper around ESLint and requires a compatible version to function correctly.","package":"eslint","optional":false}],"imports":[{"note":"XO is an ESM-only package since v2.0.0. Direct programmatic usage is typically for advanced scenarios, as it's primarily a CLI tool.","wrong":"const xo = require('xo');","symbol":"xo","correct":"import xo from 'xo';"},{"note":"This is a command-line utility for quickly adding XO to a new or existing project, not a direct JavaScript import.","symbol":"create-xo","correct":"npm init xo"},{"note":"XO integrates React linting via the `--react` CLI flag or `react: true` in its configuration, which internally uses `eslint-config-xo-react`. It's not typically imported directly by the user.","symbol":"eslint-config-xo-react","correct":"/* configured via 'react' option or implicitly */"}],"quickstart":{"code":"{\n  \"name\": \"my-project\",\n  \"version\": \"1.0.0\",\n  \"type\": \"module\",\n  \"devDependencies\": {\n    \"xo\": \"^2.0.0\"\n  },\n  \"scripts\": {\n    \"lint\": \"xo\",\n    \"lint:fix\": \"xo --fix\"\n  }\n}\n\n// src/index.js\nconst myVar =  'hello' ;  // Linting issue: extra space, single quotes\n\nfunction MyComponent(props) { // Linting issue: function-style component for React\n  return (<div>{props.message}</div>);\n}\n\nconsole.log(myVar, MyComponent);\n\n// To run:\n// npm install\n// npm run lint\n// npm run lint:fix","lang":"javascript","description":"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."},"warnings":[{"fix":"Upgrade your Node.js environment to version 20.19 or newer.","message":"XO v2.0.0 and later require Node.js version 20.19 or higher. Older Node.js versions are not supported.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Update your local ESLint installation to `eslint@^10.0.0` or higher, or remove it if you intend for XO to manage it exclusively.","message":"XO v2.0.0 and later require ESLint version 10. Ensure your project's ESLint dependency (if any) is compatible or allow XO to manage its own ESLint peer dependency.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Migrate your `xo.config.cjs` or similar CJS configuration files to `.js`, `.mjs`, or TypeScript equivalents, ensuring they use `export default` syntax.","message":"CommonJS (CJS) config files are no longer supported. Configuration must be provided in ES module format (e.g., `.js`, `.mjs`, `.ts`, `.mts`) as XO is an ESM-only package.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Be aware that these rules are currently disabled. Monitor the XO changelog for re-introduction once ESLint 10 compatibility is resolved for the plugin.","message":"The `eslint-plugin-promise` rules were temporarily removed in v2.0.0 due to compatibility issues with ESLint 10. This may affect existing projects relying on these specific rules.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure your project's `package.json` contains `\"type\": \"module\"` if you are using `.js` files, or use `.mjs` or TypeScript files. For CLI usage, `npx xo` should handle the environment correctly.","message":"XO is strictly an ESM-only package. Attempting to use `require()` or run XO in a non-ESM Node.js environment will result in errors.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Change your import statement to `import xo from 'xo';` if using XO programmatically. Ensure your `package.json` has `\"type\": \"module\"` if your `.js` files are intended to be ESM.","cause":"Attempting to import XO programmatically using CommonJS `require()` syntax in an ES module context, or running XO in a project that is not configured as an ES module.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module <path_to_xo>/index.js from <your_file> not supported."},{"fix":"Update your Node.js installation to version 20.19 or newer. Consider using a version manager like `nvm` or `volta`.","cause":"The installed Node.js version is older than the minimum required by XO v2.0.0+.","error":"Your current Node.js version is <version>. XO requires Node.js >= 20.19."},{"fix":"This is expected behavior in XO v2.0.0. You cannot re-enable these rules until XO re-integrates them in a future release. Review your linting expectations accordingly.","cause":"This specific plugin's rules were temporarily removed from XO v2.0.0 due to compatibility issues with ESLint 10.","error":"ESLint couldn't find the plugin \"eslint-plugin-promise\"."},{"fix":"Verify your `xo.config.js` or similar file is using correct ESM syntax and extending valid, compatible configurations. Ensure there are no CJS-style `module.exports` or `require()` calls within the config file itself.","cause":"A configuration file (e.g., `xo.config.js`) might be trying to extend a CJS-specific configuration or an older config that's no longer compatible with ESLint 10.","error":"ESLint couldn't find the config \"<config_name>\" to extend from."}],"ecosystem":"npm"}