mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint
This commit is contained in:
parent
8f466b4c9a
commit
111eba8c31
33 changed files with 139 additions and 155 deletions
|
|
@ -150,7 +150,7 @@ test('current-file: isCurrentFile: no', (t) => {
|
|||
global.DOM = DOM;
|
||||
global.CloudCmd = CloudCmd;
|
||||
|
||||
t.equal(result, expect, 'should equal');
|
||||
t.equal(result, expect);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,7 @@ module.exports.getById = (id, element = document) => {
|
|||
* @param className - className
|
||||
* @param element - element
|
||||
*/
|
||||
module.exports.getByClass = (className, element = document) => {
|
||||
return DOM.getByClassAll(className, element)[0];
|
||||
};
|
||||
module.exports.getByClass = (className, element = document) => DOM.getByClassAll(className, element)[0];
|
||||
|
||||
module.exports.getByDataName = (attribute, element = document) => {
|
||||
const selector = '[' + 'data-name="' + attribute + '"]';
|
||||
|
|
|
|||
|
|
@ -14,7 +14,5 @@ module.exports.clear = () => {
|
|||
list = [];
|
||||
};
|
||||
|
||||
module.exports.get = () => {
|
||||
return list;
|
||||
};
|
||||
module.exports.get = () => list;
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ const timeout = getTimeoutOnce(2000);
|
|||
|
||||
module.exports.get = getFile;
|
||||
|
||||
async function getFile(name) {
|
||||
function getFile(name) {
|
||||
const type = itype(name);
|
||||
check(name);
|
||||
|
||||
if (type === 'string')
|
||||
return await getModule(name);
|
||||
return getModule(name);
|
||||
|
||||
if (type === 'array')
|
||||
return Promise.all(name.map(getFile));
|
||||
|
|
@ -35,7 +35,7 @@ function check(name) {
|
|||
throw Error('name could not be empty!');
|
||||
}
|
||||
|
||||
async function getModule(name) {
|
||||
function getModule(name) {
|
||||
const regExpHTML = new RegExp(FILES_HTML + '|' + FILES_HTML_ROOT);
|
||||
const regExpJSON = new RegExp(FILES_JSON);
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ function getPath(name, isHTML, isJSON) {
|
|||
|
||||
function showError(name) {
|
||||
const str = 'Wrong file name: ' + name;
|
||||
const error = new Error(str);
|
||||
const error = Error(str);
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -509,9 +509,7 @@ module.exports.saveDataToStorage = async (name, data, hash) => {
|
|||
return hash;
|
||||
};
|
||||
|
||||
module.exports.getFM = () => {
|
||||
return DOM.getPanel().parentElement;
|
||||
};
|
||||
module.exports.getFM = () => DOM.getPanel().parentElement;
|
||||
|
||||
module.exports.getPanelPosition = (panel) => {
|
||||
panel = panel || DOM.getPanel();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ test('cloudcmd: client: io: replaceHash', (t) => {
|
|||
const result = _replaceHash(url);
|
||||
const expected = '/hello/%23%23%23%23world';
|
||||
|
||||
t.equal(result, expected, 'should equal');
|
||||
t.equal(result, expected);
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ module.exports = (name, options, callback = options) => {
|
|||
local = [module.local];
|
||||
}
|
||||
|
||||
const localURL = local.map((url) => {
|
||||
return prefix + url;
|
||||
});
|
||||
const localURL = local.map((url) => prefix + url);
|
||||
|
||||
const remoteURL = remoteTmpls.map((tmpl) => {
|
||||
return rendy(tmpl, {
|
||||
|
|
|
|||
|
|
@ -14,57 +14,64 @@ module.exports = async (key, event) => {
|
|||
await vim(key, operations);
|
||||
};
|
||||
|
||||
const getOperations = (event) => {
|
||||
return {
|
||||
escape: DOM.unselectFiles,
|
||||
remove: () => {
|
||||
CloudCmd.Operation.show('delete');
|
||||
},
|
||||
copy: () => {
|
||||
DOM.Buffer.copy();
|
||||
DOM.unselectFiles();
|
||||
},
|
||||
select: () => {
|
||||
const current = Info.element;
|
||||
DOM.toggleSelectedFile(current);
|
||||
},
|
||||
paste: DOM.Buffer.paste,
|
||||
moveNext: ({count, isVisual, isDelete}) => {
|
||||
setCurrent('next', {
|
||||
count,
|
||||
isVisual,
|
||||
isDelete,
|
||||
});
|
||||
},
|
||||
movePrevious: ({count, isVisual, isDelete}) => {
|
||||
setCurrent('previous', {
|
||||
count,
|
||||
isVisual,
|
||||
isDelete,
|
||||
});
|
||||
},
|
||||
find: async () => {
|
||||
event.preventDefault();
|
||||
const [, value] = await Dialog.prompt('Find', '');
|
||||
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
const names = Info.files.map(DOM.getCurrentName);
|
||||
const [result] = finder.find(value, names);
|
||||
|
||||
DOM.setCurrentByName(result);
|
||||
},
|
||||
findNext: () => {
|
||||
const name = finder.findNext();
|
||||
DOM.setCurrentByName(name);
|
||||
},
|
||||
findPrevious: () => {
|
||||
const name = finder.findPrevious();
|
||||
DOM.setCurrentByName(name);
|
||||
},
|
||||
};
|
||||
};
|
||||
const getOperations = (event) => ({
|
||||
escape: DOM.unselectFiles,
|
||||
|
||||
remove: () => {
|
||||
CloudCmd.Operation.show('delete');
|
||||
},
|
||||
|
||||
copy: () => {
|
||||
DOM.Buffer.copy();
|
||||
DOM.unselectFiles();
|
||||
},
|
||||
|
||||
select: () => {
|
||||
const current = Info.element;
|
||||
DOM.toggleSelectedFile(current);
|
||||
},
|
||||
|
||||
paste: DOM.Buffer.paste,
|
||||
|
||||
moveNext: ({count, isVisual, isDelete}) => {
|
||||
setCurrent('next', {
|
||||
count,
|
||||
isVisual,
|
||||
isDelete,
|
||||
});
|
||||
},
|
||||
|
||||
movePrevious: ({count, isVisual, isDelete}) => {
|
||||
setCurrent('previous', {
|
||||
count,
|
||||
isVisual,
|
||||
isDelete,
|
||||
});
|
||||
},
|
||||
|
||||
find: async () => {
|
||||
event.preventDefault();
|
||||
const [, value] = await Dialog.prompt('Find', '');
|
||||
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
const names = Info.files.map(DOM.getCurrentName);
|
||||
const [result] = finder.find(value, names);
|
||||
|
||||
DOM.setCurrentByName(result);
|
||||
},
|
||||
|
||||
findNext: () => {
|
||||
const name = finder.findNext();
|
||||
DOM.setCurrentByName(name);
|
||||
},
|
||||
|
||||
findPrevious: () => {
|
||||
const name = finder.findPrevious();
|
||||
DOM.setCurrentByName(name);
|
||||
},
|
||||
});
|
||||
|
||||
module.exports.selectFile = selectFile;
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ function _upload(callback, file) {
|
|||
});
|
||||
}
|
||||
|
||||
async function loadFiles() {
|
||||
function loadFiles() {
|
||||
const js = '//api.filepicker.io/v2/filepicker.js';
|
||||
|
||||
return Promise.all([
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
const currify = require('currify');
|
||||
|
||||
const isType = currify((type, object, name) => {
|
||||
return typeof object[name] === type;
|
||||
});
|
||||
const isType = currify((type, object, name) => typeof object[name] === type);
|
||||
|
||||
const isBool = isType('boolean');
|
||||
|
||||
|
|
|
|||
|
|
@ -96,9 +96,7 @@ function getEditor() {
|
|||
return editor;
|
||||
}
|
||||
|
||||
module.exports.getElement = () => {
|
||||
return Element;
|
||||
};
|
||||
module.exports.getElement = () => Element;
|
||||
|
||||
module.exports.hide = () => {
|
||||
CloudCmd.View.hide();
|
||||
|
|
|
|||
|
|
@ -63,9 +63,7 @@ function getEnv() {
|
|||
ACTIVE_DIR: DOM.getCurrentDirPath.bind(DOM),
|
||||
PASSIVE_DIR: DOM.getNotCurrentDirPath.bind(DOM),
|
||||
CURRENT_NAME: DOM.getCurrentName.bind(DOM),
|
||||
CURRENT_PATH: () => {
|
||||
return Info.path;
|
||||
},
|
||||
CURRENT_PATH: () => Info.path,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -269,9 +269,7 @@ async function promptDelete() {
|
|||
} else {
|
||||
const current = DOM.getCurrentFile();
|
||||
const isDir = DOM.isCurrentIsDir(current);
|
||||
const getType = (isDir) => {
|
||||
return isDir ? 'directory' : 'file';
|
||||
};
|
||||
const getType = (isDir) => isDir ? 'directory' : 'file';
|
||||
|
||||
const type = getType(isDir) + ' ';
|
||||
|
||||
|
|
@ -369,7 +367,7 @@ async function _processFiles(options, data) {
|
|||
const operation = isCopy ? copyFn : moveFn;
|
||||
|
||||
if (shouldAsk && config(option)) {
|
||||
const [cancel, newTo] = await prompt(title, to, names.map(encode));
|
||||
const [cancel, newTo] = prompt(title, to, names.map(encode));
|
||||
|
||||
if (!cancel)
|
||||
ask(newTo);
|
||||
|
|
@ -485,7 +483,7 @@ function twopack(operation, type) {
|
|||
});
|
||||
}
|
||||
|
||||
async function prompt(msg, to, names) {
|
||||
function prompt(msg, to, names) {
|
||||
const n = names.length;
|
||||
const [name] = names;
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ test('user-menu: getUserMenu', (t) => {
|
|||
|
||||
const [key] = Object.keys(result);
|
||||
|
||||
t.equal(key, 'F2 - Rename file', 'should equal');
|
||||
t.equal(key, 'F2 - Rename file');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -247,12 +247,10 @@ function hide() {
|
|||
|
||||
function viewImage(path, prefixURL) {
|
||||
const isSupportedImage = (a) => isImage(a) || a === path;
|
||||
const makeTitle = (path) => {
|
||||
return {
|
||||
href: `${prefixURL}${path}`,
|
||||
title: encode(basename(path)),
|
||||
};
|
||||
};
|
||||
const makeTitle = (path) => ({
|
||||
href: `${prefixURL}${path}`,
|
||||
title: encode(basename(path)),
|
||||
});
|
||||
|
||||
const names = Info.files
|
||||
.map(DOM.getCurrentPath)
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ test('cloudcmd: client: view: initConfig: no options', (t) => {
|
|||
global.CloudCmd = CloudCmd;
|
||||
global.DOM = DOM;
|
||||
|
||||
t.equal(typeof config, 'object', 'should equal');
|
||||
t.equal(typeof config, 'object');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue