Disallowing assignment and passing by value.
See original GitHub issuePlease 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
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
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
andno-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).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.