Content-Length: 83009 | pFad | https://typescript-eslint.io/rules/default-param-last

default-param-last | typescript-eslint
Skip to main content

default-param-last

Enforce default parameters to be last.

🧱

This is an "extension" rule that replaces a core ESLint rule to work with TypeScript. See Rules > Extension Rules.

This rule extends the base default-param-last rule from ESLint core. It adds support for optional parameters.

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,
) {}
}
Open in Playground

Options

See eslint/default-param-last's options.

How to Use

eslint.config.mjs
export default tseslint.config({
rules: {
// Note: you must disable the base rule as it can report incorrect errors
"default-param-last": "off",
"@typescript-eslint/default-param-last": "error"
}
});

Try this rule in the playground ↗

Resources

Taken with ❤️ from ESLint core.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://typescript-eslint.io/rules/default-param-last

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy