From 16541de708a7f3ff2ed25a3792c3a3d823bd042f Mon Sep 17 00:00:00 2001 From: camc314 <18101008+camc314@users.noreply.github.com> Date: Wed, 14 May 2025 13:42:56 +0000 Subject: [PATCH] docs(linter): improve docs of default-param-last (#11032) --- .../src/rules/eslint/default_param_last.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/default_param_last.rs b/crates/oxc_linter/src/rules/eslint/default_param_last.rs index 8bac472be4673..48372684f61f3 100644 --- a/crates/oxc_linter/src/rules/eslint/default_param_last.rs +++ b/crates/oxc_linter/src/rules/eslint/default_param_last.rs @@ -16,21 +16,29 @@ pub struct DefaultParamLast; declare_oxc_lint!( /// ### 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") /// + /// Examples of **incorrect** code for this rule: + /// + /// ```javascript /// // Incorrect: optional argument can **not** be omitted /// function createUser(isAdmin = false, id) {} /// createUser(undefined, "tabby") /// ``` + /// + /// Examples of **correct** code for this rule: + /// + /// ```javascript + /// function createUser(id, isAdmin = false) {} + /// createUser("tabby") + /// ``` DefaultParamLast, eslint, style