Skip to content

About

ESLint Plugin to require cleanup for timers, listeners, observers, AbortController, workers, streams, child processes, and disposables.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

73 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

eslint-plugin-runtime-cleanup

npm license. npm total downloads. latest GitHub release. GitHub stars. GitHub forks. GitHub open issues. codecov.

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.

Install

npm install --save-dev eslint-plugin-runtime-cleanup typescript

Usage

import 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"],
];

Presets

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.

Rules

Runtime-cleanup rules are listed below. Each rule documents the exact resource-lifetime pattern it enforces.

Rule Fix Presets
no-floating-abort-controllers - 🟑 🧬 πŸ”΄ 🟣
no-floating-audio-contexts - 🟑 🧬 πŸ”΄ 🟣
no-floating-broadcast-channels - 🟑 🧬 πŸ”΄ 🟣
no-floating-child-processes - 🟑 🧬 πŸ”΄ 🟣
no-floating-disposable-stacks - 🟑 🧬 πŸ”΄ 🟣
no-floating-file-watchers - 🟑 🧬 πŸ”΄ 🟣
no-floating-geolocation-watches - 🟑 🧬 πŸ”΄ 🟣
no-floating-infinite-animations - 🧬 πŸ”΄ 🟣
no-floating-media-streams - 🟑 🧬 πŸ”΄ 🟣
no-floating-message-channels - 🟑 🧬 πŸ”΄ 🟣
no-floating-network-connections - 🟑 🧬 πŸ”΄ 🟣
no-floating-object-urls - 🟑 🧬 πŸ”΄ 🟣
no-floating-observers - 🟑 🧬 πŸ”΄ 🟣
no-floating-servers - 🟑 🧬 πŸ”΄ 🟣
no-floating-streams - 🟑 🧬 πŸ”΄ 🟣
no-floating-timers - 🟑 🧬 πŸ”΄ 🟣
no-floating-wake-locks - 🟑 🧬 πŸ”΄ 🟣
no-floating-web-stream-locks - 🧬 πŸ”΄ 🟣
no-floating-workers - 🟑 🧬 πŸ”΄ 🟣
no-unmanaged-event-listeners - 🟑 🧬 πŸ”΄ 🟣

Rule Roadmap

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 removeEventListener calls or signal cleanup
  • observers such as MutationObserver, ResizeObserver, and IntersectionObserver
  • AbortController and AbortSignal lifecycle management
  • workers, streams, child processes, and disposable handles

Development

npm run build
npm run typecheck
npm run test
npm run lint:nocache

The release gate is:

npm run release:verify

Documentation

The Docusaurus documentation site lives under docs/docusaurus and consumes the hand-authored rule and preset docs under docs/rules.

About

ESLint Plugin to require cleanup for timers, listeners, observers, AbortController, workers, streams, child processes, and disposables.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages