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.

Example

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

// Incorrect: optional argument can **not** be omitted
function createUser(isAdmin = false, id) {}
createUser(undefined, "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.