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.

Make CLIEngine and supporting functions async via Promises

See original GitHub issue

The version of ESLint you are using. 5.1.0

The problem you want to solve. CLIEngine is synchronous in nature, and I would like it to be asynchronous/promisfied

Your take on the correct solution to problem. Instead of using fs calls that are synchronous, use the async ones, as well as allowing long running calls like executeOnFiles to return a Promise instead of an object. Upon resolution of the promise, pass the object via a resolve. This allows code using CLIEngine to not have to block. It also allows for things like Observables since we can use the from function to wrap the Promise and monitor output.

I also just noticed this, which seems to be in line with this request:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:22 (10 by maintainers)

github_iconTop GitHub Comments

Aghassicommented, Nov 24, 2018

Thanks @nzakas . I’ve opened a thread in the google group to start the process before doing a full fledge RFC write up.

To those in this thread who are interested in seeing this through, please feel free to post comments and ideas here!topic/eslint/di7l6__w2jk

platinumazurecommented, Jul 21, 2018

Hi @Aghassi, have you checked out the --cache CLI option and/or the cache: true CLIEngine constructor option? This does most of what you are suggesting 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async functions: making promises friendly -
Async functions allow you to write promise-based code as if it were synchronous. ... And here's the same thing using async functions:.
Read more >
async function - JavaScript - MDN Web Docs - Mozilla
Await expressions make promise-returning functions behave as though they're synchronous by suspending execution until the returned promise is ...
Read more >
Faster async functions and promises - V8 JavaScript engine
According to MDN, an async function is a function which operates asynchronously using an implicit promise to return its result. Async functions ......
Read more >
5. Async functions - Exploring JS
That Promise is created when starting the execution of the async function. The body is executed. Execution may finish permanently via return or...
Read more >
Understanding the Event Loop, Callbacks, Promises, and ...
It will first run through a demonstration of the event loop at work, ... Add setTimeout to the second function to simulate an...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found