Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upDisallow Use of Chained Assignment Expressions (no-multi-assign) #776
Comments
feross
added
the
enhancement
label
Feb 8, 2017
feross
added this to the
standard v9 milestone
Feb 8, 2017
This comment has been minimized.
This comment has been minimized.
var a = 5 // ok
var b = a
var c = aIs probably more likely for the 'correct' example |
This comment has been minimized.
This comment has been minimized.
|
@dcousens Yep, you're right. Updated the example. |
This comment has been minimized.
This comment has been minimized.
|
This rule fails in 34 repos, and prevents a bit more than I'm comfortable with. For example: exports.no = exports.noCase = require('no-case')
exports.dot = exports.dotCase = require('dot-case')exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = require('randombytes')self.readable = self.writable = falseself.socket = socketPool[self.announceUrl] = new Socket(self.announceUrl)These all seem fine to me, so thinking we should skip this rule. Thoughts? |
feross
removed this from the
standard v9 milestone
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
|
I don't see many negatives of allowing multiple assignments on one line. I use it often like in @feross's example above. I think it's good for condensing low value noise onto a single line. |
This comment has been minimized.
This comment has been minimized.
|
For similar reasons I often lament standard including the "no return assignment" rule, but I do appreciate the danger of accidentally returning an assignment when you meant a conditional. Not sure this pattern suffers from that risk as much. Vote skip. |
This comment has been minimized.
This comment has been minimized.
|
For me, this is purely a readability issue, and the only class of bugs it could relate to is: var x = 1
var y = x = 2instead of |
This comment has been minimized.
This comment has been minimized.
|
Agree, it's mainly a readability issue and not a source of bugs. And it prevents valid code that we don't want to rewrite, like multiple exports on one line. |
feross commentedFeb 8, 2017
•
edited
This rule disallows using multiple assignments within a single statement.
http://eslint.org/docs/rules/no-multi-assign
Rule: