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

Commit 52e2698

Browse files
committed
Add more strict rules (eslint)
1 parent b43bb17 commit 52e2698

38 files changed

+487
-433
lines changed

.eslintrc.js

Lines changed: 262 additions & 211 deletions
Large diffs are not rendered by default.

dev/App/Abstract.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

2-
import {window, _, $, key} from 'common';
2+
import window from 'window';
3+
import $ from '$';
4+
import _ from '_';
5+
import key from 'key';
36

47
import {
58
$win, $html, $doc,

dev/App/Admin.jsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
import {window, _} from 'common';
2+
import window from 'window';
3+
import _ from '_';
34
import ko from 'ko';
45
import progressJs from 'progressJs';
56

@@ -39,14 +40,12 @@ class AdminApp extends AbstractApp
3940
DomainStore.domains.loading(false);
4041
if (StorageResultType.Success === result && data && data.Result)
4142
{
42-
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => {
43-
return {
44-
name: name,
45-
disabled: ko.observable(!enabled),
46-
alias: alias,
47-
deleteAccess: ko.observable(false)
48-
};
49-
}));
43+
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => ({
44+
name: name,
45+
disabled: ko.observable(!enabled),
46+
alias: alias,
47+
deleteAccess: ko.observable(false)
48+
})));
5049
}
5150
});
5251
}
@@ -57,13 +56,11 @@ class AdminApp extends AbstractApp
5756
PluginStore.plugins.loading(false);
5857
if (StorageResultType.Success === result && data && data.Result)
5958
{
60-
PluginStore.plugins(_.map(data.Result, (item) => {
61-
return {
62-
name: item.Name,
63-
disabled: ko.observable(!item.Enabled),
64-
configured: ko.observable(!!item.Configured)
65-
};
66-
}));
59+
PluginStore.plugins(_.map(data.Result, (item) => ({
60+
name: item.Name,
61+
disabled: ko.observable(!item.Enabled),
62+
configured: ko.observable(!!item.Configured)
63+
})));
6764
}
6865
});
6966
}
@@ -203,15 +200,15 @@ class AdminApp extends AbstractApp
203200
}, force);
204201
}
205202

206-
bootend(callback = null) {
203+
bootend(bootendCallback = null) {
207204
if (progressJs)
208205
{
209206
progressJs.end();
210207
}
211208

212-
if (callback)
209+
if (bootendCallback)
213210
{
214-
callback();
211+
bootendCallback();
215212
}
216213
}
217214

dev/App/User.jsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

2-
import {window, _, $} from 'common';
2+
import window from 'window';
3+
import _ from '_';
4+
import $ from '$';
35
import progressJs from 'progressJs';
46
import Tinycon from 'Tinycon';
57

68
import {
7-
noop, trim, log, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
9+
noop, trim, log, has, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
810
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize
911
} from 'Common/Utils';
1012

@@ -411,18 +413,17 @@ class AppUser extends AbstractApp
411413
* @param {Function=} callback = null
412414
*/
413415
foldersReload(callback = null) {
414-
415-
Promises.foldersReload(FolderStore.foldersLoading).then((value) => {
416-
if (callback)
417-
{
416+
const prom = Promises.foldersReload(FolderStore.foldersLoading);
417+
if (callback)
418+
{
419+
prom.then((value) => {
418420
callback(!!value);
419-
}
420-
}).catch(() => {
421-
if (callback)
422-
{
423-
_.delay(() => callback(false), 1);
424-
}
425-
});
421+
}).catch(() => {
422+
_.delay(() => {
423+
callback(false);
424+
}, 1);
425+
});
426+
}
426427
}
427428

428429
foldersPromisesActionHelper(promise, errorDefCode) {
@@ -481,7 +482,9 @@ class AppUser extends AbstractApp
481482
iIndex,
482483
oItem.primaryKey.getFingerprint(),
483484
oItem.primaryKey.getKeyId().toHex().toLowerCase(),
484-
_.uniq(_.compact(_.map(oItem.getKeyIds(), (item) => item && item.toHex ? item.toHex() : null))),
485+
_.uniq(_.compact(_.map(
486+
oItem.getKeyIds(), (item) => (item && item.toHex ? item.toHex() : null)
487+
))),
485488
aUsers,
486489
aEmails,
487490
oItem.isPrivate(),
@@ -672,7 +675,7 @@ class AppUser extends AbstractApp
672675
{
673676
for (uid in data.Result.Flags)
674677
{
675-
if (data.Result.Flags.hasOwnProperty(uid))
678+
if (has(data.Result.Flags, uid))
676679
{
677680
check = true;
678681
const flags = data.Result.Flags[uid];
@@ -808,7 +811,7 @@ class AppUser extends AbstractApp
808811
aMessages = MessageStore.messageListChecked();
809812
}
810813

811-
aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid) ? oMessage.uid : null)));
814+
aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null))));
812815

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

935938
/**
936939
* @param {string} query
937-
* @param {Function} callback
940+
* @param {Function} autocompleteCallback
938941
*/
939-
getAutocomplete(query, callback) {
942+
getAutocomplete(query, autocompleteCallback) {
940943
Remote.suggestions((result, data) => {
941944
if (StorageResultType.Success === result && data && isArray(data.Result))
942945
{
943-
callback(_.compact(_.map(data.Result,
944-
(item) => item && item[0] ? new EmailModel(item[0], item[1]) : null)));
946+
autocompleteCallback(_.compact(_.map(data.Result, (item) => (item && item[0] ? new EmailModel(item[0], item[1]) : null))));
945947
}
946948
else if (StorageResultType.Abort !== result)
947949
{
948-
callback([]);
950+
autocompleteCallback([]);
949951
}
950952
}, query);
951953
}
@@ -1407,7 +1409,7 @@ class AppUser extends AbstractApp
14071409
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
14081410
'' + (Settings.settingsGet('Title') || 'RainLoop'));
14091411
}
1410-
catch (e) {/* eslint-disable-line no-empty */}
1412+
catch (e) {} // eslint-disable-line no-empty
14111413

14121414
if (Settings.settingsGet('MailToEmail'))
14131415
{

dev/Common/Audio.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
import {window, $} from 'common';
2+
import window from 'window';
3+
import $ from '$';
34
import {bMobileDevice, bSafari} from 'Common/Globals';
45
import * as Links from 'Common/Links';
56
import * as Events from 'Common/Events';

dev/Common/Booter.jsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
import window from 'window';
33
import progressJs from 'progressJs';
4+
import Promise from 'Promise';
45

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

3839
/**
@@ -41,7 +42,7 @@ function includeStyle(styles)
4142
*/
4243
function includeScr(src)
4344
{
44-
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E'));
45+
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
4546
}
4647

4748
/**
@@ -203,27 +204,30 @@ function runApp()
203204
}
204205
}
205206
}),
206-
common = window.Promise.all([
207+
common = Promise.all([
207208
window.jassl(appData.TemplatesLink),
208209
window.jassl(appData.LangLink)
209210
]);
210211

211-
window.Promise.all([libs, common])
212+
Promise.all([libs, common])
212213
.then(() => {
213214
p.set(30);
214215
return window.jassl(appData.StaticAppJsLink);
215-
}).then(() => {
216+
})
217+
.then(() => {
216218
p.set(50);
217219
return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve();
218-
}).then(() => {
220+
})
221+
.then(() => {
219222
p.set(70);
220223
runMainBoot(false);
221-
}).catch((e) => {
224+
})
225+
.catch((e) => {
222226
runMainBoot(true);
223227
throw e;
224-
}).then(() => {
225-
return window.jassl(appData.StaticEditorJsLink);
226-
}).then(() => {
228+
})
229+
.then(() => window.jassl(appData.StaticEditorJsLink))
230+
.then(() => {
227231
if (window.CKEDITOR && window.__initEditor) {
228232
window.__initEditor();
229233
window.__initEditor = null;

dev/Common/Cache.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import {_} from 'common';
2+
import _ from '_';
33
import {Capa, MessageSetAction} from 'Common/Enums';
44
import {trim, pInt, isArray} from 'Common/Utils';
55
import * as Links from 'Common/Links';

dev/Common/ClientStorageDriver/Cookie.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2-
import {window, JSON, $} from 'common';
2+
import window from 'window';
3+
import $ from '$';
4+
import JSON from 'JSON';
35
import {isUnd} from 'Common/Utils';
46
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
57

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

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

@@ -33,7 +35,7 @@ class CookieDriver
3335

3436
result = true;
3537
}
36-
catch (e) {/* eslint-disable-line no-empty */}
38+
catch (e) {} // eslint-disable-line no-empty
3739

3840
return result;
3941
}
@@ -54,7 +56,7 @@ class CookieDriver
5456

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

5961
return result;
6062
}

dev/Common/ClientStorageDriver/LocalStorage.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
import {window, JSON} from 'common';
2+
import window from 'window';
3+
import JSON from 'JSON';
34
import {isUnd} from 'Common/Utils';
45
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
56

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

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

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

3536
return result;
3637
}
@@ -51,7 +52,7 @@ class LocalStorageDriver
5152

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

5657
return result;
5758
}

dev/Common/Events.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import {_} from 'common';
2+
import _ from '_';
33
import {isObject, isUnd} from 'Common/Utils';
44
import * as Plugins from 'Common/Plugins';
55

0 commit comments

Comments
 (0)