ESLint plugin for rules that require explicit cleanup of runtime resources such as timers, event listeners, observers, abort controllers, workers, streams, child processes, and disposable handles.
The runtime, preset surfaces, documentation structure, tests, and release gates are in place so cleanup rules can stay consistent across rule metadata, generated docs, and flat config presets.
Oxlint: Not compatible as a complete plugin with Oxlint 1.80.0. Its type-aware animation and Web Stream lock rules require TypeScript parser services, which Oxlint JavaScript plugins do not provide; use ESLint for this plugin.
npm install --save-dev eslint-plugin-runtime-cleanup typescriptimport runtimeCleanup from "eslint-plugin-runtime-cleanup";
export default [runtimeCleanup.configs.recommended];The recommended preset targets JavaScript and TypeScript files by default:
**/*.{js,mjs,cjs,ts,tsx,mts,cts}. Type-aware presets stay scoped to
TypeScript-family files, but they do not configure TypeScript parser services
for you.
Configure type-aware parsing in the consuming flat config before adding a type-aware preset:
import tsParser from "@typescript-eslint/parser";
import runtimeCleanup from "eslint-plugin-runtime-cleanup";
export default [
{
files: ["**/*.{ts,tsx,mts,cts}"],
languageOptions: {
parser: tsParser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
runtimeCleanup.configs["recommended-type-checked"],
];| Preset | Purpose |
|---|---|
runtime-cleanup.configs.minimal |
Low-noise cleanup baseline. |
runtime-cleanup.configs.recommended |
Broadly safe cleanup rules for JS and TS files. |
runtime-cleanup.configs["recommended-type-checked"] |
Recommended cleanup rules plus checks that need TypeScript type data. |
runtime-cleanup.configs.strict |
Stronger cleanup enforcement for TypeScript-family files. |
runtime-cleanup.configs.all |
All stable cleanup rules for TypeScript-family files. |
runtime-cleanup.configs.experimental |
Rules still proving out behavior or fix safety. |
Runtime-cleanup rules are listed below. Each rule documents the exact resource-lifetime pattern it enforces.
Fixlegend:fix= autofixablesuggest= suggestions available-= report only
Preset emojilegend:
The plugin is intended to cover resource lifetime hazards where missed cleanup causes leaks, duplicate work, stuck processes, or stale callbacks. Concrete rules should be added only when the AST strategy, false-positive boundaries, and fix/suggestion behavior are explicit.
Likely future rule families:
- timers created by
setTimeout,setInterval, and related scheduling APIs - event listeners that need matching
removeEventListenercalls or signal cleanup - observers such as
MutationObserver,ResizeObserver, andIntersectionObserver AbortControllerandAbortSignallifecycle management- workers, streams, child processes, and disposable handles
npm run build
npm run typecheck
npm run test
npm run lint:nocacheThe release gate is:
npm run release:verifyThe Docusaurus documentation site lives under docs/docusaurus and consumes
the hand-authored rule and preset docs under docs/rules.