ResourcesResource lifecycle
resources/no-leaked-resources
Functions should release acquired files, streams, sockets, connections, subscriptions, watchers, locks, transactions, and handles or visibly transfer ownership.
01 Examples
TypeScript
async function read() { const file = await open(path); return file.read(); }Finding
Disallow owned resources left unreleased.
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/no-leaked-resources": "warn"- Package
@scruple/resources- Default threshold
- 0.65
- Minimum confidence
- 0.5