ResourcesResource lifecycle
resources/require-cleanup-on-failure
Cleanup must run when intervening work fails, using managed lifetimes, finally blocks, scoped helpers, or ownership transfer.
01 Examples
TypeScript
const socket = await connect(); await send(socket); socket.close();Finding
Require cleanup that is safe on failure.
02 Enable it
Setup
Install the package, register its plugin factory, then enable the rule.
Install the package
pnpm add -D @scruple/resourcesRegister the plugin
In scruple.config.ts, register the factory under the resources namespace used by the rule ID.
import { resources } from "@scruple/resources";
plugins: {
"resources": resources(),
},Enable the rule
"resources/require-cleanup-on-failure": "warn"- Package
@scruple/resources- Default threshold
- 0.9
- Minimum confidence
- 0.7