
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
eslint-plugin-consistent-subscribe
Advanced tools
ESLint rule, checking pairing subscriptions
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-consistent-subscribe
:
$ npm install eslint-plugin-consistent-subscribe --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-consistent-subscribe
globally.
Add consistent-subscribe
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"consistent-subscribe"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"consistent-subscribe/consistent-subscribe": 2
}
}
This rule aims to...
Examples of incorrect code for this rule:
$('body').on('click', onClick);
// subscribe, without unsubscribe
Examples of correct code for this rule:
$('body').on('click', onClick);
setTimeout(() => {
$('body').off('click', onClick);
}, 1000);
This rule takes a list of objects, where each object describes a separate API subscription.
Default value is:
/* eslint-enable consistent-subscribe/consistent-subscribe: [2, {open: 'addEventListener', close: 'removeEventListener'}, {open: 'on',close: 'off'}, {open: 'subscribe',close: 'unsubscribe'}] */
open name of subscribe method, i.e. on/subscribe/addEventListener
close name of unsubscribe method, i.e. off/unsubscribe/removeEventListener
contextEquality. default true - need check, that listened object strict equal The following patterns are not warnings:
/* eslint-enable consistent-subscribe/consistent-subscribe: [2, {open: 'on',close: 'off', contextEquality: false}] */
$('body').on('click', onClick);
$(document.body).off('click', onClick);
openArgumentsEquality/closeArgumentsEquality. default true - arguments should strict equal
If need check not all arguments, this is array of indexed arguments for check\
The following patterns are considered warnings:
/* eslint-enable consistent-subscribe/consistent-subscribe: [2, {open: 'on',close: 'off', openArgumentsEquality: true, closeArgumentsEquality: true}] */
$('body').on('click', onClick);
$('body').off('click');//missing handler argument
The following patterns are not warnings:
/* eslint-enable consistent-subscribe/consistent-subscribe: [2, {open: 'on',close: 'off', openArgumentsEquality: [0], closeArgumentsEquality: [0]}] */
$('body').on('click', onClick);
$('body').off('click');//missing handler argument, but it's OK, because checked only first argument
© 2016 Viktor Gvozdev gvozdev.viktor@gmail.com and contributors.
Released under the MIT license.
FAQs
ESLint rule, checking pairing subscriptions
The npm package eslint-plugin-consistent-subscribe receives a total of 0 weekly downloads. As such, eslint-plugin-consistent-subscribe popularity was classified as not popular.
We found that eslint-plugin-consistent-subscribe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.