Skip to content

Commit

Permalink
Auto generate rule notice (#1680)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryan Mishkin <698306+bmish@users.noreply.github.com>
  • Loading branch information
fisker and bmish committed Jan 5, 2022
1 parent bd6c163 commit 7a4bc97
Show file tree
Hide file tree
Showing 103 changed files with 422 additions and 52 deletions.
3 changes: 3 additions & 0 deletions docs/rules/better-regex.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Improve regexes by making them shorter, consistent, and safer

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Note: This rule uses [`regexp-tree`](https://github.com/DmitrySoshnikov/regexp-tree) and [`clean-regexp`](https://github.com/samverschueren/clean-regexp) under the hood.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/catch-error-name.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce a specific parameter name in catch clauses

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Applies to

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/consistent-destructuring.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Use destructured variables over properties

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

Enforces the use of already destructured objects and their variables over accessing each property individually. Previous destructurings are easily missed which leads to an inconsistent code style.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/consistent-function-scoping.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Move function definitions to the highest possible scope

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

A function definition should be placed as close to the top-level scope as possible without breaking its captured values. This improves readability, [directly improves performance](https://stackoverflow.com/a/81329/207247) and allows JavaScript engines to [better optimize performance](https://ponyfoo.com/articles/javascript-performance-pitfalls-v8#optimization-limit).

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/custom-error-definition.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enforce correct `Error` subclassing

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Enforces the only valid way of `Error` subclassing. It works with any super class that ends in `Error`.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/empty-brace-spaces.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce no spaces between braces

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

## Fail

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/error-message.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enforce passing a `message` value when creating a built-in error

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

This rule enforces a `message` value to be passed in when creating an instance of a built-in [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) object, which leads to more readable and debuggable code.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/escape-case.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Require escape sequences to use uppercase values

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Enforces defining escape sequence values with uppercase characters rather than lowercase ones. This promotes readability by making the escaped value more distinguishable from the identifier.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/expiring-todo-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Add expiration conditions to TODO comments

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

This rule makes it possible to pass arguments to TODO, FIXME and XXX comments to trigger ESLint to report.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/explicit-length-check.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce explicitly comparing the `length` or `size` property of a value

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

Enforce explicitly checking the length of an object and enforce the comparison style.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/filename-case.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enforce a case style for filenames

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

Enforces all linted files to have their names in a certain case style and lowercase file extension. The default is `kebabCase`.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/import-index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enforce importing index files with `.`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Enforces importing index file with `.` instead of `./`, `./index` or `./index.js`.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/import-style.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enforce specific import styles per module

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

Sometimes a module contains unrelated functions, like `util`, thus it is a good practice to enforce destructuring or named imports here. Other times, in modules like `path`, it is good to use default import as they have similar functions, all likely to be utilized.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/new-for-builtins.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce the use of `new` for all builtins, except `String`, `Number`, `Boolean`, `Symbol` and `BigInt`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

They work the same, but `new` should be preferred for consistency with other constructors.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-abusive-eslint-disable.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Enforce specifying rules to disable in `eslint-disable` comments

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

This rule makes you specify the rules you want to disable when using `eslint-disable`, `eslint-disable-line` or `eslint-disable-next-line` comments.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-array-callback-reference.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Prevent passing a function reference directly to iterator methods

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

💡 *This rule provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

Suppose you have a `unicorn` module:

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-array-for-each.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Prefer `for…of` over `Array#forEach(…)`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Benefits of [`for…of` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) over [`Array#forEach(…)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) can include:

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-array-method-this-argument.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Disallow using the `this` argument in array methods

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

The rule forbids using the `thisArg` argument in array methods:

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-array-push-push.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce combining multiple `Array#push()` into one call

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

[`Array#push()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) accepts multiple arguments. Multiple calls should be combined into one.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-array-reduce.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Disallow `Array#reduce()` and `Array#reduceRight()`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

`Array#reduce()` and `Array#reduceRight()` usually result in [hard-to-read](https://twitter.com/jaffathecake/status/1213077702300852224) and [less performant](https://www.richsnapp.com/article/2019/06-09-reduce-spread-anti-pattern) code. In almost every case, it can be replaced by `.map`, `.filter`, or a `for-of` loop.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-await-expression-member.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Forbid member access from await expression

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

When accessing a member from an await expression, the await expression has to be parenthesized, which is not readable.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-console-spaces.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Do not use leading/trailing space between `console.log` parameters

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

The [`console.log()` method](https://developer.mozilla.org/en-US/docs/Web/API/Console/log) and similar methods joins the parameters with a space, so adding a leading/trailing space to a parameter, results in two spaces being added.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-document-cookie.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Do not use `document.cookie` directly

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

It's not recommended to use [`document.cookie`](https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie) directly as it's easy to get the string wrong. Instead, you should use the [Cookie Store API](https://developer.mozilla.org/en-US/docs/Web/API/Cookie_Store_API) or a [cookie library](https://www.npmjs.com/search?q=cookie).

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-empty-file.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Disallow empty files

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

Meaningless files clutter a codebase.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-for-loop.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Do not use a `for` loop that can be replaced with a `for-of` loop

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

There's no reason to use old school for loops anymore for the common case. You can instead use for-of loop (with `.entries()` if you need to access the index).

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-hex-escape.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce the use of Unicode escapes instead of hexadecimal escapes

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Enforces a convention of using [Unicode escapes](https://mathiasbynens.be/notes/javascript-escapes#unicode) instead of [hexadecimal escapes](https://mathiasbynens.be/notes/javascript-escapes#hexadecimal) for consistency and clarity.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-instanceof-array.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Require `Array.isArray()` instead of `instanceof Array`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

The `instanceof Array` check doesn't work across realms/contexts, for example, frames/windows in browsers or the `vm` module in Node.js.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-invalid-remove-event-listener.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Prevent calling `EventTarget#removeEventListener()` with the result of an expression

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

The [`removeEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener) function must be called with a reference to the same function that was passed to [`addEventListener`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener). Calling `removeEventListener` with an inline function or the result of an inline `.bind()` call is indicative of an error, and won't actually remove the listener.

Expand Down
4 changes: 4 additions & 0 deletions docs/rules/no-keyword-prefix.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Disallow identifiers starting with `new` or `class`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
<!-- /RULE_NOTICE -->

`new Foo` and `newFoo` look very similar. Use alternatives that do not look like keyword usage.

## Fail
Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-lonely-if.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Disallow `if` statements as the only statement in `if` blocks without `else`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

This rule adds onto the built-in [`no-lonely-if`](https://eslint.org/docs/rules/no-lonely-if) rule, which only forbids `if` statements in `else`, not in `if`. It is recommended to use `unicorn/no-lonely-if` together with the core ESLint `no-lonely-if` rule.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-nested-ternary.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Disallow nested ternary expressions

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems).*
<!-- /RULE_NOTICE -->

Improved version of the [`no-nested-ternary`](https://eslint.org/docs/rules/no-nested-ternary) ESLint rule, which allows cases where the nested ternary is only one level and wrapped in parens.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-new-array.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Disallow `new Array()`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

The ESLint built-in rule [`no-array-constructor`](https://eslint.org/docs/rules/no-array-constructor) enforces using an array literal instead of the `Array` constructor, but it still allows using the `Array` constructor with **one** argument. This rule fills that gap.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-new-buffer.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Enforce the use of `Buffer.from()` and `Buffer.alloc()` instead of the deprecated `new Buffer()`

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

Enforces the use of [Buffer.from](https://nodejs.org/api/buffer.html#buffer_class_method_buffer_from_array) and [Buffer.alloc()](https://nodejs.org/api/buffer.html#buffer_class_method_buffer_alloc_size_fill_encoding) instead of [new Buffer()](https://nodejs.org/api/buffer.html#buffer_new_buffer_array), which has been deprecated since Node.js 4.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-null.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Disallow the use of the `null` literal

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*

🔧💡 *This rule is [auto-fixable](https://eslint.org/docs/user-guide/command-line-interface#fixing-problems) and provides [suggestions](https://eslint.org/docs/developer-guide/working-with-rules#providing-suggestions).*
<!-- /RULE_NOTICE -->

Disallow the use of the `null` literal, to encourage using `undefined` instead.

Expand Down
3 changes: 3 additions & 0 deletions docs/rules/no-object-as-default-parameter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Disallow the use of objects as default parameters

<!-- Do not manually modify RULE_NOTICE part -->
<!-- RULE_NOTICE -->
*This rule is part of the [recommended](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config) config.*
<!-- /RULE_NOTICE -->

Default parameters should not be passed to a function through an object literal. The `foo = {a: false}` parameter works fine if only used with one option. As soon as additional options are added, you risk replacing the whole `foo = {a: false, b: true}` object when passing only one option: `{a: true}`. For this reason, object destructuring should be used instead.

Expand Down

0 comments on commit 7a4bc97

Please sign in to comment.