Registry / testing / eslint-plugin-unicorn

eslint-plugin-unicorn

JSON →
library64.0.0jsnpmunverified

An ESLint plugin providing over 100 powerful lint rules focused on best practices, consistency, and code quality. Current stable version is 64.0.0, with regular releases following semantic versioning. Key differentiators: actively maintained by Sindre Sorhus, includes many rules not found in other plugins (e.g., `better-regex`, `prefer-spread`, `no-array-for-each`), ships TypeScript types, and supports ESM-only with ESLint flat config (>=9.20.0). Requires Node ^20.10.0 or >=21.0.0 and ESLint >=9.38.0.

npm install eslint-plugin-unicorn
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-UNIC
E
eslint-plugin-unicorn
testingjavascriptv64.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
const eslintPluginUnicorn = require('eslint-plugin-unicorn')
ESM-only; default export is the plugin object
rules
import { rules } from 'eslint-plugin-unicorn'
const { rules } = require('eslint-plugin-unicorn')
CommonJS not supported; use named import in ESM
configs
import { configs } from 'eslint-plugin-unicorn'
Named export for preset configs like `configs.recommended`

Minimum configuration to enable eslint-plugin-unicorn in flat config with recommended languageOptions and some example rules.

// eslint.config.js import eslintPluginUnicorn from 'eslint-plugin-unicorn'; import globals from 'globals'; export default [ { languageOptions: { globals: globals.builtin, }, plugins: { unicorn: eslintPluginUnicorn, }, rules: { 'unicorn/better-regex': 'error', 'unicorn/prefer-spread': 'error', 'unicorn/no-array-for-each': 'error', }, }, ];
Debug
Known issues
breakingESLint flat config required >=9.20.0; legacy .eslintrc format not supported
fix
Migrate to eslint.config.js flat config
affects: >=60.0.0
breakingNode.js 20.10 or higher required
fix
Update Node.js to ^20.10.0 or >=21.0.0
affects: >=60.0.0
breakingRename rules breaking change: no-array-push-push renamed to prefer-single-call, no-length-as-slice-end renamed to no-unnecessary-slice-end
fix
Update rule names in config
affects: 59.0.0
breakingESM-only; CommonJS require() not supported
fix
Use import statements; set type: module in package.json
affects: >=50.0.0
deprecatedDeprecated rules (e.g., no-process-exit, no-hex-escape) removed in recent versions
fix
Replace with current rule alternatives or remove from config
affects: >=60.0.0
gotchaRequires globals.builtin for languageOptions to avoid false positives
fix
Install globals package and include globals.builtin in config
affects: >=60.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'unicorn' declared in 'plugins': Cannot find module 'eslint-plugin-unicorn'
Plugin not installed or not in node_modules
fix
npm install --save-dev eslint-plugin-unicorn
Error: ConfigError: Config (unnamed): Key "rules": The key 'unicorn/better-regex' is not defined in the plugin unicorn.
Plugin not registered in plugins key
fix
Add plugins: { unicorn: eslintPluginUnicorn } to flat config
Error: Process environment variable 'NODE_OPTIONS': --require is not supported by Node.js
CommonJS require() used for plugin
fix
Use ESM import; set type: module in package.json
Error: Failed to load config 'plugin:unicorn/recommended' to extend from.
Flat config does not support extends; use configs.recommended
fix
Use eslintPluginUnicorn.configs.recommended in flat config array
Upgrade
Version history
64.0.0latest on npm
Audit
Dependencies
eslintrequiredpeer dependency - core linter
Agent activity
4 hits · last 30 days
node
4
Resources