persona-community-5/.pnpm-store/v3/files/03/daa6b991b3d0611c801258619b2c82f1dbc5398c003727778ec16a0bda762b4fb7a954fb212269a852b11cdf7f248ace410340972514025e22a1373d426d32
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

61 lines
1.2 KiB
Plaintext

---
description: 'Enforce default parameters to be last.'
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
> 🛑 This file is source code, not the primary documentation location! 🛑
>
> See **https://typescript-eslint.io/rules/default-param-last** for documentation.
This rule extends the base [`eslint/default-param-last`](https://eslint.org/docs/rules/default-param-last) rule.
It adds support for optional parameters.
<Tabs>
<TabItem value="❌ Incorrect">
```ts
function f(a = 0, b: number) {}
function f(a: number, b = 0, c: number) {}
function f(a: number, b?: number, c: number) {}
class Foo {
constructor(
public a = 10,
private b: number,
) {}
}
class Foo {
constructor(
public a?: number,
private b: number,
) {}
}
```
</TabItem>
<TabItem value="✅ Correct">
```ts
function f(a = 0) {}
function f(a: number, b = 0) {}
function f(a: number, b?: number) {}
function f(a: number, b?: number, c = 0) {}
function f(a: number, b = 0, c?: number) {}
class Foo {
constructor(
public a,
private b = 0,
) {}
}
class Foo {
constructor(
public a,
private b?: number,
) {}
}
```
</TabItem>
</Tabs>