Socket
Book a DemoInstallSign in
Socket

@putout/plugin-maybe

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/plugin-maybe

🐊Putout plugin applies Maybe monad

1.1.0
Source
npmnpm
Version published
Maintainers
1
Created
Source

@putout/plugin-maybe NPM version

🐊Putout plugin helps with maybe monad. Depends on @putout/declare.

Install

npm i @putout/plugin-maybe -D

Rules

{
    "rules": {
        "maybe/array": "on",
        "maybe/empty-array": "on",
        "maybe/fn": "on",
        "maybe/noop": "on",
        "maybe/declare": "on"
    }
}

array

❌ Example of incorrect code

const array = isArray(a) ? a : [a];

✅ Example of correct code

const maybeArray = (a) => isArray(a) ? a : [a];
const array = maybeArray(a);

empty-array

❌ Example of incorrect code

const array = !a ? [] : a;

✅ Example of correct code

const maybeArray = (a) => !a ? [] : a;
const array = maybeEmptyArray(a);

fn

❌ Example of incorrect code

const fn = isFn(a) ? a : () => {};

✅ Example of correct code

const noop = () => {};
const maybeFn = isFn(a) ? a : noop;
const fn = maybeFn(a);

noop

❌ Example of incorrect code

const fn = f || (() => {});

✅ Example of correct code

const noop = () => {};
const fn = fn || noop;

declare

❌ Example of incorrect code

const fn = maybeFn(f);

✅ Example of correct code

const noop = () => {};
const maybeFn = isFn(a) ? a : noop;
const fn = maybeFn(f);

License

MIT

Keywords

putout-plugin

FAQs

Package last updated on 08 Mar 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.