Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Add more strict rules (eslint)
Browse files Browse the repository at this point in the history
  • Loading branch information
RainLoop committed Jul 1, 2016
1 parent b43bb17 commit 52e2698
Show file tree
Hide file tree
Showing 38 changed files with 487 additions and 433 deletions.
473 changes: 262 additions & 211 deletions .eslintrc.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion dev/App/Abstract.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@

import {window, _, $, key} from 'common';
import window from 'window';
import $ from '$';
import _ from '_';
import key from 'key';

import {
$win, $html, $doc,
Expand Down
35 changes: 16 additions & 19 deletions dev/App/Admin.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import {window, _} from 'common';
import window from 'window';
import _ from '_';
import ko from 'ko';
import progressJs from 'progressJs';

Expand Down Expand Up @@ -39,14 +40,12 @@ class AdminApp extends AbstractApp
DomainStore.domains.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => {
return {
name: name,
disabled: ko.observable(!enabled),
alias: alias,
deleteAccess: ko.observable(false)
};
}));
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => ({
name: name,
disabled: ko.observable(!enabled),
alias: alias,
deleteAccess: ko.observable(false)
})));
}
});
}
Expand All @@ -57,13 +56,11 @@ class AdminApp extends AbstractApp
PluginStore.plugins.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
PluginStore.plugins(_.map(data.Result, (item) => {
return {
name: item.Name,
disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured)
};
}));
PluginStore.plugins(_.map(data.Result, (item) => ({
name: item.Name,
disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured)
})));
}
});
}
Expand Down Expand Up @@ -203,15 +200,15 @@ class AdminApp extends AbstractApp
}, force);
}

bootend(callback = null) {
bootend(bootendCallback = null) {
if (progressJs)
{
progressJs.end();
}

if (callback)
if (bootendCallback)
{
callback();
bootendCallback();
}
}

Expand Down
46 changes: 24 additions & 22 deletions dev/App/User.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

import {window, _, $} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import progressJs from 'progressJs';
import Tinycon from 'Tinycon';

import {
noop, trim, log, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
noop, trim, log, has, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize
} from 'Common/Utils';

Expand Down Expand Up @@ -411,18 +413,17 @@ class AppUser extends AbstractApp
* @param {Function=} callback = null
*/
foldersReload(callback = null) {

Promises.foldersReload(FolderStore.foldersLoading).then((value) => {
if (callback)
{
const prom = Promises.foldersReload(FolderStore.foldersLoading);
if (callback)
{
prom.then((value) => {
callback(!!value);
}
}).catch(() => {
if (callback)
{
_.delay(() => callback(false), 1);
}
});
}).catch(() => {
_.delay(() => {
callback(false);
}, 1);
});
}
}

foldersPromisesActionHelper(promise, errorDefCode) {
Expand Down Expand Up @@ -481,7 +482,9 @@ class AppUser extends AbstractApp
iIndex,
oItem.primaryKey.getFingerprint(),
oItem.primaryKey.getKeyId().toHex().toLowerCase(),
_.uniq(_.compact(_.map(oItem.getKeyIds(), (item) => item && item.toHex ? item.toHex() : null))),
_.uniq(_.compact(_.map(
oItem.getKeyIds(), (item) => (item && item.toHex ? item.toHex() : null)
))),
aUsers,
aEmails,
oItem.isPrivate(),
Expand Down Expand Up @@ -672,7 +675,7 @@ class AppUser extends AbstractApp
{
for (uid in data.Result.Flags)
{
if (data.Result.Flags.hasOwnProperty(uid))
if (has(data.Result.Flags, uid))
{
check = true;
const flags = data.Result.Flags[uid];
Expand Down Expand Up @@ -808,7 +811,7 @@ class AppUser extends AbstractApp
aMessages = MessageStore.messageListChecked();
}

aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid) ? oMessage.uid : null)));
aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null))));

if ('' !== sFolderFullNameRaw && 0 < aRootUids.length)
{
Expand Down Expand Up @@ -934,18 +937,17 @@ class AppUser extends AbstractApp

/**
* @param {string} query
* @param {Function} callback
* @param {Function} autocompleteCallback
*/
getAutocomplete(query, callback) {
getAutocomplete(query, autocompleteCallback) {
Remote.suggestions((result, data) => {
if (StorageResultType.Success === result && data && isArray(data.Result))
{
callback(_.compact(_.map(data.Result,
(item) => item && item[0] ? new EmailModel(item[0], item[1]) : null)));
autocompleteCallback(_.compact(_.map(data.Result, (item) => (item && item[0] ? new EmailModel(item[0], item[1]) : null))));
}
else if (StorageResultType.Abort !== result)
{
callback([]);
autocompleteCallback([]);
}
}, query);
}
Expand Down Expand Up @@ -1407,7 +1409,7 @@ class AppUser extends AbstractApp
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
'' + (Settings.settingsGet('Title') || 'RainLoop'));
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

if (Settings.settingsGet('MailToEmail'))
{
Expand Down
3 changes: 2 additions & 1 deletion dev/Common/Audio.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import {window, $} from 'common';
import window from 'window';
import $ from '$';
import {bMobileDevice, bSafari} from 'Common/Globals';
import * as Links from 'Common/Links';
import * as Events from 'Common/Events';
Expand Down
24 changes: 14 additions & 10 deletions dev/Common/Booter.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

import window from 'window';
import progressJs from 'progressJs';
import Promise from 'Promise';

import STYLES_CSS from 'Styles/@Boot.css';
import LAYOUT_HTML from 'Html/Layout.html';
Expand Down Expand Up @@ -32,7 +33,7 @@ function getComputedStyle(id, name)
*/
function includeStyle(styles)
{
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E'));
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E')); // eslint-disable-line no-useless-concat
}

/**
Expand All @@ -41,7 +42,7 @@ function includeStyle(styles)
*/
function includeScr(src)
{
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E'));
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E')); // eslint-disable-line no-useless-concat
}

/**
Expand Down Expand Up @@ -203,27 +204,30 @@ function runApp()
}
}
}),
common = window.Promise.all([
common = Promise.all([
window.jassl(appData.TemplatesLink),
window.jassl(appData.LangLink)
]);

window.Promise.all([libs, common])
Promise.all([libs, common])
.then(() => {
p.set(30);
return window.jassl(appData.StaticAppJsLink);
}).then(() => {
})
.then(() => {
p.set(50);
return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve();
}).then(() => {
})
.then(() => {
p.set(70);
runMainBoot(false);
}).catch((e) => {
})
.catch((e) => {
runMainBoot(true);
throw e;
}).then(() => {
return window.jassl(appData.StaticEditorJsLink);
}).then(() => {
})
.then(() => window.jassl(appData.StaticEditorJsLink))
.then(() => {
if (window.CKEDITOR && window.__initEditor) {
window.__initEditor();
window.__initEditor = null;
Expand Down
2 changes: 1 addition & 1 deletion dev/Common/Cache.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import {_} from 'common';
import _ from '_';
import {Capa, MessageSetAction} from 'Common/Enums';
import {trim, pInt, isArray} from 'Common/Utils';
import * as Links from 'Common/Links';
Expand Down
10 changes: 6 additions & 4 deletions dev/Common/ClientStorageDriver/Cookie.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

import {window, JSON, $} from 'common';
import window from 'window';
import $ from '$';
import JSON from 'JSON';
import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';

Expand All @@ -21,7 +23,7 @@ class CookieDriver
const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME);
storageResult = null === storageValue ? null : JSON.parse(storageValue);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

(storageResult || (storageResult = {}))[key] = data;

Expand All @@ -33,7 +35,7 @@ class CookieDriver

result = true;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

return result;
}
Expand All @@ -54,7 +56,7 @@ class CookieDriver

result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

return result;
}
Expand Down
9 changes: 5 additions & 4 deletions dev/Common/ClientStorageDriver/LocalStorage.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import {window, JSON} from 'common';
import window from 'window';
import JSON from 'JSON';
import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';

Expand All @@ -21,7 +22,7 @@ class LocalStorageDriver
const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null;
storageResult = null === storageValue ? null : JSON.parse(storageValue);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

(storageResult || (storageResult = {}))[key] = data;

Expand All @@ -30,7 +31,7 @@ class LocalStorageDriver
window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult);
result = true;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

return result;
}
Expand All @@ -51,7 +52,7 @@ class LocalStorageDriver

result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion dev/Common/Events.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import {_} from 'common';
import _ from '_';
import {isObject, isUnd} from 'Common/Utils';
import * as Plugins from 'Common/Plugins';

Expand Down
13 changes: 6 additions & 7 deletions dev/Common/Globals.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

/* global RL_COMMUNITY */
import {window, _, $, key} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import key from 'key';
import ko from 'ko';
import {KeyState} from 'Common/Enums';

Expand Down Expand Up @@ -182,9 +185,7 @@ export const leftPanelWidth = ko.observable(0);
// popups
export const popupVisibilityNames = ko.observableArray([]);

export const popupVisibility = ko.computed(() => {
return 0 < popupVisibilityNames().length;
});
export const popupVisibility = ko.computed(() => 0 < popupVisibilityNames().length);

popupVisibility.subscribe((bValue) => {
$html.toggleClass('rl-modal', bValue);
Expand All @@ -196,9 +197,7 @@ export const keyScopeFake = ko.observable(KeyState.All);

export const keyScope = ko.computed({
owner: this,
read: () => {
return keyScopeFake();
},
read: () => keyScopeFake(),
write: function(sValue) {

if (KeyState.Menu !== sValue)
Expand Down
Loading

0 comments on commit 52e2698

Please sign in to comment.