From 7a51d77c0a066e461ff288568fdfee0e9539a2b5 Mon Sep 17 00:00:00 2001 From: Stephen Hardy <2132243+stephen-hardy@users.noreply.github.com> Date: Fri, 25 Aug 2023 07:49:28 -0700 Subject: [PATCH] docs: no-param-reassign mention strict mode (#17494) * no-param-reassign strict mode mention * Update docs/src/rules/no-param-reassign.md Fixes #17484 Co-authored-by: Nitin Kumar --------- Co-authored-by: Nicholas C. Zakas Co-authored-by: Nitin Kumar --- docs/src/rules/no-param-reassign.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/src/rules/no-param-reassign.md b/docs/src/rules/no-param-reassign.md index 2bddf7b9921..9c23c45f981 100644 --- a/docs/src/rules/no-param-reassign.md +++ b/docs/src/rules/no-param-reassign.md @@ -6,7 +6,7 @@ further_reading: --- -Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the `arguments` object. Often, assignment to function parameters is unintended and indicative of a mistake or programmer error. +Assignment to variables declared as function parameters can be misleading and lead to confusing behavior, as modifying function parameters will also mutate the `arguments` object when not in strict mode (see [When Not To Use It](#when-not-to-use-it) below). Often, assignment to function parameters is unintended and indicative of a mistake or programmer error. This rule can be also configured to fail when function parameters are modified. Side effects on parameters can cause counter-intuitive execution flow and make errors difficult to track down. @@ -183,3 +183,5 @@ function foo(barBaz) { ## When Not To Use It If you want to allow assignment to function parameters, then you can safely disable this rule. + +Strict mode code doesn't sync indices of the arguments object with each parameter binding. Therefore, this rule is not necessary to protect against arguments object mutation in ESM modules or other strict mode functions.