Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
frontend ruleP2universalStack: JavaScript
clean-codeno-param-reassignmutationlint
Avoid reassigning function parameters
Mutating a parameter (or a property on a passed-in object like event.returnValue) is error-prone; prefer a local variable, and enable no-param-reassign to enforce it.
PR: hegnar-forum-web · org-mining-3rd-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | window.onbeforeunload = (event) => { |
| 2 | event.preventDefault(); |
| 3 | event.returnValue = 'You have unsaved changes.'; // param mutation |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | window.onbeforeunload = (event) => { |
| 2 | event.preventDefault(); |
| 3 | return 'You have unsaved changes.'; // avoid mutating the param where possible |
| 4 | }; |
Explanation (EN)
Objašnjenje (HR)