---
# Don't modify this file manually. This file is auto generated from source, and you will lose your changes next time the website is built.
# Head to the `biomejs/biome` repository, and modify the source code in there.

title: useDefaultParameterLast
description: Learn more about useDefaultParameterLast
---
import { Tabs, TabItem } from '@astrojs/starlight/components';

<Tabs>
<TabItem label="JavaScript (and super languages)" icon="seti:javascript">
## Summary
- Rule available since: `v1.0.0`
- Diagnostic Category: [`lint/style/useDefaultParameterLast`](/reference/diagnostics#diagnostic-category)
- This rule isn't recommended, so you need to enable it.
- This rule has an [**unsafe**](/linter/#unsafe-fixes) fix.
- The default severity of this rule is [**warning**](/reference/diagnostics#warning).
- Sources: 
  - Same as [`default-param-last`](https://eslint.org/docs/latest/rules/default-param-last)
  - Same as [`@typescript-eslint/default-param-last`](https://typescript-eslint.io/rules/default-param-last)

## How to configure
```json title="biome.json"
{
	"linter": {
		"rules": {
			"style": {
				"useDefaultParameterLast": "error"
			}
		}
	}
}

```
## Description
Enforce default function parameters and optional function parameters to be last.

Default and optional parameters that precede a required parameter cannot be omitted at call site.

## Examples

### Invalid

```js
function f(a = 0, b) {}
```

<pre class="language-text"><code class="language-text">code-block.js:1:12 <a href="https://biomejs.dev/linter/rules/use-default-parameter-last">lint/style/useDefaultParameterLast</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Orange;">⚠</span></strong> <span style="color: Orange;">This </span><span style="color: Orange;"><strong>default parameter</strong></span><span style="color: Orange;"> should follow the last </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;"> or should be a </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;">.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>function f(a = 0, b) &#123;&#125;<br />   <strong>   │ </strong>           <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">The last </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> is here:</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>function f(a = 0, b) &#123;&#125;<br />   <strong>   │ </strong>                  <strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">A </span><span style="color: lightgreen;"><strong>default parameter</strong></span><span style="color: lightgreen;"> that precedes a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> cannot be omitted at call site.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Turn the parameter into a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;">.</span><br />  <br />  <strong>  1 │ </strong>function<span style="opacity: 0.8;">·</span>f(a<span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">=</span><span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">0</span>,<span style="opacity: 0.8;">·</span>b)<span style="opacity: 0.8;">·</span>&#123;&#125;<br />  <strong>    │ </strong>            <span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span>       <br /></code></pre>

```js
function f(a, b = 0, c) {}
```

<pre class="language-text"><code class="language-text">code-block.js:1:15 <a href="https://biomejs.dev/linter/rules/use-default-parameter-last">lint/style/useDefaultParameterLast</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Orange;">⚠</span></strong> <span style="color: Orange;">This </span><span style="color: Orange;"><strong>default parameter</strong></span><span style="color: Orange;"> should follow the last </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;"> or should be a </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;">.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>function f(a, b = 0, c) &#123;&#125;<br />   <strong>   │ </strong>              <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">The last </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> is here:</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>function f(a, b = 0, c) &#123;&#125;<br />   <strong>   │ </strong>                     <strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">A </span><span style="color: lightgreen;"><strong>default parameter</strong></span><span style="color: lightgreen;"> that precedes a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> cannot be omitted at call site.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Turn the parameter into a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;">.</span><br />  <br />  <strong>  1 │ </strong>function<span style="opacity: 0.8;">·</span>f(a,<span style="opacity: 0.8;">·</span>b<span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">=</span><span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">0</span>,<span style="opacity: 0.8;">·</span>c)<span style="opacity: 0.8;">·</span>&#123;&#125;<br />  <strong>    │ </strong>               <span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span>       <br /></code></pre>

```ts
function f(a: number, b?: number, c: number) {}
```

<pre class="language-text"><code class="language-text">code-block.ts:1:23 <a href="https://biomejs.dev/linter/rules/use-default-parameter-last">lint/style/useDefaultParameterLast</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Orange;">⚠</span></strong> <span style="color: Orange;">This </span><span style="color: Orange;"><strong>optional parameter</strong></span><span style="color: Orange;"> should follow the last </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;"> or should be a </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;">.</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>function f(a: number, b?: number, c: number) &#123;&#125;<br />   <strong>   │ </strong>                      <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">The last </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> is here:</span><br />  <br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>1 │ </strong>function f(a: number, b?: number, c: number) &#123;&#125;<br />   <strong>   │ </strong>                                  <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>2 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">A </span><span style="color: lightgreen;"><strong>optional parameter</strong></span><span style="color: lightgreen;"> that precedes a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> cannot be omitted at call site.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Turn the parameter into a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;">.</span><br />  <br />  <strong>  1 │ </strong>function<span style="opacity: 0.8;">·</span>f(a:<span style="opacity: 0.8;">·</span>number,<span style="opacity: 0.8;">·</span>b<span style="color: Tomato;">?</span>:<span style="opacity: 0.8;">·</span>number,<span style="opacity: 0.8;">·</span>c:<span style="opacity: 0.8;">·</span>number)<span style="opacity: 0.8;">·</span>&#123;&#125;<br />  <strong>    │ </strong>                       <span style="color: Tomato;">-</span>                       <br /></code></pre>

```ts
class Foo {
    constructor(readonly a = 10, readonly b: number) {}
}
```

<pre class="language-text"><code class="language-text">code-block.ts:2:17 <a href="https://biomejs.dev/linter/rules/use-default-parameter-last">lint/style/useDefaultParameterLast</a> <span style="color: #000; background-color: #ddd;"> FIXABLE </span> ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━<br /><br />  <strong><span style="color: Orange;">⚠</span></strong> <span style="color: Orange;">This </span><span style="color: Orange;"><strong>default parameter</strong></span><span style="color: Orange;"> should follow the last </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;"> or should be a </span><span style="color: Orange;"><strong>required parameter</strong></span><span style="color: Orange;">.</span><br />  <br />    <strong>1 │ </strong>class Foo &#123;<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong>    constructor(readonly a = 10, readonly b: number) &#123;&#125;<br />   <strong>   │ </strong>                <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>3 │ </strong>&#125;<br />    <strong>4 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">The last </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> is here:</span><br />  <br />    <strong>1 │ </strong>class Foo &#123;<br />  <strong><span style="color: Tomato;">&gt;</span></strong> <strong>2 │ </strong>    constructor(readonly a = 10, readonly b: number) &#123;&#125;<br />   <strong>   │ </strong>                                 <strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><strong><span style="color: Tomato;">^</span></strong><br />    <strong>3 │ </strong>&#125;<br />    <strong>4 │ </strong><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">A </span><span style="color: lightgreen;"><strong>default parameter</strong></span><span style="color: lightgreen;"> that precedes a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;"> cannot be omitted at call site.</span><br />  <br />  <strong><span style="color: lightgreen;">ℹ</span></strong> <span style="color: lightgreen;">Unsafe fix</span><span style="color: lightgreen;">: </span><span style="color: lightgreen;">Turn the parameter into a </span><span style="color: lightgreen;"><strong>required parameter</strong></span><span style="color: lightgreen;">.</span><br />  <br />  <strong>  2 │ </strong><span style="opacity: 0.8;">·</span><span style="opacity: 0.8;">·</span><span style="opacity: 0.8;">·</span><span style="opacity: 0.8;">·</span>constructor(readonly<span style="opacity: 0.8;">·</span>a<span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">=</span><span style="opacity: 0.8;"><span style="color: Tomato;">·</span></span><span style="color: Tomato;">1</span><span style="color: Tomato;">0</span>,<span style="opacity: 0.8;">·</span>readonly<span style="opacity: 0.8;">·</span>b:<span style="opacity: 0.8;">·</span>number)<span style="opacity: 0.8;">·</span>&#123;&#125;<br />  <strong>    │ </strong>                          <span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span><span style="color: Tomato;">-</span>                        <br /></code></pre>

### Valid

```js
function f(a, b = 0) {}
```

```ts
function f(a: number, b?: number, c = 0) {}
```

```ts
function f(a: number, b = 0, c?: number) {}
```

## Related links

- [Disable a rule](/linter/#disable-a-rule)
- [Configure the code fix](/linter#configure-the-code-fix)
- [Rule options](/linter/#rule-options)
- [Source Code](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/src/lint/style/use_default_parameter_last.rs)
- [Test Cases](https://github.com/biomejs/biome/blob/main/crates/biome_js_analyze/tests/specs/style/useDefaultParameterLast)

</TabItem>
</Tabs>