chore(cloudcmd) eslint-plugin-putout: one-line-destructuring

This commit is contained in:
coderaiser 2019-02-01 15:38:18 +02:00
parent 90cec0169f
commit d93875b751
41 changed files with 83 additions and 236 deletions

View file

@ -3,6 +3,9 @@
"no-console": 0
},
"extends": [
"@putout"
"plugin:putout/recommended"
],
"plugins": [
"putout"
]
}

View file

@ -6,9 +6,7 @@ const {
join,
} = require('path');
const {
EnvironmentPlugin,
} = require('webpack');
const {EnvironmentPlugin} = require('webpack');
const ServiceWorkerWebpackPlugin = require('serviceworker-webpack-plugin');

View file

@ -305,9 +305,7 @@ function checkUpdate() {
}
function showUpdateInfo(data) {
const {
version
} = data;
const {version} = data;
if (version === Info.version)
return;

View file

@ -24,9 +24,7 @@ function main(callback) {
'**[v{{ version }}]' +
'(' + link + 'v{{ version }})**\n';
const {
version
} = Info;
const {version} = Info;
cl((error, versionNew) => {
if (error)
@ -54,9 +52,7 @@ function replaceVersion(name, version, versionNew, callback) {
}
function cl(callback) {
const {
argv
} = process;
const {argv} = process;
const length = argv.length - 1;
const last = process.argv[length];
const regExp = /^--(major|minor|patch)$/;

View file

@ -12,9 +12,7 @@ const pascalCase = require('just-pascal-case');
const isDev = process.env.NODE_ENV === 'development';
const Images = require('./dom/images');
const {
unregisterSW,
} = require('./sw/register');
const {unregisterSW} = require('./sw/register');
const jonny = require('jonny/legacy');
const currify = require('currify/legacy');
@ -330,9 +328,7 @@ function CloudCmdProto(DOM) {
const isRefresh = true;
const history = false;
const noCurrent = options ? options.noCurrent : false;
const {
currentName
} = options;
const {currentName} = options;
CloudCmd.loadDir({
path,
@ -356,15 +352,11 @@ function CloudCmdProto(DOM) {
*/
function ajaxLoad(path, options, panel, callback) {
const create = (error, json) => {
const {
RESTful
} = DOM;
const {RESTful} = DOM;
const name = options.currentName || Info.name;
const obj = jonny.parse(json);
const isRefresh = options.refresh;
const {
noCurrent
} = options;
const {noCurrent} = options;
if (!isRefresh && json)
return createFileTable(obj, panel, options, callback);
@ -426,9 +418,7 @@ function CloudCmdProto(DOM) {
const names = ['file', 'path', 'link', 'pathLink'];
Files.get(names, (error, templFile, templPath, templLink, templPathLink) => {
const {
Dialog
} = DOM;
const {Dialog} = DOM;
const panel = panelParam || DOM.getPanel();
const {prefix} = CloudCmd;
@ -440,9 +430,7 @@ function CloudCmdProto(DOM) {
if (error)
return Dialog.alert(TITLE, error.responseText);
const {
childNodes
} = panel;
const {childNodes} = panel;
let i = childNodes.length;
while (i--)

View file

@ -108,9 +108,7 @@ function BufferProto() {
exec.parallel([copy, cut], (error, cp, ct) => {
const opStr = cp ? 'copy' : 'move';
const opData = cp || ct;
const {
Operation
} = CloudCmd;
const {Operation} = CloudCmd;
const msg = 'Path is same!';
const path = Info.dirPath;

View file

@ -106,9 +106,7 @@ test('current-file: setCurrentName: return', (t) => {
});
test('current-file: getParentDirPath: result', (t) => {
const {
DOM,
} = global;
const {DOM} = global;
const getCurrentDirPath = returns('/D/Films/+++favorite films/');
const getCurrentDirName = returns('+++favorite films');

View file

@ -8,14 +8,10 @@ const Images = require('./images');
const {FS} = require('../../common/cloudfunc');
const DOM = require('.');
const {
getCurrentDirPath: getPathWhenRootEmpty,
} = DOM;
const {getCurrentDirPath: getPathWhenRootEmpty} = DOM;
module.exports = (items) => {
const {
Dialog
} = DOM;
const {Dialog} = DOM;
if (items.length)
Images.show('top');

View file

@ -20,9 +20,7 @@ const isContainClass = (element, className) => {
if (Array.isArray(className))
return className.some(currify(isContainClass, element));
const {
classList
} = element;
const {classList} = element;
return classList.contains(className);
};

View file

@ -4,9 +4,7 @@ const test = require('supertape');
const {create} = require('auto-globals');
const tryCatch = require('try-catch');
const {
isContainClass,
} = require('./dom-tree');
const {isContainClass} = require('./dom-tree');
test('dom: isContainClass: no element', (t) => {
const [e] = tryCatch(isContainClass);

View file

@ -47,9 +47,7 @@ function getElement() {
/* Функция создаёт картинку загрузки */
module.exports.loading = () => {
const element = getElement();
const {
classList
} = element;
const {classList} = element;
classList.add(LOADING, LoadingImage);
classList.remove(ERROR, HIDDEN);
@ -60,9 +58,7 @@ module.exports.loading = () => {
/* Функция создаёт картинку ошибки загрузки */
module.exports.error = () => {
const element = getElement();
const {
classList
} = element;
const {classList} = element;
classList.add(ERROR);
classList.remove(HIDDEN, LOADING, LoadingImage);

View file

@ -319,9 +319,7 @@ function CmdProto() {
*/
this.getCurrentData = (callback, currentFile) => {
let hash;
const {
Dialog
} = DOM;
const {Dialog} = DOM;
const Info = DOM.CurrentInfo;
const current = currentFile || DOM.getCurrentFile();
const path = DOM.getCurrentPath(current);
@ -334,9 +332,7 @@ function CmdProto() {
if (itype.object(data))
data = jonny.stringify(data);
const {
length
} = data;
const {length} = data;
if (hash && length < ONE_MEGABYTE)
DOM.saveDataToStorage(path, data, hash);
@ -452,9 +448,7 @@ function CmdProto() {
*/
this.expandSelection = () => {
const msg = 'expand';
const {
files
} = CurrentInfo;
const {files} = CurrentInfo;
selectByPattern(msg, files);
};
@ -464,9 +458,7 @@ function CmdProto() {
*/
this.shrinkSelection = () => {
const msg = 'shrink';
const {
files
} = CurrentInfo;
const {files} = CurrentInfo;
selectByPattern(msg, files);
};
@ -548,9 +540,7 @@ function CmdProto() {
* check storage hash
*/
this.checkStorageHash = (name, callback) => {
const {
parallel
} = exec;
const {parallel} = exec;
const loadHash = DOM.loadCurrentHash;
const nameHash = name + '-hash';
const getStoreHash = exec.with(Storage.get, nameHash);
@ -758,9 +748,7 @@ function CmdProto() {
* @currentFile
*/
this.renameCurrent = (current) => {
const {
Dialog
} = DOM;
const {Dialog} = DOM;
if (!DOM.isCurrentFile(current))
current = DOM.getCurrentFile();
@ -878,9 +866,7 @@ function CmdProto() {
this.goToDirectory = () => {
const msg = 'Go to directory:';
const path = CurrentInfo.dirPath;
const {
Dialog
} = DOM;
const {Dialog} = DOM;
const cancel = false;
const setPath = (path) => ({
path
@ -893,9 +879,7 @@ function CmdProto() {
this.duplicatePanel = () => {
const Info = CurrentInfo;
const {
isDir
} = Info;
const {isDir} = Info;
const panel = Info.panelPassive;
const noCurrent = !Info.isOnePanel;
@ -939,9 +923,7 @@ function CmdProto() {
path: dirPathPassive,
panel
}, () => {
const {
files
} = Info;
const {files} = Info;
const length = files.length - 1;
if (currentIndex > length)

View file

@ -25,9 +25,7 @@ module.exports = (name, options, callback = options) => {
const module = findObjByNameInArr(modules.remote, name);
const isArray = itype.array(module.local);
const {
version
} = module;
const {version} = module;
let remoteTmpls;
let local;

View file

@ -5,9 +5,7 @@
const itype = require('itype/legacy');
const {FS} = require('../../common/cloudfunc');
const {
encode,
} = require('../../common/entity');
const {encode} = require('../../common/entity');
module.exports = new RESTful();

View file

@ -17,9 +17,7 @@ const {TITLE} = CloudCmd;
const onEnd = wraptile(_onEnd);
const loadFile = wraptile(_loadFile);
const {
getCurrentDirPath: getPathWhenRootEmpty
} = DOM;
const {getCurrentDirPath: getPathWhenRootEmpty} = DOM;
module.exports = (dir, files) => {
if (!files) {
@ -47,9 +45,7 @@ function _onEnd(currentName) {
function _loadFile(dir, n, file, callback) {
let i = 0;
const {
name
} = file;
const {name} = file;
const path = dir + name;
const {prefixURL} = CloudCmd;
const api = prefixURL + FS;

View file

@ -52,9 +52,7 @@ function setState(state) {
module.exports.getValue = (name, element) => {
const el = getElementByName(name, element);
const {
type
} = el;
const {type} = el;
switch(type) {
case 'checkbox':
@ -70,9 +68,7 @@ module.exports.getValue = (name, element) => {
module.exports.setValue = (name, value, element) => {
const el = getElementByName(name, element);
const {
type
} = el;
const {type} = el;
switch(type) {
case 'checkbox':

View file

@ -56,9 +56,7 @@ function KeyProto() {
}
function listener(event) {
const {
keyCode
} = event;
const {keyCode} = event;
const alt = event.altKey;
const ctrl = event.ctrlKey;
const shift = event.shiftKey;
@ -132,9 +130,7 @@ function KeyProto() {
const {Operation} = CloudCmd;
const {
keyCode
} = event;
const {keyCode} = event;
const alt = event.altKey;
const shift = event.shiftKey;

View file

@ -4,9 +4,7 @@ const test = require('supertape');
const stub = require('@cloudcmd/stub');
const dir = './';
const {
getDOM,
} = require('./globals.fixture');
const {getDOM} = require('./globals.fixture');
global.DOM = getDOM();

View file

@ -3,9 +3,7 @@
const KEY = require('../key');
const Info = DOM.CurrentInfo;
const {
Dialog
} = DOM;
const {Dialog} = DOM;
const fullstore = require('fullstore/legacy');
const store = fullstore('');
@ -35,9 +33,7 @@ const rmFirst = (a) => {
module.exports = (key, event) => {
const current = Info.element;
const {
keyCode
} = event;
const {keyCode} = event;
const prevStore = store();
const value = store(prevStore.concat(key));

View file

@ -21,12 +21,8 @@ const {
global.DOM = getDOM();
global.CloudCmd = getCloudCmd();
const {
DOM
} = global;
const {
Buffer
} = DOM;
const {DOM} = global;
const {Buffer} = DOM;
const KEY = require(pathKey);
const vim = require(pathVim);

View file

@ -11,9 +11,7 @@ const getRange = require('./get-range');
const getIndex = currify(require('./get-index'));
const uploadFiles = require('../dom/upload-files');
const {
FS,
} = require('../../common/cloudfunc');
const {FS} = require('../../common/cloudfunc');
const NBSP_REG = RegExp(String.fromCharCode(160), 'g');
const SPACE = ' ';
@ -51,9 +49,7 @@ const execAll = currify((funcs, event) => {
});
const Info = DOM.CurrentInfo;
const {
Events
} = DOM;
const {Events} = DOM;
const EventsFiles = {
mousedown: exec.with(execIfNotUL, setCurrentFileByEvent),
click: execAll([
@ -117,13 +113,9 @@ module.exports.initKeysPanel = () => {
return;
Events.addClick(keysElement, ({target}) => {
const {
id
} = target;
const {id} = target;
const operation = (name) => {
const {
Operation
} = CloudCmd;
const {Operation} = CloudCmd;
const fn = Operation.show.bind(null, name);
return fn;
@ -310,9 +302,7 @@ function onTouch(event) {
function onDragStart(event) {
const {prefixURL} = CloudCmd;
const element = getLIElement(event.target);
const {
isDir
} = Info;
const {isDir} = Info;
let link = DOM.getCurrentLink(element);
let name = DOM.getCurrentName(element);
@ -445,12 +435,8 @@ function dragndrop() {
* to upload file from download bar
*/
const onDragOver = (event) => {
const {
dataTransfer
} = event;
const {
effectAllowed
} = dataTransfer;
const {dataTransfer} = event;
const {effectAllowed} = dataTransfer;
if (/move|linkMove/.test(effectAllowed))
dataTransfer.dropEffect = 'move';
@ -471,9 +457,7 @@ function dragndrop() {
function unload() {
DOM.Events.add(['unload', 'beforeunload'], (event) => {
const {
Key
} = CloudCmd;
const {Key} = CloudCmd;
const isBind = Key && Key.isBind();
if (isBind)

View file

@ -8,12 +8,8 @@ CloudCmd.Contact = exports;
const olark = require('@cloudcmd/olark');
const Images = require('../dom/images');
const {
Events
} = DOM;
const {
Key
} = CloudCmd;
const {Events} = DOM;
const {Key} = CloudCmd;
module.exports.show = show;
module.exports.hide = hide;

View file

@ -16,9 +16,7 @@ const {
Images
} = DOM;
const {
config
} = CloudCmd;
const {config} = CloudCmd;
let Menu;
@ -74,9 +72,7 @@ module.exports.show = (options) => {
.setOption('keyMap', 'default');
Info.getData((error, data) => {
const {
path
} = Info;
const {path} = Info;
const name = getName();
if (error)

View file

@ -11,9 +11,7 @@ const supermenu = require('supermenu');
const reject = Promise.reject.bind(Promise);
const Info = DOM.CurrentInfo;
const {
Dialog
} = DOM;
const {Dialog} = DOM;
const TITLE = 'Edit Names';
const alert = currify(Dialog.alert, TITLE);
@ -66,9 +64,7 @@ function keyListener(event) {
const ctrl = event.ctrlKey;
const meta = event.metaKey;
const ctrlMeta = ctrl || meta;
const {
Key
} = CloudCmd;
const {Key} = CloudCmd;
if (!ctrlMeta || event.keyCode !== Key.S)
return;

View file

@ -196,9 +196,7 @@ function isPath(x, y) {
}
function beforeShow(callback, params) {
const {
name
} = params;
const {name} = params;
const el = DOM.getCurrentByPosition({
x: params.x,
y: params.y
@ -231,9 +229,7 @@ function _uploadTo(nameModule) {
if (error)
return;
const {
name
} = Info;
const {name} = Info;
const execFrom = CloudCmd.execFromModule;
execFrom(nameModule, 'uploadFile', name, data);

View file

@ -9,9 +9,7 @@ module.exports = (currentName, names, removedNames) => {
const i = names.indexOf(currentName);
const nextNames = notOneOf(names, removedNames);
const {
length
} = nextNames;
const {length} = nextNames;
if (nextNames[i])
return nextNames[i];

View file

@ -11,9 +11,7 @@ const {promisify} = require('es6-promisify');
const exec = require('execon');
const loadJS = require('load.js').js;
const {
encode,
} = require('../../../common/entity');
const {encode} = require('../../../common/entity');
const RESTful = require('../../dom/rest');
const removeExtension = require('./remove-extension');
@ -389,9 +387,7 @@ function twopack(operation, type) {
let fileFrom;
let currentName = Info.name;
const {
Images
} = DOM;
const {Images} = DOM;
const {
path,

View file

@ -9,9 +9,7 @@ const {
} = DOM;
const forEachKey = require('for-each-key/legacy');
const {
TITLE,
} = CloudCmd;
const {TITLE} = CloudCmd;
module.exports = (options, callback) => (emitter) => {
if (!callback) {

View file

@ -28,9 +28,7 @@ let Loaded;
let Terminal;
const loadAll = async () => {
const {
prefix,
} = CloudCmd;
const {prefix} = CloudCmd;
const prefixGritty = getPrefix();
const js = `${prefixGritty}/gritty.js`;

View file

@ -40,9 +40,7 @@ const Name = 'View';
CloudCmd[Name] = module.exports;
const Info = DOM.CurrentInfo;
const {
Key
} = CloudCmd;
const {Key} = CloudCmd;
const basename = (a) => a.split('/').pop();
let El;

View file

@ -31,9 +31,7 @@ test('sw: lesten: no sw', (t) => {
});
test('sw: register: registerSW: no serviceWorker', async (t, {navigator}) => {
const {
registerSW,
} = reRequire('./register');
const {registerSW} = reRequire('./register');
delete navigator.serviceWorker;

View file

@ -3,9 +3,7 @@
const rendy = require('rendy/legacy');
const currify = require('currify/legacy');
const store = require('fullstore/legacy');
const {
encode
} = require('./entity');
const {encode} = require('./entity');
const btoa = require('./btoa');
const getHeaderField = currify(_getHeaderField);
@ -44,9 +42,7 @@ module.exports.getTitle = (options) => {
options = options || {};
const path = options.path || Path();
const {
name
} = options;
const {name} = options;
const array = [
name || NAME,
@ -122,9 +118,7 @@ module.exports.buildFromJSON = (params) => {
const path = encode(json.path);
const {
files
} = json;
const {files} = json;
const sort = params.sort || 'name';
const order = params.order || 'asc';

View file

@ -2,9 +2,7 @@
const test = require('supertape');
const cloudfunc = require('./cloudfunc');
const {
_getSize,
} = cloudfunc;
const {_getSize} = cloudfunc;
test('cloudfunc: getSize: dir', (t) => {
const type = 'directory';

View file

@ -179,7 +179,6 @@
"@cloudcmd/modal": "^1.0.0",
"@cloudcmd/olark": "^2.0.1",
"@cloudcmd/stub": "^2.0.0",
"@putout/eslint-config": "^1.0.1",
"auto-globals": "^1.7.0",
"babel-loader": "^8.0.0",
"babel-plugin-macros": "^2.2.1",
@ -193,6 +192,7 @@
"es6-promisify": "^6.0.0",
"eslint": "^5.0.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-putout": "^1.0.1",
"extract-text-webpack-plugin": "^4.0.0-alpha.0",
"fast-async": "^7.0.6",
"file-loader": "^3.0.1",

View file

@ -31,9 +31,7 @@ const save = promisify(_save);
const formatMsg = currify((a, b) => CloudFunc.formatMsg(a, b));
const {
apiURL
} = CloudFunc;
const {apiURL} = CloudFunc;
const changeEmitter = new Emitter();
const ConfigPath = path.join(DIR, 'json/config.json');

View file

@ -67,9 +67,7 @@ const push = currify((socket, key, value) => {
});
function getHost(socket) {
const {
remoteAddress
} = socket.request.connection;
const {remoteAddress} = socket.request.connection;
const {
name,

View file

@ -1,8 +1,6 @@
'use strict';
const {
env
} = process;
const {env} = process;
const up = (a) => a.toUpperCase();
module.exports = parse;

View file

@ -4,9 +4,7 @@ const net = require('net');
const repl = require('repl');
module.exports = net.createServer((socket) => {
const {
pid
} = process;
const {pid} = process;
const addr = socket.remoteAddress;
const port = socket.remotePort;

View file

@ -84,9 +84,7 @@ function sendData(params, callback) {
if (isMD)
return markdown(p.name, p.request, callback);
const {
method
} = p.request;
const {method} = p.request;
switch(method) {
case 'GET':
@ -181,9 +179,7 @@ function onPUT(name, body, callback) {
const from = root(files.from);
const to = root(files.to);
const {
names
} = files;
const {names} = files;
if (!names)
return fs.rename(from, to, fn);

View file

@ -2,15 +2,11 @@
const format = require('format-io');
const {
version
} = require('../../package');
const {version} = require('../../package');
const config = require('../config');
const getMemory = () => {
const {
rss
} = process.memoryUsage();
const {rss} = process.memoryUsage();
return format.size(rss);
};

View file

@ -4,9 +4,7 @@ const DIR_SERVER = './';
const DIR_COMMON = '../common/';
const fs = require('fs');
const {
promisify,
} = require('util');
const {promisify} = require('util');
const flop = require('flop');
const ponse = require('ponse');
@ -113,13 +111,9 @@ function indexProcessing(options) {
const noConfig = !config('configDialog');
const noConsole = !config('console');
const noTerminal = !config('terminal');
const {
panel
} = options;
const {panel} = options;
let {
data
} = options;
let {data} = options;
if (noKeysPanel)
data = hideKeysPanel(data);