question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disallowing assignment and passing by value.

See original GitHub issue

Please describe what the rule should do:

Disallowing assignment and passing by value.

What category of rule is this? (place an “X” next to just one item)

[x] Warns about a potential error (problem) [ ] Suggests an alternate way of doing something (suggestion) [ ] Enforces code style (layout) [ ] Other (please specify:)

Provide 2-3 code examples that this rule will warn about:

if(exitCode = 0){
}
const exitStatus = {
   noError: exitCode = 0,
}

Maybe we can consider a stricter version that strictly distinguishes statements with side effects.

Statements with side effects (such as a=b, a+=b, a++,a--,delete a.b) are prohibited from using as a value/expressions.

So what name should this rule be called? I encountered a naming problem.

Why should this rule be included in ESLint (instead of a plugin)?

This is a strict version of no-cond-assign and no-multi-assign. and it may also deprecating yoda

Are you willing to submit a pull request to implement this rule? Yes


this idea comes from http://www.yinwang.org/blog-cn/2013/04/16/yoda-notation

translate: https://translate.google.com/translate?sl=zh-CN&tl=en&u=http%3A%2F%2Fwww.yinwang.org%2Fblog-cn%2F2013%2F04%2F16%2Fyoda-notation

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Dec 16, 2019

My only concern is that creating a new rule will create multiple rules that warn about the same thing. I think we either need to scope this proposal to the cases not currently covered or discuss deprecating no-cond-assign and no-multi-assign in favor of a new rule that catches all these cases (with configuration options to allow turning currently supported cases on and off individually).

0reactions
kaicataldocommented, Jan 21, 2020

As the bot above mentions, it doesn’t look like we were able to drum up enough support for this proposal. ESLint is fully pluggable, though, and you can read about making your own custom rules here! Feel free to stop by our Gitter if you need help getting this to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disallowing assignment and passing by value - c++
It's useful when it doesn't make sense for your object to be copied. It is definitely not considered bad practice.
Read more >
Pass-by-value, reference, and assignment | Pydon't - Mathspp
In the pass-by-value model, when you call a function with a set of arguments, the data is copied into the function. This means...
Read more >
Pass by value vs. pass by reference - Educative.io
Pass by value means that a copy of the actual parameter's value is made in memory, i.e. the caller and callee have two...
Read more >
Java is Pass by Value, Not Pass by Reference | DigitalOcean
Many Java programmers question whether Java is pass by value or pass by reference. This article summarizes why Java is always pass by...
Read more >
Remove Assignments to Parameters - Refactoring.Guru
First, if a parameter is passed via reference, then after the parameter value is changed inside the method, this value is passed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found