$ cnpm install @putout/plugin-declare-undefined-variables
????Putout plugin adds ability to declare variable that was not defined before, including:
isFn, isString, isNumber, isObject, isBool, isUndefined, isSymbol and isNull;maybeArray, maybeFn, maybeEmptyArray;not,id, returns;freshImport, freshImportDefault;fixtures: readFixture(name);Object;Renamed to @putout/plugin-declare.
npm i putout @putout/plugin-declare-undefined-variables -D
Add .putout.json with:
{
"plugins": {
"declare-undefined-variables": "on"
}
}
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"
]
}]
}
}
assignconst hello = 'world';
const object = {};
assign(object, {
hello,
});
const hello = 'world';
const object = {};
const {assign} = Object;
assign(object, {
hello,
});
keysconst hello = 'world';
const object = {};
const allKeys = keys(object);
const hello = 'world';
const object = {};
const {keys} = Object;
const allKeys = keys(object);
valuesconst object = {};
const allValues = values(object);
const {values} = Object;
const object = {};
const allValues = values(object);
isArrayisArray(array);
const {isArray} = Array;
isArray(array);
noopnoop();
const noop = () => {};
noop();
if (isFn(fn))
fn();
const isFn = (a) => typeof a === 'function';
if (isFn(fn))
fn();
const a = [
...maybeArray(b),
];
const {isArray} = Array;
const maybeArray = (a) => isArray(a) ? a : [a];
const a = [
...maybeArray(b),
];
MIT
Copyright 2013 - present © cnpmjs.org | Home |