chore: lint

This commit is contained in:
coderaiser 2023-07-09 12:43:24 +03:00
parent f1279666b5
commit 4717e035ee
173 changed files with 1388 additions and 1627 deletions

View file

@ -3,7 +3,7 @@
module.exports.btoa = (str) => {
if (typeof btoa === 'function')
return btoa(str);
return Buffer
.from(str)
.toString('base64');
@ -12,9 +12,8 @@ module.exports.btoa = (str) => {
module.exports.atob = (str) => {
if (typeof atob === 'function')
return atob(str);
return Buffer
.from(str, 'base64')
.toString('binary');
};

View file

@ -1,9 +1,6 @@
'use strict';
const {
test,
stub,
} = require('supertape');
const {test, stub} = require('supertape');
const {btoa, atob} = require('./base64');
@ -54,4 +51,3 @@ test('atob: node', (t) => {
t.equal(result, expected, 'should encode base64');
t.end();
});

View file

@ -9,4 +9,3 @@ module.exports = (promise) => (...a) => {
.then(success(fn))
.catch(fn);
};

View file

@ -2,10 +2,8 @@
const tryToCatch = require('try-to-catch');
const {
test,
stub,
} = require('supertape');
const {test, stub} = require('supertape');
const callbackify = require('./callbackify');
const {promisify} = require('util');
@ -30,4 +28,3 @@ test('cloudcmd: common: callbackify', async (t) => {
t.equal(data, 'hi');
t.end();
});

View file

@ -9,7 +9,6 @@ const {btoa} = require('./base64');
const getHeaderField = currify(_getHeaderField);
/* КОНСТАНТЫ (общие для клиента и сервера)*/
/* название программы */
const NAME = 'Cloud Commander';
const FS = '/fs';
@ -41,10 +40,7 @@ module.exports.formatMsg = (msg, name, status) => {
module.exports.getTitle = (options) => {
options = options || {};
const {
path = Path(),
name,
} = options;
const {path = Path(), name} = options;
const array = [
name || NAME,
@ -71,7 +67,10 @@ function getPathLink(url, prefix, template) {
.split('/')
.slice(1, -1);
const allNames = ['/', ...names];
const allNames = [
'/',
...names,
];
const lines = [];
const n = allNames.length;
@ -165,7 +164,7 @@ module.exports.buildFromJSON = (params) => {
Path(path);
fileTable += `${header}<ul data-name="js-files" class="files">`;
/* Если мы не в корне */
if (path !== '/') {
const dotDot = getDotDot(path);
@ -199,7 +198,7 @@ module.exports.buildFromJSON = (params) => {
.map((file) => {
const name = encode(file.name);
const link = prefix + FS + path + name;
const {
type,
mode,
@ -207,17 +206,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,
@ -249,7 +248,7 @@ function updateField(file) {
function getAttribute(type) {
if (type === 'directory')
return '';
return 'target="_blank" ';
}
@ -286,4 +285,3 @@ function getDotDot(path) {
return dotDot;
}

View file

@ -14,6 +14,7 @@ const {
} = require('./cloudfunc');
const templatePath = join(__dirname, '../tmpl/fs');
const template = {
pathLink: readFileSync(`${templatePath}/pathLink.hbs`, 'utf8'),
path: readFileSync(`${templatePath}/path.hbs`, 'utf8'),
@ -42,7 +43,9 @@ test('cloudfunc: buildFromJSON: ..', (t) => {
const $ = cheerio.load(html);
const el = $('[data-name="js-file-Li4="]');
const result = el.find('[data-name="js-name"]').text();
const result = el
.find('[data-name="js-name"]')
.text();
const expected = '..';
t.equal(result, expected);

View file

@ -15,7 +15,7 @@ module.exports = (date) => {
const addZero = (a) => {
if (a > 9)
return a;
return `0${a}`;
};

View file

@ -51,4 +51,3 @@ test('common: datetime: wrong args', (t) => {
t.equal(error.message, 'date should be instanceof Date!', 'should throw');
t.end();
});

View file

@ -1,7 +1,7 @@
'use strict';
const Entities = {
// '&nbsp;': ' ',
// '&nbsp;': ' ',
'&lt;': '<',
'&gt;': '>',
'&quot;': '"',
@ -30,4 +30,3 @@ module.exports.decode = (str) => {
return str;
};

View file

@ -11,4 +11,3 @@ module.exports = async (a) => {
...result,
];
};

View file

@ -12,7 +12,10 @@ test('commons: try-to-promise-all', async (t) => {
resolve('b'),
]);
const expected = ['a', 'b'];
const expected = [
'a',
'b',
];
t.deepEqual(result, expected);
t.end();
@ -26,4 +29,3 @@ test('commons: try-to-promise-all: error', async (t) => {
t.equal(e, 'a');
t.end();
});

View file

@ -16,15 +16,16 @@ module.exports.escapeRegExp = (str) => {
*/
module.exports.getRegExp = (wildcard) => {
const escaped = `^${wildcard // search from start of line
.replace(/\./g, '\\.')
.replace(/\*/g, '.*')
.replace('?', '.?')}$`; // search to end of line
.replace('?', '.?')}$`;
// search to end of line
return RegExp(escaped);
};
module.exports.exec = exec;
/**
* function gets file extension
*
@ -100,4 +101,3 @@ module.exports.time = (name) => {
module.exports.timeEnd = (name) => {
exec.ifExist(console, 'timeEnd', [name]);
};

View file

@ -56,9 +56,7 @@ test('util: findObjByNameInArr: object', (t) => {
name,
};
const array = [
obj,
];
const array = [obj];
const result = findObjByNameInArr(array, name);
@ -79,10 +77,8 @@ test('util: findObjByNameInArr: array', (t) => {
};
const array = [
name, [
obj,
item,
],
name,
[obj, item],
];
const result = findObjByNameInArr(array, name);
@ -133,4 +129,3 @@ test('util: scope', (t) => {
t.end();
});