---
title: "default-param-last"
description: "Require parameters with a default value to come after the required ones"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "eslint"
aliases: ["eslint/default-param-last"]
kind: "suggestion"
category: "style"
default: "off"
fixable: "no"
typeAware: false
deprecated: false
---

A default value is used when the caller leaves the argument out, but you can only leave out arguments at the end of a call. If a required parameter comes after it, the caller has to write `createUser(undefined, "Ada")` to get the default.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"default-param-last" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
function createUser(role = "member", name) {
  return { name, role };
}
```

Not reported:

{/* good */}
```js
function createUser(name, role = "member") {
  return { name, role };
}

function log(level = "info", ...messages) {
  console[level](...messages);
}
```
