Skip to content

Commit

Permalink
chore(cloudcmd) lint
Browse files Browse the repository at this point in the history
  • Loading branch information
coderaiser committed Sep 28, 2019
1 parent d473a7e commit 794cace
Show file tree
Hide file tree
Showing 15 changed files with 42 additions and 35 deletions.
7 changes: 7 additions & 0 deletions .putout.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions .webpack/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -45,7 +45,7 @@ const rules = clean([
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: babelDev,
options,
}]);

const plugins = [
Expand Down
16 changes: 8 additions & 8 deletions client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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,
Expand All @@ -413,7 +413,7 @@ function CloudCmdProto(DOM) {

const [
error,
[templFile, templPath, templLink, templPathLink],
[file, path, link, pathLink],
] = await tryToCatch(Files.get, names);

if (error)
Expand All @@ -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,
},
});

Expand Down
2 changes: 1 addition & 1 deletion client/dom/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion client/dom/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
2 changes: 1 addition & 1 deletion client/dom/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
16 changes: 8 additions & 8 deletions client/dom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function CmdProto() {
const panel = DOM.getPanel();
const selected = DOM.getByClassAll(SELECTED_FILE, panel);

return [...selected];
return Array.from(selected);
};

/*
Expand All @@ -182,7 +182,7 @@ function CmdProto() {
this.unselectFiles = (files) => {
files = files || DOM.getSelectedFiles();

[...files].forEach(DOM.toggleSelectedFile);
Array.from(files).forEach(DOM.toggleSelectedFile);
};

/**
Expand Down Expand Up @@ -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);
};

/**
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
});
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion client/dom/upload-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions client/key/vim/globals.fixture.js
Original file line number Diff line number Diff line change
@@ -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: [],
Expand All @@ -14,7 +14,7 @@ module.exports.getDOM = () => {
};

const Dialog = {
prompt: resolve,
prompt,
};

return {
Expand Down
2 changes: 1 addition & 1 deletion client/listeners/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion client/modules/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
4 changes: 2 additions & 2 deletions server/cloudcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -249,7 +249,7 @@ function cloudcmd({modules, config}) {

rest(config),
route(config, {
html: defaultHtml,
html,
}),

ponseStatic,
Expand Down
4 changes: 2 additions & 2 deletions server/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
6 changes: 3 additions & 3 deletions server/user-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>\`);
Expand Down
4 changes: 2 additions & 2 deletions test/common/cloudfunc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TMPL = [
'link',
].map(addHBS);

const JSON_FILES = {
const data = {
path : '/etc/X11/',
files : [{
name: 'applnk',
Expand Down Expand Up @@ -73,7 +73,7 @@ test('cloudfunc: render', (t) => {
time('CloudFunc.buildFromJSON');
const result = CloudFunc.buildFromJSON({
prefix : '',
data : JSON_FILES,
data,
template,
});

Expand Down

0 comments on commit 794cace

Please sign in to comment.