putout plugin adds ability to work with promises.
npm i @putout/plugin-promises -D
{
"rules": {
"promises/add-missing-await": "on",
"promises/remove-useless-resolve": "on",
"promises/remove-useless-async": "on",
"promises/remove-useless-await": "on",
"promises/convert-reject-to-throw": "on",
"promises/convert-new-promise-to-async": "on",
"promises/apply-top-level-await": "on"
}
}async function hello() {
return world();
}
async function world() {
}async function hello() {
return await world();
}
async function world() {
}async function hello() {
return Promise.resolve('hello');
}async function hello() {
return 'hello';
}async function hello() {
return 'hello';
}function hello() {
return 'hello';
}await await Promise.resolve();await await Promise.resolve();async function hello() {
return Promise.reject(Error('error'));
}async function hello() {
throw Error('error');
}runCli();
async function runCli() {
}await runCli();
async function runCli() {
}function get() {
return new Promise((resolve, reject) => {
reject(Error("Cannot get"));
});
}async function get() {
throw Error("Cannot get");
}import {readFile} from 'fs/promises';
(async () => {
await readFile('./README.md', 'utf8');
})();import {readFile} from 'fs/promises';
await readFile('./README.md', 'utf8');MIT