Skip to content

eslint/rules/async ​

Async code: Promises, async / await, timers and generators: nothing floating, nothing forgotten. Rules of ESLint, typescript-eslint and SonarJS (the Sonar way profile of SonarQube) on this subject, every rule listed; the TypeScript rules apply to TypeScript files only.

22 rules, 18 on. Source: lint/eslint/rules/async.mjs.

RuleSettingFilesWhat it checksWhy
no-async-promise-executorerrorJS + TSDisallow using an async function as a Promise executor—
no-await-in-loopwarnJS + TSDisallow await inside of loopsWarn: some awaits must run one after the other (ordered writes, rate limits).
no-promise-executor-returnerrorJS + TSDisallow returning values from Promise executor functions—
require-atomic-updatesoffJS + TSDisallow assignments that can lead to race conditions due to usage of await or yieldOff: false positives with async/await (removed from eslint:recommended).
prefer-promise-reject-errorserrorJS + TSRequire using Error objects as Promise rejection reasonsReplaced by the TS version.
require-awaitwarnJS + TSDisallow async functions which have no await expressionReplaced by the TS version.
require-yieldwarnJS + TSRequire generator functions to contain yield—
sonarjs/generator-without-yieldoffJS + TSGenerators should explicitly "yield" a valueOff: duplicate of require-yield.
sonarjs/disabled-timeouterrorJS + TSDisabling Mocha timeouts should be explicit—
sonarjs/no-async-constructorerrorJS + TSConstructors should not contain asynchronous operations—
sonarjs/no-floating-point-equalityerrorJS + TSFloating point numbers should not be tested for equality—
sonarjs/no-try-promiseerrorJS + TSPromise rejections should not be caught by "try" blocks—
sonarjs/prefer-promise-shorthandwarnJS + TSShorthand promises should be used—
@typescript-eslint/await-thenableerrorTSDisallow awaiting a value that is not a Thenable—
@typescript-eslint/no-floating-promiseserrorTSRequire Promise-like statements to be handled appropriately—
@typescript-eslint/no-misused-promiseserrorTSDisallow Promises in places not designed to handle them—
prefer-promise-reject-errorsoffTSRequire using Error objects as Promise rejection reasonsReplaced by the TS version.
@typescript-eslint/prefer-promise-reject-errorserrorTSRequire using Error objects as Promise rejection reasons—
@typescript-eslint/promise-function-asyncerrorTSRequire any function or method that returns a Promise to be marked async—
require-awaitoffTSDisallow async functions which have no await expressionReplaced by the TS version.
@typescript-eslint/require-awaitwarnTSDisallow async functions which do not return promises and have no await expression—
@typescript-eslint/return-awaiterrorTSEnforce consistent awaiting of returned promises—

Generated from the JSDoc of the sources.