🐊Putout plugin adds ability to declare variable that was not defined before, including:
- maybe:
maybeArray,maybeFn,maybeEmptyArray; - wrap:
not,id,returns; - fresh-import:
freshImport,freshImportDefault; fixtures:readFixture;- properties of
Object; - wraptile;
- fullstore;
- currify;
- pipe-io;
- pullout;
- wait;
- simport;
- chalk;
- table;
npm i putout @putout/plugin-declare -D
Add .putout.json with:
{
"plugins": {
"declare": "on"
}
}Use options:
- ✅
dismissfor variables you don't want to declare; - ✅
declarationsto declare variables;
{
"rules": {
"declare": ["on", {
"declarations": {
"hello": "import {hello} from 'world'"
},
"dismiss": [
"assert",
"entries",
"parse",
"stringify",
"defineProperty",
"noop",
"join",
"keys",
"values",
"stopAll",
"once",
"putout",
"simport"
]
}]
}
}const hello = 'world';
const object = {};
assign(object, {
hello,
});const hello = 'world';
const object = {};
const {assign} = Object;
assign(object, {
hello,
});const hello = 'world';
const object = {};
const allKeys = keys(object);const hello = 'world';
const object = {};
const {keys} = Object;
const allKeys = keys(object);const object = {};
const allValues = values(object);const {values} = Object;
const object = {};
const allValues = values(object);noop();const noop = () => {};
noop();const isFn = (a) => typeof a === 'function';
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)];entries([1, 2, 3]);const {isArray} = Array;
const entries = (a) => isArray(a) ? a.entries() : Object.entries();
entries([1, 2, 3]);MIT