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.

eslint-plugin-unicorn is an ESLint plugin with over 100 opinionated rules designed to improve your JavaScript codebase. It enforces modern JavaScript patterns, prevents common mistakes, and encourages cleaner, more consistent code — all with auto-fix support for most rules.

Installation

Install the plugin and get up and running in minutes

Configuration

Configure individual rules or use a preset config

Preset Configs

Use recommended, unopinionated, or all rule presets

Rules Overview

Browse all 100+ available rules with descriptions

Why eslint-plugin-unicorn?

Most ESLint plugins target specific domains. eslint-plugin-unicorn covers a broad range of JavaScript best practices — from enforcing modern array methods and ES modules, to preventing subtle bugs, to ensuring consistent naming conventions.

100+ Rules

Comprehensive coverage of JavaScript best practices

Auto-fixable

Most rules support --fix for automatic correction

ESM-first

Built for modern JavaScript with flat config support

Quick start

1

Install

npm install --save-dev eslint eslint-plugin-unicorn
2

Add to your ESLint config

eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  eslintPluginUnicorn.configs.recommended,
];
3

Run ESLint

npx eslint .
4

Auto-fix issues

npx eslint . --fix
Requires ESLint >=9.20.0, flat config, and Node.js ^20.10.0 || >=21.0.0.

Explore the rules

eslint-plugin-unicorn rules are organized by theme. Start with the categories most relevant to your project:

Best Practices

Rules that prevent bugs and enforce sound coding patterns

Prefer Modern APIs

Rules that encourage modern JavaScript APIs over legacy equivalents

Code Style & Consistency

Rules that enforce consistent formatting and naming conventions

Deprecated Rules

Rules that have been removed or renamed

Build docs developers (and LLMs) love