mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore: lint
This commit is contained in:
parent
fcce26d4e1
commit
1bef0d4381
13 changed files with 54 additions and 61 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module.exports = {
|
||||
extends: [
|
||||
'plugin:putout/safe',
|
||||
'plugin:putout/safe+align',
|
||||
],
|
||||
plugins: [
|
||||
'putout',
|
||||
|
|
@ -18,9 +18,6 @@ module.exports = {
|
|||
'no-console': 'off',
|
||||
'n/shebang': 'off',
|
||||
},
|
||||
extends: [
|
||||
'plugin:n/recommended',
|
||||
],
|
||||
}, {
|
||||
files: ['client/dom/index.js'],
|
||||
rules: {
|
||||
|
|
@ -31,9 +28,6 @@ module.exports = {
|
|||
rules: {
|
||||
'no-console': 'off',
|
||||
},
|
||||
extends: [
|
||||
'plugin:n/recommended',
|
||||
],
|
||||
}, {
|
||||
files: ['{client,common,static}/**/*.js'],
|
||||
env: {
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ function CloudCmdProto(DOM) {
|
|||
currentName,
|
||||
}, panel);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Конструктор CloudClient, который
|
||||
* выполняет весь функционал по
|
||||
|
|
@ -148,7 +148,7 @@ function CloudCmdProto(DOM) {
|
|||
|
||||
await load.css(name);
|
||||
}
|
||||
|
||||
|
||||
this.route = (path) => {
|
||||
const query = path.split('/');
|
||||
|
||||
|
|
@ -216,7 +216,7 @@ function CloudCmdProto(DOM) {
|
|||
async function saveCurrentName(currentName) {
|
||||
await Storage.set('current-name', currentName);
|
||||
}
|
||||
|
||||
|
||||
async function baseInit() {
|
||||
const files = DOM.getFiles();
|
||||
|
||||
|
|
@ -253,7 +253,7 @@ function CloudCmdProto(DOM) {
|
|||
if (!data)
|
||||
await Storage.setJson(dirPath, getJsonFromFileTable());
|
||||
}
|
||||
|
||||
|
||||
function getPanels() {
|
||||
const panels = ['left'];
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ function CloudCmdProto(DOM) {
|
|||
'right',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
this.execFromModule = async (moduleName, funcName, ...args) => {
|
||||
await CloudCmd[moduleName]();
|
||||
|
||||
|
|
@ -290,7 +290,7 @@ function CloudCmdProto(DOM) {
|
|||
currentName,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Функция загружает json-данные о Файловой Системе
|
||||
* через ajax-запрос.
|
||||
|
|
@ -343,7 +343,7 @@ function CloudCmdProto(DOM) {
|
|||
|
||||
Storage.setJson(path, newObj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Функция строит файловую таблицу
|
||||
* @param json - данные о файлах
|
||||
|
|
@ -409,7 +409,7 @@ function CloudCmdProto(DOM) {
|
|||
CloudCmd.emit('active-dir', Info.dirPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.goToParentDir = async () => {
|
||||
const {
|
||||
dir,
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ function BufferProto() {
|
|||
function showMessage(msg) {
|
||||
DOM.Dialog.alert(msg);
|
||||
}
|
||||
|
||||
|
||||
function getNames() {
|
||||
const files = DOM.getActiveFiles();
|
||||
|
||||
return DOM.getFilenames(files);
|
||||
}
|
||||
|
||||
|
||||
function addCutClass() {
|
||||
const files = DOM.getActiveFiles();
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ function BufferProto() {
|
|||
element.classList.add(CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function rmCutClass() {
|
||||
const files = DOM.getByClassAll(CLASS);
|
||||
|
||||
|
|
@ -45,7 +45,7 @@ function BufferProto() {
|
|||
element.classList.remove(CLASS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function callIfEnabled(callback) {
|
||||
const is = CloudCmd.config('buffer');
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ function BufferProto() {
|
|||
|
||||
showMessage('Buffer disabled in config!');
|
||||
}
|
||||
|
||||
|
||||
async function readBuffer() {
|
||||
const [e, cp, ct] = await tryToPromiseAll([
|
||||
Storage.getJson(COPY),
|
||||
|
|
@ -67,7 +67,7 @@ function BufferProto() {
|
|||
ct,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
async function copy() {
|
||||
const names = getNames();
|
||||
const from = Info.dirPath;
|
||||
|
|
@ -83,7 +83,7 @@ function BufferProto() {
|
|||
names,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async function cut() {
|
||||
const names = getNames();
|
||||
const from = Info.dirPath;
|
||||
|
|
@ -100,14 +100,14 @@ function BufferProto() {
|
|||
names,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async function clear() {
|
||||
await Storage.remove(COPY);
|
||||
await Storage.remove(CUT);
|
||||
|
||||
rmCutClass();
|
||||
}
|
||||
|
||||
|
||||
async function paste() {
|
||||
const [error, cp, ct] = await readBuffer();
|
||||
|
||||
|
|
@ -130,6 +130,6 @@ function BufferProto() {
|
|||
|
||||
await clear();
|
||||
}
|
||||
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ module.exports.setCurrentFile = (currentFile, options) => {
|
|||
name,
|
||||
path,
|
||||
}));
|
||||
|
||||
|
||||
/* history could be present
|
||||
* but it should be false
|
||||
* to prevent default behavior
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ function EventsProto() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* safe add event listener
|
||||
*
|
||||
|
|
@ -95,7 +95,7 @@ function EventsProto() {
|
|||
|
||||
return Events;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe add event listener
|
||||
*
|
||||
|
|
@ -118,7 +118,7 @@ function EventsProto() {
|
|||
|
||||
return Events;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe remove event listener
|
||||
*
|
||||
|
|
@ -135,7 +135,7 @@ function EventsProto() {
|
|||
|
||||
return Events;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* remove all added event listeners
|
||||
*
|
||||
|
|
@ -149,7 +149,7 @@ function EventsProto() {
|
|||
|
||||
EventStore.clear();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe add event keydown listener
|
||||
*
|
||||
|
|
@ -164,7 +164,7 @@ function EventsProto() {
|
|||
|
||||
return Events.add(...args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe remove event click listener
|
||||
*
|
||||
|
|
@ -179,7 +179,7 @@ function EventsProto() {
|
|||
|
||||
return Events.remove(...args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe add event click listener
|
||||
*
|
||||
|
|
@ -194,7 +194,7 @@ function EventsProto() {
|
|||
|
||||
return Events.add(...args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe remove event click listener
|
||||
*
|
||||
|
|
@ -219,7 +219,7 @@ function EventsProto() {
|
|||
|
||||
return Events.add(...args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe add event click listener
|
||||
*
|
||||
|
|
@ -234,7 +234,7 @@ function EventsProto() {
|
|||
|
||||
return Events.add(...args);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* safe add load click listener
|
||||
*
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ module.exports = (name, options, callback = options) => {
|
|||
.then(async (modules) => {
|
||||
const online = config('online') && navigator.onLine;
|
||||
const module = findObjByNameInArr(modules.remote, name);
|
||||
|
||||
|
||||
const isArray = itype.array(module.local);
|
||||
const {version} = module;
|
||||
|
||||
|
||||
let remoteTmpls;
|
||||
let local;
|
||||
|
||||
|
||||
if (isArray) {
|
||||
remoteTmpls = module.remote;
|
||||
local = module.local;
|
||||
|
|
@ -36,22 +36,22 @@ module.exports = (name, options, callback = options) => {
|
|||
remoteTmpls = [module.remote];
|
||||
local = [module.local];
|
||||
}
|
||||
|
||||
|
||||
const localURL = local.map((url) => prefix + url);
|
||||
|
||||
|
||||
const remoteURL = remoteTmpls.map((tmpl) => {
|
||||
return rendy(tmpl, {
|
||||
version,
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
if (online) {
|
||||
const [e] = await tryToCatch(load.parallel, remoteURL);
|
||||
|
||||
|
||||
if (!e)
|
||||
return callback();
|
||||
}
|
||||
|
||||
|
||||
const [e] = await tryToCatch(load.parallel, localURL);
|
||||
callback(e);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ function _loadFile(dir, n, file, callback) {
|
|||
.on('progress', (count) => {
|
||||
const max = step(n);
|
||||
const value = (i - 1) * max + percent(count, 100, max);
|
||||
|
||||
|
||||
Images.show.load('top');
|
||||
Images.setProgress(Math.round(value));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ module.exports.buildFromJSON = (params) => {
|
|||
Path(path);
|
||||
|
||||
fileTable += `${header}<ul data-name="js-files" class="files">`;
|
||||
|
||||
|
||||
/* Если мы не в корне */
|
||||
if (path !== '/') {
|
||||
const dotDot = getDotDot(path);
|
||||
|
|
@ -199,7 +199,7 @@ module.exports.buildFromJSON = (params) => {
|
|||
.map((file) => {
|
||||
const name = encode(file.name);
|
||||
const link = prefix + FS + path + name;
|
||||
|
||||
|
||||
const {
|
||||
type,
|
||||
mode,
|
||||
|
|
@ -207,17 +207,17 @@ module.exports.buildFromJSON = (params) => {
|
|||
owner,
|
||||
size,
|
||||
} = file;
|
||||
|
||||
|
||||
const linkResult = rendy(templateLink, {
|
||||
link,
|
||||
title: name,
|
||||
name,
|
||||
attribute: getAttribute(file.type),
|
||||
});
|
||||
|
||||
|
||||
const dataName = getDataName(file.name);
|
||||
const attribute = `draggable="true" ${dataName}`;
|
||||
|
||||
|
||||
return rendy(templateFile, {
|
||||
tag: 'li',
|
||||
attribute,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ const entity = require('./entity');
|
|||
test('cloudcmd: entity: encode', (t) => {
|
||||
const result = entity.encode('<hello> ');
|
||||
const expected = '<hello> ';
|
||||
|
||||
|
||||
t.equal(result, expected, 'should encode entity');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -14,7 +14,7 @@ test('cloudcmd: entity: encode', (t) => {
|
|||
test('cloudcmd: entity: decode', (t) => {
|
||||
const result = entity.decode('<hello> ');
|
||||
const expected = '<hello> ';
|
||||
|
||||
|
||||
t.equal(result, expected, 'should decode entity');
|
||||
t.end();
|
||||
});
|
||||
|
|
@ -22,7 +22,7 @@ test('cloudcmd: entity: decode', (t) => {
|
|||
test('cloudcmd: entity: encode quote', (t) => {
|
||||
const result = entity.encode('"hello"');
|
||||
const expected = '"hello"';
|
||||
|
||||
|
||||
t.equal(result, expected, 'should encode entity');
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ function listen(manage, sock, auth) {
|
|||
.on('connection', (socket) => {
|
||||
if (!manage('auth'))
|
||||
return connection(manage, socket);
|
||||
|
||||
|
||||
const reject = () => socket.emit('reject');
|
||||
socket.on('auth', auth(connectionWraped(manage, socket), reject));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ module.exports = net
|
|||
const {pid} = process;
|
||||
const addr = socket.remoteAddress;
|
||||
const port = socket.remotePort;
|
||||
|
||||
|
||||
const r = repl.start({
|
||||
prompt: `[${pid} ${addr}:${port}>`,
|
||||
input: socket,
|
||||
|
|
@ -17,11 +17,11 @@ module.exports = net
|
|||
terminal: true,
|
||||
useGlobal: false,
|
||||
});
|
||||
|
||||
|
||||
r.on('exit', () => {
|
||||
socket.end();
|
||||
});
|
||||
|
||||
|
||||
r.context.socket = socket;
|
||||
})
|
||||
.listen(1337);
|
||||
|
|
|
|||
|
|
@ -84,9 +84,9 @@ function getError(error, source) {
|
|||
source,
|
||||
highlightCode: false,
|
||||
})}</pre>\`);
|
||||
|
||||
|
||||
e.code = 'frame';
|
||||
|
||||
|
||||
throw e;
|
||||
`;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const {time, timeEnd} = require(`../../common/util`);
|
|||
const CloudFunc = require('../../common/cloudfunc.js');
|
||||
|
||||
const DIR = `${__dirname}/../../`;
|
||||
const CloudFuncPath = `cloudfunc`;
|
||||
|
||||
const TMPLDIR = `${DIR}tmpl/`;
|
||||
|
||||
const FS_DIR = `${TMPLDIR}fs/`;
|
||||
|
|
@ -193,4 +193,3 @@ test('cloudfunc: getDotDot: two levels deep', (t) => {
|
|||
t.equal(dotDot, '/home', 'should return up level');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue