Skip to main content

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.

The recommended config enables most unicorn rules at 'error' severity. It covers the rules the maintainers consider good practice for the majority of JavaScript projects.
The preset also sets languageOptions.globals to globals.builtin, so built-in globals like Promise, Map, and Set are recognized correctly. You do not need to configure this separately when using the preset.

What it enables

Rules are included in recommended when their meta.docs.recommended property is true or 'unopinionated'. Rules that are off by default (no recommended value) are not enabled. Two ESLint core rules that overlap with unicorn rules are explicitly disabled:
Disabled core ruleReplaced by
no-negated-conditionunicorn/no-negated-condition
no-nested-ternaryunicorn/no-nested-ternary

Usage

Add the preset as an entry in your eslint.config.js array:
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  eslintPluginUnicorn.configs.recommended,
];

Overriding individual rules

Place an additional config object after the preset to override specific rules:
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  eslintPluginUnicorn.configs.recommended,
  {
    rules: {
      'unicorn/better-regex': 'warn', // override to warn
      'unicorn/no-null': 'off',       // disable a rule
    },
  },
];
Rules you do not mention in the override inherit their severity from the preset.

Legacy aliases

The plugin also exports flat/recommended and flat/all as aliases for recommended and all respectively. These exist only for backward compatibility with older configurations and will be removed in a future version. Use configs.recommended and configs.all in new code.
// Deprecated — prefer configs.recommended
eslintPluginUnicorn.configs['flat/recommended']

Build docs developers (and LLMs) love