Skip to content
← All rules
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.

cleanupmultiple-resourcesfailure-paths
TypeScript
const input = await openInput(); const output = await openOutput(); await copy(input, output); output.close();
Finding

Require complete cleanup of multiple resources.

Setup

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

Install the package

pnpm add -D @scruple/resources

Register 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

Released under the MIT License.