mirror of
https://git.proxmox.com/git/pve-eslint
synced 2025-10-06 11:50:34 +00:00

includes a (minimal) working wrapper Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
36 lines
766 B
Markdown
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) {}
|
|
```
|