chore: lint

This commit is contained in:
coderaiser 2023-01-30 20:33:36 +02:00
parent 8e25a02568
commit 88da092fdb
38 changed files with 125 additions and 124 deletions

View file

@ -141,7 +141,7 @@ function CloudCmdProto(DOM) {
async function loadStyle() {
const {prefix} = CloudCmd;
const name = prefix + '/dist/cloudcmd.common.css';
const name = `${prefix}/dist/cloudcmd.common.css`;
await load.css(name);
}
@ -303,7 +303,7 @@ function CloudCmdProto(DOM) {
async function ajaxLoad(path, options = {}, panel) {
const {RESTful} = DOM;
CloudCmd.log('reading dir: "' + path + '";');
CloudCmd.log(`reading dir: "${path}";`);
const dirStorage = CloudCmd.config('dirStorage');
const json = dirStorage && await Storage.getJson(path);

View file

@ -115,7 +115,7 @@ module.exports.getCurrentDirName = () => {
.replace(/\/$/, '');
const substr = href.substr(href, href.lastIndexOf('/'));
const ret = href.replace(substr + '/', '') || '/';
const ret = href.replace(`${substr}/`, '') || '/';
return ret;
};

View file

@ -72,6 +72,6 @@ function uploadFile(url, data) {
}
function uploadDir(url) {
return DOM.load.put(url + '?dir');
return DOM.load.put(`${url}?dir`);
}

View file

@ -41,7 +41,7 @@ module.exports.getByTag = (tag, element = document) => {
* @param Id - id
*/
module.exports.getById = (id, element = document) => {
return element.querySelector('#' + id);
return element.querySelector(`#${id}`);
};
/**

View file

@ -33,7 +33,7 @@ function EventsProto() {
switch(type) {
default:
if (!type.endsWith('element'))
throw Error('unknown eventName: ' + type);
throw Error(`unknown eventName: ${type}`);
parseArgs(
args[EVENT_NAME],

View file

@ -13,7 +13,7 @@ const FILES_JSON = 'config|modules';
const FILES_HTML = 'file|path|link|pathLink|media';
const FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl|upload';
const DIR_HTML = '/tmpl/';
const DIR_HTML_FS = DIR_HTML + 'fs/';
const DIR_HTML_FS = `${DIR_HTML}fs/`;
const DIR_JSON = '/json/';
const timeout = getTimeoutOnce(2000);
@ -72,7 +72,7 @@ function getPath(name, isHTML, isJSON) {
}
function showError(name) {
const str = 'Wrong file name: ' + name;
const str = `Wrong file name: ${name}`;
const error = Error(str);
throw error;

View file

@ -127,7 +127,7 @@ module.exports.setProgress = (value, title) => {
if (!element)
return Images;
element.setAttribute(DATA, value + '%');
element.setAttribute(DATA, `${value}%`);
if (title)
element.title = title;

View file

@ -79,7 +79,7 @@ module.exports.promptNewFile = async () => {
async function promptNew(typeName) {
const {Dialog} = DOM;
const dir = DOM.getCurrentDirPath();
const msg = 'New ' + typeName || 'File';
const msg = `New ${typeName}` || 'File';
const getName = () => {
const name = DOM.getCurrentName();
@ -115,7 +115,7 @@ module.exports.getCurrentDirName = () => {
.replace(/\/$/, '');
const substr = href.substr(href, href.lastIndexOf('/'));
const ret = href.replace(substr + '/', '') || '/';
const ret = href.replace(`${substr}/`, '') || '/';
return ret;
};
@ -457,7 +457,7 @@ module.exports.getFilenames = (files) => {
* check storage hash
*/
module.exports.checkStorageHash = async (name) => {
const nameHash = name + '-hash';
const nameHash = `${name}-hash`;
if (typeof name !== 'string')
throw Error('name should be a string!');
@ -486,8 +486,8 @@ module.exports.saveDataToStorage = async (name, data, hash) => {
hash = hash || await DOM.loadCurrentHash();
const nameHash = name + '-hash';
const nameData = name + '-data';
const nameHash = `${name}-hash`;
const nameData = `${name}-data`;
await Storage.set(nameHash, hash);
await Storage.set(nameData, data);

View file

@ -133,7 +133,7 @@ module.exports.Markdown = {
read: async (url) => {
return await sendRequest({
method: 'GET',
url: '/markdown' + url,
url: `/markdown${url}`,
imgPosition,
notLog: true,
});

View file

@ -12,7 +12,7 @@ module.exports = function setCurrentByChar(char, charStore) {
let i = 0;
const escapeChar = escapeRegExp(char);
const regExp = new RegExp('^' + escapeChar + '.*$', 'i');
const regExp = new RegExp(`^${escapeChar}.*$`, 'i');
const {files} = Info;
const chars = charStore();
const n = chars.length;

View file

@ -10,7 +10,7 @@ global.DOM = getDOM();
const {
_next,
_previous,
} = require(dir + 'find');
} = require(`${dir}find`);
test('cloudcmd: client: vim: _next', (t) => {
const result = _next(1, 2);

View file

@ -462,7 +462,7 @@ test('cloudcmd: client: key: N', (t) => {
findPrevious,
});
const vim = reRequire(dir + 'vim');
const vim = reRequire(`${dir}vim`);
const event = {};
vim('N', event);

View file

@ -147,7 +147,7 @@ const getPanel = (side) => {
if (!itype.string(side))
return side;
return DOM.getByDataName('js-' + side);
return DOM.getByDataName(`js-${side}`);
};
module.exports.setOnPanel = (side) => {

View file

@ -57,7 +57,7 @@ module.exports.init = async () => {
[Template] = await Promise.all([
Files.get('config-tmpl'),
loadSocket(),
loadCSS(prefix + '/dist/config.css'),
loadCSS(`${prefix}/dist/config.css`),
CloudCmd.View(),
]);
@ -94,7 +94,7 @@ function initSocket() {
const socket = io.connect(href + prefixSocket + '/config', {
reconnectionAttempts: Infinity,
reconnectionDelay: ONE_MINUTE,
path: prefix + '/socket.io',
path: `${prefix}/socket.io`,
});
const save = (data) => {
@ -148,9 +148,9 @@ async function fillTemplate() {
...obj
} = input.convert(config);
obj[editor + '-selected'] = 'selected';
obj[packer + '-selected'] = 'selected';
obj[columns + '-selected'] = 'selected';
obj[`${editor}-selected`] = 'selected';
obj[`${packer}-selected`] = 'selected';
obj[`${columns}-selected`] = 'selected';
obj.configAuth = configAuth ? '' : 'hidden';
const innerHTML = rendy(Template, obj);

View file

@ -177,7 +177,7 @@ function getMenuData() {
}
function setMsgChanged(name) {
MSG_CHANGED = 'Do you want to save changes to ' + name + '?';
MSG_CHANGED = `Do you want to save changes to ${name}?`;
}
module.exports.isChanged = isChanged;

View file

@ -52,7 +52,7 @@ function create() {
function checkFn(name, fn) {
if (typeof fn !== 'function')
throw Error(name + ' should be a function!');
throw Error(`${name} should be a function!`);
}
function initConfig(options = {}) {
@ -104,7 +104,7 @@ const loadFiles = async (element) => {
const prefixSocket = `${CloudCmd.prefixSocket}/${EditorName}`;
const url = `${prefix}/${EditorName}.js`;
time(Name + ' load');
time(`${Name} load`);
await loadJS(url);
@ -116,7 +116,7 @@ const loadFiles = async (element) => {
socketPath,
});
timeEnd(Name + ' load');
timeEnd(`${Name} load`);
editor = ed;
Loading = false;
};

View file

@ -133,14 +133,14 @@ module.exports.show = (callback) => {
};
const load = async () => {
Util.time(Name + ' load');
Util.time(`${Name} load`);
const prefix = getPrefix();
const url = prefix + '/console.js';
const url = `${prefix}/console.js`;
const [error] = await tryToCatch(loadJS, url);
Loaded = true;
Util.timeEnd(Name + ' load');
Util.timeEnd(`${Name} load`);
if (error)
return Dialog.alert(error.message, {

View file

@ -239,7 +239,7 @@ async function _uploadTo(nameModule) {
const {name} = Info;
CloudCmd.execFromModule(nameModule, 'uploadFile', name, data);
CloudCmd.log('Uploading to ' + name + '...');
CloudCmd.log(`Uploading to ${name}...`);
}
function uploadFromCloud() {
@ -275,7 +275,7 @@ function download(type) {
const isDir = DOM.isCurrentIsDir(file);
const path = DOM.getCurrentPath(file);
CloudCmd.log('downloading file ' + path + '...');
CloudCmd.log(`downloading file ${path}...`);
/*
* if we send ajax request -
* no need in hash so we escape #

View file

@ -421,7 +421,7 @@ async function _processFiles(options, data) {
function checkEmpty(name, operation) {
if (!operation)
throw Error(name + ' could not be empty!');
throw Error(`${name} could not be empty!`);
}
function twopack(operation, type) {
@ -487,9 +487,9 @@ async function prompt(msg, to, names) {
msg += ' ';
if (names.length > 1)
msg += n + ' file(s)';
msg += `${n} file(s)`;
else
msg += '"' + name + '"';
msg += `"${name}"`;
msg += ' to';

View file

@ -72,7 +72,8 @@ module.exports = (options) => (emitter) => {
return;
}
const [cancel] = await Dialog.confirm(error + '\n Continue?');
const [cancel] = await Dialog.confirm(`${error}
Continue?`);
if (!done && !cancel)
return emitter.continue();

View file

@ -320,7 +320,7 @@ function check(src) {
async function loadAll() {
const {DIR_DIST} = CloudCmd;
time(Name + ' load');
time(`${Name} load`);
Loading = true;
await loadCSS(`${DIR_DIST}/view.css`);