{"id":20008,"library":"eslint-unicorn","title":"eslint-plugin-unicorn","description":"ESLint plugin providing more than 100 powerful rules for enforcing consistent, error-free code style and catching common mistakes. Current stable version is 55.0.0, with frequent releases (often multiple per month). Key differentiators include a broad focus beyond stylistic concerns (e.g., security, performance, best practices), automatic fixing for many rules, and strong integration with XO. It requires ESLint >=8.56.0 and Node >=18.18, and ships TypeScript definitions.","status":"active","version":"55.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-unicorn","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-unicorn","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-unicorn","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for plugin to run","package":"eslint","optional":false},{"reason":"commonly used alongside to provide builtin globals in flat config","package":"globals","optional":true}],"imports":[{"note":"Default export is the plugin object. In CommonJS, use `require('eslint-plugin-unicorn')` directly without .default.","wrong":"const eslintPluginUnicorn = require('eslint-plugin-unicorn').default;","symbol":"eslintPluginUnicorn","correct":"import eslintPluginUnicorn from 'eslint-plugin-unicorn';"},{"note":"Access recommended config via the default export. In CJS, use `require('eslint-plugin-unicorn').configs.recommended`.","wrong":"const { configs } = require('eslint-plugin-unicorn');","symbol":"configs.recommended","correct":"import eslintPluginUnicorn from 'eslint-plugin-unicorn';\neslintPluginUnicorn.configs.recommended"},{"note":"Rules are accessed via the plugin object's 'rules' property. There is no separate 'rules' export.","wrong":"const rules = require('eslint-plugin-unicorn/rules');","symbol":"rules","correct":"import eslintPluginUnicorn from 'eslint-plugin-unicorn';\neslintPluginUnicorn.rules['unicorn/better-regex']"}],"quickstart":{"code":"import eslintPluginUnicorn from 'eslint-plugin-unicorn';\nimport globals from 'globals';\n\nexport default [\n  eslintPluginUnicorn.configs.recommended,\n  {\n    languageOptions: {\n      globals: globals.builtin,\n    },\n    plugins: {\n      unicorn: eslintPluginUnicorn,\n    },\n    rules: {\n      'unicorn/better-regex': 'error',\n      'unicorn/catch-error-name': 'error',\n    },\n  },\n];","lang":"typescript","description":"Shows how to set up eslint-plugin-unicorn with flat config (ESLint >=8.56.0) using the recommended preset and additional rules."},"warnings":[{"fix":"Update Node.js to >=18.18 or pin eslint-plugin-unicorn to <60.0.0.","message":"Minimum Node.js version is 18.18 starting from v60.0.0","severity":"breaking","affected_versions":">=60.0.0"},{"fix":"Replace 'unicorn/no-array-push-push' with 'unicorn/prefer-single-call'.","message":"Rule 'no-array-push-push' renamed to 'prefer-single-call' in v59.0.0","severity":"deprecated","affected_versions":">=59.0.0"},{"fix":"Replace 'unicorn/no-length-as-slice-end' with 'unicorn/no-unnecessary-slice-end'.","message":"Rule 'no-length-as-slice-end' renamed to 'no-unnecessary-slice-end' in v59.0.0","severity":"deprecated","affected_versions":">=59.0.0"},{"fix":"Upgrade ESLint to >=8.56.0 and migrate to flat config (eslint.config.js).","message":"ESLint <8.56.0 is no longer supported (flat config required starting v55?)","severity":"breaking","affected_versions":">=55.0.0"},{"fix":"Import the plugin in eslint.config.js as shown in the quickstart.","message":"Flat config (eslint.config.js) requires explicit import of plugin; global plugins no longer work","severity":"gotcha","affected_versions":">=55.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Update ESLint to >=8.56.0 and use eslint.config.js.","cause":"Using older ESLint version or missing flat config migration","error":"Oops! Something went wrong! :( ESLint: 8.x.x. eslint-plugin-unicorn: 55.x.x. No configuration matching."},{"fix":"Run 'npm install --save-dev eslint eslint-plugin-unicorn'.","cause":"Package not installed or missing in node_modules","error":"Error: Cannot find module 'eslint-plugin-unicorn'"},{"fix":"Use 'const eslintPluginUnicorn = require('eslint-plugin-unicorn');' (no .default).","cause":"Incorrectly importing default export in CommonJS","error":"TypeError: eslintPluginUnicorn is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}