1 # enforce default parameters to be last (default-param-last)
3 Putting default parameter at last allows function calls to omit optional tail arguments.
6 // Correct: optional argument can be omitted
7 function createUser(id, isAdmin = false) {}
10 // Incorrect: optional argument can **not** be omitted
11 function createUser(isAdmin = false, id) {}
12 createUser(undefined, "tabby")
17 This rule enforces default parameters to be the last of parameters.
19 Examples of **incorrect** code for this rule:
22 /* eslint default-param-last: ["error"] */
24 function f(a = 0, b) {}
26 function f(a, b = 0, c) {}
29 Examples of **correct** code for this rule:
32 /* eslint default-param-last: ["error"] */
34 function f(a, b = 0) {}