Skip to content

eslint/default-param-last Style

What it does

Enforce default parameters to be last

Why is this bad?

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

Examples

Examples of incorrect code for this rule:

javascript
// Incorrect: optional argument can **not** be omitted
function createUser(isAdmin = false, id) {}
createUser(undefined, "tabby");

Examples of correct code for this rule:

javascript
function createUser(id, isAdmin = false) {}
createUser("tabby");

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny default-param-last
json
{
  "rules": {
    "default-param-last": "error"
  }
}

References

Released under the MIT License.