pve-eslint/eslint/docs/rules/default-param-last.md
Dominik Csapak eb39fafa4f first commit
includes a (minimal) working wrapper

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-06 15:06:03 +02:00

36 lines
766 B
Markdown

# enforce default parameters to be last (default-param-last)
Putting default parameter at last allows function calls to omit optional tail arguments.
```js
// Correct: optional argument can be omitted
function createUser(id, isAdmin = false) {}
createUser("tabby")
// Incorrect: optional argument can **not** be omitted
function createUser(isAdmin = false, id) {}
createUser(undefined, "tabby")
```
## Rule Details
This rule enforces default parameters to be the last of parameters.
Examples of **incorrect** code for this rule:
```js
/* eslint default-param-last: ["error"] */
function f(a = 0, b) {}
function f(a, b = 0, c) {}
```
Examples of **correct** code for this rule:
```js
/* eslint default-param-last: ["error"] */
function f(a, b = 0) {}
```