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 unnecessary concatenation of strings (no-useless-concat) #700
Comments
feross
added
the
enhancement
label
Nov 23, 2016
This comment has been minimized.
This comment has been minimized.
|
I wonder if this will break the "optional dependecy" browserify workaround some people use: ACK anyway, there is probably other ways to fool browserify |
This comment has been minimized.
This comment has been minimized.
dougwilson
commented
Nov 23, 2016
|
I had the same though, but the whole |
This comment has been minimized.
This comment has been minimized.
|
@dcousens Heh, didn't know people were using that hack. The main use case I've seen for omitting a module is for big core things like |
This comment has been minimized.
This comment has been minimized.
|
@feross or the alterior, where they want to detect if they should support methods like |
feross
added this to the
standard v10 milestone
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
|
Ran the test suite and found minor to moderate ecosystem impact (2.5%). The rule is not automatically fixable.
Specifically, I found several cases that I think should be allowed. They are:
var text = '\uD83D\uDE38' + '\uD83D\uDCAD' + '\uD83D\uDC4D'
test('encode', function (t) {
var buf = txtBin.encode(obj)
var expected = new Buffer('0a' + '537472696e67' + '3d' + '666f6f' +
'09' + '6e756d626572' + '3d' + '3432' +
'06' + '656d707479' + '3d' +
'09' + '6e756c6c' + '3d' + '6e756c6c' +
'04' + '626f6f6c' +
'0a' + '627566666572' + '3d' + '626172', 'hex')
this.query('select info from "' + this.infoTable + '" where id=\'' + (id + ':info') + "'", function (err, result) {In this last example, I think using a Does anyone have thoughts on this particular rule, in light of these findings? cc @dcousens @dougwilson (Going to push this to the v11 milestone in the meantime) |
feross
modified the milestones:
standard v11,
standard v10
Mar 2, 2017
feross
added
the
need more info
label
Mar 2, 2017
This comment has been minimized.
This comment has been minimized.
dougwilson
commented
Mar 2, 2017
|
Nothing in particular. |
This comment has been minimized.
This comment has been minimized.
This reads like magic to me, why are they unique? var PREFIX = '\uD83D\uDE38'
var text = PREFIX + '\uD83D\uDC4D' |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Mar 2, 2017
|
Absolutely agree with @dcousens. There are other possible workarounds, so no need for "specials". Both 1 and 2 would look better if array + join is used. 2c |
feross commentedNov 23, 2016
It’s unnecessary to concatenate two strings together, such as:
This code is likely the result of refactoring where a variable was removed from the concatenation (such as
'a' + b + 'b'). In such a case, the concatenation isn’t important and the code can be rewritten as:http://eslint.org/docs/rules/no-useless-concat