• Assignment to property of function parameter no-param-reassign

avatar

Last updated: Mar 7, 2024 Reading time · 3 min

banner

# Table of Contents

  • Disabling the no-param-reassign ESLint rule for a single line
  • Disabling the no-param-reassign ESLint rule for an entire file
  • Disabling the no-param-reassign ESLint rule globally

# Assignment to property of function parameter no-param-reassign

The ESLint error "Assignment to property of function parameter 'X' eslint no-param-reassign" occurs when you try to assign a property to a function parameter.

To solve the error, disable the ESLint rule or create a new object based on the parameter to which you can assign properties.

assignment to property of function parameter eslint no param reassign

Here is an example of how the error occurs.

The ESLint rule forbids assignment to function parameters because modifying a function's parameters also mutates the arguments object and can lead to confusing behavior.

One way to resolve the issue is to create a new object to which you can assign properties.

We used the spread syntax (...) to unpack the properties of the function parameter into a new object to which we can assign properties.

If you need to unpack an array, use the following syntax instead.

The same approach can be used if you simply need to assign the function parameter to a variable so you can mutate it.

We declared the bar variable using the let keyword and set it to the value of the foo parameter.

We are then able to reassign the bar variable without any issues.

# Disabling the no-param-reassign ESLint rule for a single line

You can use a comment if you want to disable the no-param-reassign ESLint rule for a single line.

Make sure to add the comment directly above the assignment that causes the error.

# Disabling the no-param-reassign ESLint rule for an entire file

You can also use a comment to disable the no-param-reassign ESLint rule for an entire file.

Make sure to add the comment at the top of the file or at least above the function in which you reassign parameters.

The same approach can be used to disable the rule only for a single function.

The first comment disables the no-param-reassign rule and the second comment enables it.

If you try to reassign a parameter after the second comment, you will get an ESLint error.

# Disabling the no-param-reassign ESLint rule globally

If you need to disable the no-param-reassign rule globally, you have to edit your .eslintrc.js file.

disable no param reassign rule globally

If you only want to be able to assign properties to an object parameter, set props to false instead of disabling the rule completely.

The following code is valid after making the change.

If you use a .eslintrc or .eslintrc.json file, make sure to double-quote the properties and values.

If you want to only allow assignment to object parameters, use the following line instead.

Make sure all properties are double-quoted and there are no trailing commas if your config is written in JSON.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

  • eslint is not recognized as an internal or external command
  • Plugin "react" was conflicted between package.json » eslint-config-react-app
  • React: Unexpected use of 'X' no-restricted-globals in ESLint
  • TypeScript ESLint: Unsafe assignment of an any value [Fix]
  • ESLint error Unary operator '++' used no-plusplus [Solved]
  • ESLint Prefer default export import/prefer-default-export
  • Arrow function should not return assignment. eslint no-return-assign
  • TypeError: Cannot redefine property: X in JavaScript [Fixed]
  • ESLint: disable multiple rules or a rule for multiple lines
  • Expected linebreaks to be 'LF' but found 'CRLF' linebreak-style
  • Missing return type on function TypeScript ESLint error

book cover

Borislav Hadzhiev

Web Developer

buy me a coffee

Copyright © 2024 Borislav Hadzhiev

Disallow Reassignment of Function Parameters (no-param-reassign)

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.

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.

Rule Details

This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

Examples of incorrect code for this rule:

Examples of correct code for this rule:

This rule takes one option, an object, with a boolean property "props" , and arrays "ignorePropertyModificationsFor" and "ignorePropertyModificationsForRegex" . "props" is false by default. If "props" is set to true , this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor" or "ignorePropertyModificationsForRegex" , which is an empty array by default.

Examples of correct code for the default { "props": false } option:

Examples of incorrect code for the { "props": true } option:

Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

Examples of correct code for the { "props": true } option with "ignorePropertyModificationsForRegex" set:

When Not To Use It

If you want to allow assignment to function parameters, then you can safely disable this rule.

Further Reading

  • JavaScript: Don’t Reassign Your Function Arguments

This rule was introduced in ESLint 0.18.0.

  • Rule source
  • Documentation source

© OpenJS Foundation and other contributors Licensed under the MIT License. https://eslint.org/docs/rules/no-param-reassign

no-param-reassign

Disallow reassigning function parameters

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.

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.

Rule Details

This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

Examples of incorrect code for this rule:

Examples of correct code for this rule:

This rule takes one option, an object, with a boolean property "props" , and arrays "ignorePropertyModificationsFor" and "ignorePropertyModificationsForRegex" . "props" is false by default. If "props" is set to true , this rule warns against the modification of parameter properties unless they’re included in "ignorePropertyModificationsFor" or "ignorePropertyModificationsForRegex" , which is an empty array by default.

Examples of correct code for the default { "props": false } option:

Examples of incorrect code for the { "props": true } option:

Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

Examples of correct code for the { "props": true } option with "ignorePropertyModificationsForRegex" set:

When Not To Use It

If you want to allow assignment to function parameters, then you can safely disable this rule.

This rule was introduced in ESLint v0.18.0.

Further Reading

JavaScript: Don’t Reassign Your Function Arguments

  • Rule source
  • Tests source

© OpenJS Foundation and other contributors Licensed under the MIT License. https://eslint.org/docs/latest/rules/no-param-reassign

no-param-reassign

Disallow reassigning function parameters

对作为函数参数声明的变量进行赋值可能会产生误导并导致混乱的行为,因为修改函数参数也会改变 arguments 对象。通常情况下,对函数参数的赋值是无意的,表明了一个错误或程序员的错误。

这条规则也可以被配置为在修改函数参数时失败。参数的副作用会导致反直觉的执行流程,使错误难以追踪。

这条规则的目的是防止因修改或重新分配函数参数而引起的非预期行为。

使用此规则的 错误 示例:

使用此规则的 正确 示例:

这个规则有一个选项,是一个对象,有一个布尔属性 "props" 和数组 "ignorePropertyModificationsFor" 和 "ignorePropertyModificationsForRegex" 。 "props" 默认为 false 。如果 "props" 设置为 true ,本规则警告不要修改参数属性,除非它们被包含在 "ignorePropertyModificationsFor" 或 "ignorePropertyModificationsForRegex" 中,默认为空数组。

使用默认的 { "props": false } 选项的 正确 示例:

使用 { "props": true } 选项的 错误 示例:

设置了 "ignorePropertyModificationsFor" 的 { "props": true } 选项的**正确的代码示例:

设置了 "ignorePropertyModificationsForRegex" 的 { "props": true } 选项的**正确的代码示例:

如果你想允许对函数参数进行赋值,你可以安全地禁用此规则。

This rule was introduced in ESLint v0.18.0.

Further Reading

Avatar image for spin.atomicobject.com

  • Rule source
  • Tests source

Disallow Reassignment of Function Parameters (no-param-reassign)

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.

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.

Rule Details

This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

Examples of incorrect code for this rule:

Examples of correct code for this rule:

This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor" . "props" is false by default. If "props" is set to true , this rule warns against the modification of parameter properties unless they're included in "ignorePropertyModificationsFor" , which is an empty array by default.

Examples of correct code for the default { "props": false } option:

Examples of incorrect code for the { "props": true } option:

Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

When Not To Use It

If you want to allow assignment to function parameters, then you can safely disable this rule.

Further Reading

  • JavaScript: Don’t Reassign Your Function Arguments

This rule was introduced in ESLint 0.18.0.

  • Rule source
  • Documentation source

Disallow Reassignment of Function Parameters (no-param-reassign)

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.

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.

Rule Details

This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

Examples of incorrect code for this rule:

Examples of correct code for this rule:

This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor" . "props" is false by default. If "props" is set to true , this rule warns against the modification of parameter properties unless they’re included in "ignorePropertyModificationsFor" , which is an empty array by default.

Examples of correct code for the default { "props" : false } option:

Examples of incorrect code for the { "props" : true } option:

Examples of correct code for the { "props" : true } option with "ignorePropertyModificationsFor" set:

When Not To Use It

If you want to allow assignment to function parameters, then you can safely disable this rule.

Further Reading

  • JavaScript: Don’t Reassign Your Function Arguments

This rule was introduced in ESLint 0.18.0.

  • Rule source
  • Documentation source

Disallow Reassignment of Function Parameters (no-param-reassign)

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.

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.

Rule Details

This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters.

Examples of incorrect code for this rule:

Examples of correct code for this rule:

This rule takes one option, an object, with a boolean property "props" and an array "ignorePropertyModificationsFor" . "props" is false by default. If "props" is set to true , this rule warns against the modification of parameter properties unless they’re included in "ignorePropertyModificationsFor" , which is an empty array by default.

Examples of correct code for the default { "props": false } option:

Examples of incorrect code for the { "props": true } option:

Examples of correct code for the { "props": true } option with "ignorePropertyModificationsFor" set:

When Not To Use It

If you want to allow assignment to function parameters, then you can safely disable this rule.

Further Reading

  • JavaScript: Don’t Reassign Your Function Arguments

This rule was introduced in ESLint 0.18.0.

  • Rule source
  • Documentation source

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable no-param-reassign per function scope #8907

@dandv

dandv commented Jul 9, 2017 • edited

If the function body code modifies a parameter that's passed by value (Number, String, Boolean, Date), eslint should not warn that the parameter is modified, since the modifications won't survive after the function returns.

(contrived) example:

timestamp2unix(timestamp) { if (!timestamp) timestamp = Date.now(); // <-- // another legitimate parameter reassignment if (timestamp < MIN_DATE_IN_HISTORY) timestamp = MIN_DATE_IN_HISTORY;assignment return new Date(timestamp).getTime(); }

@eslintbot

eslintbot commented Jul 9, 2017 • edited by platinumazure

Hi , thanks for the issue. It looks like there's not enough information for us to know how to help you.

Requesting a new rule? Please see for instructions.

Sorry, something went wrong.

@platinumazure

dandv commented Jul 10, 2017 • edited

: What I would like to do is disable for parameters passed by value. Something like

: [ 'warn', { 'allowPassedByValue': true }, ],

If ESLint can't infer the parameter passing type (e.g. from the adjacent JSDoc), then a function-level comment like this would solve the problem:

@ilyavolodin

ilyavolodin commented Jul 14, 2017

ESLint can't determine if the argument was passed by value, you need type system for that. (JSDoc is unreliable, since not everyone uses it, and it can be outdated). As to inline comment, you can already do that by adding

next to the assignment. Or by wrapping function into comments.

dandv commented Jul 14, 2017

Thanks . I meant a function-level comment like to disable the check for the entire function (or block) that line was found in.

Anyway, compared to your solution, my proposal would only save one line of comments, so probably the current way to wrap the function between and is good enough.

@not-an-aardvark

not-an-aardvark commented Aug 10, 2017

Closing because the existing solution is satisfactory.

@not-an-aardvark

No branches or pull requests

@dandv

  • Stack Overflow Public questions & answers
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Talent Build your employer brand
  • Advertising Reach developers & technologists worldwide
  • Labs The future of collective knowledge sharing
  • About the company

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

How to handle eslint no-param-reassign rule in Array.prototype.reduce() functions

I've recently added the eslint rule no-param-reassign .

However, when I use reduce to build out an object (empty object as initialValue ), I find myself needing to modify the accumulator (first arg of callback function) on each callback iteration, which causes a no-param-reassign linter complaint (as one would expect it would).

Is there a better way to build out an object with reduce that doesn't modify the accumulator argument?

Or should I simply disable the linting rule for that line in my reduce callback functions?

  • ecmascript-6

sfletche's user avatar

  • 6 Note, this is specifically because you've passed "props": true to the rule. By default it does not complain about this. If you don't want that behavior, seems like setting that to false is what you want? Or flag it with // eslint-disable-line no-param-reassign. –  loganfsmyth Commented Jan 13, 2017 at 0:36
  • that's a good point @loganfsmyth. i'll do some re-examination to see if setting "props" to true is really what we want... –  sfletche Commented Jan 13, 2017 at 0:39
  • 1 btw, there's a great conversation on this topic at github.com/airbnb/javascript/issues/719 –  ptim Commented Oct 2, 2018 at 7:04

5 Answers 5

I just wrap the reduce functions in a lint rule disable block, ie:

Zack Knopp's user avatar

  • 9 This should be the correct answer for performance reasons. I believe this is the optimal solution. No-param-reassign is a way to keep us from inducing side effects outside of scope, but the case of Array.reduce is an exception to issue of side-effects, since it is internally pure. –  jaimefps Commented Dec 11, 2019 at 1:07

Whenever I use Array.prototype.reduce I always name the "accumulator" parameter accu . This convention conveniently allowed me to set my eslint rule:

If you have your own naming convention for this parameter, replace "accu" in the rule above with whatever you use, and eslint will not complain about modifying your accumulator.

Anj's user avatar

  • 1 Even though this answer is approved, I would discourage from taking this approach. Naming every reduce accumulator "accu" will lead to code that is hard to read. you should try to make your code explain itself instead (clean code). Even more confusion and potential mistakes will arise if you ever nest reduce functions. Wrapping the block like Zack Knopp answer would be advised imo. –  Pieter-Jan De Bruyne Commented Dec 14, 2022 at 17:28
  • 3 In every case I have encountered, there is enough context from the name of the variable to which the output will be assigned (and what's going on in the function) that it's not an issue. If the function is too complex where that isn't the case, it may make sense to refactor and take a different approach. –  Anj Commented Dec 14, 2022 at 18:08
  • 2 I agree with @Anj, the point above is pedantic in this regard. –  Alexander Forbes-Reed Commented Apr 23, 2023 at 14:37

One solution would be to leverage the object spread operator

Performance Warning!! This is a non-performant ( O(n^2 ) solution that should be avoided.

Patrick Fowler's user avatar

  • 35 Is this really a good solution? Reducing an array with many elements, let's say 2000, would create as many new object instances, like 2000 in this case. –  Kev Commented Oct 13, 2017 at 15:41
  • 1 @Amida yes, it's very non performant solution - cause you can possibly have very large arrays. Instead of just using new (single) object you are creating new object each iteration what is very slow. –  Jurosh Commented Jul 11, 2018 at 7:46
  • 3 As other have said before, this is not performant. You should just disable the lint rule in that line. And perhaps ask the eslint folks to consider adding an exception specifically for Array.reduce –  jaimefps Commented Dec 11, 2019 at 1:08
  • 1 I agree that it's less performant, but it does make it a pure function with no side-effects, so that it could fit in to a functional-programming approach. –  Jimbali Commented Jul 14, 2023 at 13:12

Well, you could do (result, item) => Object.assign({}, result, {[item]: whatever}) to create a new object on every iteration :-)

If you want to trick the linter, you could use => Object.assign(result, {[item]: whatever}) (which does the same as your current code but without an explicit assignment), but yeah I guess you should simply disable that rule.

Bergi's user avatar

  • 4 yeah, that's kinda what i figured. maybe disabling the rule for that line is the best option... –  sfletche Commented Jan 13, 2017 at 0:37

As I found no other reasonable solution, I just disable that single check:

vault's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged javascript ecmascript-6 eslint or ask your own question .

  • Featured on Meta
  • Upcoming sign-up experiments related to tags
  • The return of Staging Ground to Stack Overflow
  • The 2024 Developer Survey Is Live
  • Policy: Generative AI (e.g., ChatGPT) is banned

Hot Network Questions

  • Would killing 444 billion humans leave any physical impact on Earth that's measurable?
  • Does the recommendation to use password managers also apply to corporate environments?
  • Is this crumbling concrete step salvageable?
  • UTF-8 characters in POSIX shell script *comments* - anything against it?
  • What are philosophers doing when they are discussing free will?
  • Prove that the numbers 2008 and 2106 are not terms of this sequence.
  • What's North Korea's yearly production capacity for artillery shells?
  • I'm a web developer but I am being asked to automate testing in Selenium
  • English translation of a quatrain from the "Rubaiyat" of Omar Khayyam
  • tnih neddih eht kcehc
  • Finding equivalent resistance in a circuit in which 12 resistors are arranged in the edge of a cube
  • Best practices for relicensing what was once a derivative work
  • QGIS show only one label
  • How to modify overlay specifications in a new command in LaTeX Beamer?
  • Tool Storage Corrosion Risk
  • Is there any way to play Runescape singleplayer?
  • In "Romeo and Juliet", why is Juliet the "sun"?
  • Australian citizen married to dual Australian/Italian citizen wanting to travel Europe for 6 months
  • How to define a function that returns a variable storing plots instead of plotting them to the output
  • How would wyrms develop culture, houses, etc?
  • Where did Borobudur's stones come from?
  • I have an active multiple-entry C1 US visa. I also have a Canadian citizenship certificate. Need to travel (not transit) US in 20 days. My options?
  • Going around in circles
  • Intercept significant, but confidence intervals around its standardized β include 0

eslint assignment to property of function parameter no param reassign

Get the Reddit app

A subreddit for all questions related to programming in any language.

Why eslint throws "Assignment to property of function parameter 'element'." for this?

I started learning javascript a week ago. Started using eslint yesterday and it's very useful. I have been trying this part of the code for sometime now and eslint keeps throwing Assignment to property of function parameter 'element'.Here is the code;

Before this I was doing something like this;

I know eslint isn't showing error for nothing so I would like to know what's reason and how it should be done.

And I have another eventListner with same pattern but that changes the opacity to 0 and pointerEvents to 'none'. So is there a way to do that using ternary operator or should I just stick to if else for that?Thanks and lemme know if there anything else I can improve.

IMAGES

  1. Assignment to property of function parameter no-param-reassign

    eslint assignment to property of function parameter no param reassign

  2. 解决Vue、vuex报“Assignment to property of function parameter ‘state‘” 的方法

    eslint assignment to property of function parameter no param reassign

  3. javascript

    eslint assignment to property of function parameter no param reassign

  4. no-param-reassign

    eslint assignment to property of function parameter no param reassign

  5. 一些eslint的报红及解决

    eslint assignment to property of function parameter no param reassign

  6. How to fix this ESlint no param reassign error in my Filter

    eslint assignment to property of function parameter no param reassign

VIDEO

  1. Sum Numbers Using Function

  2. ICSE CLASS IX

  3. How to use Contour Tool with Full Property Function in CorelDraw X-7,6,5,4,3 |Hindi/Urdu| # 19

  4. Virat In A Family Function vs Virat Kohli In Friend Party #shorts #viratkohli #trending #party

  5. Use Destructuring Assignment to Pass an Object as a Function's Parameters (ES6) freeCodeCamp

  6. Program dan parameter no 3 dan 4 mesin metik jadul. #tutorial #maintenance #mesinjahit #tips #trik

COMMENTS

  1. javascript

    The no-param-reassign warning makes sense for common functions, but for a classic Array.forEach loop over an array which you intend to mutate it isn't to appropriate. However, to get around this, you can also use Array.map with a new object (if you are like me, dislike snoozing warnings with comments): someArray = someArray.map((_item) => {.

  2. Assignment to property of function parameter (no-param-reassign)

    10. This is a common ESLint issue that appears frequently on old codebase. You have modified the result variable which was passed as parameter. This behavior is prohibited by the rule. To resolve it, copy the argument to a temporary variable and work on it instead: export const fn = article => article.categoryValueDtoSet.reduce((res, item) => {.

  3. no-param-reassign

    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. Version

  4. Assignment to property of function parameter no-param-reassign

    function createEmployee(emp) { // ⛔️ Assignment to property of function parameter 'emp'. eslint no-param-reassign. emp.name = 'bobby hadz'; emp.salary = 500; return emp; } The ESLint rule forbids assignment to function parameters because modifying a function's parameters also mutates the arguments object and can lead to confusing behavior.

  5. no-param-reassign

    A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.

  6. no-param-reassign

    Disallow Reassignment of Function Parameters (no-param-reassign) 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. ... Disallow Reassignment of Function Parameters (no-param-reassign) Assignment to variables declared ...

  7. No-param-reassign

    Rule Details. This rule aims to prevent unintended behavior caused by modification or reassignment of function parameters. Examples of incorrect code for this rule: /*eslint no-param-reassign: "error"*/ function foo(bar) {. bar = 13; } function foo(bar) {. bar++; } function foo(bar) { for (bar in baz) {} } function foo(bar) { for (bar of baz) {} }

  8. no-param-reassign

    Disallow Reassignment of Function Parameters (no-param-reassign) 禁止对函数参数再赋值 (no-param-reassign) 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 ...

  9. no-param-reassign

    对作为函数参数声明的变量进行赋值可能会产生误导并导致混乱的行为,因为修改函数参数也会改变 arguments 对象。 通常情况下,对函数参数的赋值是无意的,表明了一个错误或程序员的错误。

  10. no-param-reassign

    Disallow Reassignment of Function Parameters (no-param-reassign) Assignment to variables declared as function parameters can be misleading and lead to confusing ... /*eslint no-param-reassign: "error"*/ function foo ... an object, with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If ...

  11. no-param-reassign: function type exceptions #6339

    eslint output: Assignment to function parameter 'line' no-param-reassign. In such cases creation an intermediate variable could be overcomplication. May be some additions to the rule like proxyTraps: false, eventListeners: false would be helpful.

  12. no-param-reassign: add option to ignore property assignment for

    archived due to age This issue has been archived; please open a new issue for any further discussion enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules

  13. Do we want to recommend the `no-param-reassign` eslint rule in the docs

    I just had this idea when another user tried to assign to the state function argument. There is actually an eslint rule for that: no-param-reassign. I'd suggest we either add that rule as a recommendation somehwere in the docs or go even one step farther and create a shareable config package .. That way we could add some more recommended rules in the future.

  14. no-param-reassign

    Disallow Reassignment of Function Parameters (no-param-reassign) Assignment to variables declared as function parameters can be misleading and lead to confusing ... /*eslint no-param-reassign: "error"*/ function foo ... with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set ...

  15. no-param-reassign

    Disallow Reassignment of Function Parameters (no-param-reassign) Assignment to variables declared as function parameters can be misleading and lead to confusing ... /*eslint no-param-reassign: "error"*/ function foo ... with a boolean property "props" and an array "ignorePropertyModificationsFor". "props" is false by default. If "props" is set ...

  16. Why eslint throws "Assignment to property of function parameter

    I started learning javascript a week ago. Started using eslint yesterday and it's very useful. I have been trying this part of the code for sometime now and eslint keeps throwing Assignment to property of function parameter 'element'. Here is the code;

  17. Option to disable no-param-reassign per function scope #8907

    Thanks @ilyavolodin.I meant a function-level comment like // eslint-disable-func no-param-reassign to disable the check for the entire function (or block) that line was found in.. Anyway, compared to your solution, my proposal would only save one line of comments, so probably the current way to wrap the function between /* eslint-disable no-param-reassign */ and /* eslint-enable */ is good enough.

  18. javascript

    I've recently added the eslint rule no-param-reassign. However, when I use reduce to build out an object (empty object as initialValue), I find myself needing to modify the accumulator (first arg of callback function) on each callback iteration, which causes a no-param-reassign linter complaint (as one would expect it would).

  19. Why eslint throws "Assignment to property of function parameter

    I started learning javascript a week ago. Started using eslint yesterday and it's very useful. I have been trying this part of the code for sometime now and eslint keeps throwing Assignment to property of function parameter 'element'.Here is the code;