ResourcesResource lifecycle
resources/require-complete-resource-cleanup
When a function acquires multiple resources, all of them must be cleaned up across acquisition, work, and cleanup failure paths.
01 Examples
TypeScript
const input = await openInput(); const output = await openOutput(); await copy(input, output); output.close();Finding
Require complete cleanup of multiple resources.
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-complete-resource-cleanup": "warn"- Package
@scruple/resources- Default threshold
- Plugin default
- Minimum confidence
- Plugin default