Add more strict rules (eslint)

This commit is contained in:
RainLoop Team 2016-07-02 01:49:59 +03:00
parent b43bb17cdb
commit 52e2698cdf
38 changed files with 488 additions and 434 deletions

View file

@ -1,236 +1,287 @@
module.exports = { module.exports = {
"extends": "eslint:recommended", 'extends': 'eslint:recommended',
"ecmaFeatures": { 'ecmaFeatures': {
"modules": true 'modules': true
}, },
"parserOptions": { 'parserOptions': {
"ecmaVersion": 6, 'ecmaVersion': 6,
"sourceType": "module" 'sourceType': 'module'
}, },
"env": { 'env': {
"node": true, 'node': true,
"commonjs": true, 'commonjs': true,
"es6": true, 'es6': true,
"browser": true 'browser': true
}, },
"globals": { 'globals': {
"RL_COMMUNITY": true, 'RL_COMMUNITY': true,
"ko": true, 'ko': true,
"ssm": true, 'ssm': true,
"moment": true, 'moment': true,
"ifvisible": true, 'ifvisible': true,
"crossroads": true, 'crossroads': true,
"hasher": true, 'hasher': true,
"key": true, 'key': true,
"Jua": true, 'Jua': true,
"_": true, '_': true,
"$": true, '$': true,
"Dropbox": true 'Dropbox': true
}, },
"rules": { // http://eslint.org/docs/rules/
'rules': {
"strict": 2, // require or disallow strict mode directives
// errors // errors
'no-cond-assign': [2, 'always'],
"comma-dangle": [2, "never"], // disallow or enforce trailing commas 'no-console': 2,
"no-cond-assign": [2, "always"], // disallow assignment in conditional expressions 'no-constant-condition': 2,
"no-console": 2, // disallow use of console (off by default in the node environment) 'no-control-regex': 2,
"no-constant-condition": 2, // disallow use of constant expressions in conditions 'no-debugger': 2,
"no-control-regex": 2, // disallow control characters in regular expressions 'no-dupe-args': 2,
"no-debugger": 2, // disallow use of debugger 'no-dupe-keys': 2,
"no-dupe-args": 2, // disallow duplicate arguments in functions 'no-duplicate-case': 2,
"no-dupe-keys": 2, // disallow duplicate keys when creating object literals 'no-empty': 2,
"no-duplicate-case": 2, // disallow a duplicate case label. 'no-empty-character-class': 2,
"no-empty": 2, // disallow empty statements 'no-ex-assign': 2,
"no-empty-character-class": 2, // disallow the use of empty character classes in regular expressions 'no-extra-boolean-cast': 2,
"no-ex-assign": 2, // disallow assigning to the exception in a catch block // 'no-extra-parens': 2,
"no-extra-boolean-cast": 2, // disallow double-negation boolean casts in a boolean context 'no-extra-semi': 2,
// "no-extra-parens": 2, // disallow unnecessary parentheses (off by default) 'no-func-assign': 2,
"no-extra-semi": 2, // disallow unnecessary semicolons 'no-inner-declarations': 2,
"no-func-assign": 2, // disallow overwriting functions written as function declarations 'no-invalid-regexp': 2,
"no-inner-declarations": 2, // disallow function or variable declarations in nested blocks 'no-irregular-whitespace': 2,
"no-invalid-regexp": 2, // disallow invalid regular expression strings in the RegExp constructor 'no-negated-in-lhs': 2,
"no-irregular-whitespace": 2, // disallow irregular whitespace outside of strings and comments 'no-obj-calls': 2,
"no-negated-in-lhs": 2, // disallow negation of the left operand of an in expression 'no-prototype-builtins': 2,
"no-obj-calls": 2, // disallow the use of object properties of the global object (Math and JSON) as functions 'no-regex-spaces': 2,
"no-regex-spaces": 2, // disallow multiple spaces in a regular expression literal 'no-sparse-arrays': 2,
"no-sparse-arrays": 2, // disallow sparse arrays 'no-unexpected-multiline': 2,
"no-unexpected-multiline": 2, // disallow confusing multiline expressions 'no-unreachable': 2,
"no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement 'no-unsafe-finally': 2,
"use-isnan": 2, // disallow comparisons with the value NaN 'use-isnan': 2,
"valid-typeof": 2, // Ensure that the results of typeof are compared against a valid string // 'valid-jsdoc': [2, {
// 'requireParamDescription': false,
// "valid-jsdoc": [2, { // Ensure JSDoc comments are valid (off by default) // 'requireReturnDescription': false
// "requireParamDescription": false,
// "requireReturnDescription": false
// }], // }],
'valid-typeof': 2,
// best practices // best practices
'accessor-pairs': 2,
'array-callback-return': 2,
'block-scoped-var': 2,
// 'complexity': 2,
'consistent-return': 2,
'curly': 2,
'default-case': 2,
'dot-location': [2, 'property'],
'dot-notation': 2,
'eqeqeq': 2,
'guard-for-in': 2,
'no-alert': 2,
'no-caller': 2,
'no-case-declarations': 2,
'no-div-regex': 2,
'no-else-return': 2,
'no-empty-function': 2,
'no-empty-pattern': 2,
'no-eq-null': 2,
'no-eval': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-label': 2,
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-implicit-coercion': [2, {'allow': ['!!', '+']}],
'no-implicit-globals': 2,
'no-implied-eval': 2,
// 'no-invalid-this': 2,
'no-iterator': 2,
'no-labels': 2,
'no-lone-blocks': 2,
'no-loop-func': 2,
// 'no-magic-numbers': [2, {
// 'ignore': [-1, 0, 1],
// 'ignoreArrayIndexes': true
// }],
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-native-reassign': 2,
'no-new': 2,
'no-new-func': 2,
'no-new-wrappers': 2,
'no-octal': 2,
'no-octal-escape': 2,
// 'no-param-reassign': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-return-assign': 2,
'no-script-url': 2,
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-throw-literal': 2,
'no-unmodified-loop-condition': 2,
'no-unused-expressions': 2,
'no-unused-labels': 2,
'no-useless-call': 2,
'no-useless-concat': 2,
'no-useless-escape': 2,
'no-void': 2,
'no-warning-comments': 2,
'no-with': 2,
'radix': 2,
// 'vars-on-top': 2,
'wrap-iife': 2,
'yoda': [2, 'always'],
"accessor-pairs": 2, // enforce getter and setter pairs in objects // strict mode
"block-scoped-var": 2, // treat var statements as if they were block scoped (off by default). 0: deep destructuring is not compatible https://github.com/eslint/eslint/issues/1863 'strict': 2,
// "complexity": 2, // specify the maximum cyclomatic complexity allowed in a program (off by default)
"consistent-return": 2, // require return statements to either always or never specify values
"curly": 2, // specify curly brace conventions for allphpuni control statements
"default-case": 2, // require default case in switch statements (off by default)
"dot-location": [2, "property"], // enforce consistent newlines before and after dots
"dot-notation": 2, // encourages use of dot notation whenever possible
"eqeqeq": 2, // require the use of === and !==
"guard-for-in": 2, // make sure for-in loops have an if statement (off by default)
"no-alert": 2, // disallow the use of alert, confirm, and prompt
"no-caller": 2, // disallow use of arguments.caller or arguments.callee
"no-div-regex": 2, // disallow division operators explicitly at beginning of regular expression (off by default)
"no-else-return": 2, // disallow else after a return in an if (off by default)
"no-eq-null": 2, // disallow comparisons to null without a type-checking operator (off by default)
"no-eval": 2, // disallow use of eval()
"no-extend-native": 2, // disallow adding to native types
"no-extra-bind": 2, // disallow unnecessary function binding
"no-fallthrough": 2, // disallow fallthrough of case statements
"no-floating-decimal": 2, // disallow the use of leading or trailing decimal points in numeric literals (off by default)
"no-implied-eval": 2, // disallow use of eval()-like methods
"no-iterator": 2, // disallow usage of __iterator__ property
"no-labels": 2, // disallow use of labeled statements
"no-lone-blocks": 2, // disallow unnecessary nested blocks
"no-loop-func": 2, // disallow creation of functions within loops
"no-multi-spaces": 2, // disallow use of multiple spaces
"no-multi-str": 2, // disallow use of multiline strings
"no-native-reassign": 2, // disallow reassignments of native objects
"no-new": 2, // disallow use of new operator when not part of the assignment or comparison
"no-new-func": 2, // disallow use of new operator for Function object
"no-new-wrappers": 2, // disallows creating new instances of String,Number, and Boolean
"no-octal": 2, // disallow use of octal literals
"no-octal-escape": 2, // disallow use of octal escape sequences in string literals, such as var foo = "Copyright \251";
// "no-param-reassign": 2, // disallow reassignment of function parameters (off by default)
"no-process-env": 2, // disallow use of process.env (off by default)
"no-proto": 2, // disallow usage of __proto__ property
"no-redeclare": 2, // disallow declaring the same variable more then once
"no-return-assign": 2, // disallow use of assignment in return statement
"no-script-url": 2, // disallow use of javascript: urls.
"no-self-compare": 2, // disallow comparisons where both sides are exactly the same (off by default)
"no-sequences": 2, // disallow use of comma operator
"no-throw-literal": 2, // restrict what can be thrown as an exception (off by default)
"no-unused-expressions": 2, // disallow usage of expressions in statement position
"no-void": 2, // disallow use of void operator (off by default)
"no-warning-comments": 2, // disallow usage of configurable warning terms in comments": 2, // e.g. TODO or FIXME (off by default)
"no-with": 2, // disallow use of the with statement
"radix": 2, // require use of the second argument for parseInt() (off by default)
// "vars-on-top": 2, // requires to declare all vars on top of their containing scope (off by default)
"wrap-iife": 2, // require immediate function invocation to be wrapped in parentheses (off by default)
"yoda": [2, "always"], // require or disallow Yoda conditions
// variables // variables
'init-declarations': 2,
'no-catch-shadow': 2,
'no-delete-var': 2,
'no-label-var': 2,
'no-restricted-globals': 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,
"no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment) // node.js and commonjs
"no-delete-var": 2, // disallow deletion of variables 'callback-return': 2,
"no-label-var": 2, // disallow labels that share a name with a variable // 'global-require': 2,
"no-shadow": 2, // disallow declaration of variables already declared in the outer scope 'handle-callback-err': 2,
"no-shadow-restricted-names": 2, // disallow shadowing of names such as arguments // 'no-mixed-requires': 2,
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block 'no-new-require': 2,
"no-undef-init": 2, // disallow use of undefined when initializing variables 'no-path-concat': 2,
"no-undefined": 2, // disallow use of undefined variable (off by default) 'no-process-env': 2,
"no-unused-vars": 2, // disallow declaration of variables that are not used in the code 'no-process-exit': 2,
"no-use-before-define": 2, // disallow use of variables before they are defined 'no-restricted-modules': 2,
// 'no-sync': 2,
// stylistic issues // stylistic issues
'array-bracket-spacing': 2,
"array-bracket-spacing": 2, // enforce consistent spacing inside array brackets 'block-spacing': [2, 'never'],
"block-spacing": [2, "never"], // enforce consistent spacing inside single-line blocks // 'brace-style': [2, 'allman'],
// 'camelcase': 2,
// "brace-style": [2, "1tbs"], // enforce consistent brace style for blocks 'comma-dangle': [2, 'never'],
'comma-spacing': 2,
// "camelcase": 2, // enforce camelcase naming convention 'comma-style': 2,
"comma-spacing": 2, // enforce consistent spacing before and after commas 'computed-property-spacing': 2,
"comma-style": 2, // enforce consistent comma style 'consistent-this': [2, 'self'],
"computed-property-spacing": 2, // enforce consistent spacing inside computed property brackets 'eol-last': 2,
"consistent-this": [2, "self"], // enforce consistent naming when capturing the current execution context 'func-names': [2, 'never'],
"eol-last": 2, // enforce at least one newline at the end of files // 'func-style': 2,
"id-match": 2, // require identifiers to match a specified regular expression 'id-blacklist': [2, 'x'],
'id-length': [2, {'min': 1, 'max': 50}],
"indent": [2, "tab", { // enforce consistent indentation 'id-match': 2,
"SwitchCase": 1, 'indent': [2, 'tab', {
"VariableDeclarator": { 'SwitchCase': 1,
"var": 1, 'VariableDeclarator': {
"let": 1, 'var': 1,
"const": 1 'let': 1,
'const': 1
} }
}], }],
'jsx-quotes': 2,
"key-spacing": 2, // enforce consistent spacing between keys and values in object literal properties 'key-spacing': 2,
"linebreak-style": [2, "unix"], // enforce consistent linebreak style 'keyword-spacing': 2,
// "lines-around-comment": 2, // require empty lines around comments 'linebreak-style': [2, 'unix'],
// "max-depth": 2, // enforce a maximum depth that blocks can be nested // 'lines-around-comment': 2,
"max-len": [2, 200], // enforce a maximum line length 'max-depth': [2, 10],
// "max-lines": 2, // enforce a maximum file length 'max-len': [2, 200],
"max-nested-callbacks": [2, 5], // enforce a maximum depth that callbacks can be nested // 'max-lines': 2,
// "max-params": 2, // enforce a maximum number of parameters in function definitions 'max-nested-callbacks': [2, 5],
// "max-statements": 2, // enforce a maximum number of statements allowed in function blocks // 'max-params': 2,
"max-statements-per-line": 2, // enforce a maximum number of statements allowed per line // 'max-statements': [2, {'max': 10}, {'ignoreTopLevelFunctions': true}],
"new-cap": 2, // require constructor function names to begin with a capital letter 'max-statements-per-line': 2,
"new-parens": 2, // require parentheses when invoking a constructor with no arguments 'new-cap': 2,
// "newline-after-var": 2, // require or disallow an empty line after var declarations 'new-parens': 2,
// "newline-before-return": 2, // require an empty line before return statements // 'newline-after-var': 2,
// "newline-per-chained-call": 2, // require a newline after each call in a method chain // 'newline-before-return': 2,
"no-array-constructor": 2, // disallow Array constructors // 'newline-per-chained-call': 2,
"no-bitwise": 2, // disallow bitwise operators 'no-array-constructor': 2,
"no-continue": 2, // disallow continue statements 'no-bitwise': 2,
// "no-inline-comments": 2, // disallow inline comments after code 'no-continue': 2,
// "no-lonely-if": 2, // disallow if statements as the only statement in else blocks // 'no-inline-comments': 2,
// "no-mixed-operators": 2, // disallow mixes of different operators // 'no-lonely-if': 2,
"no-mixed-spaces-and-tabs": 2, // disallow mixed spaces and tabs for indentation // 'no-mixed-operators': 2,
"no-multiple-empty-lines": 2, // disallow multiple empty lines 'no-mixed-spaces-and-tabs': 2,
// "no-negated-condition": 2, // disallow negated conditions 'no-multiple-empty-lines': 2,
// "no-nested-ternary": 2, // disallow nested ternary expressions // 'no-negated-condition': 2,
"no-new-object": 2, // disallow Object constructors // 'no-nested-ternary': 2,
"no-plusplus": [2, { // disallow the unary operators ++ and -- 'no-new-object': 2,
"allowForLoopAfterthoughts": true 'no-plusplus': [2, {
'allowForLoopAfterthoughts': true
}], }],
"no-restricted-syntax": 2, // disallow specified syntax 'no-restricted-syntax': 2,
"no-spaced-func": 2, // disallow spacing between function identifiers and their applications 'no-spaced-func': 2,
"no-ternary": 0, // disallow ternary operators 'no-ternary': 0,
"no-trailing-spaces": 2, // disallow trailing whitespace at the end of lines 'no-trailing-spaces': 2, // disallow trailing whitespace at the end of lines
// "no-underscore-dangle": 2, // disallow dangling underscores in identifiers // 'no-underscore-dangle': 2, // disallow dangling underscores in identifiers
"no-unneeded-ternary": 2, // disallow ternary operators when simpler alternatives exist 'no-unneeded-ternary': 2, // disallow ternary operators when simpler alternatives exist
// "no-whitespace-before-property": 2, // disallow whitespace before properties 'no-whitespace-before-property': 2,
// "object-curly-newline": 2, // enforce consistent line breaks inside braces // 'object-curly-newline': 2,
"object-curly-spacing": [2, "never"], // enforce consistent spacing inside braces 'object-curly-spacing': [2, 'never'],
'object-property-newline': [2, {'allowMultiplePropertiesPerLine': true}],
// "object-property-newline": [2, { // enforce placing object properties on separate lines // 'one-var': [2, {
// "allowMultiplePropertiesPerLine": false // 'var': 'always',
// 'let': 'always',
// 'const': 'never'
// }], // }],
// 'one-var-declaration-per-line': [2, 'always'],
// "one-var": [2, { // enforce variables to be declared either together or separately in functions 'operator-assignment': 2,
// "var": "always", 'operator-linebreak': [2, 'after'],
// "let": "always", // 'padded-blocks': [2, 'never'],
// "const": "never" // 'quote-props': [2, 'as-needed'],
// }], 'quotes': [2, 'single'],
'require-jsdoc': 2,
// "one-var-declaration-per-line": [2, "always"], // require or disallow newlines around var declarations 'semi': [2, 'always'],
"operator-assignment": 2, // require or disallow assignment operator shorthand where possible 'semi-spacing': 2,
"operator-linebreak": [2, "after"], // enforce consistent linebreak style for operators // 'sort-vars': 2,
// "padded-blocks": [2, "never"], // require or disallow padding within blocks 'space-before-blocks': 2,
// "quote-props": [2, "as-needed"], // require quotes around object literal property names 'space-before-function-paren': [2, 'never'],
"quotes": [2, "single"], // enforce the consistent use of either backticks, double, or single quotes 'space-in-parens': 2,
"require-jsdoc": 2, // require JSDoc comments 'space-infix-ops': 2,
"semi": [2, "always"], // require or disallow semicolons instead of ASI 'space-unary-ops': 2,
"semi-spacing": 2, // enforce consistent spacing before and after semicolons 'spaced-comment': 2,
// "sort-vars": 2, // require variables within the same declaration block to be sorted 'unicode-bom': [2, 'never'],
"space-before-blocks": 2, // enforce consistent spacing before blocks 'wrap-regex': 2,
"space-before-function-paren": [2, "never"], // enforce consistent spacing before function definition opening parenthesis
"space-in-parens": 2, // enforce consistent spacing inside parentheses
"space-infix-ops": 2, // require spacing around operators
"space-unary-ops": 2, // enforce consistent spacing before or after unary operators
"spaced-comment": 2, // enforce consistent spacing after the // or /* in a comment
// "unicode-bom": [2, "never"], // require or disallow the Unicode BOM
"wrap-regex": 2, // require parenthesis around regex literals
// es6 // es6
'arrow-body-style': [2, 'as-needed'],
'arrow-parens': 2,
'arrow-spacing': 2,
'constructor-super': 2,
'generator-star-spacing': 2,
'no-class-assign': 2,
'no-confusing-arrow': [2, {'allowParens': true}],
'no-const-assign': 2,
'no-dupe-class-members': 2,
'no-duplicate-imports': 2,
'no-new-symbol': 2,
'no-restricted-imports': 2,
'no-this-before-super': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-rename': 2,
// 'no-var': 2,
// 'object-shorthand': 2,
// 'prefer-arrow-callback': 2,
'prefer-const': 2,
// 'prefer-reflect': 2,
"constructor-super": 2, // require super() calls in constructors 'prefer-rest-params': 2,
"no-class-assign": 2, // disallow reassigning class members 'prefer-spread': 2,
"no-const-assign": 2, // disallow reassigning const variables
"no-dupe-class-members": 2, // disallow duplicate class members // 'prefer-template': 2,
"no-this-before-super": 2, // disallow this/super before calling super() in constructors 'require-yield': 2,
"prefer-const": 2 // require const declarations for variables that are never reassigned after declared 'rest-spread-spacing': 2,
'sort-imports': 0,
'template-curly-spacing': 2,
'yield-star-spacing': 2
} }
}; };

View file

@ -1,5 +1,8 @@
import {window, _, $, key} from 'common'; import window from 'window';
import $ from '$';
import _ from '_';
import key from 'key';
import { import {
$win, $html, $doc, $win, $html, $doc,

View file

@ -1,5 +1,6 @@
import {window, _} from 'common'; import window from 'window';
import _ from '_';
import ko from 'ko'; import ko from 'ko';
import progressJs from 'progressJs'; import progressJs from 'progressJs';
@ -39,14 +40,12 @@ class AdminApp extends AbstractApp
DomainStore.domains.loading(false); DomainStore.domains.loading(false);
if (StorageResultType.Success === result && data && data.Result) if (StorageResultType.Success === result && data && data.Result)
{ {
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => { DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => ({
return {
name: name, name: name,
disabled: ko.observable(!enabled), disabled: ko.observable(!enabled),
alias: alias, alias: alias,
deleteAccess: ko.observable(false) deleteAccess: ko.observable(false)
}; })));
}));
} }
}); });
} }
@ -57,13 +56,11 @@ class AdminApp extends AbstractApp
PluginStore.plugins.loading(false); PluginStore.plugins.loading(false);
if (StorageResultType.Success === result && data && data.Result) if (StorageResultType.Success === result && data && data.Result)
{ {
PluginStore.plugins(_.map(data.Result, (item) => { PluginStore.plugins(_.map(data.Result, (item) => ({
return {
name: item.Name, name: item.Name,
disabled: ko.observable(!item.Enabled), disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured) configured: ko.observable(!!item.Configured)
}; })));
}));
} }
}); });
} }
@ -203,15 +200,15 @@ class AdminApp extends AbstractApp
}, force); }, force);
} }
bootend(callback = null) { bootend(bootendCallback = null) {
if (progressJs) if (progressJs)
{ {
progressJs.end(); progressJs.end();
} }
if (callback) if (bootendCallback)
{ {
callback(); bootendCallback();
} }
} }

View file

@ -1,10 +1,12 @@
import {window, _, $} from 'common'; import window from 'window';
import _ from '_';
import $ from '$';
import progressJs from 'progressJs'; import progressJs from 'progressJs';
import Tinycon from 'Tinycon'; import Tinycon from 'Tinycon';
import { 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 pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize
} from 'Common/Utils'; } from 'Common/Utils';
@ -411,19 +413,18 @@ class AppUser extends AbstractApp
* @param {Function=} callback = null * @param {Function=} callback = null
*/ */
foldersReload(callback = null) { foldersReload(callback = null) {
const prom = Promises.foldersReload(FolderStore.foldersLoading);
Promises.foldersReload(FolderStore.foldersLoading).then((value) => {
if (callback) if (callback)
{ {
prom.then((value) => {
callback(!!value); callback(!!value);
}
}).catch(() => { }).catch(() => {
if (callback) _.delay(() => {
{ callback(false);
_.delay(() => callback(false), 1); }, 1);
}
}); });
} }
}
foldersPromisesActionHelper(promise, errorDefCode) { foldersPromisesActionHelper(promise, errorDefCode) {
@ -481,7 +482,9 @@ class AppUser extends AbstractApp
iIndex, iIndex,
oItem.primaryKey.getFingerprint(), oItem.primaryKey.getFingerprint(),
oItem.primaryKey.getKeyId().toHex().toLowerCase(), 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, aUsers,
aEmails, aEmails,
oItem.isPrivate(), oItem.isPrivate(),
@ -672,7 +675,7 @@ class AppUser extends AbstractApp
{ {
for (uid in data.Result.Flags) for (uid in data.Result.Flags)
{ {
if (data.Result.Flags.hasOwnProperty(uid)) if (has(data.Result.Flags, uid))
{ {
check = true; check = true;
const flags = data.Result.Flags[uid]; const flags = data.Result.Flags[uid];
@ -808,7 +811,7 @@ class AppUser extends AbstractApp
aMessages = MessageStore.messageListChecked(); 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) if ('' !== sFolderFullNameRaw && 0 < aRootUids.length)
{ {
@ -934,18 +937,17 @@ class AppUser extends AbstractApp
/** /**
* @param {string} query * @param {string} query
* @param {Function} callback * @param {Function} autocompleteCallback
*/ */
getAutocomplete(query, callback) { getAutocomplete(query, autocompleteCallback) {
Remote.suggestions((result, data) => { Remote.suggestions((result, data) => {
if (StorageResultType.Success === result && data && isArray(data.Result)) if (StorageResultType.Success === result && data && isArray(data.Result))
{ {
callback(_.compact(_.map(data.Result, autocompleteCallback(_.compact(_.map(data.Result, (item) => (item && item[0] ? new EmailModel(item[0], item[1]) : null))));
(item) => item && item[0] ? new EmailModel(item[0], item[1]) : null)));
} }
else if (StorageResultType.Abort !== result) else if (StorageResultType.Abort !== result)
{ {
callback([]); autocompleteCallback([]);
} }
}, query); }, query);
} }
@ -1407,7 +1409,7 @@ class AppUser extends AbstractApp
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s', window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
'' + (Settings.settingsGet('Title') || 'RainLoop')); '' + (Settings.settingsGet('Title') || 'RainLoop'));
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
if (Settings.settingsGet('MailToEmail')) if (Settings.settingsGet('MailToEmail'))
{ {

View file

@ -1,5 +1,6 @@
import {window, $} from 'common'; import window from 'window';
import $ from '$';
import {bMobileDevice, bSafari} from 'Common/Globals'; import {bMobileDevice, bSafari} from 'Common/Globals';
import * as Links from 'Common/Links'; import * as Links from 'Common/Links';
import * as Events from 'Common/Events'; import * as Events from 'Common/Events';

View file

@ -1,6 +1,7 @@
import window from 'window'; import window from 'window';
import progressJs from 'progressJs'; import progressJs from 'progressJs';
import Promise from 'Promise';
import STYLES_CSS from 'Styles/@Boot.css'; import STYLES_CSS from 'Styles/@Boot.css';
import LAYOUT_HTML from 'Html/Layout.html'; import LAYOUT_HTML from 'Html/Layout.html';
@ -32,7 +33,7 @@ function getComputedStyle(id, name)
*/ */
function includeStyle(styles) 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
} }
/** /**
@ -41,7 +42,7 @@ function includeStyle(styles)
*/ */
function includeScr(src) 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
} }
/** /**
@ -203,27 +204,30 @@ function runApp()
} }
} }
}), }),
common = window.Promise.all([ common = Promise.all([
window.jassl(appData.TemplatesLink), window.jassl(appData.TemplatesLink),
window.jassl(appData.LangLink) window.jassl(appData.LangLink)
]); ]);
window.Promise.all([libs, common]) Promise.all([libs, common])
.then(() => { .then(() => {
p.set(30); p.set(30);
return window.jassl(appData.StaticAppJsLink); return window.jassl(appData.StaticAppJsLink);
}).then(() => { })
.then(() => {
p.set(50); p.set(50);
return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve(); return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve();
}).then(() => { })
.then(() => {
p.set(70); p.set(70);
runMainBoot(false); runMainBoot(false);
}).catch((e) => { })
.catch((e) => {
runMainBoot(true); runMainBoot(true);
throw e; throw e;
}).then(() => { })
return window.jassl(appData.StaticEditorJsLink); .then(() => window.jassl(appData.StaticEditorJsLink))
}).then(() => { .then(() => {
if (window.CKEDITOR && window.__initEditor) { if (window.CKEDITOR && window.__initEditor) {
window.__initEditor(); window.__initEditor();
window.__initEditor = null; window.__initEditor = null;

View file

@ -1,5 +1,5 @@
import {_} from 'common'; import _ from '_';
import {Capa, MessageSetAction} from 'Common/Enums'; import {Capa, MessageSetAction} from 'Common/Enums';
import {trim, pInt, isArray} from 'Common/Utils'; import {trim, pInt, isArray} from 'Common/Utils';
import * as Links from 'Common/Links'; import * as Links from 'Common/Links';

View file

@ -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 {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts'; import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
@ -21,7 +23,7 @@ class CookieDriver
const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME); const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME);
storageResult = null === storageValue ? null : JSON.parse(storageValue); 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; (storageResult || (storageResult = {}))[key] = data;
@ -33,7 +35,7 @@ class CookieDriver
result = true; result = true;
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
return result; return result;
} }
@ -54,7 +56,7 @@ class CookieDriver
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null; result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
return result; return result;
} }

View file

@ -1,5 +1,6 @@
import {window, JSON} from 'common'; import window from 'window';
import JSON from 'JSON';
import {isUnd} from 'Common/Utils'; import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts'; import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
@ -21,7 +22,7 @@ class LocalStorageDriver
const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null; const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null;
storageResult = null === storageValue ? null : JSON.parse(storageValue); 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; (storageResult || (storageResult = {}))[key] = data;
@ -30,7 +31,7 @@ class LocalStorageDriver
window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult); window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult);
result = true; result = true;
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
return result; return result;
} }
@ -51,7 +52,7 @@ class LocalStorageDriver
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null; result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
return result; return result;
} }

View file

@ -1,5 +1,5 @@
import {_} from 'common'; import _ from '_';
import {isObject, isUnd} from 'Common/Utils'; import {isObject, isUnd} from 'Common/Utils';
import * as Plugins from 'Common/Plugins'; import * as Plugins from 'Common/Plugins';

View file

@ -1,6 +1,9 @@
/* global RL_COMMUNITY */ /* 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 ko from 'ko';
import {KeyState} from 'Common/Enums'; import {KeyState} from 'Common/Enums';
@ -182,9 +185,7 @@ export const leftPanelWidth = ko.observable(0);
// popups // popups
export const popupVisibilityNames = ko.observableArray([]); export const popupVisibilityNames = ko.observableArray([]);
export const popupVisibility = ko.computed(() => { export const popupVisibility = ko.computed(() => 0 < popupVisibilityNames().length);
return 0 < popupVisibilityNames().length;
});
popupVisibility.subscribe((bValue) => { popupVisibility.subscribe((bValue) => {
$html.toggleClass('rl-modal', bValue); $html.toggleClass('rl-modal', bValue);
@ -196,9 +197,7 @@ export const keyScopeFake = ko.observable(KeyState.All);
export const keyScope = ko.computed({ export const keyScope = ko.computed({
owner: this, owner: this,
read: () => { read: () => keyScopeFake(),
return keyScopeFake();
},
write: function(sValue) { write: function(sValue) {
if (KeyState.Menu !== sValue) if (KeyState.Menu !== sValue)

View file

@ -1,5 +1,7 @@
import {window, _, $} from 'common'; import window from 'window';
import _ from '_';
import $ from '$';
import {oHtmlEditorDefaultConfig, oHtmlEditorLangsMap} from 'Common/Globals'; import {oHtmlEditorDefaultConfig, oHtmlEditorLangsMap} from 'Common/Globals';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';
@ -115,7 +117,7 @@ class HtmlEditor
this.editor.getData() + '</div>' : this.editor.getData(); this.editor.getData() + '</div>' : this.editor.getData();
} }
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
if (clearSignatureSigns) if (clearSignatureSigns)
{ {
@ -154,7 +156,7 @@ class HtmlEditor
} }
} }
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
if (resize) if (resize)
{ {
@ -184,7 +186,7 @@ class HtmlEditor
try { try {
this.editor.setData(html); this.editor.setData(html);
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
if (focus) if (focus)
{ {
@ -200,7 +202,7 @@ class HtmlEditor
this.editor.setData( this.editor.setData(
this.editor.getData().replace(find, replaceHtml)); this.editor.getData().replace(find, replaceHtml));
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
} }
@ -217,7 +219,7 @@ class HtmlEditor
try { try {
this.editor.setData(plain); this.editor.setData(plain);
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
if (focus) if (focus)
@ -358,7 +360,7 @@ class HtmlEditor
try { try {
this.editor.focus(); this.editor.focus();
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
} }
@ -368,7 +370,7 @@ class HtmlEditor
try { try {
return !!this.editor.focusManager.hasFocus; return !!this.editor.focusManager.hasFocus;
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
return false; return false;
@ -380,7 +382,7 @@ class HtmlEditor
try { try {
this.editor.focusManager.blur(true); this.editor.focusManager.blur(true);
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
} }
@ -390,7 +392,7 @@ class HtmlEditor
try { try {
this.editor.resize(this.$element.width(), this.$element.innerHeight()); this.editor.resize(this.$element.width(), this.$element.innerHeight());
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
} }
@ -400,7 +402,7 @@ class HtmlEditor
try { try {
this.editor.setReadOnly(!!value); this.editor.setReadOnly(!!value);
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
} }

View file

@ -1,5 +1,5 @@
import {window} from 'common'; import window from 'window';
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils'; import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';

View file

@ -1,5 +1,8 @@
import {window, $, _, moment} from 'common'; import window from 'window';
import _ from '_';
import $ from '$';
import moment from 'moment';
import {i18n} from 'Common/Translator'; import {i18n} from 'Common/Translator';
let _moment = null; let _moment = null;

View file

@ -1,12 +1,13 @@
import {_} from 'common'; import _ from '_';
import {isFunc, isArray, isUnd} from 'Common/Utils'; import {isFunc, isArray, isUnd} from 'Common/Utils';
import {data as GlobalsData} from 'Common/Globals'; import {data as GlobalsData} from 'Common/Globals';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';
const SIMPLE_HOOKS = {}; const
const USER_VIEW_MODELS_HOOKS = []; SIMPLE_HOOKS = {},
const ADMIN_VIEW_MODELS_HOOKS = []; USER_VIEW_MODELS_HOOKS = [],
ADMIN_VIEW_MODELS_HOOKS = [];
/** /**
* @param {string} name * @param {string} name
@ -34,7 +35,7 @@ export function runHook(name, args = [])
if (isArray(SIMPLE_HOOKS[name])) if (isArray(SIMPLE_HOOKS[name]))
{ {
_.each(SIMPLE_HOOKS[name], (callback) => { _.each(SIMPLE_HOOKS[name], (callback) => {
callback.apply(null, args); callback(...args);
}); });
} }
} }

View file

@ -1,5 +1,7 @@
import {$, _, key} from 'common'; import $ from '$';
import _ from '_';
import key from 'key';
import ko from 'ko'; import ko from 'ko';
import {EventKeyCode} from 'Common/Enums'; import {EventKeyCode} from 'Common/Enums';
import {isArray, inArray, noop, noopTrue} from 'Common/Utils'; import {isArray, inArray, noop, noopTrue} from 'Common/Utils';
@ -21,10 +23,7 @@ class Selector
{ {
this.list = koList; this.list = koList;
this.listChecked = ko.computed(() => { this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({rateLimit: 0});
return _.filter(this.list(), (item) => item.checked());
}, this).extend({rateLimit: 0});
this.isListChecked = ko.computed(() => 0 < this.listChecked().length); this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
this.focusedItem = koFocusedItem || ko.observable(null); this.focusedItem = koFocusedItem || ko.observable(null);

View file

@ -1,5 +1,7 @@
import {window, $, _} from 'common'; import window from 'window';
import _ from '_';
import $ from '$';
import ko from 'ko'; import ko from 'ko';
import {Notification, UploadErrorCode} from 'Common/Enums'; import {Notification, UploadErrorCode} from 'Common/Enums';
import {pInt, isUnd, isNull, has, microtime, inArray} from 'Common/Utils'; import {pInt, isUnd, isNull, has, microtime, inArray} from 'Common/Utils';

View file

@ -19,21 +19,21 @@ const isUnd = _.isUndefined;
const isNull = _.isNull; const isNull = _.isNull;
const has = _.has; const has = _.has;
const bind = _.bind; const bind = _.bind;
const noop = () => {}; const noop = () => {}; // eslint-disable-line no-empty-function
const noopTrue = () => true; const noopTrue = () => true;
const noopFalse = () => false; const noopFalse = () => false;
export {trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse}; export {trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse};
/** /**
* @param {Function} callback * @param {Function} func
*/ */
export function silentTryCatch(callback) export function silentTryCatch(func)
{ {
try { try {
callback(); func();
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
/** /**
@ -314,7 +314,7 @@ export function removeInFocus(force)
window.document.activeElement.blur(); window.document.activeElement.blur();
} }
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
} }
@ -337,7 +337,7 @@ export function removeSelection()
window.document.selection.empty(); window.document.selection.empty();
} }
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
/** /**
@ -453,14 +453,16 @@ export function delegateRun(object, methodName, params, delay = 0)
if (object && object[methodName]) if (object && object[methodName])
{ {
delay = pInt(delay); delay = pInt(delay);
params = isArray(params) ? params : [];
if (0 >= delay) if (0 >= delay)
{ {
object[methodName].apply(object, isArray(params) ? params : []); object[methodName](...params);
} }
else else
{ {
_.delay(() => { _.delay(() => {
object[methodName].apply(object, isArray(params) ? params : []); object[methodName](...params);
}, delay); }, delay);
} }
} }
@ -511,7 +513,6 @@ export function kill_CtrlA_CtrlS(event)
*/ */
export function createCommand(context, fExecute, fCanExecute = true) export function createCommand(context, fExecute, fCanExecute = true)
{ {
let fResult = null; let fResult = null;
const fNonEmpty = (...args) => { const fNonEmpty = (...args) => {
if (fResult && fResult.canExecute && fResult.canExecute()) if (fResult && fResult.canExecute && fResult.canExecute())
@ -526,15 +527,11 @@ export function createCommand(context, fExecute, fCanExecute = true)
if (isFunc(fCanExecute)) if (isFunc(fCanExecute))
{ {
fResult.canExecute = ko.computed(() => { fResult.canExecute = ko.computed(() => fResult.enabled() && fCanExecute.call(context));
return fResult.enabled() && fCanExecute.call(context);
});
} }
else else
{ {
fResult.canExecute = ko.computed(() => { fResult.canExecute = ko.computed(() => fResult.enabled() && !!fCanExecute);
return fResult.enabled() && !!fCanExecute;
});
} }
return fResult; return fResult;
@ -848,14 +845,11 @@ export function htmlToPlain(html)
text = ''; text = '';
const const
convertBlockquote = (blockquoteText) => { convertBlockquote = (blockquoteText) => {
blockquoteText = '> ' + trim(blockquoteText).replace(/\n/gm, '\n> '); blockquoteText = '> ' + trim(blockquoteText).replace(/\n/gm, '\n> ');
return blockquoteText.replace(/(^|\n)([> ]+)/gm, (...args) => { return blockquoteText.replace(/(^|\n)([> ]+)/gm,
return (args && 2 < args.length) ? args[1] + trim(args[2].replace(/[\s]/g, '')) + ' ' : ''; (...args) => (args && 2 < args.length ? args[1] + trim(args[2].replace(/[\s]/g, '')) + ' ' : ''));
});
}, },
convertDivs = (...args) => { convertDivs = (...args) => {
if (args && 1 < args.length) if (args && 1 < args.length)
{ {
@ -871,19 +865,9 @@ export function htmlToPlain(html)
return ''; return '';
}, },
convertPre = (...args) => (args && 1 < args.length ? args[1].toString().replace(/[\n]/gm, '<br />').replace(/[\r]/gm, '') : ''),
convertPre = (...args) => { fixAttibuteValue = (...args) => (args && 1 < args.length ? '' + args[1] + _.escape(args[2]) : ''),
return (args && 1 < args.length) ? convertLinks = (...args) => (args && 1 < args.length ? trim(args[1]) : '');
args[1].toString().replace(/[\n]/gm, '<br />').replace(/[\r]/gm, '') : '';
},
fixAttibuteValue = (...args) => {
return (args && 1 < args.length) ? '' + args[1] + _.escape(args[2]) : '';
},
convertLinks = (...args) => {
return (args && 1 < args.length) ? trim(args[1]) : '';
};
text = html text = html
.replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C') .replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C')
@ -971,10 +955,7 @@ export function htmlToPlain(html)
export function plainToHtml(plain, findEmailAndLinksInText = false) export function plainToHtml(plain, findEmailAndLinksInText = false)
{ {
plain = plain.toString().replace(/\r/g, ''); plain = plain.toString().replace(/\r/g, '');
plain = plain.replace(/^>[> ]>+/gm, ([match]) => (match ? match.replace(/[ ]+/g, '') : match));
plain = plain.replace(/^>[> ]>+/gm, ([match]) => {
return match ? match.replace(/[ ]+/g, '') : match;
});
let let
bIn = false, bIn = false,
@ -1110,7 +1091,7 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++) for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++)
{ {
oItem = aSystem[iIndex]; oItem = aSystem[iIndex];
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) if (fVisibleCallback ? fVisibleCallback(oItem) : true)
{ {
if (bSep && 0 < aResult.length) if (bSep && 0 < aResult.length)
{ {
@ -1126,11 +1107,11 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
bSep = false; bSep = false;
aResult.push({ aResult.push({
id: oItem.fullNameRaw, id: oItem.fullNameRaw,
name: fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(), name: fRenameCallback ? fRenameCallback(oItem) : oItem.name(),
system: true, system: true,
seporator: false, seporator: false,
disabled: !oItem.selectable || -1 < inArray(oItem.fullNameRaw, aDisabled) || disabled: !oItem.selectable || -1 < inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false) (fDisableCallback ? fDisableCallback(oItem) : false)
}); });
} }
} }
@ -1142,7 +1123,7 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
// if (oItem.subScribed() || !oItem.existen || bBuildUnvisible) // if (oItem.subScribed() || !oItem.existen || bBuildUnvisible)
if ((oItem.subScribed() || !oItem.existen || bBuildUnvisible) && (oItem.selectable || oItem.hasSubScribedSubfolders())) if ((oItem.subScribed() || !oItem.existen || bBuildUnvisible) && (oItem.selectable || oItem.hasSubScribedSubfolders()))
{ {
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true) if (fVisibleCallback ? fVisibleCallback(oItem) : true)
{ {
if (FolderType.User === oItem.type() || !bSystem || oItem.hasSubScribedSubfolders()) if (FolderType.User === oItem.type() || !bSystem || oItem.hasSubScribedSubfolders())
{ {
@ -1161,11 +1142,11 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
aResult.push({ aResult.push({
id: oItem.fullNameRaw, id: oItem.fullNameRaw,
name: (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) + name: (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
(fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()), (fRenameCallback ? fRenameCallback(oItem) : oItem.name()),
system: false, system: false,
seporator: false, seporator: false,
disabled: !oItem.selectable || -1 < inArray(oItem.fullNameRaw, aDisabled) || disabled: !oItem.selectable || -1 < inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false) (fDisableCallback ? fDisableCallback(oItem) : false)
}); });
} }
} }
@ -1187,7 +1168,7 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
*/ */
export function selectElement(element) export function selectElement(element)
{ {
let sel, range; let sel = null, range = null;
if (window.getSelection) if (window.getSelection)
{ {
sel = window.getSelection(); sel = window.getSelection();
@ -1205,9 +1186,7 @@ export function selectElement(element)
} }
export const detectDropdownVisibility = _.debounce(() => { export const detectDropdownVisibility = _.debounce(() => {
dropdownVisibility(!!_.find(GlobalsData.aBootstrapDropdowns, (item) => { dropdownVisibility(!!_.find(GlobalsData.aBootstrapDropdowns, (item) => item.hasClass('open')));
return item.hasClass('open');
}));
}, 50); }, 50);
/** /**
@ -1246,7 +1225,7 @@ export function getConfigurationFromScriptTag(configuration)
{ {
return JSON.parse(configurationScriptTagCache[configuration].text()); return JSON.parse(configurationScriptTagCache[configuration].text());
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
return {}; return {};
} }
@ -1615,13 +1594,12 @@ export function mailToHelper(mailToUrl, PopupComposeVoreModel)
email = mailToUrl.replace(/\?.+$/, ''), email = mailToUrl.replace(/\?.+$/, ''),
query = mailToUrl.replace(/^[^\?]*\?/, ''), query = mailToUrl.replace(/^[^\?]*\?/, ''),
EmailModel = require('Model/Email'), EmailModel = require('Model/Email'),
fParseEmailLine = (line) => { emailObj = new EmailModel(),
return line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => { fParseEmailLine = (line) => (line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => {
const emailObj = new EmailModel(); emailObj.clear();
emailObj.mailsoParse(item); emailObj.mailsoParse(item);
return '' !== emailObj.email ? emailObj : null; return '' !== emailObj.email ? emailObj : null;
})) : null; })) : null);
};
to = fParseEmailLine(email); to = fParseEmailLine(email);
params = simpleQueryParser(query); params = simpleQueryParser(query);

View file

@ -1,5 +1,5 @@
import {_} from 'common'; import _ from '_';
import ko from 'ko'; import ko from 'ko';
import {isUnd} from 'Common/Utils'; import {isUnd} from 'Common/Utils';
import {AbstractComponent} from 'Component/Abstract'; import {AbstractComponent} from 'Component/Abstract';
@ -27,9 +27,7 @@ class AbstracRadio extends AbstractComponent
if (params.values) if (params.values)
{ {
this.values(_.map(params.values, (label, value) => { this.values(_.map(params.values, (label, value) => ({label: label, value: value})));
return {label: label, value: value};
}));
} }
this.click = _.bind(this.click, this); this.click = _.bind(this.click, this);

View file

@ -1,7 +1,7 @@
import {$} from 'common'; import $ from '$';
import {isUnd} from 'Common/Utils';
import ko from 'ko'; import ko from 'ko';
import {isUnd} from 'Common/Utils';
class AbstractComponent class AbstractComponent
{ {
@ -24,8 +24,7 @@ class AbstractComponent
* @param {string} templateID = '' * @param {string} templateID = ''
* @returns {Object} * @returns {Object}
*/ */
const componentExportHelper = (ClassObject, templateID = '') => { const componentExportHelper = (ClassObject, templateID = '') => ({
return {
template: templateID ? {element: templateID} : '<b></b>', template: templateID ? {element: templateID} : '<b></b>',
viewModel: { viewModel: {
createViewModel: (params, componentInfo) => { createViewModel: (params, componentInfo) => {
@ -49,7 +48,6 @@ const componentExportHelper = (ClassObject, templateID = '') => {
return new ClassObject(params); return new ClassObject(params);
} }
} }
}; });
};
export {AbstractComponent, componentExportHelper}; export {AbstractComponent, componentExportHelper};

View file

@ -1,5 +1,5 @@
import {_} from 'common'; import _ from '_';
import ko from 'ko'; import ko from 'ko';
import {componentExportHelper} from 'Component/Abstract'; import {componentExportHelper} from 'Component/Abstract';
import {AbstracCheckbox} from 'Component/AbstracCheckbox'; import {AbstracCheckbox} from 'Component/AbstracCheckbox';

View file

@ -1,5 +1,5 @@
import {$} from 'common'; import $ from '$';
import {AbstractComponent, componentExportHelper} from 'Component/Abstract'; import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
class ScriptComponent extends AbstractComponent class ScriptComponent extends AbstractComponent

View file

@ -1,5 +1,5 @@
import {$} from 'common'; import $ from '$';
let cachedUrl = null; let cachedUrl = null;
const getUrl = () => { const getUrl = () => {

5
dev/External/ko.js vendored
View file

@ -120,7 +120,8 @@ ko.bindingHandlers.scrollerShadows = {
ko.bindingHandlers.pikaday = { ko.bindingHandlers.pikaday = {
init: function(oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) { init: function(oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
ko.bindingHandlers.textInput.init.apply(oViewModel, Array.prototype.slice.call(arguments)); ko.bindingHandlers.textInput
.init.apply(oViewModel, Array.prototype.slice.call(arguments)); // eslint-disable-line prefer-rest-params
if (Pikaday) if (Pikaday)
{ {
@ -971,7 +972,7 @@ ko.bindingHandlers.command = {
jqElement.addClass('command'); jqElement.addClass('command');
ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click'] ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click']
.init.apply(oViewModel, Array.prototype.slice.call(arguments)); .init.apply(oViewModel, Array.prototype.slice.call(arguments)); // eslint-disable-line prefer-rest-params
}, },
update: function(oElement, fValueAccessor) { update: function(oElement, fValueAccessor) {

View file

@ -4,11 +4,6 @@ import EmailModel from 'Model/Email';
class MessageHelper class MessageHelper
{ {
/**
* @constructor
*/
constructor() {}
/** /**
* @param {Array.<EmailModel>} emails * @param {Array.<EmailModel>} emails
* @param {boolean=} friendlyView = false * @param {boolean=} friendlyView = false

View file

@ -84,8 +84,8 @@ AbstractView.prototype.viewModelPosition = function()
return this.sPosition; return this.sPosition;
}; };
AbstractView.prototype.cancelCommand = function() {}; AbstractView.prototype.cancelCommand = Utils.noop;
AbstractView.prototype.closeCommand = function() {}; AbstractView.prototype.closeCommand = Utils.noop;
AbstractView.prototype.storeAndSetKeyScope = function() AbstractView.prototype.storeAndSetKeyScope = function()
{ {

View file

@ -37,7 +37,7 @@ Knoin.prototype.constructorEnd = function(context)
{ {
if (Utils.isFunc(context.__constructor_end)) if (Utils.isFunc(context.__constructor_end))
{ {
context.__constructor_end.call(context); context.__constructor_end();
} }
}; };

View file

@ -250,10 +250,11 @@ EmailModel.prototype.mailsoParse = function($sEmailAddress)
var var
substr = function(str, start, len) { substr = function(str, start, len) {
str += ''; str = Utils.pString(str);
var end = str.length; var end = str.length;
if (0 > start) { if (0 > start)
{
start += end; start += end;
} }
@ -263,11 +264,15 @@ EmailModel.prototype.mailsoParse = function($sEmailAddress)
}, },
substrReplace = function(str, replace, start, length) { substrReplace = function(str, replace, start, length) {
if (0 > start) { str = Utils.pString(str);
if (0 > start)
{
start += str.length; start += str.length;
} }
length = 'undefined' === typeof length ? length : str.length;
if (0 > length) { length = 'undefined' !== typeof length ? length : str.length;
if (0 > length)
{
length = length + str.length - start; length = length + str.length - start;
} }
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length); return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);

View file

@ -1,5 +1,5 @@
import {_} from 'common'; import _ from '_';
import {CookieDriver} from 'Common/ClientStorageDriver/Cookie'; import {CookieDriver} from 'Common/ClientStorageDriver/Cookie';
import {LocalStorageDriver} from 'Common/ClientStorageDriver/LocalStorage'; import {LocalStorageDriver} from 'Common/ClientStorageDriver/LocalStorage';

View file

@ -1,5 +1,5 @@
import {window} from 'common'; import window from 'window';
import {isUnd, isNormal, isArray, inArray} from 'Common/Utils'; import {isUnd, isNormal, isArray, inArray} from 'Common/Utils';
let SETTINGS = window.__rlah_data() || null; let SETTINGS = window.__rlah_data() || null;

View file

@ -1,5 +1,5 @@
import {_} from 'common'; import _ from '_';
import ko from 'ko'; import ko from 'ko';
class IdentityUserStore class IdentityUserStore
@ -9,9 +9,7 @@ class IdentityUserStore
this.identities = ko.observableArray([]); this.identities = ko.observableArray([]);
this.identities.loading = ko.observable(false).extend({throttle: 100}); this.identities.loading = ko.observable(false).extend({throttle: 100});
this.identitiesIDS = ko.computed(() => { this.identitiesIDS = ko.computed(() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
return _.compact(_.map(this.identities(), (item) => item ? item.id : null));
}, this);
} }
} }

View file

@ -916,7 +916,7 @@ ComposePopupView.prototype.converSignature = function(sSignature)
sSignature = sSignature.replace(/{{MOMENT:[^}]+}}/g, ''); sSignature = sSignature.replace(/{{MOMENT:[^}]+}}/g, '');
} }
catch (e) {/* eslint-disable-line no-empty */} catch (e) {} // eslint-disable-line no-empty
} }
return sSignature; return sSignature;
@ -1324,7 +1324,7 @@ ComposePopupView.prototype.onMessageUploadAttachments = function(sResult, oData)
{ {
for (sTempName in oData.Result) for (sTempName in oData.Result)
{ {
if (oData.Result.hasOwnProperty(sTempName)) if (Utils.has(oData.Result, oData.Result))
{ {
oAttachment = this.getAttachmentById(oData.Result[sTempName]); oAttachment = this.getAttachmentById(oData.Result[sTempName]);
if (oAttachment) if (oAttachment)

View file

@ -695,8 +695,9 @@ MessageViewMailBoxUserView.prototype.onBuild = function(oDom)
oDom oDom
.on('click', 'a', function(oEvent) { .on('click', 'a', function(oEvent) {
// setup maito protocol // setup maito protocol
return !(!!oEvent && 3 !== oEvent.which && Utils.mailToHelper($(this).attr('href'), return !(!!oEvent && 3 !== oEvent.which && Utils.mailToHelper(
Settings.capa(Enums.Capa.Composer) ? require('View/Popup/Compose') : null)); $(this).attr('href'), Settings.capa(Enums.Capa.Composer) ? require('View/Popup/Compose') : null
));
}) })
// .on('mouseover', 'a', _.debounce(function(oEvent) { // .on('mouseover', 'a', _.debounce(function(oEvent) {
// //

View file

@ -35,11 +35,6 @@ _.extend(MenuSettingsUserView.prototype, AbstractView.prototype);
MenuSettingsUserView.prototype.onBuild = function(oDom) MenuSettingsUserView.prototype.onBuild = function(oDom)
{ {
// var self = this;
// key('esc', Enums.KeyState.Settings, function() {
// self.backToMailBoxClick();
// });
if (this.mobile) if (this.mobile)
{ {
oDom oDom
@ -75,7 +70,7 @@ MenuSettingsUserView.prototype.onBuild = function(oDom)
} }
} }
}, 200)); }, 200)); // eslint-disable-line no-magic-numbers
}; };
MenuSettingsUserView.prototype.link = function(sRoute) MenuSettingsUserView.prototype.link = function(sRoute)

View file

@ -1,10 +0,0 @@
import window from 'window';
import $ from '$';
import JSON from 'JSON';
import _ from '_';
import Promise from 'Promise';
import moment from 'moment';
import key from 'key';
export {window, $, JSON, _, Promise, moment, key};

View file

@ -45,6 +45,8 @@ var
gulpif = require('gulp-if'), gulpif = require('gulp-if'),
eol = require('gulp-eol'), eol = require('gulp-eol'),
livereload = require('gulp-livereload'), livereload = require('gulp-livereload'),
eslint = require('gulp-eslint'),
cache = require('gulp-cached'),
gutil = require('gulp-util') gutil = require('gulp-util')
; ;
@ -414,9 +416,10 @@ gulp.task('js:min', ['js:app', 'js:admin', 'js:validate'], function() {
// lint // lint
gulp.task('js:eslint', function() { gulp.task('js:eslint', function() {
var eslint = require('gulp-eslint');
return gulp.src(cfg.paths.globjsall) return gulp.src(cfg.paths.globjsall)
.pipe(cache('eslint'))
.pipe(eslint()) .pipe(eslint())
.pipe(gulpif(cfg.watch, plumber({errorHandler: notify.onError("Error: <%= error.message %>")})))
.pipe(eslint.format()) .pipe(eslint.format())
.pipe(eslint.failAfterError()); .pipe(eslint.failAfterError());
}); });
@ -662,6 +665,7 @@ gulp.task('watch', ['fast'], function() {
cfg.watch = true; cfg.watch = true;
livereload.listen(); livereload.listen();
gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']); gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']);
gulp.watch(cfg.paths.globjsall, {interval: cfg.watchInterval}, ['js:validate']);
gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']); gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']);
}); });
@ -669,6 +673,7 @@ gulp.task('watch+', ['fast+'], function() {
cfg.watch = true; cfg.watch = true;
livereload.listen(); livereload.listen();
gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']); gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:app', 'js:admin']);
gulp.watch(cfg.paths.globjsall, {interval: cfg.watchInterval}, ['js:validate']);
gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']); gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']);
}); });

22
npm-shrinkwrap.json generated
View file

@ -1472,6 +1472,28 @@
"from": "gulp-beautify@*", "from": "gulp-beautify@*",
"resolved": "https://registry.npmjs.org/gulp-beautify/-/gulp-beautify-2.0.0.tgz" "resolved": "https://registry.npmjs.org/gulp-beautify/-/gulp-beautify-2.0.0.tgz"
}, },
"gulp-cached": {
"version": "1.1.0",
"from": "gulp-cached@*",
"resolved": "https://registry.npmjs.org/gulp-cached/-/gulp-cached-1.1.0.tgz",
"dependencies": {
"readable-stream": {
"version": "1.0.34",
"from": "readable-stream@>=1.0.17 <1.1.0",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz"
},
"through2": {
"version": "0.5.1",
"from": "through2@>=0.5.1 <0.6.0",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz"
},
"xtend": {
"version": "3.0.0",
"from": "xtend@>=3.0.0 <3.1.0",
"resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz"
}
}
},
"gulp-clean-css": { "gulp-clean-css": {
"version": "2.0.10", "version": "2.0.10",
"from": "gulp-clean-css@>=2.0.7 <3.0.0", "from": "gulp-clean-css@>=2.0.7 <3.0.0",

View file

@ -2,7 +2,7 @@
"name": "RainLoop", "name": "RainLoop",
"title": "RainLoop Webmail", "title": "RainLoop Webmail",
"version": "1.10.2", "version": "1.10.2",
"release": "136", "release": "137",
"private": true, "private": true,
"ownCloudPackageVersion": "4.19", "ownCloudPackageVersion": "4.19",
"description": "Simple, modern & fast web-based email client", "description": "Simple, modern & fast web-based email client",
@ -59,6 +59,7 @@
"gulp": "~3.9.0", "gulp": "~3.9.0",
"gulp-autoprefixer": "*", "gulp-autoprefixer": "*",
"gulp-beautify": "*", "gulp-beautify": "*",
"gulp-cached": "^1.1.0",
"gulp-clean-css": "^2.0.7", "gulp-clean-css": "^2.0.7",
"gulp-concat-util": "*", "gulp-concat-util": "*",
"gulp-eol": "*", "gulp-eol": "*",