chore: lint

This commit is contained in:
coderaiser 2023-08-07 17:40:25 +03:00
parent 13279299c4
commit 24dcf78be8
16 changed files with 25 additions and 26 deletions

View file

@ -39,6 +39,7 @@ jobs:
run: typos --write-changes run: typos --write-changes
- name: Commit fixes - name: Commit fixes
uses: EndBug/add-and-commit@v9 uses: EndBug/add-and-commit@v9
continue-on-error: true
with: with:
message: "chore: ${{ env.NAME }}: actions: lint ☘️" message: "chore: ${{ env.NAME }}: actions: lint ☘️"
- name: Build - name: Build
@ -49,5 +50,6 @@ jobs:
run: redrun coverage coverage:report run: redrun coverage coverage:report
- name: Coveralls - name: Coveralls
uses: coverallsapp/github-action@v2 uses: coverallsapp/github-action@v2
continue-on-error: true
with: with:
github-token: ${{ secrets.GITHUB_TOKEN }} github-token: ${{ secrets.GITHUB_TOKEN }}

View file

@ -24,7 +24,7 @@ const simport = createSimport(import.meta.url);
const choose = (a, b) => { const choose = (a, b) => {
if (a === undefined) if (a === undefined)
return b; return b;
return a; return a;
}; };
@ -37,7 +37,7 @@ const DIR_SERVER = '../server/';
const maybeRoot = (a) => { const maybeRoot = (a) => {
if (a === '.') if (a === '.')
return process.cwd(); return process.cwd();
return a; return a;
}; };

View file

@ -68,6 +68,6 @@ async function cl() {
function getVersionNew(last, match) { function getVersionNew(last, match) {
if (match) if (match)
return minor(match, Info.version); return minor(match, Info.version);
return last.substr(3); return last.substr(3);
} }

View file

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const isString = (a) => typeof a === 'string';
/* global CloudCmd */ /* global CloudCmd */
const Util = require('../../common/util'); const Util = require('../../common/util');
@ -38,8 +37,9 @@ DOM.Events = require('./events');
const loadRemote = require('./load-remote'); const loadRemote = require('./load-remote');
const selectByPattern = require('./select-by-pattern'); const selectByPattern = require('./select-by-pattern');
const isString = (a) => typeof a === 'string';
const SELECTED_FILE = 'selected-file'; const SELECTED_FILE = 'selected-file';
const TabPanel = { const TabPanel = {
'js-left': null, 'js-left': null,
'js-right': null, 'js-right': null,

View file

@ -2,7 +2,6 @@
'use strict'; 'use strict';
const isFn = (a) => typeof a === 'function';
const montag = require('montag'); const montag = require('montag');
const {promisify} = require('es6-promisify'); const {promisify} = require('es6-promisify');
@ -12,6 +11,7 @@ const load = require('load.js');
const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc'); const {MAX_FILE_SIZE: maxSize} = require('../../common/cloudfunc');
const {time, timeEnd} = require('../../common/util'); const {time, timeEnd} = require('../../common/util');
const isFn = (a) => typeof a === 'function';
const loadJS = load.js; const loadJS = load.js;
const Name = 'Edit'; const Name = 'Edit';

View file

@ -2,7 +2,6 @@
'use strict'; 'use strict';
const isString = (a) => typeof a === 'string';
require('../../../css/view.css'); require('../../../css/view.css');
const rendy = require('rendy'); const rendy = require('rendy');
@ -28,7 +27,7 @@ const Events = require('../../dom/events');
const Images = require('../../dom/images'); const Images = require('../../dom/images');
const {encode} = require('../../../common/entity'); const {encode} = require('../../../common/entity');
const isString = (a) => typeof a === 'string';
const {assign} = Object; const {assign} = Object;
const {isArray} = Array; const {isArray} = Array;

View file

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

View file

@ -249,7 +249,7 @@ function updateField(file) {
function getAttribute(type) { function getAttribute(type) {
if (type === 'directory') if (type === 'directory')
return ''; return '';
return 'target="_blank" '; return 'target="_blank" ';
} }

View file

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

View file

@ -1,9 +1,10 @@
'use strict'; 'use strict';
const exec = require('execon'); const exec = require('execon');
const isString = (a) => typeof a === 'string';
module.exports.escapeRegExp = (str) => { module.exports.escapeRegExp = (str) => {
const isStr = typeof str === 'string'; const isStr = isString(str);
if (isStr) if (isStr)
str = str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); str = str.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
@ -33,7 +34,7 @@ module.exports.exec = exec;
* @return ext * @return ext
*/ */
module.exports.getExt = (name) => { module.exports.getExt = (name) => {
const isStr = typeof name === 'string'; const isStr = isString(name);
if (!isStr) if (!isStr)
return ''; return '';
@ -58,7 +59,7 @@ module.exports.findObjByNameInArr = (array, name) => {
if (!Array.isArray(array)) if (!Array.isArray(array))
throw Error('array should be array!'); throw Error('array should be array!');
if (typeof name !== 'string') if (!isString(name))
throw Error('name should be string!'); throw Error('name should be string!');
array.some((item) => { array.some((item) => {

View file

@ -109,7 +109,7 @@ module.exports._getPrefix = getPrefix;
function getPrefix(prefix) { function getPrefix(prefix) {
if (isFn(prefix)) if (isFn(prefix))
return prefix() || ''; return prefix() || '';
return prefix || ''; return prefix || '';
} }
@ -258,7 +258,7 @@ module.exports._replaceDist = replaceDist;
function replaceDist(url) { function replaceDist(url) {
if (!isDev) if (!isDev)
return url; return url;
return url.replace(/^\/dist\//, '/dist-dev/'); return url.replace(/^\/dist\//, '/dist-dev/');
} }

View file

@ -76,7 +76,7 @@ const manageListen = currify((manage, socket, auth) => {
function initWrite(filename, configManager) { function initWrite(filename, configManager) {
if (filename) if (filename)
return write.bind(null, filename, configManager); return write.bind(null, filename, configManager);
return resolve; return resolve;
} }

View file

@ -1,6 +1,5 @@
'use strict'; 'use strict';
const isString = (a) => typeof a === 'string';
const {join} = require('path'); const {join} = require('path');
const {callbackify} = require('util'); const {callbackify} = require('util');
@ -10,7 +9,7 @@ const threadIt = require('thread-it');
const {read} = require('redzip'); const {read} = require('redzip');
const root = require('../root'); const root = require('../root');
const isString = (a) => typeof a === 'string';
const parse = threadIt(join(__dirname, 'worker')); const parse = threadIt(join(__dirname, 'worker'));
threadIt.init(); threadIt.init();

View file

@ -1,7 +1,5 @@
'use strict'; 'use strict';
const isFn = (a) => typeof a === 'function';
const isString = (a) => typeof a === 'string';
const DIR = '../'; const DIR = '../';
const DIR_COMMON = `${DIR}../common/`; const DIR_COMMON = `${DIR}../common/`;
@ -24,7 +22,8 @@ const ponse = require('ponse');
const copymitter = require('copymitter'); const copymitter = require('copymitter');
const moveFiles = require('@cloudcmd/move-files'); const moveFiles = require('@cloudcmd/move-files');
const isString = (a) => typeof a === 'string';
const isFn = (a) => typeof a === 'function';
const swap = wraptile((fn, a, b) => fn(b, a)); const swap = wraptile((fn, a, b) => fn(b, a));
const isWin32 = process.platform === 'win32'; const isWin32 = process.platform === 'win32';
const {apiURL} = CloudFunc; const {apiURL} = CloudFunc;

View file

@ -1,10 +1,10 @@
'use strict'; 'use strict';
const isString = (a) => typeof a === 'string';
const tryCatch = require('try-catch'); const tryCatch = require('try-catch');
const exit = require('./exit'); const exit = require('./exit');
const columns = require('./columns'); const columns = require('./columns');
const isString = (a) => typeof a === 'string';
module.exports.root = (dir, config) => { module.exports.root = (dir, config) => {
if (!isString(dir)) if (!isString(dir))

View file

@ -131,9 +131,8 @@ async function createDefaultMenu({path, data, DOM, CloudCmd}) {
async function readDefaultMenu({prefix}) { async function readDefaultMenu({prefix}) {
const res = await fetch(`${prefix}/api/v1/user-menu/default`); const res = await fetch(`${prefix}/api/v1/user-menu/default`);
const data = await res.text();
return data; return await res.text();
} }
module.exports._selectNames = selectNames; module.exports._selectNames = selectNames;