• Stars
    star
    3,765
  • Rank 11,110 (Top 0.3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

More than 100 powerful ESLint rules

eslint-plugin-unicorn Coverage Status npm version

More than 100 powerful ESLint rules

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

Propose or contribute a new rule ➡

Install

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

Usage

Use a preset config or configure each rule in package.json.

If you don't use the preset, ensure you use the same env and parserOptions config as below.

{
	"name": "my-awesome-project",
	"eslintConfig": {
		"env": {
			"es2024": true
		},
		"parserOptions": {
			"ecmaVersion": "latest",
			"sourceType": "module"
		},
		"plugins": [
			"unicorn"
		],
		"rules": {
			"unicorn/better-regex": "error",
			"unicorn/…": "error"
		}
	}
}

Rules

💼 Configurations enabled in.
✅ Set in the recommended configuration.
🔧 Automatically fixable by the --fix CLI option.
💡 Manually fixable by editor suggestions.

Name                                    Description 💼 🔧 💡
better-regex Improve regexes by making them shorter, consistent, and safer. 🔧
catch-error-name Enforce a specific parameter name in catch clauses. 🔧
consistent-destructuring Use destructured variables over properties. 🔧 💡
consistent-function-scoping Move function definitions to the highest possible scope.
custom-error-definition Enforce correct Error subclassing. 🔧
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 values. 🔧
expiring-todo-comments Add expiration conditions to TODO comments.
explicit-length-check Enforce explicitly comparing the length or size property of a value. 🔧 💡
filename-case Enforce a case style for filenames.
import-style Enforce specific import styles per module.
new-for-builtins Enforce the use of new for all builtins, except String, Number, Boolean, Symbol and BigInt. 🔧
no-abusive-eslint-disable Enforce specifying rules to disable in eslint-disable comments.
no-array-callback-reference Prevent passing a function reference directly to iterator methods. 💡
no-array-for-each Prefer for…of over the forEach method. 🔧 💡
no-array-method-this-argument Disallow using the this argument in array methods. 🔧 💡
no-array-push-push Enforce combining multiple Array#push() into one call. 🔧 💡
no-array-reduce Disallow Array#reduce() and Array#reduceRight().
no-await-expression-member Disallow member access from await expression. 🔧
no-console-spaces Do not use leading/trailing space between console.log parameters. 🔧
no-document-cookie Do not use document.cookie directly.
no-empty-file Disallow empty files.
no-for-loop Do not use a for loop that can be replaced with a for-of loop. 🔧
no-hex-escape Enforce the use of Unicode escapes instead of hexadecimal escapes. 🔧
no-instanceof-array Require Array.isArray() instead of instanceof Array. 🔧
no-invalid-remove-event-listener Prevent calling EventTarget#removeEventListener() with the result of an expression.
no-keyword-prefix Disallow identifiers starting with new or class.
no-lonely-if Disallow if statements as the only statement in if blocks without else. 🔧
no-negated-condition Disallow negated conditions. 🔧
no-nested-ternary Disallow nested ternary expressions. 🔧
no-new-array Disallow new Array(). 🔧 💡
no-new-buffer Enforce the use of Buffer.from() and Buffer.alloc() instead of the deprecated new Buffer(). 🔧 💡
no-null Disallow the use of the null literal. 🔧 💡
no-object-as-default-parameter Disallow the use of objects as default parameters.
no-process-exit Disallow process.exit().
no-static-only-class Disallow classes that only have static members. 🔧
no-thenable Disallow then property.
no-this-assignment Disallow assigning this to a variable.
no-typeof-undefined Disallow comparing undefined using typeof. 🔧 💡
no-unnecessary-await Disallow awaiting non-promise values. 🔧
no-unreadable-array-destructuring Disallow unreadable array destructuring. 🔧
no-unreadable-iife Disallow unreadable IIFEs.
no-unused-properties Disallow unused object properties.
no-useless-fallback-in-spread Disallow useless fallback when spreading in object literals. 🔧
no-useless-length-check Disallow useless array length check. 🔧
no-useless-promise-resolve-reject Disallow returning/yielding Promise.resolve/reject() in async functions or promise callbacks 🔧
no-useless-spread Disallow unnecessary spread. 🔧
no-useless-switch-case Disallow useless case in switch statements. 💡
no-useless-undefined Disallow useless undefined. 🔧
no-zero-fractions Disallow number literals with zero fractions or dangling dots. 🔧
number-literal-case Enforce proper case for numeric literals. 🔧
numeric-separators-style Enforce the style of numeric separators by correctly grouping digits. 🔧
prefer-add-event-listener Prefer .addEventListener() and .removeEventListener() over on-functions. 🔧
prefer-array-find Prefer .find(…) and .findLast(…) over the first or last element from .filter(…). 🔧 💡
prefer-array-flat Prefer Array#flat() over legacy techniques to flatten arrays. 🔧
prefer-array-flat-map Prefer .flatMap(…) over .map(…).flat(). 🔧
prefer-array-index-of Prefer Array#{indexOf,lastIndexOf}() over Array#{findIndex,findLastIndex}() when looking for the index of an item. 🔧 💡
prefer-array-some Prefer .some(…) over .filter(…).length check and .{find,findLast}(…). 🔧 💡
prefer-at Prefer .at() method for index access and String#charAt(). 🔧 💡
prefer-blob-reading-methods Prefer Blob#arrayBuffer() over FileReader#readAsArrayBuffer(…) and Blob#text() over FileReader#readAsText(…).
prefer-code-point Prefer String#codePointAt(…) over String#charCodeAt(…) and String.fromCodePoint(…) over String.fromCharCode(…). 💡
prefer-date-now Prefer Date.now() to get the number of milliseconds since the Unix Epoch. 🔧
prefer-default-parameters Prefer default parameters over reassignment. 🔧 💡
prefer-dom-node-append Prefer Node#append() over Node#appendChild(). 🔧
prefer-dom-node-dataset Prefer using .dataset on DOM elements over calling attribute methods. 🔧
prefer-dom-node-remove Prefer childNode.remove() over parentNode.removeChild(childNode). 🔧 💡
prefer-dom-node-text-content Prefer .textContent over .innerText. 💡
prefer-event-target Prefer EventTarget over EventEmitter.
prefer-export-from Prefer export…from when re-exporting. 🔧 💡
prefer-includes Prefer .includes() over .indexOf() and Array#some() when checking for existence or non-existence. 🔧 💡
prefer-json-parse-buffer Prefer reading a JSON file as a buffer. 🔧
prefer-keyboard-event-key Prefer KeyboardEvent#key over KeyboardEvent#keyCode. 🔧
prefer-logical-operator-over-ternary Prefer using a logical operator over a ternary. 💡
prefer-math-trunc Enforce the use of Math.trunc instead of bitwise operators. 🔧 💡
prefer-modern-dom-apis Prefer .before() over .insertBefore(), .replaceWith() over .replaceChild(), prefer one of .before(), .after(), .append() or .prepend() over insertAdjacentText() and insertAdjacentElement(). 🔧
prefer-modern-math-apis Prefer modern Math APIs over legacy patterns. 🔧
prefer-module Prefer JavaScript modules (ESM) over CommonJS. 🔧 💡
prefer-native-coercion-functions Prefer using String, Number, BigInt, Boolean, and Symbol directly. 🔧
prefer-negative-index Prefer negative index over .length - index when possible. 🔧
prefer-node-protocol Prefer using the node: protocol when importing Node.js builtin modules. 🔧
prefer-number-properties Prefer Number static properties over global ones. 🔧 💡
prefer-object-from-entries Prefer using Object.fromEntries(…) to transform a list of key-value pairs into an object. 🔧
prefer-optional-catch-binding Prefer omitting the catch binding parameter. 🔧
prefer-prototype-methods Prefer borrowing methods from the prototype instead of the instance. 🔧
prefer-query-selector Prefer .querySelector() over .getElementById(), .querySelectorAll() over .getElementsByClassName() and .getElementsByTagName(). 🔧
prefer-reflect-apply Prefer Reflect.apply() over Function#apply(). 🔧
prefer-regexp-test Prefer RegExp#test() over String#match() and RegExp#exec(). 🔧 💡
prefer-set-has Prefer Set#has() over Array#includes() when checking for existence or non-existence. 🔧 💡
prefer-set-size Prefer using Set#size instead of Array#length. 🔧
prefer-spread Prefer the spread operator over Array.from(…), Array#concat(…), Array#{slice,toSpliced}() and String#split(''). 🔧 💡
prefer-string-replace-all Prefer String#replaceAll() over regex searches with the global flag. 🔧
prefer-string-slice Prefer String#slice() over String#substr() and String#substring(). 🔧
prefer-string-starts-ends-with Prefer String#startsWith() & String#endsWith() over RegExp#test(). 🔧 💡
prefer-string-trim-start-end Prefer String#trimStart() / String#trimEnd() over String#trimLeft() / String#trimRight(). 🔧
prefer-switch Prefer switch over multiple else-if. 🔧
prefer-ternary Prefer ternary expressions over simple if-else statements. 🔧
prefer-top-level-await Prefer top-level await over top-level promises and async function calls. 💡
prefer-type-error Enforce throwing TypeError in type checking conditions. 🔧
prevent-abbreviations Prevent abbreviations. 🔧
relative-url-style Enforce consistent relative URL style. 🔧 💡
require-array-join-separator Enforce using the separator argument with Array#join(). 🔧
require-number-to-fixed-digits-argument Enforce using the digits argument with Number#toFixed(). 🔧
require-post-message-target-origin Enforce using the targetOrigin argument with window.postMessage(). 💡
string-content Enforce better string content. 🔧 💡
switch-case-braces Enforce consistent brace style for case clauses. 🔧
template-indent Fix whitespace-insensitive template indentation. 🔧
text-encoding-identifier-case Enforce consistent case for text encoding identifiers. 🔧 💡
throw-new-error Require new when throwing an error. 🔧

Deprecated Rules

See docs/deprecated-rules.md

Preset configs

See the ESLint docs for more information about extending config files.

Note: Preset configs will also enable the correct parser options and environment.

Recommended config

This plugin exports a recommended config that enforces good practices.

{
	"name": "my-awesome-project",
	"eslintConfig": {
		"extends": "plugin:unicorn/recommended"
	}
}

All config

This plugin exports an all config that makes use of all rules (except for deprecated ones).

{
	"name": "my-awesome-project",
	"eslintConfig": {
		"extends": "plugin:unicorn/all"
	}
}

Maintainers

Former

More Repositories

1

awesome

😎 Awesome lists about all kinds of interesting topics
270,042
star
2

awesome-nodejs

⚡ Delightful Node.js packages and resources
52,854
star
3

awesome-electron

Useful resources for creating apps with Electron
25,164
star
4

quick-look-plugins

List of useful Quick Look plugins for developers
17,497
star
5

got

🌐 Human-friendly and powerful HTTP request library for Node.js
TypeScript
13,910
star
6

type-fest

A collection of essential TypeScript types
TypeScript
13,080
star
7

pure

Pretty, minimal and fast ZSH prompt
Shell
12,391
star
8

ky

🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API
TypeScript
11,367
star
9

pageres

Capture website screenshots
TypeScript
9,573
star
10

ora

Elegant terminal spinner
JavaScript
8,591
star
11

github-markdown-css

The minimal amount of CSS to replicate the GitHub Markdown style
CSS
7,421
star
12

np

A better `npm publish`
JavaScript
7,395
star
13

screenfull

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
HTML
6,891
star
14

caprine

Elegant Facebook Messenger desktop app
TypeScript
6,862
star
15

Gifski

🌈 Convert videos to high-quality GIFs on your Mac
Swift
6,807
star
16

fkill-cli

Fabulously kill processes. Cross-platform.
JavaScript
6,782
star
17

query-string

Parse and stringify URL query strings
JavaScript
6,453
star
18

execa

Process execution for humans
JavaScript
6,019
star
19

modern-normalize

🐒 Normalize browsers' default style
TypeScript
5,038
star
20

css-in-readme-like-wat

Style your readme using CSS with this simple trick
5,013
star
21

awesome-npm

Awesome npm resources and tips
4,315
star
22

promise-fun

Promise packages, patterns, chat, and tutorials
4,277
star
23

electron-store

Simple data persistence for your Electron app or module - Save and load user preferences, app state, cache, etc
JavaScript
4,165
star
24

awesome-scifi

Sci-Fi worth consuming
4,085
star
25

create-dmg

Create a good-looking DMG for your macOS app in seconds
JavaScript
3,950
star
26

speed-test

Test your internet connection speed and ping using speedtest.net from the CLI
JavaScript
3,882
star
27

ow

Function argument validation for humans
TypeScript
3,779
star
28

file-type

Detect the file type of a Buffer/Uint8Array/ArrayBuffer
JavaScript
3,438
star
29

meow

🐈 CLI app helper
JavaScript
3,305
star
30

p-queue

Promise queue with concurrency control
TypeScript
3,202
star
31

open

Open stuff like URLs, files, executables. Cross-platform.
JavaScript
2,976
star
32

Plash

💦 Make any website your Mac desktop wallpaper
Swift
2,735
star
33

alfy

Create Alfred workflows with ease
JavaScript
2,570
star
34

trash

Move files and directories to the trash
JavaScript
2,512
star
35

fast-cli

Test your download and upload speed using fast.com
JavaScript
2,484
star
36

guides

A collection of succinct guides - Public Domain
2,424
star
37

globby

User-friendly glob matching
JavaScript
2,376
star
38

slugify

Slugify a string
JavaScript
2,357
star
39

emoj

Find relevant emoji from text on the command-line 😮 ✨ 🙌 🐴 💥 🙈
JavaScript
2,311
star
40

cli-spinners

Spinners for use in the terminal
JavaScript
2,255
star
41

on-change

Watch an object or array for changes
JavaScript
1,946
star
42

devtools-detect

Detect if DevTools is open and its orientation
HTML
1,924
star
43

touch-bar-simulator

Use the Touch Bar on any Mac
Swift
1,892
star
44

gulp-imagemin

Minify PNG, JPEG, GIF and SVG images
JavaScript
1,888
star
45

notifier-for-github

Browser extension - Get notified about new GitHub notifications
JavaScript
1,788
star
46

editorconfig-sublime

Sublime Text plugin for EditorConfig - Helps developers maintain consistent coding styles between different editors
Python
1,757
star
47

capture-website

Capture screenshots of websites
JavaScript
1,670
star
48

emittery

Simple and modern async event emitter
JavaScript
1,664
star
49

Defaults

💾 Swifty and modern UserDefaults
Swift
1,661
star
50

electron-boilerplate

Boilerplate to kickstart creating an app with Electron
JavaScript
1,632
star
51

pageres-cli

Capture website screenshots
JavaScript
1,620
star
52

is

Type check values
TypeScript
1,605
star
53

clipboardy

Access the system clipboard (copy/paste)
JavaScript
1,598
star
54

gulp-rev

Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
JavaScript
1,538
star
55

pify

Promisify a callback-style function
JavaScript
1,494
star
56

boxen

Create boxes in the terminal
JavaScript
1,467
star
57

Actions

⚙️ Supercharge your shortcuts
Swift
1,437
star
58

multiline

Multiline strings in JavaScript
JavaScript
1,424
star
59

hyper-snazzy

Elegant Hyper theme with bright colors
JavaScript
1,412
star
60

amas

Awesome & Marvelous Amas
1,392
star
61

LaunchAtLogin

Add “Launch at Login” functionality to your macOS app in seconds
Swift
1,346
star
62

refined-twitter

Browser extension that simplifies the Twitter interface and adds useful features
JavaScript
1,313
star
63

KeyboardShortcuts

⌨️ Add user-customizable global keyboard shortcuts (hotkeys) to your macOS app in minutes
Swift
1,313
star
64

iterm2-snazzy

Elegant iTerm2 theme with bright colors
1,313
star
65

del

Delete files and directories
JavaScript
1,305
star
66

electron-context-menu

Context menu for your Electron app
JavaScript
1,297
star
67

p-limit

Run multiple promise-returning & async functions with limited concurrency
JavaScript
1,294
star
68

Settings

⚙ Add a settings window to your macOS app in minutes
Swift
1,282
star
69

trash-cli

Move files and folders to the trash
JavaScript
1,244
star
70

electron-util

Useful utilities for Electron apps and modules
JavaScript
1,188
star
71

is-online

Check if the internet connection is up
JavaScript
1,181
star
72

ponyfill

🦄 Like polyfill but with pony pureness
1,136
star
73

conf

Simple config handling for your app or module
TypeScript
1,109
star
74

anatine

[DEPRECATED] 🐦 Pristine Twitter app
JavaScript
1,097
star
75

electron-dl

Simplified file downloads for your Electron app
JavaScript
1,087
star
76

log-update

Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.
JavaScript
1,027
star
77

pretty-bytes

Convert bytes to a human readable string: 1337 → 1.34 kB
JavaScript
1,022
star
78

grunt-sass

Compile Sass to CSS
JavaScript
1,020
star
79

mem

Memoize functions - an optimization technique used to speed up consecutive function calls by caching the result of calls with identical input
TypeScript
1,019
star
80

DockProgress

Show progress in your app's Dock icon
Swift
1,003
star
81

wallpaper

Manage the desktop wallpaper
JavaScript
996
star
82

p-map

Map over promises concurrently
JavaScript
996
star
83

public-ip

Get your public IP address - very fast!
JavaScript
979
star
84

gulp-app

[DEPRECATED] Gulp as an app
JavaScript
961
star
85

grunt-shell

Run shell commands
JavaScript
952
star
86

load-grunt-tasks

Load multiple grunt tasks using globbing patterns
JavaScript
940
star
87

hasha

Hashing made simple. Get the hash of a buffer/string/stream/file.
JavaScript
934
star
88

pretty-ms

Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
JavaScript
929
star
89

terminal-image

Display images in the terminal
JavaScript
923
star
90

object-assign

ES2015 Object.assign() ponyfill
JavaScript
919
star
91

copy-text-to-clipboard

Copy text to the clipboard in modern browsers (0.2 kB)
JavaScript
858
star
92

System-Color-Picker

🎨 The macOS color picker as an app with more features
Swift
842
star
93

normalize-url

Normalize a URL
JavaScript
818
star
94

get-port

Get an available TCP port
JavaScript
817
star
95

atom-editorconfig

Helps developers maintain consistent coding styles between different editors
JavaScript
815
star
96

grunt-concurrent

Run grunt tasks concurrently
JavaScript
799
star
97

dot-prop

Get, set, or delete a property from a nested object using a dot path
JavaScript
777
star
98

p-progress

Create a promise that reports progress
TypeScript
751
star
99

gulp-changed

Only pass through changed files
JavaScript
747
star
100

generator-nm

Scaffold out a node module
JavaScript
742
star