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 upNew Rule: no-callback-literal #623
Comments
This comment has been minimized.
This comment has been minimized.
|
There is currently at least one open question: Should we allow |
This comment has been minimized.
This comment has been minimized.
dougwilson
commented
Sep 14, 2016
|
Thankfully some time ago, Node.js added documentation around this: https://nodejs.org/dist/latest-v6.x/docs/api/errors.html#errors_node_js_style_callbacks Sadly reading through the whole page, the only things that are truly implicated is that it must be either |
This comment has been minimized.
This comment has been minimized.
|
I support this change. |
feross
added
the
enhancement
label
Sep 14, 2016
feross
modified the milestone:
standard v9
Sep 16, 2016
This comment has been minimized.
This comment has been minimized.
|
I kind of let this die. Let me me revisit the PR with the suggested changes and we can hopefully move forward! |
This comment has been minimized.
This comment has been minimized.
|
Just an update on this rule. The PR is all ready in |
This comment has been minimized.
This comment has been minimized.
|
I actually think this might bite a little bit, but, I still agree with it on principle. |
feross
modified the milestones:
standard v9,
standard v10
Feb 9, 2017
This comment has been minimized.
This comment has been minimized.
|
Ecosystem impact is moderate (4%).
It turns out that several of these were in code that wrote myself, so after fixing those up, the new impact is better:
A good 3-4 of them are actually strings being passed to a callback instead of an |
This comment has been minimized.
This comment has been minimized.
|
This will be part of the standard v10 beta. |
feross
closed this
Mar 2, 2017
feross
added a commit
to standard/eslint-config-standard
that referenced
this issue
Mar 2, 2017
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Mar 2, 2017
|
@feross I'm totally okey with that rule et al. But just tried the v10 beta, but it seems there something wrong in the impl. I'll post an issue to show for what i'm talking about. Otherwise |
This comment has been minimized.
This comment has been minimized.
dutchenkoOleg
commented
Jul 20, 2017
•
|
What about return cb(...someArray);why it'is error? |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Jul 20, 2017
|
@dutchenkoOleg, probably because you must pass |
This comment has been minimized.
This comment has been minimized.
|
The lack of |
This comment has been minimized.
This comment has been minimized.
timbl
commented
Jan 6, 2018
|
Coming across this way after the fact, I think you really have decide whether your limits are. New this makes any API which does not start with an error param illegal Javascript. This was a big overreach IMMHO. We have APIs going back before node where the callback param is a success flag. Suddenly to be able to use everyone's favourite linter we have change our APIs? |
This comment has been minimized.
This comment has been minimized.
tunnckoCore
commented
Jan 6, 2018
This comment has been minimized.
This comment has been minimized.
|
FWIW the |
This comment has been minimized.
This comment has been minimized.
|
Hey everyone, just letting you all know that I'm considering removing this rule in standard v12. You can follow this issue for updates: https://github.com/standard/eslint-plugin-standard/issues/27 |
This comment has been minimized.
This comment has been minimized.
|
|
xjamundx commentedSep 14, 2016
•
edited
What does everyone think of a rule that more strictly enforce the callback pattern? This will help people avoid the common mistake of calling back with an error message instead of an error object, which can lead to all sorts of weird bugs.
There is already this similar rule in ESLint:
http://eslint.org/docs/rules/no-throw-literal
Here is how it will work:
Allowed
Not allowed
Of course we can figure out if we should include
cbandnextas well ascallbackin the list of allowed function names.