{"id":19967,"library":"eslint-plugin-unicorn","title":"eslint-plugin-unicorn","description":"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.","status":"active","version":"64.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/sindresorhus/eslint-plugin-unicorn","tags":["javascript","eslint","eslintplugin","eslint-plugin","unicorn","linter","lint","style","xo","typescript"],"install":[{"cmd":"npm install eslint-plugin-unicorn","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-unicorn","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-unicorn","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - core linter","package":"eslint","optional":false}],"imports":[{"note":"ESM-only; default export is the plugin object","wrong":"const eslintPluginUnicorn = require('eslint-plugin-unicorn')","symbol":"default","correct":"import eslintPluginUnicorn from 'eslint-plugin-unicorn'"},{"note":"CommonJS not supported; use named import in ESM","wrong":"const { rules } = require('eslint-plugin-unicorn')","symbol":"rules","correct":"import { rules } from 'eslint-plugin-unicorn'"},{"note":"Named export for preset configs like `configs.recommended`","wrong":"","symbol":"configs","correct":"import { configs } from 'eslint-plugin-unicorn'"}],"quickstart":{"code":"// eslint.config.js\nimport eslintPluginUnicorn from 'eslint-plugin-unicorn';\nimport globals from 'globals';\n\nexport default [\n  {\n    languageOptions: {\n      globals: globals.builtin,\n    },\n    plugins: {\n      unicorn: eslintPluginUnicorn,\n    },\n    rules: {\n      'unicorn/better-regex': 'error',\n      'unicorn/prefer-spread': 'error',\n      'unicorn/no-array-for-each': 'error',\n    },\n  },\n];","lang":"javascript","description":"Minimum configuration to enable eslint-plugin-unicorn in flat config with recommended languageOptions and some example rules."},"warnings":[{"fix":"Migrate to eslint.config.js flat config","message":"ESLint flat config required >=9.20.0; legacy .eslintrc format not supported","severity":"breaking","affected_versions":">=60.0.0"},{"fix":"Update Node.js to ^20.10.0 or >=21.0.0","message":"Node.js 20.10 or higher required","severity":"breaking","affected_versions":">=60.0.0"},{"fix":"Update rule names in config","message":"Rename rules breaking change: no-array-push-push renamed to prefer-single-call, no-length-as-slice-end renamed to no-unnecessary-slice-end","severity":"breaking","affected_versions":"59.0.0"},{"fix":"Use import statements; set type: module in package.json","message":"ESM-only; CommonJS require() not supported","severity":"breaking","affected_versions":">=50.0.0"},{"fix":"Replace with current rule alternatives or remove from config","message":"Deprecated rules (e.g., no-process-exit, no-hex-escape) removed in recent versions","severity":"deprecated","affected_versions":">=60.0.0"},{"fix":"Install globals package and include globals.builtin in config","message":"Requires globals.builtin for languageOptions to avoid false positives","severity":"gotcha","affected_versions":">=60.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev eslint-plugin-unicorn","cause":"Plugin not installed or not in node_modules","error":"Error: Failed to load plugin 'unicorn' declared in 'plugins': Cannot find module 'eslint-plugin-unicorn'"},{"fix":"Add plugins: { unicorn: eslintPluginUnicorn } to flat config","cause":"Plugin not registered in plugins key","error":"Error: ConfigError: Config (unnamed): Key \"rules\": The key 'unicorn/better-regex' is not defined in the plugin unicorn."},{"fix":"Use ESM import; set type: module in package.json","cause":"CommonJS require() used for plugin","error":"Error: Process environment variable 'NODE_OPTIONS': --require is not supported by Node.js"},{"fix":"Use eslintPluginUnicorn.configs.recommended in flat config array","cause":"Flat config does not support extends; use configs.recommended","error":"Error: Failed to load config 'plugin:unicorn/recommended' to extend from."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}