Skip to content
← All rules
ResourcesResource lifecycle

resources/no-leaked-resources

Functions should release acquired files, streams, sockets, connections, subscriptions, watchers, locks, transactions, and handles or visibly transfer ownership.

cleanupownershiphandles
TypeScript
async function read() { const file = await open(path); return file.read(); }
Finding

Disallow owned resources left unreleased.

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/no-leaked-resources": "warn"
Package
@scruple/resources
Default threshold
0.65
Minimum confidence
0.5

Released under the MIT License.