ESLint v8.x reached end-of-life on 2024-10-05 and is no longer maintained. Upgrade or consider long-term support options
Versions

default-param-last

Enforce default parameters to be last

Putting default parameter at last allows function calls to omit optional tail arguments.

// 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:

Open in Playground
/* eslint default-param-last: ["error"] */

function f(a = 0, b) {}

function g(a, b = 0, c) {}

Examples of correct code for this rule:

Open in Playground
/* eslint default-param-last: ["error"] */

function f(a, b = 0) {}

Version

This rule was introduced in ESLint v6.4.0.

Resources

Change Language