feature(eslintrc) add no-use-before-define

This commit is contained in:
coderaiser 2017-02-17 16:14:21 +02:00
parent 1aaf9e63ec
commit 5c99214ae3
11 changed files with 54 additions and 65 deletions

View file

@ -10,7 +10,8 @@
},
"rules": {
"indent": ["error", 4],
"semi": "error"
"semi": "error",
"no-use-before-define": ["error", "nofunc"]
},
"extends": ["eslint:recommended"]
}

View file

@ -438,9 +438,7 @@ function CloudCmdProto(Util, DOM, CloudFunc) {
CloudCmd.log('reading dir: "' + path + '";');
var dirStorage = CloudCmd.config(dirStorage);
if (!dirStorage)
if (!CloudCmd.config('dirStorage'))
return create();
Storage.get(path, create);

View file

@ -58,13 +58,6 @@ function ConfigProto() {
const href = getHost();
const prefix = CloudCmd.PREFIX;
const FIVE_SECONDS = 5000;
const save = (data) => {
onSave(data);
socket.send(data);
};
if (error)
return;
const socket = io.connect(href + prefix + '/config', {
'max reconnection attempts' : Math.pow(2, 32),
@ -72,6 +65,14 @@ function ConfigProto() {
path: prefix + '/socket.io'
});
const save = (data) => {
onSave(data);
socket.send(data);
};
if (error)
return;
authCheck(socket);
socket.on('connect', () => {

View file

@ -326,19 +326,19 @@ function CmdProto() {
isArray = itype.array(module.local),
version = module.version,
funcON = function() {
load.parallel(remote, function(error) {
if (error)
funcOFF();
else
callback();
});
funcOFF = () => {
load.parallel(local, callback);
},
funcOFF = function() {
load.parallel(local, callback);
funcON = () => {
load.parallel(remote, (error) => {
if (error)
return funcOFF();
callback();
});
};
if (isArray) {
remoteTmpls = module.remote;
local = module.local;

View file

@ -114,6 +114,7 @@ CloudCmd.EditFile = function EditFileProto(callback) {
!Menu && DOM.loadRemote('menu', (error) => {
let noFocus;
const editor = CloudCmd.Edit.getEditor();
const options = {
beforeShow: (params) => {
params.x -= 18;
@ -125,8 +126,6 @@ CloudCmd.EditFile = function EditFileProto(callback) {
}
};
const editor = CloudCmd.Edit.getEditor();
const menuData = {
'Save Ctrl+S' : () => {
editor.save();

View file

@ -146,6 +146,7 @@ CloudCmd.EditNames = function EditNamesProto(callback) {
!Menu && DOM.loadRemote('menu', (error) => {
MenuIO = window.MenuIO;
let noFocus;
const editor = CloudCmd.Edit.getEditor();
const options = {
beforeShow: (params) => {
params.x -= 18;
@ -157,8 +158,6 @@ CloudCmd.EditNames = function EditNamesProto(callback) {
}
};
const editor = CloudCmd.Edit.getEditor();
const menuData = {
'Save Ctrl+S' : () => {
editor.save();

View file

@ -4,6 +4,8 @@
CloudCmd.Help = HelpProto;
const {Images} = require('./dom');
function HelpProto() {
Images.show.load('top');
show();
@ -11,8 +13,6 @@ function HelpProto() {
return exports;
}
const {Images} = require('./dom');
module.exports.show = show;
module.exports.hide = hide;

View file

@ -46,19 +46,14 @@ function load(params) {
notAppend,
} = params;
/*
* if passed arguments function
* then it's onload by default
*
* if object - then onload and onerror
*/
const funcLoad = () => {
const callback = func && func.onload || func;
Events.remove('error', element, funcError);
exec(callback);
};
let element = document.getElementById(id);
if (element) {
exec(func);
return element;
}
element = document.createElement(name);
const funcError = () => {
const msg = `file ${src} could not be loaded`;
@ -73,14 +68,13 @@ function load(params) {
exec(callback, error);
};
let element = document.getElementById(id);
if (element) {
exec(func);
return element;
}
element = document.createElement(name);
const funcLoad = () => {
const callback = func && func.onload || func;
Events.remove('error', element, funcError);
exec(callback);
};
if (/^(script|link)$/.test(name))
Events.addOnce('load', element, funcLoad)

View file

@ -267,11 +267,7 @@ function MenuProto(position) {
files.forEach((file) => {
const selected = DOM.isSelected(file);
const id = load.getIdBySrc(path);
const isDir = DOM.isCurrentIsDir(file);
CloudCmd.log('downloading file ' + path + '...');
/*
* if we send ajax request -
* no need in hash so we escape #
@ -280,7 +276,9 @@ function MenuProto(position) {
const path = DOM.getCurrentPath(file)
.replace(/#/g, '%23');
CloudCmd.log('downloading file ' + path + '...');
const encodedPath = encodeURI(path);
const id = load.getIdBySrc(path);
let src;

View file

@ -173,21 +173,21 @@ function OperationProto(operation, data) {
options = {};
}
var done;
var lastError;
let done;
let lastError;
var listeners = {
progress: function(value) {
const listeners = {
progress: (value) => {
done = value === 100;
Images.setProgress(value);
},
end: function() {
end: () => {
Images
.hide()
.clearProgress();
events.forEach(function(name) {
Object.keys(listeners).forEach((name) => {
emitter.removeListener(name, listeners[name]);
});
@ -195,7 +195,7 @@ function OperationProto(operation, data) {
callback(lastError);
},
error: function(error) {
error: (error) => {
lastError = error;
if (options.noContinue) {
@ -203,18 +203,18 @@ function OperationProto(operation, data) {
Dialog.alert(TITLE, error);
} else {
Dialog.confirm(TITLE, error + '\n Continue?')
.then(function() {
.then(() => {
emitter.continue();
}, function() {
}, () => {
emitter.abort();
});
}
}
};
var events = Object.keys(listeners);
const events = Object.keys(listeners);
events.forEach(function(name) {
events.forEach((name) => {
emitter.on(name, listeners[name]);
});
}

View file

@ -6,6 +6,7 @@ const exec = require('execon');
const load = require('./load');
const Files = require('./files');
const {Images} = DOM;
CloudCmd.Upload = UploadProto;
@ -20,8 +21,6 @@ function UploadProto() {
return exports;
}
const {Images} = DOM;
module.exports.show = show;
module.exports.hide = hide;