1.0.1 • Published 1 year ago

eslint-plugin-observers v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

eslint-plugin-observers

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

Installation

You'll first need to install ESLint:

npmyarnpnpm
npm i eslint -Dyarn add eslint -Dpnpm add eslint -D

Next, install eslint-plugin-observers:

npmyarnpnpm
npm i eslint-plugin-observers -Dyarn add eslint-plugin-observers -Dpnpm 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.