eslint-plugin-unicorn is an ESLint plugin with over 100 opinionated rules. It enforces modern JavaScript patterns, prevents common mistakes, and promotes consistent code — with auto-fix support for most rules. You might also want to check out XO, a JavaScript linter that includes eslint-plugin-unicorn out of the box.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.
Key features
100+ rules
Broad coverage of JavaScript best practices, from naming conventions to modern API enforcement.
Auto-fixable
Most rules support
--fix for automatic correction and editor suggestions for the rest.Flat config support
Built for ESLint’s modern flat config system (
eslint.config.js). Legacy .eslintrc is not supported.ESM-first
Written as an ES module. You import it — not
require() it.Preset configs
Three ready-made configs:
recommended, all, and unopinionated. Use one or configure rules individually.Editor suggestions
Rules that can’t be auto-fixed provide inline editor suggestions for guided manual fixes.
Requirements
eslint-plugin-unicorn requires ESLint
>=9.38.0, ESLint’s flat config format, and Node.js ^20.10.0 || >=21.0.0.
Legacy .eslintrc configuration files are not supported.How it differs from other ESLint plugins
Most ESLint plugins target a single domain — React, imports, accessibility, and so on. eslint-plugin-unicorn covers a wide range of general JavaScript best practices in one package:- Modern APIs — rules prefer
Array#at(),structuredClone(),node:protocol imports, and other contemporary built-ins over legacy equivalents. - Consistency — rules enforce uniform style for things like filename casing, error naming, template literals, and numeric separators.
- Bug prevention — rules catch subtle mistakes like passing a function reference directly to an iterator method, using
awaitin non-async contexts, or misusingPromisemethods. - Code clarity — rules flag patterns that are hard to read, such as nested ternaries, unreadable array destructuring, or implicit
undefinedreturns.
Rule categories
eslint-plugin-unicorn rules fall broadly into these themes:| Category | Examples |
|---|---|
| Prefer modern APIs | prefer-at, prefer-node-protocol, prefer-structured-clone |
| Code style & consistency | filename-case, numeric-separators-style, number-literal-case |
| Best practices | no-array-reduce, no-await-expression-member, throw-new-error |
| Bug prevention | no-invalid-fetch-options, no-accessor-recursion, no-thenable |
| ESM & modules | prefer-module, prefer-export-from, prefer-import-meta-properties |
Next steps
Installation
Install the plugin and set up your project.
Configuration
Use a preset config or configure individual rules.