@putout/plugin-declare-undefined-variables
🐊Putout plugin adds ability to declare undefined variables
Last updated 4 years ago by coderaiser .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @putout/plugin-declare-undefined-variables 
SYNC missed versions from official npm registry.

@putout/plugin-declare-undefined-variables NPM version

????Putout plugin adds ability to declare variable that was not defined before, including:

  • is types: isFn, isString, isNumber, isObject, isBool, isUndefined, isSymbol and isNull;
  • maybe: maybeArray, maybeFn, maybeEmptyArray;
  • wrap: not,id, returns;
  • fresh-import: freshImport, freshImportDefault;
  • fixtures: readFixture(name);
  • properties of Object;
  • wraptile;
  • fullstore;
  • currify;
  • pipe-io;
  • pullout;
  • simport;
  • chalk;
  • table;

Renamed to @putout/plugin-declare.

Install

npm i putout @putout/plugin-declare-undefined-variables -D

Add .putout.json with:

{
    "plugins": {
        "declare-undefined-variables": "on"
    }
}

Rules

Use options:

  • βœ… dismiss for variables you don't want to declare;
  • βœ… declarations to declare variables;
{
    "rules": {
        "declare-undefined-variables": ["on", {
            "declarations": {
                "hello": "import {hello} from 'world'"
            },
            "dismiss": [
                "assert",
                "entries",
                "parse",
                "stringify",
                "defineProperty",
                "isArray",
                "noop",
                "join",
                "keys",
                "values",
                "stopAll",
                "once",
                "putout",
                "simport"
            ]
        }]
    }
}

assign

❌ Example of incorrect code

const hello = 'world';
const object = {};

assign(object, {
    hello,
});

βœ… Example of correct code

const hello = 'world';
const object = {};
const {assign} = Object;

assign(object, {
    hello,
});

keys

❌ Example of incorrect code

const hello = 'world';
const object = {};

const allKeys = keys(object);

βœ… Example of correct code

const hello = 'world';
const object = {};
const {keys} = Object;

const allKeys = keys(object);

values

❌ Example of incorrect code

const object = {};
const allValues = values(object);

βœ… Example of correct code

const {values} = Object;

const object = {};
const allValues = values(object);

isArray

❌ Example of incorrect code

isArray(array);

βœ… Example of correct code

const {isArray} = Array;
isArray(array);

noop

❌ Example of incorrect code

noop();

βœ… Example of correct code

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

Types

❌ Example of incorrect code

if (isFn(fn))
    fn();

βœ… Example of correct code

const isFn = (a) => typeof a === 'function';

if (isFn(fn))
    fn();

Maybe

❌ Example of incorrect code

const a = [
    ...maybeArray(b),
];

βœ… Example of correct code

const {isArray} = Array;
const maybeArray = (a) => isArray(a) ? a : [a];

const a = [
    ...maybeArray(b),
];

License

MIT

Current Tags

  • 8.0.3                                ...           latest (3 years ago)

65 Versions

  • 8.0.3                                ...           3 years ago
  • 8.0.2                                ...           3 years ago
  • 8.0.1                                ...           3 years ago
  • 8.0.0                                ...           3 years ago
  • 7.2.0                                ...           4 years ago
  • 7.1.1                                ...           4 years ago
  • 7.1.0                                ...           4 years ago
  • 7.0.1                                ...           4 years ago
  • 7.0.0                                ...           4 years ago
  • 6.8.1                                ...           4 years ago
  • 6.8.0                                ...           4 years ago
  • 6.7.0                                ...           4 years ago
  • 6.6.0                                ...           4 years ago
  • 6.5.0                                ...           4 years ago
  • 6.4.0                                ...           4 years ago
  • 6.3.0                                ...           4 years ago
  • 6.2.0                                ...           4 years ago
  • 6.1.0                                ...           4 years ago
  • 6.0.0                                ...           4 years ago
  • 5.16.0                                ...           4 years ago
  • 5.15.0                                ...           4 years ago
  • 5.14.0                                ...           4 years ago
  • 5.13.0                                ...           4 years ago
  • 5.12.0                                ...           4 years ago
  • 5.10.0                                ...           4 years ago
  • 5.9.0                                ...           4 years ago
  • 5.8.0                                ...           4 years ago
  • 5.7.0                                ...           4 years ago
  • 5.6.0                                ...           4 years ago
  • 5.5.0                                ...           4 years ago
  • 5.4.0                                ...           4 years ago
  • 5.3.0                                ...           4 years ago
  • 5.2.0                                ...           4 years ago
  • 5.1.0                                ...           5 years ago
  • 5.0.0                                ...           5 years ago
  • 4.3.0                                ...           5 years ago
  • 4.2.1                                ...           5 years ago
  • 4.2.0                                ...           5 years ago
  • 4.1.0                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 3.2.0                                ...           5 years ago
  • 3.1.1                                ...           5 years ago
  • 3.1.0                                ...           5 years ago
  • 3.0.0                                ...           5 years ago
  • 2.6.0                                ...           5 years ago
  • 2.5.0                                ...           5 years ago
  • 2.4.0                                ...           5 years ago
  • 2.3.1                                ...           5 years ago
  • 2.3.0                                ...           5 years ago
  • 2.2.0                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.9.0                                ...           5 years ago
  • 1.8.1                                ...           5 years ago
  • 1.8.0                                ...           5 years ago
  • 1.7.0                                ...           5 years ago
  • 1.6.0                                ...           5 years ago
  • 1.5.1                                ...           5 years ago
  • 1.5.0                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.0                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 7
Dependencies (0)
None
Dev Dependencies (12)

Copyright 2013 - present © cnpmjs.org | Home |