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.

eslint-plugin-unicorn supports two approaches: drop in a preset config to enable a curated set of rules with one line, or configure rules manually for full control over which rules are active and at what severity.

Preset configs

Preset configs include the plugin, all required languageOptions, and a pre-selected set of rules. You do not need to register the plugin or set languageOptions separately when using a preset.Choose the preset that matches how much enforcement you want:
PresetDescription
recommendedEnables rules that enforce well-established best practices. The right starting point for most projects.
unopinionatedA subset of recommended containing only rules that are broadly agreed upon. Avoids rules where reasonable people disagree.
allEnables every rule (except deprecated ones) at error severity.
eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  // …
  eslintPluginUnicorn.configs.recommended,
];

All config

eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  // …
  eslintPluginUnicorn.configs.all,
];

Unopinionated config

eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  // …
  eslintPluginUnicorn.configs.unopinionated,
];

Override a rule’s severity in a preset

Spread the preset into your config array, then add a second config object with your overrides. ESLint merges configs in order, so the override takes effect:
eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  // …
  eslintPluginUnicorn.configs.recommended,
  {
    rules: {
      'unicorn/better-regex': 'warn',
    },
  },
];

Disable a rule

Set a rule to 'off' in an override config:
eslint.config.js
import eslintPluginUnicorn from 'eslint-plugin-unicorn';

export default [
  // …
  eslintPluginUnicorn.configs.recommended,
  {
    rules: {
      'unicorn/no-array-reduce': 'off',
    },
  },
];

Build docs developers (and LLMs) love