eslint-plugin-unicorn-x
raw JSON → 3.2.1 verified Sat Apr 25 auth: no javascript
A modern, faster fork of eslint-plugin-unicorn with 100+ powerful ESLint rules. Current version 3.2.1, requires ESLint >=9.29.0 and Node.js >=20.10.0. Uses flat config only. Offers performance improvements and reduced install footprint compared to upstream, with the same rule set but prefix 'unicorn-x' instead of 'unicorn'. Ships TypeScript types. Active development with frequent syncing from the upstream source.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-plugin-unicorn-x/index.js not supported. ↓
cause Using CommonJS require() on an ESM-only package.
fix
Change to ESM import:
import eslintPluginUnicorn from 'eslint-plugin-unicorn-x'; error ESLint couldn't find the plugin 'eslint-plugin-unicorn-x'. ↓
cause Plugin not installed or not properly declared in flat config.
fix
Run
npm install --save-dev eslint-plugin-unicorn-x and ensure your flat config has plugins: { unicorn: eslintPluginUnicorn }. error Configuration for rule 'unicorn/better-regex' is invalid. Rule 'unicorn/better-regex' was not found. ↓
cause Using upstream rule prefix 'unicorn/' instead of 'unicorn-x/'.
fix
Change rule name from 'unicorn/better-regex' to 'unicorn-x/better-regex'.
error Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'globals' imported from /path/to/eslint.config.js ↓
cause Missing the 'globals' package required for the recommended config.
fix
Install globals:
npm install --save-dev globals or remove the globals reference. Warnings
breaking Requires ESLint >=9.29.0 and flat config only. Legacy eslintrc format is not supported. ↓
fix Migrate to flat config (eslint.config.js) and ensure ESLint version meets requirement.
breaking Node.js >=20.10.0 required since v3.0.0. Older Node versions are not supported. ↓
fix Upgrade Node.js to version 20.10.0 or later.
breaking ESM-only since v3.0.0; CommonJS require will throw an error. ↓
fix Convert to ESM imports (import statement) or use dynamic import().
deprecated Rule prefix changed from 'unicorn' (upstream) to 'unicorn-x' for this fork. Using 'unicorn/...' will not work. ↓
fix Replace 'unicorn/' with 'unicorn-x/' in rule names (e.g., 'unicorn/better-regex' -> 'unicorn-x/better-regex').
gotcha The default export is the plugin object, not a config. You must spread it into plugins or rules manually. ↓
fix Use `plugins: { unicorn: eslintPluginUnicorn }` in your flat config.
Install
npm install eslint-plugin-unicorn-x yarn add eslint-plugin-unicorn-x pnpm add eslint-plugin-unicorn-x Imports
- default wrong
const eslintPluginUnicorn = require('eslint-plugin-unicorn-x');correctimport eslintPluginUnicorn from 'eslint-plugin-unicorn-x'; - recommended wrong
const { recommended } = require('eslint-plugin-unicorn-x');correctimport { recommended } from 'eslint-plugin-unicorn-x'; - rules
import { rules } from 'eslint-plugin-unicorn-x';
Quickstart
import eslintPluginUnicorn from 'eslint-plugin-unicorn-x';
import globals from 'globals';
export default [
{
languageOptions: {
globals: globals.builtin,
},
plugins: {
unicorn: eslintPluginUnicorn,
},
rules: {
'unicorn-x/better-regex': 'error',
'unicorn-x/catch-error-name': 'error',
},
},
];