Skip to content

Conversation

@AlicanC
Copy link
Contributor

@AlicanC AlicanC commented Dec 29, 2015

Made the change discussed in #641.

@ljharb
Copy link
Collaborator

ljharb commented Dec 29, 2015

I'm not sure why GH is unable to show the diff here :-/ However, it looks good on my machine.

ljharb added a commit that referenced this pull request Dec 29, 2015
[Docs] Make no-param-reassign a separate section.
@ljharb ljharb merged commit aacaca8 into airbnb:master Dec 29, 2015
@AlicanC
Copy link
Contributor Author

AlicanC commented Dec 29, 2015

I have said that no-param-reassign has nothing to do with mutation, but it looks like it does:
https://github.com/eslint/eslint/blob/master/docs/rules/no-param-reassign.md

Setting props to true should also prevent parameter mutation and it's enabled in Airbnb config:
https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb/rules/best-practices.js#L79

The weird thing is, ESLint doesn't warn me when I do this:

function f(obj) {
  obj.key = 1;
}

f({ key: 1 });

Am I misreading the rule? What is wrong here?

@ljharb
Copy link
Collaborator

ljharb commented Dec 29, 2015

hm, it should give you an error when doing that. that might be an eslint bug?

@AlicanC
Copy link
Contributor Author

AlicanC commented Dec 29, 2015

Hmm, the change was actually made in 2589c67 which is yet to be released. It should work when it's released.


I think putting these under separate rules is still a good idea. I could add the same eslint rules: indication to "Never mutate parameters." since it will also covered by that rule on the next release.

If having two Airbnb rules pointing to the same ESLint rule would be weird, I could merge the rules again under "Never reassign or mutate parameters." and keep the "It can also cause optimization issues, especially in V8." part.

@ljharb
Copy link
Collaborator

ljharb commented Dec 29, 2015

I like having a separate section for no-param-reassign. Multiple rules in one guide section is fine, but ideally each rule is only in one guide section.

@AlicanC
Copy link
Contributor Author

AlicanC commented Dec 29, 2015

So we merge this one and we are done?
AlicanC@a503047

It looks like this PR won't update itself since it's merged. I'm supposed to create another PR right?

@ljharb
Copy link
Collaborator

ljharb commented Dec 29, 2015

yes, you'd need to make a new PR once the original is merged, on a new branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants