MCPcopy
hub / github.com/sindresorhus/eslint-plugin-unicorn

github.com/sindresorhus/eslint-plugin-unicorn @v70.0.0 sqlite

repository ↗ · DeepWiki ↗ · release v70.0.0 ↗
4,203 symbols 12,589 edges 879 files 89 documented · 2%
README

eslint-plugin-unicorn Coverage Status npm version

Unicorn

More than 300 powerful ESLint rules

Most rules target JavaScript and TypeScript, but some also lint CSS, HTML, JSON, and Markdown when used with the matching ESLint language plugin.

Propose a new rule ➡

We do not accept pull requests because of too much AI slop.

Install

npm install --save-dev eslint eslint-plugin-unicorn

Requires ESLint >=10.4, flat config, and ESM.

You might want to check out XO, which includes this plugin.

Usage

Use a preset config or configure each rule in eslint.config.js.

If you don't use a preset, set the same languageOptions as shown below.

import unicorn from 'eslint-plugin-unicorn';
import {defineConfig} from 'eslint/config';
import globals from 'globals';

export default defineConfig([
    {
        files: ['**/*.js'],
        languageOptions: {
            globals: globals.builtin,
        },
        plugins: {
            unicorn,
        },
        rules: {
            'unicorn/prefer-module': 'error',
            'unicorn/…': 'error',
        },
    },
    // …
]);

For TypeScript, scope Unicorn to TypeScript files and configure a TypeScript parser for the same config object:

import typescriptEslintParser from '@typescript-eslint/parser';
import unicorn from 'eslint-plugin-unicorn';
import {defineConfig} from 'eslint/config';
import globals from 'globals';

export default defineConfig([
    {
        files: ['**/*.ts'],
        languageOptions: {
            globals: globals.builtin,
            parser: typescriptEslintParser,
        },
        plugins: {
            unicorn,
        },
        rules: {
            'unicorn/prefer-module': 'error',
            'unicorn/…': 'error',
        },
    },
    // …
]);

Rules

💼 Configurations enabled in.\ ✅ Set in the recommended configuration.\ ☑️ Set in the unopinionated configuration.\ 🔧 Automatically fixable by the --fix CLI option.\ 💡 Manually fixable by editor suggestions.\ 💭 Requires type information.

Name                                         Description 💼 🔧 💡 💭
better-dom-traversing Prefer better DOM traversal APIs. ✅ ☑️ 💡
catch-error-name Enforce a specific parameter name in catch clauses. 🔧
class-reference-in-static-methods Enforce consistent class references in static methods. 💡
comment-content Enforce better comment content. 🔧
consistent-assert Enforce consistent assertion style with node:assert. 🔧
consistent-boolean-name Enforce consistent naming for boolean names. 🔧 💡
consistent-class-member-order Enforce consistent class member order. 💡
consistent-compound-words Enforce consistent spelling of compound words in identifiers. ✅ ☑️ 💡
consistent-conditional-object-spread Enforce consistent conditional object spread style. 🔧
consistent-date-clone Prefer passing Date directly to the constructor when cloning. ✅ ☑️ 🔧
consistent-destructuring Use destructured variables over properties. 💡
consistent-empty-array-spread Prefer consistent types when spreading a ternary in an array literal. 🔧
consistent-existence-index-check Enforce consistent style for element existence checks with indexOf(), lastIndexOf(), findIndex(), and findLastIndex(). ✅ ☑️ 🔧
consistent-export-decorator-position Enforce consistent decorator position on exported classes. ✅ ☑️ 🔧
consistent-function-scoping Move function definitions to the highest possible scope.
consistent-function-style Enforce function syntax by role. 💡
consistent-json-file-read Enforce consistent JSON file reads before JSON.parse(). 🔧
consistent-optional-chaining Enforce consistent optional chaining for same-base member access. ✅ ☑️ 💡
consistent-template-literal-escape Enforce consistent style for escaping ${ in template literals. 🔧
consistent-tuple-labels Enforce consistent labels on tuple type elements.
custom-error-definition Enforce correct Error subclassing. 🔧
default-export-style Enforce consistent default export declarations. 🔧 💡
dom-node-dataset Enforce consistent style for DOM element dataset access. ✅ ☑️ 🔧
empty-brace-spaces Enforce no spaces between braces. 🔧
error-message Enforce passing a message value when creating a built-in error. ✅ ☑️
escape-case Require escape sequences to use uppercase or lowercase values. ✅ ☑️ 🔧
expiring-todo-comments Add expiration conditions to TODO comments. ✅ ☑️
explicit-length-check Enforce explicitly comparing the length or size property of a value. 🔧 💡
explicit-timer-delay Enforce or disallow explicit delay argument for setTimeout() and setInterval(). ✅ ☑️ 🔧
filename-case Enforce a case style for filenames and directory names.
id-match Require identifiers to match a specified regular expression.
import-style Enforce specific import styles per module. ✅ ☑️
isolated-functions Prevent usage of variables from outside the scope of isolated functions.
logical-assignment-operators Require or disallow logical assignment operator shorthand 🔧 💡
max-nested-calls Limit the depth of nested calls.
name-replacements Enforce replacements for variable, property, and filenames. 🔧 💡
new-for-builtins Enforce correct use of new for builtin constructors. ✅ ☑️ 🔧 💡
no-abusive-eslint-disable Enforce specifying rules to disable in eslint-disable comments. ✅ ☑️
no-accessor-recursion Disallow recursive access to this within getters and setters. ✅ ☑️
no-accidental-bitwise-operator Disall

Core symbols most depended-on inside this repo

on
called by 499
rules/rule/unicorn-listeners.js
snapshot
called by 456
test/utils/test.js
getTester
called by 324
test/utils/test.js
isMethodCall
called by 302
rules/ast/is-method-call.js
typescript
called by 135
test/consistent-boolean-name.js
testCase
called by 123
test/filename-case.js
caseInsensitive
called by 118
rules/comment-content.js
unwrapTypeScriptExpression
called by 113
rules/prefer-math-abs.js

Shape

Function 4,171
Method 18
Class 14

Languages

TypeScript100%

Modules by API surface

rules/prefer-spread.js66 symbols
rules/prefer-abort-signal-any.js64 symbols
rules/comment-content.js59 symbols
rules/no-unsafe-promise-all-settled-values.js55 symbols
rules/consistent-boolean-name.js53 symbols
rules/prefer-has-check.js48 symbols
rules/no-for-loop.js45 symbols
rules/no-array-reduce.js39 symbols
rules/prefer-path2d.js37 symbols
rules/prefer-group-by.js36 symbols
rules/no-unsafe-buffer-conversion.js35 symbols
rules/prefer-object-iterable-methods.js33 symbols

Dependencies from manifests, versioned

@babel/code-frame8.0.0-rc.6 · 1×
@babel/helper-validator-identifier7.29.7 · 1×
@eslint-community/eslint-utils4.9.1 · 1×
@eslint/css1.3.0 · 1×
@eslint/eslintrc3.3.5 · 1×
@eslint/json2.0.0 · 1×
@eslint/markdown8.0.2 · 1×
@html-eslint/eslint-plugin0.62.0 · 1×
@html-eslint/parser0.62.0 · 1×
@lubien/fixture-beta-package1.0.0-beta.1 · 1×
@typescript-eslint/parser8.61.0 · 1×
@typescript-eslint/types8.61.0 · 1×

For agents

$ claude mcp add eslint-plugin-unicorn \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact