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 upProblem with no-callback-literal #888
Comments
This comment has been minimized.
This comment has been minimized.
rkurbatov
commented
Jun 6, 2017
|
Confirm, it complains about callback with rested arguments. |
This comment has been minimized.
This comment has been minimized.
toddself
commented
Jun 21, 2017
|
Also, it is complaining about: if (err) {
log.error(err, 'Cannot get from database')
return cb({
message: 'Cannot get data',
code: 500
})
}We use this frequently since we don't actually want the end user to see the backend message since it is 100% useless to them (and could potentially leak table names, etc), so we return an object that our HTTP framework understands. |
This comment has been minimized.
This comment has been minimized.
|
@toddself We have a similar setup at work, but we still use class UserError extends Error {
constructor (...args) {
super(...args)
this.name = this.constructor.name
Error.captureStackTrace(this, this.constructor)
}
}app.use((err, req, res, next) => {
if (err instanceof UserError) {
// send nice detailed error
} else {
// send generic 500 and log error
}
}) |
This comment has been minimized.
This comment has been minimized.
toddself
commented
Jun 22, 2017
|
This was easy to fix by just moving the object creation to a new variable and returning that variable. Not sure if this is a bad thing though? |
This comment has been minimized.
This comment has been minimized.
maxbrunsfeld
commented
Jan 5, 2018
|
I think this rule should simply be removed. Not all callbacks need to take errors as their first argument. |
This comment has been minimized.
This comment has been minimized.
|
I’m guessing the rule semantics didn’t take spread operators into account. Perhaps there is a newer version of he rule? |
This comment has been minimized.
This comment has been minimized.
catdaddy23
commented
Jan 6, 2018
|
I agree. It should be removed all together
…Sent from my iPhone
On Jan 5, 2018, at 5:12 PM, Bret Comnes ***@***.***> wrote:
I’m guessing the rule semantics didn’t take spread operators into account. Perhaps there is a newer version of he rule?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
feross
added this to the
standard v12 milestone
May 10, 2018
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Aug 8, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
Aug 8, 2018
This comment has been minimized.
This comment has been minimized.
I really don't think so. E.g. the code posted by @toddself is exactly the code we want to specifically want to disallow, since it breaks assumptions that people have on how Node.js-style callbacks works.
This problem would be nice to fix though, this should be reported upstream to ESLint, anyone feel up for doing that? |
stale
bot
removed
the
stale
label
Aug 8, 2018
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Nov 6, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
stale
bot
added
the
stale
label
Nov 6, 2018
stale
bot
closed this
Nov 13, 2018
lock
bot
locked as resolved and limited conversation to collaborators
Feb 11, 2019
standard
unlocked this conversation
Aug 12, 2019
This comment has been minimized.
This comment has been minimized.
The problem is that we're the maintainers of the |
standard
locked and limited conversation to collaborators
Aug 12, 2019
This comment has been minimized.
This comment has been minimized.
|
Let's move discussion here: #1352 |
saratitan commentedMay 15, 2017
I fail to see what's invalid with the following code, what makes this callback literal?
results in