Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sindresorhus/eslint-plugin-unicorn/llms.txt

Use this file to discover all available pages before exploring further.

Prerequisites

Before you install, confirm your environment meets these requirements:
  • Node.js ^20.10.0 || >=21.0.0
  • ESLint >=9.38.0
  • Flat config — your project must use eslint.config.js, not .eslintrc
  • ESM — your config file must use import, not require()
eslint-plugin-unicorn is published as an ES module. You must use import eslintPluginUnicorn from 'eslint-plugin-unicorn'require() is not supported.

Install

1

Install the package

Add eslint-plugin-unicorn to your dev dependencies. If you don’t have ESLint yet, install it at the same time.
npm install --save-dev eslint eslint-plugin-unicorn
2

Verify the installation

Confirm eslint-plugin-unicorn appears in your package.json under devDependencies:
package.json
{
  "devDependencies": {
    "eslint": ">=9.38.0",
    "eslint-plugin-unicorn": "^64.0.0"
  }
}
3

Configure ESLint

Add the plugin to your eslint.config.js. The fastest way is to use a preset config:
eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  eslintPluginUnicorn.configs.recommended,
];
See the configuration guide for preset options and manual rule setup.
4

Run ESLint

npx eslint .
To automatically fix issues that support --fix:
npx eslint . --fix

Build docs developers (and LLMs) love