diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 000000000..d1fe6ef29 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,156 @@ +{ + "parser": "babel-eslint", + "ecmaFeatures": { + "modules": true, + "arrowFunctions": true, + "blockBindings": true + }, + "env": { + "node": true, + "es6": true, + "browser": true + }, + "rules": { + "comma-dangle": [2, "never"], + "no-cond-assign": 2, + "no-console": 2, + "no-constant-condition": 2, + "no-control-regex": 2, + "no-debugger": 2, + "no-dupe-keys": 2, + "no-empty": 2, + "no-empty-character-class": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": 0, + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-negated-in-lhs": 2, + "no-obj-calls": 2, + "no-regex-spaces": 2, + "no-reserved-keys": 0, + "no-sparse-arrays": 2, + "no-unreachable": 2, + "use-isnan": 2, + "valid-jsdoc": 0, + "valid-typeof": 2, + // Best Practices + "block-scoped-var": 2, + "complexity": 0, + "consistent-return": 2, + "curly": 2, +// "default-case": 2, + "dot-notation": 2, + "eqeqeq": 2, + "guard-for-in": 2, + "no-alert": 2, + "no-caller": 2, + "no-div-regex": 2, + "no-else-return": 2, + "no-eq-null": 2, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-implied-eval": 2, + "no-iterator": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-multi-spaces": 2, + "no-multi-str": 0, + "no-native-reassign": 2, + "no-new": 2, + "no-new-func": 2, + "no-new-wrappers": 2, + "no-octal": 2, + "no-octal-escape": 2, + "no-process-env": 2, + "no-proto": 2, + "no-redeclare": 2, + "no-return-assign": 2, + "no-script-url": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-unused-expressions": 2, + "no-void": 0, + "no-warning-comments": 2, + "no-with": 2, + "radix": 2, + "vars-on-top": 0, + "wrap-iife": 2, + "yoda": 0, + // Strict Mode + "strict": 0, + // Variables + "no-catch-shadow": 2, + "no-delete-var": 2, + "no-label-var": 2, + "no-shadow": 2, + "no-shadow-restricted-names": 2, + "no-undef": 2, + "no-undef-init": 2, + "no-undefined": 2, + "no-unused-vars": 2, + "no-use-before-define": 2, + // Stylistic Issues +// "indent": [2, "tab", { +// "SwitchCase": 1, +// "VariableDeclarator": 1 +// }], + "camelcase": 0, + "comma-spacing": 2, + "comma-style": 2, + "consistent-this": 0, + "eol-last": 2, + "func-names": 0, + "func-style": 0, + "key-spacing": [2, { + "beforeColon": false, + "afterColon": true + }], + "max-nested-callbacks": 0, + "new-cap": 2, + "new-parens": 2, + "no-array-constructor": 2, + "no-inline-comments": 0, +// "no-lonely-if": 2, + "no-mixed-spaces-and-tabs": 2, +// "no-nested-ternary": 2, + "no-new-object": 2, + "semi-spacing": [2, { + "before": false, + "after": true + }], + "no-spaced-func": 2, + "no-ternary": 0, + "no-trailing-spaces": 2, + "no-multiple-empty-lines": 2, + "no-underscore-dangle": 0, + "one-var": 0, + "operator-assignment": [2, "always"], + "padded-blocks": 0, + "quotes": [2, "single"], + "quote-props": [2, "as-needed"], + "semi": [2, "always"], +// "sort-vars": [2, {"ignoreCase": true}], + "space-before-blocks": 2, + "object-curly-spacing": [2, "never"], + "array-bracket-spacing": [2, "never"], + "space-in-parens": 2, + "space-infix-ops": 2, + "space-unary-ops": 2, + "spaced-comment": 2, + "wrap-regex": 0, + // Legacy + "max-depth": 0, + "max-len": [2, 200], + "max-params": 0, + "max-statements": 0, + "no-plusplus": 0 + } +} \ No newline at end of file diff --git a/dev/App/Abstract.jsx b/dev/App/Abstract.jsx index 3791a03b1..4e9fbbc11 100644 --- a/dev/App/Abstract.jsx +++ b/dev/App/Abstract.jsx @@ -1,7 +1,7 @@ import {window, _, $, key} from 'common'; import Globals from 'Common/Globals'; -import * as Enums from 'Common/Enums'; +import * as Enums from 'Common/Enums'; import Utils from 'Common/Utils'; import Links from 'Common/Links'; import Events from 'Common/Events'; @@ -64,7 +64,7 @@ class AbstractApp extends AbstractBoot }, 50)); - // DEBUG +// DEBUG // Events.sub({ // 'window.resize': function () { // window.console.log('window.resize'); @@ -112,15 +112,15 @@ class AbstractApp extends AbstractBoot if (Globals.sUserAgent && (Globals.sUserAgent.indexOf('chrome') > -1 || Globals.sUserAgent.indexOf('chrome') > -1)) { const oLink = window.document.createElement('a'); - oLink['href'] = link; + oLink.href = link; - if (window.document['createEvent']) + if (window.document && window.document.createEvent) { - const oE = window.document['createEvent']('MouseEvents'); - if (oE && oE['initEvent'] && oLink['dispatchEvent']) + const oE = window.document.createEvent.MouseEvents; + if (oE && oE.initEvent && oLink.dispatchEvent) { - oE['initEvent']('click', true, true); - oLink['dispatchEvent'](oE); + oE.initEvent('click', true, true); + oLink.dispatchEvent(oE); return true; } } @@ -179,14 +179,14 @@ class AbstractApp extends AbstractBoot } /** - * @param {string} key + * @param {string} token */ - setClientSideToken(key) { + setClientSideToken(token) { if (window.__rlah_set) { - window.__rlah_set(key); + window.__rlah_set(token); - require('Storage/Settings').settingsSet('AuthAccountHash', key); + require('Storage/Settings').settingsSet('AuthAccountHash', token); require('Common/Links').populateAuthSuffix(); } } @@ -203,7 +203,7 @@ class AbstractApp extends AbstractBoot inIframe = !!Settings.settingsGet('InIframe') ; - let customLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')) + let customLogoutLink = Utils.pString(Settings.settingsGet('CustomLogoutLink')); if (logout) { @@ -273,7 +273,7 @@ class AbstractApp extends AbstractBoot ko.components.register('x-script', require('Component/Script')); // ko.components.register('svg-icon', require('Component/SvgIcon')); - if (/**false && /**/Settings.settingsGet('MaterialDesign') && Globals.bAnimationSupported) + if (Settings.settingsGet('MaterialDesign') && Globals.bAnimationSupported) { ko.components.register('Checkbox', require('Component/MaterialDesign/Checkbox')); ko.components.register('CheckboxSimple', require('Component/Checkbox')); @@ -291,49 +291,49 @@ class AbstractApp extends AbstractBoot _.delay(Utils.windowResizeCallback, 1000); ssm.addState({ - 'id': 'mobile', - 'maxWidth': 767, - 'onEnter': () => { + id: 'mobile', + maxWidth: 767, + onEnter: () => { Globals.$html.addClass('ssm-state-mobile'); Events.pub('ssm.mobile-enter'); }, - 'onLeave': () => { + onLeave: () => { Globals.$html.removeClass('ssm-state-mobile'); Events.pub('ssm.mobile-leave'); } }); ssm.addState({ - 'id': 'tablet', - 'minWidth': 768, - 'maxWidth': 999, - 'onEnter': function() { + id: 'tablet', + minWidth: 768, + maxWidth: 999, + onEnter: function() { Globals.$html.addClass('ssm-state-tablet'); }, - 'onLeave': function() { + onLeave: function() { Globals.$html.removeClass('ssm-state-tablet'); } }); ssm.addState({ - 'id': 'desktop', - 'minWidth': 1000, - 'maxWidth': 1400, - 'onEnter': () => { + id: 'desktop', + minWidth: 1000, + maxWidth: 1400, + onEnter: () => { Globals.$html.addClass('ssm-state-desktop'); }, - 'onLeave': () => { + onLeave: () => { Globals.$html.removeClass('ssm-state-desktop'); } }); ssm.addState({ - 'id': 'desktop-large', - 'minWidth': 1400, - 'onEnter': () => { + id: 'desktop-large', + minWidth: 1400, + onEnter: () => { Globals.$html.addClass('ssm-state-desktop-large'); }, - 'onLeave': () => { + onLeave: () => { Globals.$html.removeClass('ssm-state-desktop-large'); } }); @@ -360,7 +360,7 @@ class AbstractApp extends AbstractBoot require('Stores/Language').populate(); require('Stores/Theme').populate(); require('Stores/Social').populate(); - }; + } } -export {AbstractApp, AbstractApp as default}; \ No newline at end of file +export {AbstractApp, AbstractApp as default}; diff --git a/dev/App/Admin.jsx b/dev/App/Admin.jsx index 47ab2e34c..470fc3d51 100644 --- a/dev/App/Admin.jsx +++ b/dev/App/Admin.jsx @@ -3,7 +3,7 @@ import {window, _} from 'common'; import ko from 'ko'; import progressJs from 'progressJs'; -import * as Enums from 'Common/Enums'; +import * as Enums from 'Common/Enums'; import Utils from 'Common/Utils'; import Links from 'Common/Links'; import Translator from 'Common/Translator'; @@ -41,9 +41,9 @@ class AdminApp extends AbstractApp { DomainStore.domains(_.map(data.Result, (enabled, name) => { return { - 'name': name, - 'disabled': ko.observable(!enabled), - 'deleteAccess': ko.observable(false) + name: name, + disabled: ko.observable(!enabled), + deleteAccess: ko.observable(false) }; })); } @@ -58,9 +58,9 @@ class AdminApp extends AbstractApp { PluginStore.plugins(_.map(data.Result, (item) => { return { - 'name': item['Name'], - 'disabled': ko.observable(!item['Enabled']), - 'configured': ko.observable(!!item['Configured']) + name: item.Name, + disabled: ko.observable(!item.Enabled), + configured: ko.observable(!!item.Configured) }; })); } @@ -83,9 +83,9 @@ class AdminApp extends AbstractApp ; _.each(PackageStore.packages(), (item) => { - if (item && item['loading']()) + if (item && item.loading()) { - loading[item['file']] = item; + loading[item.file] = item; } }); @@ -94,8 +94,8 @@ class AdminApp extends AbstractApp list = _.compact(_.map(data.Result.List, (item) => { if (item) { - item['loading'] = ko.observable(!Utils.isUnd(loading[item['file']])); - return 'core' === item['type'] && !item['canBeInstalled'] ? null : item; + item.loading = ko.observable(!Utils.isUnd(loading[item.file])); + return 'core' === item.type && !item.canBeInstalled ? null : item; } return null; })); @@ -170,10 +170,10 @@ class AdminApp extends AbstractApp LicenseStore.licenseError(''); Remote.licensing((result, data) => { LicenseStore.licensingProcess(false); - if (Enums.StorageResultType.Success === result && data && data.Result && Utils.isNormal(data.Result['Expired'])) + if (Enums.StorageResultType.Success === result && data && data.Result && Utils.isNormal(data.Result.Expired)) { LicenseStore.licenseValid(true); - LicenseStore.licenseExpired(Utils.pInt(data.Result['Expired'])); + LicenseStore.licenseExpired(Utils.pInt(data.Result.Expired)); LicenseStore.licenseError(''); LicenseStore.licensing(true); AppStore.prem(true); @@ -237,7 +237,7 @@ class AdminApp extends AbstractApp } else { - if (!!Settings.settingsGet('Auth')) + if (Settings.settingsGet('Auth')) { kn.startScreens([ require('Screen/Admin/Settings') diff --git a/dev/App/User.jsx b/dev/App/User.jsx index a16792283..d080b206b 100644 --- a/dev/App/User.jsx +++ b/dev/App/User.jsx @@ -1,6 +1,5 @@ import {window, _, $} from 'common'; -import ko from 'ko'; import progressJs from 'progressJs'; import Tinycon from 'Tinycon'; @@ -86,10 +85,15 @@ class AppUser extends AbstractApp if (Settings.settingsGet('UserBackgroundHash')) { _.delay(() => { - $('#rl-bg').attr('style', 'background-image: none !important;') - .backstretch(Links.userBackground(Settings.settingsGet('UserBackgroundHash')), { - 'fade': Globals.bAnimationSupported ? 1000 : 0, 'centeredX': true, 'centeredY': true - }).removeAttr('style'); + $('#rl-bg') + .attr('style', 'background-image: none !important;') + .backstretch(Links.userBackground(Settings.settingsGet('UserBackgroundHash')), { + fade: Globals.bAnimationSupported ? 1000 : 0, + centeredX: true, + centeredY: true + }) + .removeAttr('style') + ; }, 1000); } @@ -205,12 +209,12 @@ class AppUser extends AbstractApp _.each(this.oMoveCache, (oItem) => { var - bSpam = sSpamFolder === oItem['To'], - bTrash = sTrashFolder === oItem['To'], - bHam = !bSpam && sSpamFolder === oItem['From'] && Cache.getFolderInboxName() === oItem['To'] + bSpam = sSpamFolder === oItem.To, + bTrash = sTrashFolder === oItem.To, + bHam = !bSpam && sSpamFolder === oItem.From && Cache.getFolderInboxName() === oItem.To ; - Remote.messagesMove(this.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'], + Remote.messagesMove(this.moveOrDeleteResponseHelper, oItem.From, oItem.To, oItem.Uid, bSpam ? 'SPAM' : (bHam ? 'HAM' : ''), bSpam || bTrash); }); @@ -223,13 +227,13 @@ class AppUser extends AbstractApp if (!this.oMoveCache[sH]) { this.oMoveCache[sH] = { - 'From': sFromFolderFullNameRaw, - 'To': sToFolderFullNameRaw, - 'Uid': [] + From: sFromFolderFullNameRaw, + To: sToFolderFullNameRaw, + Uid: [] }; } - this.oMoveCache[sH]['Uid'] = _.union(this.oMoveCache[sH]['Uid'], aUidForMove); + this.oMoveCache[sH].Uid = _.union(this.oMoveCache[sH].Uid, aUidForMove); this.messagesMoveTrigger(); } @@ -434,13 +438,13 @@ class AppUser extends AbstractApp ; if (oItem.users) { - _.each(oItem.users, (oItem) => { + _.each(oItem.users, (item) => { oEmail.clear(); - oEmail.mailsoParse(oItem.userId.userid); + oEmail.mailsoParse(item.userId.userid); if (oEmail.validate()) { aEmails.push(oEmail.email); - aUsers.push(oItem.userId.userid); + aUsers.push(item.userId.userid); } }); } @@ -494,7 +498,7 @@ class AppUser extends AbstractApp // }); // } // }); - }; + } accountsAndIdentities(bBoot) { @@ -516,7 +520,7 @@ class AppUser extends AbstractApp sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; - if (Utils.isArray(oData.Result['Accounts'])) + if (Utils.isArray(oData.Result.Accounts)) { _.each(AccountStore.accounts(), (oAccount) => { aCounts[oAccount.email] = oAccount.count(); @@ -524,7 +528,7 @@ class AppUser extends AbstractApp Utils.delegateRunOnDestroy(AccountStore.accounts()); - AccountStore.accounts(_.map(oData.Result['Accounts'], + AccountStore.accounts(_.map(oData.Result.Accounts, (sValue) => new AccountModel(sValue, sValue !== sParentEmail, aCounts[sValue] || 0))); } @@ -534,23 +538,23 @@ class AppUser extends AbstractApp Events.sub('interval.10m-after5m', () => this.accountsCounts()); } - if (Utils.isArray(oData.Result['Identities'])) + if (Utils.isArray(oData.Result.Identities)) { Utils.delegateRunOnDestroy(IdentityStore.identities()); - IdentityStore.identities(_.map(oData.Result['Identities'], (oIdentityData) => { + IdentityStore.identities(_.map(oData.Result.Identities, (oIdentityData) => { const - sId = Utils.pString(oIdentityData['Id']), - sEmail = Utils.pString(oIdentityData['Email']), + sId = Utils.pString(oIdentityData.Id), + sEmail = Utils.pString(oIdentityData.Email), oIdentity = new IdentityModel(sId, sEmail) ; - oIdentity.name(Utils.pString(oIdentityData['Name'])); - oIdentity.replyTo(Utils.pString(oIdentityData['ReplyTo'])); - oIdentity.bcc(Utils.pString(oIdentityData['Bcc'])); - oIdentity.signature(Utils.pString(oIdentityData['Signature'])); - oIdentity.signatureInsertBefore(!!oIdentityData['SignatureInsertBefore']); + oIdentity.name(Utils.pString(oIdentityData.Name)); + oIdentity.replyTo(Utils.pString(oIdentityData.ReplyTo)); + oIdentity.bcc(Utils.pString(oIdentityData.Bcc)); + oIdentity.signature(Utils.pString(oIdentityData.Signature)); + oIdentity.signatureInsertBefore(!!oIdentityData.SignatureInsertBefore); return oIdentity; })); @@ -568,11 +572,11 @@ class AppUser extends AbstractApp TemplateStore.templates.loading(false); if (Enums.StorageResultType.Success === result && data.Result && - Utils.isArray(data.Result['Templates'])) + Utils.isArray(data.Result.Templates)) { Utils.delegateRunOnDestroy(TemplateStore.templates()); - TemplateStore.templates(_.compact(_.map(data.Result['Templates'], (templateData) => { + TemplateStore.templates(_.compact(_.map(data.Result.Templates, (templateData) => { const template = new TemplateModel(); return template.parse(templateData) ? template : null; }))); @@ -606,15 +610,14 @@ class AppUser extends AbstractApp { let uid = '', - list = [], check = false, unreadCountChange = false ; - const folder = Cache.getFolderFromCacheList(data.Result.Folder); - if (folder) + const folderFromCache = Cache.getFolderFromCacheList(data.Result.Folder); + if (folderFromCache) { - folder.interval = Momentor.momentNowUnix(); + folderFromCache.interval = Momentor.momentNowUnix(); if (data.Result.Hash) { @@ -623,22 +626,22 @@ class AppUser extends AbstractApp if (Utils.isNormal(data.Result.MessageCount)) { - folder.messageCountAll(data.Result.MessageCount); + folderFromCache.messageCountAll(data.Result.MessageCount); } if (Utils.isNormal(data.Result.MessageUnseenCount)) { - if (Utils.pInt(folder.messageCountUnread()) !== Utils.pInt(data.Result.MessageUnseenCount)) + if (Utils.pInt(folderFromCache.messageCountUnread()) !== Utils.pInt(data.Result.MessageUnseenCount)) { unreadCountChange = true; } - folder.messageCountUnread(data.Result.MessageUnseenCount); + folderFromCache.messageCountUnread(data.Result.MessageUnseenCount); } if (unreadCountChange) { - Cache.clearMessageFlagsFromCacheByFolder(folder.fullNameRaw); + Cache.clearMessageFlagsFromCacheByFolder(folderFromCache.fullNameRaw); } if (data.Result.Flags) @@ -649,8 +652,8 @@ class AppUser extends AbstractApp { check = true; const flags = data.Result.Flags[uid]; - Cache.storeMessageFlagsToCacheByFolderAndUid(folder.fullNameRaw, uid.toString(), [ - !flags['IsSeen'], !!flags['IsFlagged'], !!flags['IsAnswered'], !!flags['IsForwarded'], !!flags['IsReadReceipt'] + Cache.storeMessageFlagsToCacheByFolderAndUid(folderFromCache.fullNameRaw, uid.toString(), [ + !flags.IsSeen, !!flags.IsFlagged, !!flags.IsAnswered, !!flags.IsForwarded, !!flags.IsReadReceipt ]); } } @@ -661,16 +664,16 @@ class AppUser extends AbstractApp } } - MessageStore.initUidNextAndNewMessages(folder.fullNameRaw, data.Result.UidNext, data.Result.NewMessages); + MessageStore.initUidNextAndNewMessages(folderFromCache.fullNameRaw, data.Result.UidNext, data.Result.NewMessages); const hash = Cache.getFolderHash(data.Result.Folder); if (data.Result.Hash !== hash || '' === hash || unreadCountChange) { - if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw()) + if (folderFromCache.fullNameRaw === FolderStore.currentFolderFullNameRaw()) { this.reloadMessageList(); } - else if (Cache.getFolderInboxName() === folder.fullNameRaw) + else if (Cache.getFolderInboxName() === folderFromCache.fullNameRaw) { this.recacheInboxMessageList(); } @@ -680,7 +683,7 @@ class AppUser extends AbstractApp } }, folder, list); } - }; + } /** * @param {boolean=} boot = false @@ -762,7 +765,7 @@ class AppUser extends AbstractApp } }, folders); } - }; + } /** * @param {string} sFolderFullNameRaw @@ -873,9 +876,9 @@ class AppUser extends AbstractApp if (Enums.StorageResultType.Success === result && data && data.Result) { - SocialStore.google.userName(data.Result['Google'] || ''); - SocialStore.facebook.userName(data.Result['Facebook'] || ''); - SocialStore.twitter.userName(data.Result['Twitter'] || ''); + SocialStore.google.userName(data.Result.Google || ''); + SocialStore.facebook.userName(data.Result.Facebook || ''); + SocialStore.twitter.userName(data.Result.Twitter || ''); } else { @@ -955,6 +958,21 @@ class AppUser extends AbstractApp oTop = null, oBottom = null, + fSetHeight = (height) => { + if (height) + { + if (oTop) + { + oTop.attr('style', 'height:' + height + 'px'); + } + + if (oBottom) + { + oBottom.attr('style', 'top:' + (55 /* top toolbar */ + height) + 'px'); + } + } + }, + fResizeCreateFunction = (event) => { if (event && event.target) { @@ -992,29 +1010,14 @@ class AppUser extends AbstractApp }, oOptions = { - 'helper': 'ui-resizable-helper-h', - 'minHeight': iMinHeight, - 'maxHeight': iMaxHeight, - 'handles': 's', - 'create': fResizeCreateFunction, - 'resize': fResizeResizeFunction, - 'start': fResizeStartFunction, - 'stop': fResizeStopFunction - }, - - fSetHeight = (height) => { - if (height) - { - if (oTop) - { - oTop.attr('style', 'height:' + height + 'px'); - } - - if (oBottom) - { - oBottom.attr('style', 'top:' + (55 /* top toolbar */ + height) + 'px'); - } - } + helper: 'ui-resizable-helper-h', + minHeight: iMinHeight, + maxHeight: iMaxHeight, + handles: 's', + create: fResizeCreateFunction, + resize: fResizeResizeFunction, + start: fResizeStartFunction, + stop: fResizeStopFunction }, fDisable = (bDisable) => { @@ -1054,7 +1057,7 @@ class AppUser extends AbstractApp Events.sub('layout', (layout) => { fDisable(Enums.Layout.BottomPreview !== layout); }); - }; + } initVerticalLayoutResizer(sClientSideKeyName) { @@ -1070,11 +1073,11 @@ class AppUser extends AbstractApp if (iWidth) { oLeft.css({ - 'width': '' + iWidth + 'px' + width: '' + iWidth + 'px' }); oRight.css({ - 'left': '' + iWidth + 'px' + left: '' + iWidth + 'px' }); } }, @@ -1118,7 +1121,7 @@ class AppUser extends AbstractApp Local.set(sClientSideKeyName, oObject.size.width); oRight.css({ - 'left': '' + oObject.size.width + 'px' + left: '' + oObject.size.width + 'px' }); } } @@ -1130,14 +1133,14 @@ class AppUser extends AbstractApp } oLeft.resizable({ - 'helper': 'ui-resizable-helper-w', - 'minWidth': iMinWidth, - 'maxWidth': 350, - 'handles': 'e', - 'create': fResizeCreateFunction, - 'resize': fResizeResizeFunction, - 'start': fResizeStartFunction, - 'stop': fResizeStopFunction + helper: 'ui-resizable-helper-w', + minWidth: iMinWidth, + maxWidth: 350, + handles: 'e', + create: fResizeCreateFunction, + resize: fResizeResizeFunction, + start: fResizeStartFunction, + stop: fResizeStopFunction }); Events.sub('left-panel.off', () => { @@ -1154,7 +1157,7 @@ class AppUser extends AbstractApp this.loginAndLogoutReload(false, true, Settings.settingsGet('ParentEmail') && 0 < Settings.settingsGet('ParentEmail').length); }); - }; + } bootstartTwoFactorScreen() { kn.showScreenPopup(require('View/Popup/TwoFactorConfiguration'), [true]); @@ -1195,7 +1198,7 @@ class AppUser extends AbstractApp { kn.hideLoading(); - progressJs.onbeforeend(() => { + progressJs.onbeforeend(() => { $('.progressjs-container').hide(); _.delay(() => { $('.progressjs-container').remove(); @@ -1208,7 +1211,7 @@ class AppUser extends AbstractApp { kn.hideLoading(); } - }; + } bootstart() { @@ -1240,7 +1243,7 @@ class AppUser extends AbstractApp }); this.setWindowTitle(''); - if (!!Settings.settingsGet('Auth')) + if (Settings.settingsGet('Auth')) { Globals.$html.addClass('rl-user-auth'); @@ -1255,7 +1258,7 @@ class AppUser extends AbstractApp { this.setWindowTitle(Translator.i18n('TITLES/LOADING')); -//require.ensure([], function() { // require code splitting +// require.ensure([], function() { // require code splitting this.foldersReload((value) => { @@ -1319,8 +1322,8 @@ class AppUser extends AbstractApp kn.startScreens([ require('Screen/User/MailBox'), - Settings.capa(Enums.Capa.Settings) ? require('Screen/User/Settings') : null, - false ? require('Screen/User/About') : null + Settings.capa(Enums.Capa.Settings) ? require('Screen/User/Settings') : null +// false ? require('Screen/User/About') : null ]); if (bGoogle || bFacebook || bTwitter) @@ -1381,7 +1384,7 @@ class AppUser extends AbstractApp window.navigator.registerProtocolHandler('mailto', window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', '' + (Settings.settingsGet('Title') || 'RainLoop')); - } catch(e) {} + } catch (e) {/* eslint-disable-line no-empty */} if (Settings.settingsGet('MailToEmail')) { @@ -1394,7 +1397,7 @@ class AppUser extends AbstractApp { _.defer(() => this.initVerticalLayoutResizer(Enums.ClientSideKeyName.FolderListSize)); - if (Tinycon && Settings.settingsGet('FaviconStatus') && !Settings.settingsGet('Filtered') ) + if (Tinycon && Settings.settingsGet('FaviconStatus') && !Settings.settingsGet('Filtered')) { Tinycon.setOptions({ fallback: false @@ -1412,7 +1415,7 @@ class AppUser extends AbstractApp }); -//}); // require code splitting +// }); // require code splitting } } diff --git a/dev/Common/Audio.jsx b/dev/Common/Audio.jsx index a3aa20571..7a0ae10d1 100644 --- a/dev/Common/Audio.jsx +++ b/dev/Common/Audio.jsx @@ -21,7 +21,7 @@ class Audio this.player = this.createNewObject(); this.supported = !Globals.bMobileDevice && !Globals.bSafari && !!this.player && !!this.player.play; - if (this.supported && this.player.canPlayType) + if (this.supported && this.player.canPlayType) { this.supportedMp3 = '' !== this.player.canPlayType('audio/mpeg;').replace(/no/, ''); this.supportedWav = '' !== this.player.canPlayType('audio/wav; codecs="1"').replace(/no/, ''); diff --git a/dev/Common/Base64.jsx b/dev/Common/Base64.jsx index eeba0c976..eab6cad4d 100644 --- a/dev/Common/Base64.jsx +++ b/dev/Common/Base64.jsx @@ -4,7 +4,8 @@ const BASE_64_CHR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; -/*jslint bitwise: true*/ +/* jslint bitwise: true */ +/* eslint-disable */ const Base64 = { // public method for urlsafe encoding @@ -13,7 +14,7 @@ const Base64 = { // public method for encoding encode: (input) => { - + let output = '', chr1, chr2, chr3, enc1, enc2, enc3, enc4, @@ -164,4 +165,5 @@ const Base64 = { }; module.exports = Base64; -/*jslint bitwise: false*/ +/* jslint bitwise: false */ +/* eslint-enable */ diff --git a/dev/Common/Cache.jsx b/dev/Common/Cache.jsx index 369c7677f..77ed2e054 100644 --- a/dev/Common/Cache.jsx +++ b/dev/Common/Cache.jsx @@ -1,5 +1,4 @@ - import {_} from 'common'; import {Capa, MessageSetAction} from 'Common/Enums'; import Utils from 'Common/Utils'; @@ -239,17 +238,17 @@ class CacheUserStorage if (0 < message.threads().length) { const unseenSubUid = _.find(message.threads(), (sSubUid) => { - if (uid !== sSubUid){ - const flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid); - return flags && 0 < flags.length && !!flags[0]; + if (uid !== sSubUid) { + const subFlags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid); + return subFlags && 0 < subFlags.length && !!subFlags[0]; } return false; }); const flaggedSubUid = _.find(message.threads(), (sSubUid) => { if (uid !== sSubUid) { - const flags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid); - return flags && 0 < flags.length && !!flags[1]; + const subFlags = this.getMessageFlagsFromCache(message.folderFullNameRaw, sSubUid); + return subFlags && 0 < subFlags.length && !!subFlags[1]; } return false; }); @@ -269,7 +268,7 @@ class CacheUserStorage this.setMessageFlagsToCache( message.folderFullNameRaw, message.uid, [message.unseen(), message.flagged(), message.answered(), message.forwarded(), - message.isReadReceipt(), message.deletedMark()] + message.isReadReceipt(), message.deletedMark()] ); } } @@ -293,7 +292,7 @@ class CacheUserStorage */ storeMessageFlagsToCacheBySetAction(folder, uid, setAction) { - let unread = 0; + let unread = 0; const flags = this.getMessageFlagsFromCache(folder, uid); if (Utils.isArray(flags) && 0 < flags.length) diff --git a/dev/Common/ClientStorageDriver/Cookie.jsx b/dev/Common/ClientStorageDriver/Cookie.jsx index 106021758..d7c493ede 100644 --- a/dev/Common/ClientStorageDriver/Cookie.jsx +++ b/dev/Common/ClientStorageDriver/Cookie.jsx @@ -22,19 +22,25 @@ class CookieDriver const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME); storageResult = null === storageValue ? null : JSON.parse(storageValue); } - catch (e) {} + catch (e) + { + // eslint-disable-line no-empty + } (storageResult || (storageResult = {}))[key] = data; try { $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME, JSON.stringify(storageResult), { - 'expires': 30 + expires: 30 }); result = true; } - catch (e) {} + catch (e) + { + // eslint-disable-line no-empty + } return result; } @@ -43,7 +49,7 @@ class CookieDriver * @param {string} key * @return {*} */ - get(sKey) { + get(key) { let result = null; @@ -56,10 +62,13 @@ class CookieDriver result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null; } - catch (e) {} + catch (e) + { + // eslint-disable-line no-empty + } - return mResult; - }; + return result; + } /** * @return {boolean} diff --git a/dev/Common/ClientStorageDriver/LocalStorage.jsx b/dev/Common/ClientStorageDriver/LocalStorage.jsx index 16e71fdf0..b71799644 100644 --- a/dev/Common/ClientStorageDriver/LocalStorage.jsx +++ b/dev/Common/ClientStorageDriver/LocalStorage.jsx @@ -22,7 +22,10 @@ class LocalStorageDriver const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null; storageResult = null === storageValue ? null : JSON.parse(storageValue); } - catch (e) {} + catch (e) + { + // eslint-disable-line no-empty + } (storageResult || (storageResult = {}))[key] = data; @@ -31,7 +34,10 @@ class LocalStorageDriver window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult); result = true; } - catch (e) {} + catch (e) + { + // eslint-disable-line no-empty + } return result; } @@ -41,19 +47,22 @@ class LocalStorageDriver * @return {*} */ get(key) { - + let result = null; - + try { - const + const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null, storageResult = null === storageValue ? null : JSON.parse(storageValue) ; - result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null + result = (storageResult && !Utils.isUnd(storageResult[key])) ? storageResult[key] : null; + } + catch (e) + { + // eslint-disable-line no-empty } - catch (e) {} return result; } diff --git a/dev/Common/Consts.jsx b/dev/Common/Consts.jsx index 19fc462e1..7b150b60d 100644 --- a/dev/Common/Consts.jsx +++ b/dev/Common/Consts.jsx @@ -1,7 +1,9 @@ +/* eslint max-len: 0 */ + export const MESSAGES_PER_PAGE = 20; -export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100/*, 150, 200, 300*/]; +export const MESSAGES_PER_PAGE_VALUES = [10, 20, 30, 50, 100]; export const CONTACTS_PER_PAGE = 50; diff --git a/dev/Common/Enums.jsx b/dev/Common/Enums.jsx index 210315dbe..f19bdaa45 100644 --- a/dev/Common/Enums.jsx +++ b/dev/Common/Enums.jsx @@ -1,4 +1,6 @@ +/* eslint quote-props: 0 */ + /** * @enum {string} */ @@ -18,7 +20,7 @@ export const FileType = { 'Certificate': 'certificate', 'CertificateBin': 'certificate-bin', 'Archive': 'archive' -} +}; /** * @enum {string} @@ -28,7 +30,7 @@ export const StorageResultType = { 'Abort': 'abort', 'Error': 'error', 'Unload': 'unload' -} +}; /** * @enum {string} @@ -38,7 +40,7 @@ export const Focused = { 'MessageList': 'message-list', 'MessageView': 'message-view', 'FolderList': 'folder-list' -} +}; /** * @enum {number} @@ -47,7 +49,7 @@ export const State = { 'Empty': 10, 'Login': 20, 'Auth': 30 -} +}; /** * @enum {number} @@ -55,7 +57,7 @@ export const State = { export const StateType = { 'Webmail': 0, 'Admin': 1 -} +}; /** * @enum {string} @@ -87,7 +89,7 @@ export const Capa = { 'AutoLogout': 'AUTOLOGOUT', 'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS', 'Identities': 'IDENTITIES' -} +}; /** * @enum {string} @@ -107,7 +109,7 @@ export const KeyState = { 'PopupViewOpenPGP': 'view-open-pgp', 'PopupKeyboardShortcutsHelp': 'popup-keyboard-shortcuts-help', 'PopupAsk': 'popup-ask' -} +}; /** * @enum {number} @@ -121,7 +123,7 @@ export const FolderType = { 'Archive': 15, 'NotSpam': 80, 'User': 99 -} +}; /** * @enum {number} @@ -136,7 +138,7 @@ export const ServerFolderType = { 'IMPORTANT': 10, 'FLAGGED': 11, 'ALL': 12 -} +}; /** * @enum {string} @@ -145,7 +147,7 @@ export const LoginSignMeTypeAsString = { 'DefaultOff': 'defaultoff', 'DefaultOn': 'defaulton', 'Unused': 'unused' -} +}; /** * @enum {number} @@ -154,7 +156,7 @@ export const LoginSignMeType = { 'DefaultOff': 0, 'DefaultOn': 1, 'Unused': 2 -} +}; /** * @enum {string} @@ -167,7 +169,7 @@ export const ComposeType = { 'ForwardAsAttachment': 'forward-as-attachment', 'Draft': 'draft', 'EditAsNew': 'editasnew' -} +}; /** * @enum {number} @@ -181,7 +183,7 @@ export const UploadErrorCode = { 'FileOnSaveingError': 5, 'FileType': 98, 'Unknown': 99 -} +}; /** * @enum {number} @@ -193,7 +195,7 @@ export const SetSystemFoldersNotification = { 'Spam': 3, 'Trash': 4, 'Archive': 5 -} +}; /** * @enum {number} @@ -208,7 +210,7 @@ export const ClientSideKeyName = { 'LastReplyAction': 6, 'LastSignMe': 7, 'ComposeLastIdentityID': 8 -} +}; /** * @enum {number} @@ -231,7 +233,7 @@ export const EventKeyCode = { 'Delete': 46, 'A': 65, 'S': 83 -} +}; /** * @enum {number} @@ -241,7 +243,7 @@ export const MessageSetAction = { 'UnsetSeen': 1, 'SetFlag': 2, 'UnsetFlag': 3 -} +}; /** * @enum {number} @@ -254,7 +256,7 @@ export const MessageSelectAction = { 'Seen': 4, 'Flagged': 5, 'Unflagged': 6 -} +}; /** * @enum {number} @@ -264,7 +266,7 @@ export const DesktopNotification = { 'NotAllowed': 1, 'Denied': 2, 'NotSupported': 9 -} +}; /** * @enum {number} @@ -273,7 +275,7 @@ export const MessagePriority = { 'Low': 5, 'Normal': 3, 'High': 1 -} +}; /** * @enum {string} @@ -283,7 +285,7 @@ export const EditorDefaultType = { 'Plain': 'Plain', 'HtmlForced': 'HtmlForced', 'PlainForced': 'PlainForced' -} +}; /** * @enum {number} @@ -292,7 +294,7 @@ export const ServerSecure = { 'None': 0, 'SSL': 1, 'TLS': 2 -} +}; /** * @enum {number} @@ -302,7 +304,7 @@ export const SearchDateType = { 'Days3': 3, 'Days7': 7, 'Month': 30 -} +}; /** * @enum {number} @@ -312,7 +314,7 @@ export const SaveSettingsStep = { 'Idle': -1, 'TrueResult': 1, 'FalseResult': 0 -} +}; /** * @enum {number} @@ -322,7 +324,7 @@ export const Layout = { 'SidePreview': 1, 'BottomPreview': 2, 'Mobile': 3 -} +}; /** * @enum {string} @@ -333,7 +335,7 @@ export const FilterConditionField = { 'Subject': 'Subject', 'Header': 'Header', 'Size': 'Size' -} +}; /** * @enum {string} @@ -345,7 +347,7 @@ export const FilterConditionType = { 'NotEqualTo': 'NotEqualTo', 'Over': 'Over', 'Under': 'Under' -} +}; /** * @enum {string} @@ -357,7 +359,7 @@ export const FiltersAction = { 'Vacation': 'Vacation', 'Reject': 'Reject', 'Forward': 'Forward' -} +}; /** * @enum {string} @@ -365,7 +367,7 @@ export const FiltersAction = { export const FilterRulesType = { 'All': 'All', 'Any': 'Any' -} +}; /** * @enum {number} @@ -377,7 +379,7 @@ export const SignedVerifyStatus = { 'Error': -1, 'None': 0, 'Success': 1 -} +}; /** * @enum {number} @@ -409,7 +411,7 @@ export const ContactPropertyType = { 'Note': 110, 'Custom': 250 -} +}; /** * @enum {number} @@ -489,4 +491,4 @@ export const Notification = { 'UnknownNotification': 999, 'UnknownError': 999 -} \ No newline at end of file +}; diff --git a/dev/Common/HtmlEditor.jsx b/dev/Common/HtmlEditor.jsx index d323a0a8b..af20f2d24 100644 --- a/dev/Common/HtmlEditor.jsx +++ b/dev/Common/HtmlEditor.jsx @@ -1,5 +1,5 @@ -import {window, _} from 'common'; +import {window, _, $} from 'common'; import Globals from 'Common/Globals'; import Settings from 'Storage/Settings'; @@ -9,7 +9,7 @@ class HtmlEditor $element = null; blurTimer = 0; - + onBlur = null; onReady = null; onModeChange = null; @@ -70,9 +70,9 @@ class HtmlEditor if (this.editor) { this.editor.execCommand('insertSignature', { - 'isHtml': html, - 'insertBefore': insertBefore, - 'signature': signature + isHtml: html, + insertBefore: insertBefore, + signature: signature }); } } @@ -117,12 +117,11 @@ class HtmlEditor } else { - result = wrapIsHtml ? + result = wrapIsHtml ? '