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
d63169ccc0
commit
d55b6fb393
10 changed files with 23 additions and 31 deletions
|
|
@ -278,7 +278,7 @@ function CloudCmdProto(DOM) {
|
|||
|
||||
const isRefresh = true;
|
||||
const history = false;
|
||||
const noCurrent = options ? options.noCurrent : false;
|
||||
const noCurrent = options?.noCurrent;
|
||||
|
||||
await CloudCmd.changeDir(path, {
|
||||
isRefresh,
|
||||
|
|
|
|||
|
|
@ -26,9 +26,8 @@ function BufferProto() {
|
|||
|
||||
function getNames() {
|
||||
const files = DOM.getActiveFiles();
|
||||
const names = DOM.getFilenames(files);
|
||||
|
||||
return names;
|
||||
return DOM.getFilenames(files);
|
||||
}
|
||||
|
||||
function addCutClass() {
|
||||
|
|
|
|||
|
|
@ -109,9 +109,8 @@ module.exports.getCurrentDirName = () => {
|
|||
.replace(/\/$/, '');
|
||||
|
||||
const substr = href.substr(href, href.lastIndexOf('/'));
|
||||
const ret = href.replace(`${substr}/`, '') || '/';
|
||||
|
||||
return ret;
|
||||
return href.replace(`${substr}/`, '') || '/';
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -266,7 +265,7 @@ module.exports.getCurrentByPosition = ({x, y}) => {
|
|||
module.exports.isCurrentFile = (currentFile) => {
|
||||
if (!currentFile)
|
||||
return false;
|
||||
|
||||
|
||||
return DOM.isContainClass(currentFile, CURRENT_FILE);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const isString = (a) => typeof a === 'string';
|
||||
/* global CloudCmd */
|
||||
const Util = require('../../common/util');
|
||||
|
||||
|
|
@ -116,9 +117,8 @@ module.exports.getCurrentDirName = () => {
|
|||
.replace(/\/$/, '');
|
||||
|
||||
const substr = href.substr(href, href.lastIndexOf('/'));
|
||||
const ret = href.replace(`${substr}/`, '') || '/';
|
||||
|
||||
return ret;
|
||||
return href.replace(`${substr}/`, '') || '/';
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -143,9 +143,7 @@ module.exports.getNotCurrentDirPath = () => {
|
|||
active: false,
|
||||
});
|
||||
|
||||
const path = DOM.getCurrentDirPath(panel);
|
||||
|
||||
return path;
|
||||
return DOM.getCurrentDirPath(panel);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -189,9 +187,8 @@ module.exports.getActiveFiles = () => {
|
|||
|
||||
module.exports.getCurrentDate = (currentFile) => {
|
||||
const current = currentFile || DOM.getCurrentFile();
|
||||
const date = DOM.getByDataName('js-date', current).textContent;
|
||||
|
||||
return date;
|
||||
return DOM.getByDataName('js-date', current).textContent;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -438,7 +435,7 @@ module.exports.setHistory = (data, title, url) => {
|
|||
module.exports.isSelected = (selected) => {
|
||||
if (!selected)
|
||||
return false;
|
||||
|
||||
|
||||
return DOM.isContainClass(selected, SELECTED_FILE);
|
||||
};
|
||||
|
||||
|
|
@ -479,7 +476,7 @@ module.exports.getFilenames = (files) => {
|
|||
module.exports.checkStorageHash = async (name) => {
|
||||
const nameHash = `${name}-hash`;
|
||||
|
||||
if (typeof name !== 'string')
|
||||
if (!isString(name))
|
||||
throw Error('name should be a string!');
|
||||
|
||||
const [loadHash, storeHash] = await Promise.all([
|
||||
|
|
@ -723,7 +720,7 @@ module.exports.changePanel = () => {
|
|||
module.exports.getPackerExt = (type) => {
|
||||
if (type === 'zip')
|
||||
return '.zip';
|
||||
|
||||
|
||||
return '.tar.gz';
|
||||
};
|
||||
|
||||
|
|
@ -749,7 +746,7 @@ module.exports.duplicatePanel = async () => {
|
|||
const getPath = (isDir) => {
|
||||
if (isDir)
|
||||
return Info.path;
|
||||
|
||||
|
||||
return Info.dirPath;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -111,9 +111,8 @@ function getSymbol(shift, keyCode) {
|
|||
function fromCharCode(keyIdentifier) {
|
||||
const code = keyIdentifier.substring(2);
|
||||
const hex = parseInt(code, 16);
|
||||
const char = String.fromCharCode(hex);
|
||||
|
||||
return char;
|
||||
return String.fromCharCode(hex);
|
||||
}
|
||||
|
||||
async function switchKey(event) {
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ function header() {
|
|||
function getPath(el, path = []) {
|
||||
if (!el)
|
||||
return path;
|
||||
|
||||
|
||||
return getPath(el.parentElement, path.concat(el));
|
||||
}
|
||||
|
||||
|
|
@ -115,9 +115,8 @@ module.exports.initKeysPanel = () => {
|
|||
const {id} = target;
|
||||
const operation = (name) => {
|
||||
const {Operation} = CloudCmd;
|
||||
const fn = Operation.show.bind(null, name);
|
||||
|
||||
return fn;
|
||||
return Operation.show.bind(null, name);
|
||||
};
|
||||
|
||||
const clickFuncs = {
|
||||
|
|
@ -143,7 +142,7 @@ module.exports.initKeysPanel = () => {
|
|||
const getPanel = (side) => {
|
||||
if (!itype.string(side))
|
||||
return side;
|
||||
|
||||
|
||||
return DOM.getByDataName(`js-${side}`);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -75,9 +75,7 @@ function getHost() {
|
|||
protocol,
|
||||
} = location;
|
||||
|
||||
const href = origin || `${protocol}//${host}`;
|
||||
|
||||
return href;
|
||||
return origin || `${protocol}//${host}`;
|
||||
}
|
||||
|
||||
function initSocket() {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const isFn = (a) => typeof a === 'function';
|
||||
const montag = require('montag');
|
||||
|
||||
const {promisify} = require('es6-promisify');
|
||||
|
|
@ -54,7 +55,7 @@ function create() {
|
|||
}
|
||||
|
||||
function checkFn(name, fn) {
|
||||
if (typeof fn !== 'function')
|
||||
if (!isFn(fn))
|
||||
throw Error(`${name} should be a function!`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ function getPosition(position) {
|
|||
x: position.x,
|
||||
y: position.y,
|
||||
};
|
||||
|
||||
|
||||
return getCurrentPosition();
|
||||
}
|
||||
|
||||
|
|
@ -196,9 +196,8 @@ function isPath(x, y) {
|
|||
|
||||
const el = document.elementFromPoint(x, y);
|
||||
const elements = panel.querySelectorAll('[data-name="js-path"] *');
|
||||
const is = ~[].indexOf.call(elements, el);
|
||||
|
||||
return is;
|
||||
return ~[].indexOf.call(elements, el);
|
||||
}
|
||||
|
||||
function beforeShow(callback, params) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
const isString = (a) => typeof a === 'string';
|
||||
require('../../../css/view.css');
|
||||
|
||||
const rendy = require('rendy');
|
||||
|
|
@ -317,7 +318,7 @@ async function getMediaElement(src) {
|
|||
}
|
||||
|
||||
function check(src) {
|
||||
if (typeof src !== 'string')
|
||||
if (!isString(src))
|
||||
throw Error('src should be a string!');
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue