chore(cloudcmd) lint

This commit is contained in:
coderaiser 2022-05-12 22:29:01 +03:00
parent b3f3510b2d
commit 42248bc0f4
10 changed files with 24 additions and 46 deletions

View file

@ -40,13 +40,6 @@ load.addErrorListener((e, src) => {
function CloudCmdProto(DOM) {
let Listeners;
const log = (...a) => {
if (!isDev)
return;
console.log(...a);
};
Emitify.call(this);
const CloudCmd = this;
@ -57,7 +50,12 @@ function CloudCmdProto(DOM) {
Files,
} = DOM;
this.log = log;
this.log = (...a) => {
if (!isDev)
return;
console.log(...a);
};
this.prefix = '';
this.prefixSocket = '';
this.prefixURL = '';
@ -67,8 +65,7 @@ function CloudCmdProto(DOM) {
this.MIN_ONE_PANEL_WIDTH = 1155;
this.HOST = location.origin || location.protocol + '//' + location.host;
const TITLE = 'Cloud Commander';
this.TITLE = TITLE;
this.TITLE = 'Cloud Commander';
this.sort = {
left: 'name',

View file

@ -22,9 +22,7 @@ module.exports = window.CloudCmd = async (config) => {
window.Util = require('../common/util');
window.CloudFunc = require('../common/cloudfunc');
const DOM = require('./dom');
window.DOM = DOM;
window.DOM = require('./dom');
window.CloudCmd = require('./client');
await register(config);

View file

@ -5,12 +5,8 @@
const Util = require('../../common/util');
const Images = require('./images');
const load = require('./load');
const Files = require('./files');
const RESTful = require('./rest');
const IO = require('./io');
const Storage = require('./storage');
const Dialog = require('./dialog');
const renameCurrent = require('./operations/rename-current');
const CurrentFile = require('./current-file');
@ -26,12 +22,12 @@ const DOM = {
const CurrentInfo = {};
DOM.Images = Images;
DOM.load = load;
DOM.Files = Files;
DOM.load = require('./load');
DOM.Files = require('./files');
DOM.RESTful = RESTful;
DOM.IO = IO;
DOM.IO = require('./io');
DOM.Storage = Storage;
DOM.Dialog = Dialog;
DOM.Dialog = require('./dialog');
DOM.CurrentInfo = CurrentInfo;
module.exports = DOM;
@ -791,7 +787,6 @@ module.exports.updateCurrentInfo = (currentFile) => {
const info = DOM.CurrentInfo;
const current = currentFile || DOM.getCurrentFile();
const files = current.parentElement;
const panel = files.parentElement || DOM.getPanel();
const panelPassive = DOM.getPanel({
active: false,
@ -814,7 +809,7 @@ module.exports.updateCurrentInfo = (currentFile) => {
info.mode = DOM.getCurrentMode(current);
info.name = name;
info.path = DOM.getCurrentPath(current);
info.panel = panel;
info.panel = files.parentElement || DOM.getPanel();
info.panelPassive = panelPassive;
info.size = DOM.getCurrentSize(current);
info.isDir = DOM.isCurrentIsDir();

View file

@ -29,12 +29,10 @@ test('cloudcmd: client: dom: renameCurrent: file exist', async (t) => {
const name = 'hello';
const {CloudCmd} = global;
const CloudCmdStub = {
global.CloudCmd = {
refresh: stub(),
};
global.CloudCmd = CloudCmdStub;
const prompt = stub().returns([null, name]);
const confirm = stub().returns([true]);

View file

@ -13,19 +13,15 @@ const {
getCloudCmd,
} = require('./vim/globals.fixture');
const DOM = getDOM();
const CloudCmd = getCloudCmd();
global.DOM = DOM;
global.CloudCmd = CloudCmd;
global.DOM = getDOM();
global.CloudCmd = getCloudCmd();
test('cloudcmd: client: key: enable vim', async (t) => {
const vim = stub();
const configStub = stub().returns(true);
const {CloudCmd} = global;
const {config} = CloudCmd;
CloudCmd.config = configStub;
CloudCmd.config = stub().returns(true);
mockRequire('./vim', vim);
const {_listener, setBind} = reRequire('.');

View file

@ -235,10 +235,9 @@ test('cloudcmd: client: key: paste', (t) => {
});
test('cloudcmd: client: key: selectFile: ..', (t) => {
const selectFile = stub();
const getCurrentName = stub();
DOM.selectFile = selectFile;
DOM.selectFile = stub();
DOM.getCurrentName = () => '..';
const current = {};

View file

@ -22,7 +22,6 @@ module.exports.hide = () => {
};
async function show(name, options = {}) {
const relativeQuery = '?relative';
const {
positionLoad,
relative,
@ -31,7 +30,7 @@ async function show(name, options = {}) {
Images.show.load(positionLoad);
if (relative)
name += relativeQuery;
name += '?relative';
const [error, innerHTML] = await Markdown.read(name);
Images.hide();

View file

@ -38,14 +38,12 @@ test('cloudcmd: client: view: types: detectType', async (t) => {
});
test('cloudcmd: client: view: types: detectType: found', async (t) => {
const fetch = stub().returns({
const originalFetch = global.fetch;
global.fetch = stub().returns({
headers: [
['content-type', 'image/png'],
],
});
const originalFetch = global.fetch;
global.fetch = fetch;
const result = await _detectType('/hello');
global.fetch = originalFetch;

View file

@ -19,15 +19,14 @@ test('common: datetime: no arg', (t) => {
const {Date} = global;
let called = false;
const myDate = class extends Date {
global.Date = class extends Date {
constructor() {
super();
called = true;
}
};
global.Date = myDate;
datetime();
global.Date = Date;

View file

@ -68,7 +68,6 @@ let Expect = '<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
test('cloudfunc: render', (t) => {
const template = readFilesSync(FS_DIR, TMPL, 'utf8');
const expect = fs.readFileSync(EXPECT_PATH, 'utf8');
time('CloudFunc.buildFromJSON');
const result = CloudFunc.buildFromJSON({
@ -77,7 +76,7 @@ test('cloudfunc: render', (t) => {
template,
});
Expect += expect;
Expect += fs.readFileSync(EXPECT_PATH, 'utf8');
let i;
const isNotOk = Expect