Skip to content

Override eslint rule to "no-param-reassign": ["error", { "props": false }] #1065

@openorclose

Description

@openorclose

Because of our no-param-reassign rule, a lot of redeclaration of a function parameter is done, e.g. in parser.js:

 _preprocess(node, context, config) {
    const element = node; //redecl
    const self = this;
...
}

Why this rule is recommended is because reassigning the function parameter can cause the arguments object to be weird:

var makePerson = function(favoriteColor, name, age) {
  if (arguments.length < 3) {
    favoriteColor = "green";
    name = arguments[0];
    age = arguments[1];
  }

  return {
    name: name,
    age: age,
    favoriteColor: favoriteColor
  };
};

var person = makePerson("Joe", 18);
console.log(JSON.stringify(person));
// => {"name":"green","age":"green","favoriteColor":"green"}

https://spin.atomicobject.com/2011/04/10/javascript-don-t-reassign-your-function-arguments/

This won't happen if we are just changing properties on the parameter!

(Describe your proposed solution here.)

Let's override the eslint rule with "no-param-reassign": ["error", { "props": false }], so that we can change properties on parameters, and avoid the unnecessary redeclarations of parameters.

A nonexhaustive list of places this is done:

const element = node;

const element = node;

const element = node;

and many others in componentParser.js

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions