no-unused-expressions : sequence expressions
See original GitHub issueTell us about your environment
- ESLint Version: v3.15.0
- Node Version: v7.3.0
- npm Version: v3.10.8
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration: .eslintrc.js
module.exports = {
root: true,
parserOptions: {
ecmaVersion: 8,
},
rules: {
'no-unused-expressions': [2, { 'allowShortCircuit': true, 'allowTernary': true }]
}
};
What did you do? Please include the actual source code causing the issue. test.js
let readFile = function (filePath, encoding, cb) {
if (typeof encoding === 'function')
cb = encoding, encoding = 'utf8';
// ...
return [encoding, cb];
};
What did you expect to happen? As the rule name says “no unused expressions”, I wouldn’t expect an error for the example above.
There is an example in the docs: c = a, b; This is obviously an unused expression and the rule should error in this case. But I can’t see something unused in this one: cb = encoding, encoding = ‘utf8’; It’s just 2 AssignmentExpression inside of a SequenceExpression. So, I am wondering if I’m right and this rule can be changed slightly.
What actually happened? Please include the actual, raw output from ESLint. $ eslint ./test.js > output.txt
C:\nodejs\test\test.js
3:7 error Expected an assignment or function call and instead saw an expression no-unused-expressions
✖ 1 problem (1 error, 0 warnings)
Issue Analytics
- State:
- Created 7 years ago
- Comments:16 (10 by maintainers)
Top GitHub Comments
It’s true that expression isn’t technically useless, but it is confusing to read and there exists a more conventional equivalent:
I’m going to lock this thread. This is not a right venue for this type of conversation.
P.S. @nemoxps You are having a discussion about knowledge of JS with one of the members of TC39. I don’ t think the argument is on your side.