question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[callback-return] only accepts callbacks that are by themselves or prefixed with a return

See original GitHub issue

callback-return only accepts callbacks that are by themselves on a line, or prefixed with return.

Tell us about your environment

  • ESLint Version: 6.8.0
  • Node Version: 12.14.1
  • npm Version: 6.14.2

What parser (default, Babel-ESLint, etc.) are you using? @typescript-eslint/parser

Please show your full configuration:

Configuration
module.exports = {
  root: true,
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: 'tsconfig.eslint.json',
    ecmaVersion: 2019,
    sourceType: 'module'
  },
  env: { node: true },
  rules: {
    'callback-return': 'warn'
  }
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const mutate = <TObject extends object, TKey extends keyof TObject>(
  obj: TObject,
  key: TKey,
  callback: (value: TObject[TKey]) => TObject[TKey]
): void => {
  obj[key] = callback(obj[key]);
};
eslint . --ext ts

What did you expect to happen?

callback not to be flagged by callback-return.

What actually happened? Please include the actual, raw output from ESLint.

callback is flagged by callback-return:

16:14 warning Expected return with your callback function callback-return

Are you willing to submit a pull request to fix this bug? Maybe - looking at the source code & documentation, it might be tough to implement a sound fix.


Demo reproduction.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
kaicataldocommented, Mar 31, 2020

I’m clearly a bit scattered, because this is one of the rules we just ported over to eslint-plugin-node. Since we are deprecating this rule, I would suggest closing this and moving this discussion to a new issue over in that repository. Sorry for the confusion, all!

0reactions
eslint-deprecated[bot]commented, Jun 20, 2020

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that accepted issues failing to be implemented after 90 days tend to never be implemented, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

callback-return - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Everything About Callback Functions in JavaScript
The callback is a function being called by another function, either synchronously or asynchronously.
Read more >
When does the useEffect's callback's return statement execute?
No, component dismounts only once at end of its life time, React allows to execute a callback with useEffect hook by providing an...
Read more >
Effective Dart: Design
Here are some guidelines for writing consistent, usable APIs for libraries. Names. Naming is an important part of writing readable, maintainable code.
Read more >
Using promises - JavaScript - MDN Web Docs
Essentially, a promise is a returned object to which you attach callbacks, instead of passing callbacks into a function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found