Skip to content
← All rules
AsyncAsync lifecycle

async/no-async-initialization

Constructors should not start asynchronous work before callers have an explicit lifecycle boundary that can observe readiness or failure.

constructorsinitializationpromises
TypeScript
class Client { constructor() { void this.connect(); } }
Finding

Disallow async work hidden in initialization.

Setup

Install the package, register its plugin factory, then enable the rule.

Install the package

pnpm add -D @scruple/async

Register the plugin

In scruple.config.ts, register the factory under the async namespace used by the rule ID.

import { asyncRules } from "@scruple/async";

plugins: {
  "async": asyncRules(),
},

Enable the rule

"async/no-async-initialization": "warn"
Package
@scruple/async
Default threshold
Plugin default
Minimum confidence
Plugin default

Released under the MIT License.