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.
01 Examples
TypeScript
class Client { constructor() { void this.connect(); } }Finding
Disallow async work hidden in initialization.
02 Enable it
Setup
Install the package, register its plugin factory, then enable the rule.
Install the package
pnpm add -D @scruple/asyncRegister 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