diff --git a/.es5/.eslintrc b/.es5/.eslintrc index ab8cb76c..672de656 100644 --- a/.es5/.eslintrc +++ b/.es5/.eslintrc @@ -7,5 +7,9 @@ "ecmaVersion": 5, "sourceType": "module" }, + "rules": { + "indent": ["error", 4], + "semi": "error" + }, "extends": ["eslint:recommended"] } diff --git a/.eslintrc b/.eslintrc index 3e7ab532..a9f31e6e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -8,7 +8,8 @@ "sourceType": "module" }, "rules": { - "indent": ["error", 4] + "indent": ["error", 4], + "semi": "error" }, "extends": ["eslint:recommended"] } diff --git a/bin/legacy.js b/bin/legacy.js index d93054b9..470d0269 100755 --- a/bin/legacy.js +++ b/bin/legacy.js @@ -21,7 +21,7 @@ function fillFile(name) { return { name: setDir(name), data: `module.exports = require(\'../../server_/${name}\');` - } + }; } function writeFile({name, data}) { diff --git a/client/buffer.js b/client/buffer.js index 8a06fd6d..94025433 100644 --- a/client/buffer.js +++ b/client/buffer.js @@ -68,7 +68,7 @@ } function callIfEnabled(callback) { - isEnabled(function(is) { + isEnabled(function(is) { if (is) callback(); else @@ -110,7 +110,7 @@ } function clear() { - Storage.remove(COPY) + Storage.remove(COPY) .remove(CUT); rmCutClass(); diff --git a/client/client.js b/client/client.js index f246ed0e..c38c1d5e 100644 --- a/client/client.js +++ b/client/client.js @@ -166,9 +166,9 @@ var Util, DOM, CloudFunc, join; funcBefore = function(callback) { var src = prefix + '/join:' + [ - CloudCmd.LIBDIRCLIENT + 'polyfill.js', - '/modules/domtokenlist-shim/dist/domtokenlist.min.js', - ].join(':'); + CloudCmd.LIBDIRCLIENT + 'polyfill.js', + '/modules/domtokenlist-shim/dist/domtokenlist.min.js', + ].join(':'); DOM.loadJquery(function() { DOM.load.js(src, callback); diff --git a/client/cloud.js b/client/cloud.js index a65b3bb2..6bf6ff64 100644 --- a/client/cloud.js +++ b/client/cloud.js @@ -17,13 +17,13 @@ var log = CloudCmd.log; filepicker.store(data, { - mimetype: '', - filename: name - }, + mimetype: '', + filename: name + }, function(fpFile) { log(fpFile); filepicker.exportFile(fpFile, log, log); - }); + }); }; this.saveFile = function(callback) { @@ -49,13 +49,13 @@ picker = Util.findObjByNameInArr(storage, 'FilePicker'), key = picker && picker.key; - filepicker.setKey(key); + filepicker.setKey(key); - DOM.Images.hide(); - Util.timeEnd('filepicker loaded'); - Util.exec(callback); - }); + DOM.Images.hide(); + Util.timeEnd('filepicker loaded'); + Util.exec(callback); }); + }); } init(callback); diff --git a/client/cloudcmd.js b/client/cloudcmd.js index 5ea1fa56..93221998 100644 --- a/client/cloudcmd.js +++ b/client/cloudcmd.js @@ -39,7 +39,7 @@ var CloudCmd; ].filter(function(name) { return name; }).map(function(name) { - return modules + name; + return modules + name; }); var allFiles = moduleFiles diff --git a/client/dom.js b/client/dom.js index 26b1e94f..72b5e557 100644 --- a/client/dom.js +++ b/client/dom.js @@ -62,7 +62,7 @@ var CloudCmd, Util, DOM, CloudFunc; return element; }; - }; + }; Images = new ImageElementProto(); @@ -138,7 +138,7 @@ var CloudCmd, Util, DOM, CloudFunc; var DATA = 'data-progress', element = Images.get(); - if (element) { + if (element) { element.setAttribute(DATA, ''); element.title = ''; } @@ -321,8 +321,8 @@ var CloudCmd, Util, DOM, CloudFunc; remoteTmpls = module.remote; local = module.local; } else { - remoteTmpls = [module.remote]; - local = [module.local]; + remoteTmpls = [module.remote]; + local = [module.local]; } local = local.map(function(url) { @@ -405,18 +405,18 @@ var CloudCmd, Util, DOM, CloudFunc; FS = CloudFunc.FS, api = prefixURL + FS; - ++i; + ++i; - uploader = DOM.load.put(api + path, file); - uploader.on('progress', function(count) { - var max = step(n), - value = (i - 1) * max + percent(count, 100, max); + uploader = DOM.load.put(api + path, file); + uploader.on('progress', function(count) { + var max = step(n), + value = (i - 1) * max + percent(count, 100, max); - Images.show.load('top'); - Images.setProgress(Math.round(value)); - }); + Images.show.load('top'); + Images.setProgress(Math.round(value)); + }); - uploader.on('end', callback); + uploader.on('end', callback); }; if (!files) { @@ -447,7 +447,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @type */ this.promptNewFile = function() { - promptNew('file'); + promptNew('file'); }; function promptNew(typeName, type) { @@ -686,7 +686,7 @@ var CloudCmd, Util, DOM, CloudFunc; var ret, current = currentFile || this.getCurrentFile(), lMode = this.getByDataName('js-mode', current); - ret = lMode.textContent; + ret = lMode.textContent; return ret; }; @@ -710,7 +710,7 @@ var CloudCmd, Util, DOM, CloudFunc; * @param callback * @param currentFile */ - this.getCurrentData = function(callback, currentFile) { + this.getCurrentData = function(callback, currentFile) { var hash, RESTful = DOM.RESTful, Dialog = DOM.Dialog, @@ -721,7 +721,7 @@ var CloudCmd, Util, DOM, CloudFunc; func = function(error, data) { var length, - ONE_MEGABYTE = 1024 * 1024 * 1024; + ONE_MEGABYTE = 1024 * 1024 * 1024; if (!error) { if (Util.type.object(data)) @@ -782,9 +782,9 @@ var CloudCmd, Util, DOM, CloudFunc; }; this.setCurrentByName = function(name) { - var current = this.getCurrentByName(name) + var current = this.getCurrentByName(name); return this.setCurrentFile(current); - } + }; /** * unified way to set current file @@ -958,7 +958,7 @@ var CloudCmd, Util, DOM, CloudFunc; var msg = 'shrink', files = DOM.getSelectedFiles(); - selectByPattern(msg, files); + selectByPattern(msg, files); }; /** @@ -1460,7 +1460,7 @@ var CloudCmd, Util, DOM, CloudFunc; /* scroll on one page*/ this.scrollByPages = function(element, pPages) { - var ret = element && element.scrollByPages && pPages; + var ret = element && element.scrollByPages && pPages; if (ret) element.scrollByPages(pPages); @@ -1514,7 +1514,7 @@ var CloudCmd, Util, DOM, CloudFunc; return '.zip'; return '.tar.gz'; - } + }; this.goToDirectory = function() { var msg = 'Go to directory:', @@ -1554,7 +1554,7 @@ var CloudCmd, Util, DOM, CloudFunc; dirPath = DOM.getCurrentDirPath(), dirPathPassive = DOM.getNotCurrentDirPath(); - CloudCmd.loadDir({ + CloudCmd.loadDir({ path: dirPath, panel: panelPassive, noCurrent: true diff --git a/client/edit.js b/client/edit.js index e1aedfbf..a85d4175 100644 --- a/client/edit.js +++ b/client/edit.js @@ -37,7 +37,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format; } }; - function init(callback) { + function init(callback) { var element = createElement(); DOM.Events.addOnce('contextmenu', element, setMenu); diff --git a/client/events.js b/client/events.js index 0f73d04f..5855cc59 100644 --- a/client/events.js +++ b/client/events.js @@ -30,7 +30,7 @@ var Util, DOM; eventName = arguments[ELEMENT]; element = arguments[EVENT_NAME]; - parseArgs( + parseArgs( eventName, element, listener, @@ -110,9 +110,9 @@ var Util, DOM; */ this.addOnce = function(type, element, listener) { var once = function (event) { - Events.remove(type, element, once); - listener(event); - }; + Events.remove(type, element, once); + listener(event); + }; if (!listener) { listener = element; diff --git a/client/key.js b/client/key.js index 0c86f3c8..447fcf62 100644 --- a/client/key.js +++ b/client/key.js @@ -520,7 +520,7 @@ var CloudCmd, Util, DOM; case Key.V: if (ctrlMeta) - Buffer.paste(); + Buffer.paste(); break; case Key.Z: diff --git a/client/konsole.js b/client/konsole.js index 46470d44..36be98e0 100644 --- a/client/konsole.js +++ b/client/konsole.js @@ -56,7 +56,7 @@ CURRENT_PATH: function() { return DOM.CurrentInfo.path; } - } + }; } function create(callback) { diff --git a/client/listeners.js b/client/listeners.js index a8f97795..7d2a8e3f 100644 --- a/client/listeners.js +++ b/client/listeners.js @@ -3,9 +3,9 @@ var Util, DOM, CloudFunc, CloudCmd; (function (Util, DOM, CloudFunc, CloudCmd) { 'use strict'; - CloudCmd.Listeners = new ListenersProto(Util, DOM, CloudFunc, CloudCmd); + CloudCmd.Listeners = new ListenersProto(Util, DOM, CloudFunc, CloudCmd); - function ListenersProto(Util, DOM, CloudFunc, CloudCmd) { + function ListenersProto(Util, DOM, CloudFunc, CloudCmd) { var Info = DOM.CurrentInfo, Storage = DOM.Storage, Events = DOM.Events, @@ -286,7 +286,7 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.setCurrentFile(element); toName = Info.name; - if (key.shift) + if (key.shift) files = getFilesRange(fromName, toName); else files.push(Info.element); @@ -443,6 +443,6 @@ var Util, DOM, CloudFunc, CloudCmd; }); } - } + } })(Util, DOM, CloudFunc, CloudCmd); diff --git a/client/markdown.js b/client/markdown.js index 963d1cc9..ce44582a 100644 --- a/client/markdown.js +++ b/client/markdown.js @@ -34,10 +34,10 @@ var CloudCmd, Util, DOM; Markdown.read(name, function(error, result) { var div = DOM.load({ - name : 'div', - className : 'help', - inner : result - }); + name : 'div', + className : 'help', + inner : result + }); Images.hide(); diff --git a/client/menu.js b/client/menu.js index 5fa9759b..bfb43d53 100644 --- a/client/menu.js +++ b/client/menu.js @@ -141,8 +141,8 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; var menu = { 'Paste' : Buffer.paste, 'New' : { - 'File' : DOM.promptNewFile, - 'Directory' : DOM.promptNewDir + 'File' : DOM.promptNewFile, + 'Directory' : DOM.promptNewDir }, 'Upload' : function() { CloudCmd.Upload.show(); @@ -199,7 +199,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; Dialog.alert.noFiles(TITLE); }); }, - }; + }; Util.copyObj(menu, menuData); @@ -340,10 +340,10 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; function getCurrentPosition() { var current = Info.element, rect = current.getBoundingClientRect(); - position = { - x: rect.left + rect.width / 3, - y: rect.top - }; + position = { + x: rect.left + rect.width / 3, + y: rect.top + }; return position; } @@ -361,7 +361,7 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO; event.preventDefault(); } else if (key === ESC) { - Menu.hide(); + Menu.hide(); } } diff --git a/client/notify.js b/client/notify.js index 82565bb4..76beee4f 100644 --- a/client/notify.js +++ b/client/notify.js @@ -33,11 +33,11 @@ var Util, DOM; granted = Notify.check(); if (notifications && granted && Show) { - notify = new Notification(msg, { - icon: '/img/favicon/favicon-notify.png' - }); + notify = new Notification(msg, { + icon: '/img/favicon/favicon-notify.png' + }); - Events.addClick(notify, focus); + Events.addClick(notify, focus); } }); }; diff --git a/client/operation.js b/client/operation.js index 20b46f05..18493048 100644 --- a/client/operation.js +++ b/client/operation.js @@ -195,7 +195,7 @@ error: function(error) { if (options.noContinue) { listeners.end(error); - Dialog.alert(TITLE, error) + Dialog.alert(TITLE, error); } else { Dialog.confirm(TITLE, error + '\n Continue?') .then(function() { @@ -309,7 +309,7 @@ else type = 'file'; - type += ' '; + type += ' '; name = DOM.getCurrentName(current); msg = msgAsk + msgSel + type + name + '?'; @@ -373,7 +373,7 @@ * @param operation */ function processFiles(data, operation, message) { - var name, selFiles, files, + var name, selFiles, files, Info = DOM.CurrentInfo, panel, shouldAsk, @@ -466,7 +466,7 @@ if (type === 'zip') return /\.zip$/; - return /\.tar\.gz$/ + return /\.tar\.gz$/; } function twopack(operation, type) { @@ -552,9 +552,9 @@ '/remedy/remedy.js', '/ishtar/ishtar.js', '/salam/salam.js' - ].map(function(name) { - return prefix + name; - }); + ].map(function(name) { + return prefix + name; + }); DOM.load.parallel(files, function(error) { if (error) { diff --git a/client/polyfill.js b/client/polyfill.js index 6ecc1e30..f2416b03 100644 --- a/client/polyfill.js +++ b/client/polyfill.js @@ -28,7 +28,7 @@ var Util, DOM, jQuery; fBound.prototype = new NOP(); return fBound; - }; + }; if (!Array.isArray) Array.isArray = function(arr) { diff --git a/client/rest.js b/client/rest.js index aba91481..33156679 100644 --- a/client/rest.js +++ b/client/rest.js @@ -85,7 +85,7 @@ var Util, DOM, CloudFunc, CloudCmd; }); }; - this.cp = function(data, callback) { + this.cp = function(data, callback) { sendRequest({ method : 'PUT', url : '/cp', @@ -168,7 +168,7 @@ var Util, DOM, CloudFunc, CloudCmd; } }; - function sendRequest(params) { + function sendRequest(params) { var p = params, prefixUrl = CloudCmd.PREFIX_URL; diff --git a/client/storage.js b/client/storage.js index e732a174..cafb429c 100644 --- a/client/storage.js +++ b/client/storage.js @@ -11,7 +11,7 @@ Storage: Storage }); - function StorageProto() { + function StorageProto() { /* приватный переключатель возможности работы с кэшем */ var Allowed; diff --git a/client/view.js b/client/view.js index 8b25d8ee..2e5eb2eb 100644 --- a/client/view.js +++ b/client/view.js @@ -1,4 +1,4 @@ -var CloudCmd, Util, DOM, CloudFunc, $; +var CloudCmd, Util, DOM, CloudFunc, $, exec; (function(CloudCmd, Util, DOM, CloudFunc) { 'use strict'; @@ -14,26 +14,26 @@ var CloudCmd, Util, DOM, CloudFunc, $; Info = DOM.CurrentInfo, Key = CloudCmd.Key, Images = DOM.Images, - View = Util.exec.bind(Util), + View = exec.bind(Util), Element, TemplateAudio, Overlay, Config = { beforeShow : function(callback) { Images.hide(); Key.unsetBind(); showOverlay(); - Util.exec(callback); + exec(callback); }, beforeClose : function(callback) { Key.setBind(); - Util.exec(callback); + exec(callback); hideOverlay(); }, afterShow : function(callback) { Element.focus(); - Util.exec(callback); + exec(callback); }, afterClose : function(callback) { - Util.exec(callback); + exec(callback); }, fitToView : true, loop : false, @@ -59,16 +59,16 @@ var CloudCmd, Util, DOM, CloudFunc, $; View.hide = hide; function init() { - var func = CallBack || Util.exec.with(show, null); + var func = CallBack || exec.with(show, null); Loading = true; - Util.exec.series([ + exec.series([ DOM.loadJquery, load, function(callback) { Loading = false; - Util.exec(callback); + exec(callback); } ], func); @@ -127,9 +127,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; break; case 'media': - getMediaElement(path, function(element) { + getMediaElement(path, function(element) { var media = DOM.getByDataName('js-media', element); - var onKey = Util.exec.with(onMediaKey, media); + var onKey = exec.with(onMediaKey, media); $.fancybox.open(element, { parent : Overlay, @@ -334,9 +334,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; id : 'view-inlince-css', inner : [ '.fancybox-title-float-wrap .child {', - '-webkit-border-radius: 0;', - '-moz-border-radius: 0;', - 'border-radius: 0;', + '-webkit-border-radius: 0;', + '-moz-border-radius: 0;', + 'border-radius: 0;', '}' ].join('') }); diff --git a/package.json b/package.json index 4684869e..7df3dfa5 100644 --- a/package.json +++ b/package.json @@ -53,10 +53,12 @@ "lint:js": "redrun jshint jscs eslint:*", "lint:js:es5": "redrun es5:*", "eslint:bin": "eslint --rule 'no-console:0' bin test server", + "fix:eslint:bin": "redrun eslint:bin -- --fix", "jshint": "jshint bin/release.js", "jscs": "jscs --esnext $npm_package_config_dirs", "es5:jshint": "jshint --config .es5/.jshintrc $npm_package_config_dirs_dirs_legacy --exclude bin/release.js", "es5:eslint": "eslint -c .es5/.eslintrc --rule 'no-console:0' $npm_package_config_dirs_legacy --ignore-path bin/release.js", + "fix:es5:eslint": "redrun es5:eslint -- --fix", "test": "tape 'test/**/*.js'", "watch:test": "nodemon -w server -w test -x \"npm run test\"", "spell": "yaspeller .", diff --git a/server/route.js b/server/route.js index 25bce7ab..1f845cf0 100644 --- a/server/route.js +++ b/server/route.js @@ -41,7 +41,7 @@ const FS = CloudFunc.FS; const CSS_URL = require(DIR_JSON + 'css.json') .map((name) => { - return 'css/' + name + '.css' + return 'css/' + name + '.css'; }).join(':'); module.exports = (req, res, next) => { diff --git a/test/console.js b/test/console.js index 26a5e4e8..f7a35320 100644 --- a/test/console.js +++ b/test/console.js @@ -7,7 +7,7 @@ const before = require('./before'); test('cloudcmd: console: enabled by default', (t) => { before({}, (port, after) => { - const socket = io(`http://localhost:${port}/console`) + const socket = io(`http://localhost:${port}/console`); socket.once('data', (data) => { socket.close(); @@ -22,7 +22,7 @@ test('cloudcmd: console: enabled', (t) => { const config = {console: true}; before({config}, (port, after) => { - const socket = io(`http://localhost:${port}/console`) + const socket = io(`http://localhost:${port}/console`); socket.once('data', (data) => { socket.close();