mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint
This commit is contained in:
parent
d473a7e187
commit
794caced01
15 changed files with 42 additions and 35 deletions
|
|
@ -13,6 +13,13 @@
|
|||
"client/(client|cloudcmd|load-module).js": {
|
||||
"remove-console": false
|
||||
},
|
||||
"client/modules/config/index.js": {
|
||||
"apply-shorthand-properties": [{
|
||||
"ignore": [
|
||||
"ONE_MINUTE"
|
||||
]
|
||||
}]
|
||||
},
|
||||
"test/common/cloudfunc.js": {
|
||||
"remove-console": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ const clean = (array) => array.filter(notEmpty);
|
|||
|
||||
const noParse = (a) => /\.spec\.js$/.test(a);
|
||||
|
||||
const babelDev = {
|
||||
const options = {
|
||||
babelrc: false,
|
||||
plugins: [
|
||||
'module:babel-plugin-macros',
|
||||
|
|
@ -45,7 +45,7 @@ const rules = clean([
|
|||
test: /\.js$/,
|
||||
exclude: /node_modules/,
|
||||
loader: 'babel-loader',
|
||||
options: babelDev,
|
||||
options,
|
||||
}]);
|
||||
|
||||
const plugins = [
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ function CloudCmdProto(DOM) {
|
|||
const {noCurrent} = options;
|
||||
|
||||
if (!isRefresh && json)
|
||||
return createFileTable(json, panel, options, callback);
|
||||
return await createFileTable(json, panel, options, callback);
|
||||
|
||||
const position = DOM.getPanelPosition(panel);
|
||||
const sort = CloudCmd.sort[position];
|
||||
|
|
@ -403,7 +403,7 @@ function CloudCmdProto(DOM) {
|
|||
* @param history
|
||||
* @param callback
|
||||
*/
|
||||
async function createFileTable(json, panelParam, options) {
|
||||
async function createFileTable(data, panelParam, options) {
|
||||
const {
|
||||
history,
|
||||
noCurrent,
|
||||
|
|
@ -413,7 +413,7 @@ function CloudCmdProto(DOM) {
|
|||
|
||||
const [
|
||||
error,
|
||||
[templFile, templPath, templLink, templPathLink],
|
||||
[file, path, link, pathLink],
|
||||
] = await tryToCatch(Files.get, names);
|
||||
|
||||
if (error)
|
||||
|
|
@ -436,14 +436,14 @@ function CloudCmdProto(DOM) {
|
|||
panel.innerHTML = buildFromJSON({
|
||||
sort : options.sort,
|
||||
order : options.order,
|
||||
data : json,
|
||||
data,
|
||||
id : panel.id,
|
||||
prefix,
|
||||
template : {
|
||||
file : templFile,
|
||||
path : templPath,
|
||||
pathLink : templPathLink,
|
||||
link : templLink,
|
||||
file,
|
||||
path,
|
||||
pathLink,
|
||||
link,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ function BufferProto() {
|
|||
function rmCutClass() {
|
||||
const files = DOM.getByClassAll(CLASS);
|
||||
|
||||
for (const element of [...files]) {
|
||||
for (const element of files) {
|
||||
element.classList.remove(CLASS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module.exports = (items) => {
|
|||
if (items.length)
|
||||
Images.show('top');
|
||||
|
||||
const entries = [...items].map((item) => {
|
||||
const entries = Array.from(items).map((item) => {
|
||||
return item.webkitGetAsEntry();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ async function getFile(name) {
|
|||
check(name);
|
||||
|
||||
if (type === 'string')
|
||||
return getModule(name);
|
||||
return await getModule(name);
|
||||
|
||||
if (type === 'array')
|
||||
return Promise.all(unaryMap(name, get));
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ function CmdProto() {
|
|||
const panel = DOM.getPanel();
|
||||
const selected = DOM.getByClassAll(SELECTED_FILE, panel);
|
||||
|
||||
return [...selected];
|
||||
return Array.from(selected);
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
@ -182,7 +182,7 @@ function CmdProto() {
|
|||
this.unselectFiles = (files) => {
|
||||
files = files || DOM.getSelectedFiles();
|
||||
|
||||
[...files].forEach(DOM.toggleSelectedFile);
|
||||
Array.from(files).forEach(DOM.toggleSelectedFile);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -412,7 +412,7 @@ function CmdProto() {
|
|||
const from = (a) => a === '..' ? 1 : 0;
|
||||
const i = from(name);
|
||||
|
||||
return [...files].slice(i);
|
||||
return Array.from(files).slice(i);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -496,7 +496,7 @@ function CmdProto() {
|
|||
const first = files[0] || DOM.getCurrentFile();
|
||||
const name = DOM.getCurrentName(first);
|
||||
|
||||
const allFiles = [...files];
|
||||
const allFiles = Array.from(files);
|
||||
|
||||
if (name === '..')
|
||||
allFiles.shift();
|
||||
|
|
@ -852,13 +852,13 @@ function CmdProto() {
|
|||
panelPassive,
|
||||
} = Info;
|
||||
|
||||
const dirPath = DOM.getCurrentDirPath();
|
||||
const path = DOM.getCurrentDirPath();
|
||||
const dirPathPassive = DOM.getNotCurrentDirPath();
|
||||
|
||||
let currentIndex = files.indexOf(element);
|
||||
|
||||
CloudCmd.loadDir({
|
||||
path: dirPath,
|
||||
path,
|
||||
panel: panelPassive,
|
||||
noCurrent: true,
|
||||
});
|
||||
|
|
@ -901,8 +901,8 @@ function CmdProto() {
|
|||
info.parentDirPath = DOM.getParentDirPath();
|
||||
info.element = current;
|
||||
info.ext = Util.getExt(name);
|
||||
info.files = [...files.children];
|
||||
info.filesPassive = [...filesPassive];
|
||||
info.files = Array.from(files.children);
|
||||
info.filesPassive = Array.from(filesPassive);
|
||||
info.first = files.firstChild;
|
||||
info.getData = DOM.getCurrentData;
|
||||
info.last = files.lastChild;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module.exports = (dir, files) => {
|
|||
if (!n)
|
||||
return;
|
||||
|
||||
const array = [...files];
|
||||
const array = Array.from(files);
|
||||
const {name} = files[0];
|
||||
|
||||
eachSeries(array, loadFile(dir, n), onEnd(name));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
module.exports.getDOM = () => {
|
||||
const resolve = Promise.resolve.bind(Promise);
|
||||
const prompt = Promise.resolve.bind(Promise);
|
||||
const CurrentInfo = {
|
||||
element: {},
|
||||
files: [],
|
||||
|
|
@ -14,7 +14,7 @@ module.exports.getDOM = () => {
|
|||
};
|
||||
|
||||
const Dialog = {
|
||||
prompt: resolve,
|
||||
prompt,
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ function dragndrop() {
|
|||
return uploadFiles(files);
|
||||
|
||||
const isFile = (item) => item.kind === 'file';
|
||||
const dirFiles = [...items].filter(isFile);
|
||||
const dirFiles = Array.from(items).filter(isFile);
|
||||
|
||||
if (dirFiles.length)
|
||||
return DOM.uploadDirectory(dirFiles);
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ async function fillTemplate() {
|
|||
const getTarget = ({target}) => target;
|
||||
const handleChange = squad(onChange, getTarget);
|
||||
|
||||
[...inputs]
|
||||
Array.from(inputs)
|
||||
.map(addKey(onKey))
|
||||
.map(addChange(handleChange));
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const isDev = process.env.NODE_ENV === 'development';
|
|||
const getDist = (isDev) => isDev ? 'dist-dev' : 'dist';
|
||||
|
||||
const getIndexPath = (isDev) => path.join(DIR, '..', `${getDist(isDev)}/index.html`);
|
||||
const defaultHtml = fs.readFileSync(getIndexPath(isDev), 'utf8');
|
||||
const html = fs.readFileSync(getIndexPath(isDev), 'utf8');
|
||||
|
||||
const initAuth = currify(_initAuth);
|
||||
const notEmpty = (a) => a;
|
||||
|
|
@ -249,7 +249,7 @@ function cloudcmd({modules, config}) {
|
|||
|
||||
rest(config),
|
||||
route(config, {
|
||||
html: defaultHtml,
|
||||
html,
|
||||
}),
|
||||
|
||||
ponseStatic,
|
||||
|
|
|
|||
|
|
@ -169,9 +169,9 @@ function indexProcessing(config, options) {
|
|||
return data;
|
||||
}
|
||||
|
||||
function buildIndex(config, html, json) {
|
||||
function buildIndex(config, html, data) {
|
||||
const panel = CloudFunc.buildFromJSON({
|
||||
data: json,
|
||||
data,
|
||||
prefix: getPrefix(config),
|
||||
template: Template,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ module.exports = currify(async({menuName}, req, res, next) => {
|
|||
const {method} = req;
|
||||
|
||||
if (method === 'GET')
|
||||
return onGET({
|
||||
return await onGET({
|
||||
req,
|
||||
res,
|
||||
menuName,
|
||||
|
|
@ -76,10 +76,10 @@ async function onGET({req, res, menuName}) {
|
|||
.send(result.code);
|
||||
}
|
||||
|
||||
function getError(parseError, source) {
|
||||
function getError(error, source) {
|
||||
return `
|
||||
const e = Error(\`<pre>${codeframe({
|
||||
error: parseError,
|
||||
error,
|
||||
source,
|
||||
highlightCode: false,
|
||||
})}</pre>\`);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ const TMPL = [
|
|||
'link',
|
||||
].map(addHBS);
|
||||
|
||||
const JSON_FILES = {
|
||||
const data = {
|
||||
path : '/etc/X11/',
|
||||
files : [{
|
||||
name: 'applnk',
|
||||
|
|
@ -73,7 +73,7 @@ test('cloudfunc: render', (t) => {
|
|||
time('CloudFunc.buildFromJSON');
|
||||
const result = CloudFunc.buildFromJSON({
|
||||
prefix : '',
|
||||
data : JSON_FILES,
|
||||
data,
|
||||
template,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue