chore(cloudcmd) lint: no-multi-spaces

This commit is contained in:
coderaiser 2019-02-08 15:47:05 +02:00
parent d3ecafe0ea
commit 62e2ca2a64
28 changed files with 78 additions and 72 deletions

View file

@ -18,10 +18,10 @@ main((error) => {
}); });
function main(callback) { function main(callback) {
const history = 'Version history\n---------------\n'; const history = 'Version history\n---------------\n';
const link = '//github.com/coderaiser/cloudcmd/releases/tag/'; const link = '//github.com/coderaiser/cloudcmd/releases/tag/';
const template = '- *{{ date }}*, ' + const template = '- *{{ date }}*, ' +
'**[v{{ version }}]' + '**[v{{ version }}]' +
'(' + link + 'v{{ version }})**\n'; '(' + link + 'v{{ version }})**\n';
const {version} = Info; const {version} = Info;
@ -47,7 +47,7 @@ function replaceVersion(name, version, versionNew, callback) {
if (error) if (error)
return callback(error); return callback(error);
callback(null, 'done: ' + name); callback(null, 'done: ' + name);
}); });
} }

View file

@ -66,8 +66,8 @@ function CloudCmdProto(DOM) {
this.DIRCLIENT = '/dist/'; this.DIRCLIENT = '/dist/';
this.DIRCLIENT_MODULES = this.DIRCLIENT + 'modules/'; this.DIRCLIENT_MODULES = this.DIRCLIENT + 'modules/';
this.MIN_ONE_PANEL_WIDTH = 1155; this.MIN_ONE_PANEL_WIDTH = 1155;
this.HOST = location.origin || this.HOST = location.origin ||
location.protocol + '//' + location.host; location.protocol + '//' + location.host;
const TITLE = 'Cloud Commander'; const TITLE = 'Cloud Commander';
@ -392,7 +392,7 @@ function CloudCmdProto(DOM) {
}; };
if (!options) if (!options)
options = {}; options = {};
CloudCmd.log('reading dir: "' + path + '";'); CloudCmd.log('reading dir: "' + path + '";');

View file

@ -17,7 +17,7 @@ function BufferProto() {
const CUT = 'cut'; const CUT = 'cut';
const TITLE = 'Buffer'; const TITLE = 'Buffer';
const Buffer = { const Buffer = {
cut : callIfEnabled.bind(null, cut), cut : callIfEnabled.bind(null, cut),
copy : callIfEnabled.bind(null, copy), copy : callIfEnabled.bind(null, copy),
clear : callIfEnabled.bind(null, clear), clear : callIfEnabled.bind(null, clear),

View file

@ -101,7 +101,7 @@ module.exports.getCurrentDirName = () => {
const href = DOM.getCurrentDirPath() const href = DOM.getCurrentDirPath()
.replace(/\/$/, ''); .replace(/\/$/, '');
const substr = href.substr(href, href.lastIndexOf('/')); const substr = href.substr(href, href.lastIndexOf('/'));
const ret = href.replace(substr + '/', '') || '/'; const ret = href.replace(substr + '/', '') || '/';
return ret; return ret;

View file

@ -54,7 +54,7 @@ module.exports.getByClass = (className, element = document) => {
}; };
module.exports.getByDataName = (attribute, element = document) => { module.exports.getByDataName = (attribute, element = document) => {
const selector = '[' + 'data-name="' + attribute + '"]'; const selector = '[' + 'data-name="' + attribute + '"]';
return element.querySelector(selector); return element.querySelector(selector);
}; };

View file

@ -47,8 +47,8 @@ function EventsProto() {
isFunc = itype.function(element); isFunc = itype.function(element);
if (isFunc) { if (isFunc) {
listener = element; listener = element;
element = null; element = null;
} }
if (!element) if (!element)
@ -122,8 +122,8 @@ function EventsProto() {
}; };
if (!listener) { if (!listener) {
listener = element; listener = element;
element = null; element = null;
} }
this.add(type, element, once); this.add(type, element, once);

View file

@ -80,11 +80,11 @@ function getPath(name, isHTML, isJSON) {
if (isRoot) if (isRoot)
path = DIR_HTML + name.replace('-tmpl', ''); path = DIR_HTML + name.replace('-tmpl', '');
else else
path = DIR_HTML_FS + name; path = DIR_HTML_FS + name;
path += '.hbs'; path += '.hbs';
} else if (isJSON) { } else if (isJSON) {
path = DIR_JSON + name + '.json'; path = DIR_JSON + name + '.json';
} }
return path; return path;

View file

@ -67,7 +67,7 @@ module.exports.error = () => {
}; };
module.exports.show = show; module.exports.show = show;
module.exports.show.load = show; module.exports.show.load = show;
module.exports.show.error = error; module.exports.show.error = error;
/** /**
@ -135,7 +135,7 @@ module.exports.setProgress = (value, title) => {
return Images; return Images;
}; };
module.exports.clearProgress = () => { module.exports.clearProgress = () => {
const DATA = 'data-progress'; const DATA = 'data-progress';
const element = Images.get(); const element = Images.get();

View file

@ -950,6 +950,8 @@ function CmdProto() {
const filesPassive = DOM.getFiles(panelPassive); const filesPassive = DOM.getFiles(panelPassive);
const name = DOM.getCurrentName(current); const name = DOM.getCurrentName(current);
/* eslint no-multi-spaces:0 */
info.dir = DOM.getCurrentDirName(); info.dir = DOM.getCurrentDirName();
info.dirPath = DOM.getCurrentDirPath(); info.dirPath = DOM.getCurrentDirPath();
info.parentDirPath = DOM.getParentDirPath(); info.parentDirPath = DOM.getParentDirPath();

View file

@ -31,10 +31,10 @@ module.exports = (name, options, callback = options) => {
let local; let local;
if (isArray) { if (isArray) {
remoteTmpls = module.remote; remoteTmpls = module.remote;
local = module.local; local = module.local;
} else { } else {
remoteTmpls = [module.remote]; remoteTmpls = [module.remote];
local = [module.local]; local = [module.local];
} }
const localURL = local.map((url) => { const localURL = local.map((url) => {

View file

@ -64,7 +64,7 @@ module.exports.ajax = (params) => {
xhr.onreadystatechange = (event) => { xhr.onreadystatechange = (event) => {
const xhr = event.target; const xhr = event.target;
const OK = 200; const OK = 200;
if (xhr.readyState !== xhr.DONE) if (xhr.readyState !== xhr.DONE)
return; return;
@ -72,7 +72,7 @@ module.exports.ajax = (params) => {
Images.clearProgress(); Images.clearProgress();
const TYPE_JSON = 'application/json'; const TYPE_JSON = 'application/json';
const type = xhr.getResponseHeader('content-type'); const type = xhr.getResponseHeader('content-type');
if (xhr.status !== OK) if (xhr.status !== OK)
return exec(p.error, xhr); return exec(p.error, xhr);
@ -104,7 +104,7 @@ module.exports.put = (url, body) => {
return; return;
const percent = (event.loaded / event.total) * 100; const percent = (event.loaded / event.total) * 100;
const count = Math.round(percent); const count = Math.round(percent);
emitter.emit('progress', count); emitter.emit('progress', count);
}; };

View file

@ -55,8 +55,8 @@ function RESTful() {
const isFunc = itype.function(data); const isFunc = itype.function(data);
if (!callback && isFunc) { if (!callback && isFunc) {
callback = data; callback = data;
data = null; data = null;
} }
sendRequest({ sendRequest({
@ -149,7 +149,7 @@ function RESTful() {
}, },
}; };
this.Markdown = { this.Markdown = {
read(url, callback) { read(url, callback) {
sendRequest({ sendRequest({
method : 'GET', method : 'GET',

View file

@ -315,8 +315,8 @@ function onDragStart(event) {
} }
event.dataTransfer.setData('DownloadURL', event.dataTransfer.setData('DownloadURL',
'application/octet-stream' + ':' + 'application/octet-stream' + ':' +
name + ':' + name + ':' +
link); link);
} }

View file

@ -8,7 +8,7 @@ const Events = require('../dom/events');
const {Key} = CloudCmd; const {Key} = CloudCmd;
const ConfigView = { const ConfigView = {
bindKeys: false, bindKeys: false,
beforeClose: () => { beforeClose: () => {
Events.rmKey(listener); Events.rmKey(listener);

View file

@ -25,7 +25,7 @@ const TITLE = 'Edit';
let MSG_CHANGED; let MSG_CHANGED;
const isLoading = fullstore(); const isLoading = fullstore();
const ConfigView = { const ConfigView = {
beforeClose: () => { beforeClose: () => {
exec.ifExist(Menu, 'hide'); exec.ifExist(Menu, 'hide');
isChanged(); isChanged();

View file

@ -7,7 +7,7 @@ CloudCmd.EditNamesVim = exports;
const Events = require('../dom/events'); const Events = require('../dom/events');
const {Key} = CloudCmd; const {Key} = CloudCmd;
const ConfigView = { const ConfigView = {
bindKeys: false, bindKeys: false,
beforeClose: () => { beforeClose: () => {
Events.rmKey(listener); Events.rmKey(listener);

View file

@ -21,7 +21,7 @@ const rename = currify(_rename);
let Menu; let Menu;
const EditNames = exec.bind(); const EditNames = exec.bind();
const ConfigView = { const ConfigView = {
beforeClose: () => { beforeClose: () => {
exec.ifExist(Menu, 'hide'); exec.ifExist(Menu, 'hide');
DOM.Events.remove('keydown', keyListener); DOM.Events.remove('keydown', keyListener);

View file

@ -39,8 +39,8 @@ module.exports.init = async () => {
function create() { function create() {
const element = createElement('div', { const element = createElement('div', {
style: style:
'width : 100%;' + 'width : 100%;' +
'height : 100%;' + 'height : 100%;' +
'font-family: "Droid Sans Mono";', 'font-family: "Droid Sans Mono";',
notAppend: true, notAppend: true,
}); });

View file

@ -94,10 +94,10 @@ function getOptions(notFile) {
let func; let func;
if (notFile) { if (notFile) {
name = 'context'; name = 'context';
func = Key.unsetBind; func = Key.unsetBind;
} else { } else {
name = 'contextFile'; name = 'contextFile';
} }
const options = { const options = {
@ -244,7 +244,7 @@ function uploadFromCloud() {
CloudCmd.execFromModule('Cloud', 'saveFile', (currentName, data) => { CloudCmd.execFromModule('Cloud', 'saveFile', (currentName, data) => {
const path = DOM.getCurrentDirPath() + currentName; const path = DOM.getCurrentDirPath() + currentName;
RESTful.write(path, data, (error) => { RESTful.write(path, data, (error) => {
if (error) if (error)
return; return;

View file

@ -294,6 +294,8 @@ function _processFiles(options, data) {
let names = []; let names = [];
/* eslint no-multi-spaces: 0 */
if (data) { if (data) {
from = data.from; from = data.from;
to = data.to; to = data.to;

View file

@ -43,9 +43,9 @@ function show() {
createElement('style', { createElement('style', {
dataName: 'upload-css', dataName: 'upload-css',
innerText: '[data-name=js-upload-file-button] {' + innerText: '[data-name=js-upload-file-button] {' +
`font-family: ${fontFamily};` + `font-family: ${fontFamily};` +
'font-size: 20px;' + 'font-size: 20px;' +
'width: 97%' + 'width: 97%' +
'}', '}',
}); });
} }

View file

@ -267,10 +267,10 @@ function getMediaElement(src, callback) {
return alert(error); return alert(error);
if (!TemplateAudio) if (!TemplateAudio)
TemplateAudio = template; TemplateAudio = template;
const is = isAudio(name); const is = isAudio(name);
const type = is ? 'audio' : 'video'; const type = is ? 'audio' : 'video';
const innerHTML = rendy(TemplateAudio, { const innerHTML = rendy(TemplateAudio, {
src, src,

View file

@ -253,7 +253,7 @@ function getSize(file) {
} }
function _getHeaderField(sort, order, name) { function _getHeaderField(sort, order, name) {
const arrow = order === 'asc' ? '↑' : '↓'; const arrow = order === 'asc' ? '↑' : '↓';
if (sort !== name) if (sort !== name)
return name; return name;

View file

@ -58,9 +58,9 @@ const config = {
const connectionWraped = wraptile(connection); const connectionWraped = wraptile(connection);
module.exports = manage; module.exports = manage;
module.exports.save = save; module.exports.save = save;
module.exports.middle = middle; module.exports.middle = middle;
module.exports.subscribe = (fn) => { module.exports.subscribe = (fn) => {
changeEmitter.on('change', fn); changeEmitter.on('change', fn);
}; };
@ -69,7 +69,7 @@ module.exports.unsubscribe = (fn) => {
changeEmitter.removeListener('change', fn); changeEmitter.removeListener('change', fn);
}; };
module.exports.listen = (socket, auth) => { module.exports.listen = (socket, auth) => {
check(socket, auth); check(socket, auth);
if (!manage('configDialog')) if (!manage('configDialog'))

View file

@ -42,7 +42,7 @@ module.exports = (request, response, next) => {
function rest(request, response) { function rest(request, response) {
const name = ponse.getPathName(request); const name = ponse.getPathName(request);
const params = { const params = {
request, request,
response, response,
name: name.replace(apiURL, '') || '/', name: name.replace(apiURL, '') || '/',
@ -194,8 +194,8 @@ function onPUT(name, body, callback) {
if (isRootAll([files.to, files.from])) if (isRootAll([files.to, files.from]))
return callback(getWin32RootMsg()); return callback(getWin32RootMsg());
files.from = root(files.from); files.from = root(files.from);
files.to = root(files.to); files.to = root(files.to);
copy(files.from, files.to, files.names, (error) => { copy(files.from, files.to, files.names, (error) => {
const msg = formatMsg('copy', files.names); const msg = formatMsg('copy', files.names);
@ -262,8 +262,8 @@ function getPacker(operation) {
function operation(op, from, to, names, fn) { function operation(op, from, to, names, fn) {
if (!fn) { if (!fn) {
fn = names; fn = names;
names = [ names = [
path.basename(from), path.basename(from),
]; ];
} }

View file

@ -34,11 +34,11 @@ const logger = tryRequire('morgan');
module.exports = async (options) => { module.exports = async (options) => {
const prefix = config('prefix'); const prefix = config('prefix');
const port = process.env.PORT || /* c9 */ const port = process.env.PORT || /* c9 */
config('port'); config('port');
const ip = process.env.IP || /* c9 */ const ip = process.env.IP || /* c9 */
config('ip') || config('ip') ||
'0.0.0.0'; '0.0.0.0';
const app = express(); const app = express();

View file

@ -21,7 +21,7 @@ const {reRequire} = require('mock-require');
const htmlLooksLike = require('html-looks-like'); const htmlLooksLike = require('html-looks-like');
const readFilesSync = require('@cloudcmd/read-files-sync'); const readFilesSync = require('@cloudcmd/read-files-sync');
const FS_DIR = TMPLDIR + 'fs/'; const FS_DIR = TMPLDIR + 'fs/';
const EXPECT_PATH = __dirname + '/cloudfunc.html'; const EXPECT_PATH = __dirname + '/cloudfunc.html';
const addHBS = (a) => `${a}.hbs`; const addHBS = (a) => `${a}.hbs`;
@ -51,19 +51,21 @@ const JSON_FILES = {
}], }],
}; };
/* eslint no-multi-space: 0 */
let Expect = let Expect =
'<div data-name="js-path" class="reduce-text" title="/etc/X11/">' + '<div data-name="js-path" class="reduce-text" title="/etc/X11/">' +
'<span data-name="js-copy-path" class="path-icon icon-copy-to-clipboard"' + '<span data-name="js-copy-path" class="path-icon icon-copy-to-clipboard"' +
' title="copy path (Ctrl+P)">' + ' title="copy path (Ctrl+P)">' +
'</span>' + '</span>' +
'<a data-name="js-refresh" href="/fs/etc/X11/" ' + '<a data-name="js-refresh" href="/fs/etc/X11/" ' +
'class="path-icon icon-refresh" title="refresh (Ctrl+R)"></a>' + 'class="path-icon icon-refresh" title="refresh (Ctrl+R)"></a>' +
'<span data-name="js-links" class=links>' + '<span data-name="js-links" class=links>' +
'<a data-name="js-path-link" href="/fs/" title="/">/</a>' + '<a data-name="js-path-link" href="/fs/" title="/">/</a>' +
'<a data-name="js-path-link" href="/fs/etc/" title="/etc/">' + '<a data-name="js-path-link" href="/fs/etc/" title="/etc/">' +
'etc' + 'etc' +
'</a>/X11/' + '</a>/X11/' +
'</span>' + '</span>' +
'</div>'; '</div>';
test('cloudfunc: render', (t) => { test('cloudfunc: render', (t) => {

View file

@ -8,7 +8,7 @@ const dir = join(__dirname, '..', '..');
const modulesPath = join(dir, 'json', 'modules.json'); const modulesPath = join(dir, 'json', 'modules.json');
const cloudcmdPath = dir; const cloudcmdPath = dir;
const localModules = require(modulesPath); const localModules = require(modulesPath);
const modulas = require(`${dir}/server/modulas`); const modulas = require(`${dir}/server/modulas`);
const cloudcmd = require(cloudcmdPath); const cloudcmd = require(cloudcmdPath);