Skip to content

ESLint plugin for preventing memory leaks around observers (ResizeObserver, IntersectionObserver, MutationObserver)

Notifications You must be signed in to change notification settings

gquinteros93/eslint-plugin-observers

Repository files navigation

eslint-plugin-observers

ESLint plugin for preventing memory leaks around observers (ResizeObserver, IntersectionObserver, MutationObserver)

Installation

You'll first need to install ESLint:

npm yarn pnpm
npm i eslint -D yarn add eslint -D pnpm add eslint -D

Next, install eslint-plugin-observers:

npm yarn pnpm
npm i eslint-plugin-observers -D yarn add eslint-plugin-observers -D pnpm add eslint-plugin-observers -D

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-observers globally.

Usage

Add observers to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["observers"]
}

Then configure the rules you want to use under the rules section.

{
  "rules": {
    "observers/no-missing-unobserve-or-disconnect": "error",
    "observers/matching-unobserve-target": "error",
  }
}

or

You can use our "recommended" settings which enables most of the rules for you

{
  "extends": ["plugin:observers/recommended"]
}

We also support a "strict" settings which enabled all of the rules for you

{
  "extends": ["plugin:observers/strict"]
}

Rule Documentation

Credits

This package is based on eslint-plugin-listeners, most of the functions were reused or based on functions used in eslint-plugin-listeners. Because of that, this plugin deserves a lot of credit.

About

ESLint plugin for preventing memory leaks around observers (ResizeObserver, IntersectionObserver, MutationObserver)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published