chore: lint

This commit is contained in:
coderaiser 2023-12-04 20:13:53 +02:00
parent 094df666f4
commit b04cbcd8c5
3 changed files with 37 additions and 40 deletions

View file

@ -13,9 +13,6 @@
"base64": {
"convert-typeof-to-is-type": "off"
},
"route.spec.js": {
"tape/convert-ok-to-match": "off"
},
"*.md": {
"nodejs/convert-commonjs-to-esm": "on"
},

View file

@ -28,46 +28,46 @@ const getOperations = (event, deps) => {
toggleSelectedFile,
Buffer = {},
} = deps;
return {
escape: unselectFiles,
remove: () => {
Operation.show('delete');
},
makeDirectory: () => {
event.stopImmediatePropagation();
event.preventDefault();
DOM.promptNewDir();
},
makeFile: () => {
event.stopImmediatePropagation();
event.preventDefault();
DOM.promptNewFile();
},
terminal: () => {
CloudCmd.Terminal.show();
},
edit: () => {
CloudCmd.EditFileVim.show();
},
copy: () => {
Buffer.copy();
unselectFiles();
},
select: () => {
const current = Info.element;
toggleSelectedFile(current);
},
paste: Buffer.paste,
moveNext: ({count, isVisual, isDelete}) => {
setCurrent('next', {
count,
@ -80,7 +80,7 @@ const getOperations = (event, deps) => {
Operation,
});
},
movePrevious: ({count, isVisual, isDelete}) => {
setCurrent('previous', {
count,
@ -93,25 +93,25 @@ const getOperations = (event, deps) => {
Operation,
});
},
find: async () => {
event.preventDefault();
const [, value] = await Dialog.prompt('Find', '');
if (!value)
return;
const names = Info.files.map(getCurrentName);
const [result] = finder.find(value, names);
setCurrentByName(result);
},
findNext: () => {
const name = finder.findNext();
setCurrentByName(name);
},
findPrevious: () => {
const name = finder.findPrevious();
setCurrentByName(name);
@ -123,33 +123,33 @@ module.exports.selectFile = selectFileNotParent;
function selectFileNotParent(current, {getCurrentName, selectFile} = DOM) {
const name = getCurrentName(current);
if (name === '..')
return;
selectFile(current);
}
function setCurrent(sibling, {count, isVisual, isDelete}, {Info, setCurrentFile, unselectFiles, Operation}) {
let current = Info.element;
const select = isVisual ? selectFileNotParent : unselectFiles;
select(current);
const position = `${sibling}Sibling`;
for (let i = 0; i < count; i++) {
const next = current[position];
if (!next)
break;
current = next;
select(current);
}
setCurrentFile(current);
if (isDelete)
Operation.show('delete');
}

View file

@ -43,7 +43,7 @@ test('cloudcmd: route: buttons: no console', async (t) => {
options,
});
t.ok(/icon-console none/.test(body), 'should hide console');
t.match(body, 'icon-console none', 'should hide console');
t.end();
});
@ -77,7 +77,7 @@ test('cloudcmd: route: buttons: no config', async (t) => {
options,
});
t.ok(/icon-config none/.test(body), 'should hide config');
t.match(body, 'icon-config none', 'should hide config');
t.end();
});
@ -94,7 +94,7 @@ test('cloudcmd: route: buttons: no contact', async (t) => {
options,
});
t.ok(/icon-contact none/.test(body), 'should hide contact');
t.match(body, 'icon-contact none', 'should hide contact');
t.end();
});
@ -111,7 +111,7 @@ test('cloudcmd: route: buttons: one file panel: move', async (t) => {
options,
});
t.ok(/icon-move none/.test(body), 'should hide move button');
t.match(body, 'icon-move none', 'should hide move button');
t.end();
});
@ -128,7 +128,7 @@ test('cloudcmd: route: buttons: one file panel: copy', async (t) => {
options,
});
t.ok(/icon-copy none/.test(body), 'should hide copy button');
t.match(body, 'icon-copy none', 'should hide copy button');
t.end();
});
@ -145,7 +145,7 @@ test('cloudcmd: route: keys panel: hide', async (t) => {
options,
});
t.ok(/keyspanel hidden/.test(body), 'should hide keyspanel');
t.match(body, 'keyspanel hidden', 'should hide keyspanel');
t.end();
});
@ -246,7 +246,7 @@ test('cloudcmd: route: sendIndex: encode', async (t) => {
stopAll();
t.ok(body.includes(nameEncoded), 'should encode name');
t.match(body, nameEncoded, 'should encode name');
t.end();
});
@ -338,7 +338,7 @@ test('cloudcmd: route: buttons: no terminal', async (t) => {
options,
});
t.ok(/icon-terminal none/.test(body), 'should hide terminal');
t.match(body, 'icon-terminal none', 'should hide terminal');
t.end();
});
@ -358,7 +358,7 @@ test('cloudcmd: route: no termianl: /fs', async (t) => {
options,
});
t.ok(/icon-terminal none/.test(body), 'should hide terminal');
t.match(body, 'icon-terminal none', 'should hide terminal');
t.end();
});
@ -376,7 +376,7 @@ test('cloudcmd: route: buttons: terminal: can not load', async (t) => {
options,
});
t.ok(/icon-terminal none/.test(body), 'should not enable terminal');
t.match(body, 'icon-terminal none', 'should not enable terminal');
t.end();
});
@ -427,7 +427,7 @@ test('cloudcmd: route: dropbox', async (t) => {
const readdir = _getReadDir(config);
const [e] = await tryToCatch(readdir, '/root');
t.ok(/API/.test(e.message), 'should contain word token in message');
t.match(e.message, 'API', 'should contain word token in message');
t.end();
});