diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 89f3f6da..00000000 --- a/.eslintrc +++ /dev/null @@ -1,209 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": "airbnb-base", - "env": { - "browser": true, - "commonjs": true, - "jasmine": true, - "jest": true - }, - "globals": {}, - "rules": { - "class-methods-use-this": 0, - "comma-dangle": 0, - "consistent-return": 1, - "dot-notation": 2, - "eol-last": 2, - "eqeqeq": 1, - "func-names": 0, - "import/extensions": 0, - "import/no-extraneous-dependencies": 0, - "new-cap": 2, - "newline-per-chained-call": 1, - "no-eq-null": 1, - "no-extra-semi": 0, - "no-irregular-whitespace": 2, - "no-mixed-spaces-and-tabs": 2, - "no-multi-str": 2, - "no-multiple-empty-lines": 2, - "no-new": 2, - "no-param-reassign": 0, - "no-plusplus": 0, - "no-restricted-properties": 0, - "no-restricted-syntax": 1, - "no-shadow": 1, - "no-spaced-func": 2, - "no-trailing-spaces": 2, - "no-undef": 0, - "no-underscore-dangle": 0, - "no-unused-vars": 1, - "no-restricted-globals": [ - 2, - "Handsontable", - { - "name": "console", - "message": "Using the `console` object is not allowed within Handsontable. Please use one of the helpers from `console.js` file inside the Handsontable CE instead." - } - ], - "no-use-before-define": 0, - "no-var": 0, - "no-void": 0, - "no-with": 2, - "object-curly-spacing": 0, - "object-shorthand": 1, - "one-var": 0, - "padded-blocks": 0, - "prefer-arrow-callback": 1, - "prefer-const": 0, - "prefer-rest-params": 1, - "prefer-spread": 1, - "prefer-template": 1, - "space-infix-ops": 2, - "vars-on-top": 0, - "linebreak-style": 0, - "camelcase": [ - 2, - { - "properties": "never" - } - ], - "curly": [ - 2, - "all" - ], - "import/no-unresolved": [ - 2, - { - "ignore": ["handsontable"] - } - ], - "no-mixed-operators": [ - 2, - "groups": [ - ["+", "-", "*", "/", "%", "**"] - ] - ], - "arrow-parens": [ - 2, - "always", - { - "requireForBlockBody": true - } - ], - "no-unneeded-ternary": [ - 2, - { - "defaultAssignment": true - } - ], - "no-confusing-arrow": [ - 2, - { - "allowParens": true - } - ], - "indent": [ - 2, - 2, - { - "SwitchCase": 1, - "FunctionDeclaration": {"parameters": "first"}, - "FunctionExpression": {"parameters": "first"} - } - ], - "comma-style": [ - 2, - "last" - ], - "max-depth": [ - 2, - 5 - ], - "max-len": [ - 2, - { - "code": 170, - "ignoreComments": true - } - ], - "max-params": [ - 2, - 9 - ], - "space-before-function-paren": [ - 2, - { - "anonymous": "ignore", - "named": "never" - } - ], - "array-bracket-spacing": [ - 2, - "never", - {} - ], - "space-in-parens": [ - 2, - "never" - ], - "quote-props": [ - 2, - "as-needed" - ], - "key-spacing": [ - 2, - { - "beforeColon": false, - "afterColon": true - } - ], - "space-unary-ops": [ - 2, - { - "words": false, - "nonwords": false - } - ], - "yoda": [ - 2, - "never" - ], - "brace-style": [ - 2, - "1tbs", - { - "allowSingleLine": true - } - ], - "comma-spacing": [ - 2, - { - "after": true, - "before": false - } - ], - "semi-spacing": [ - 2, - { - "before": false, - "after": true - } - ], - "space-before-blocks": [ - 2, - "always" - ], - "keyword-spacing": [ - 2, - {} - ], - "semi": [ - 2, - "always" - ], - "quotes": [ - 2, - "single" - ] - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..b67ac96d --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,92 @@ +module.exports = { + "extends": "airbnb-base", + "parser": "babel-eslint", + "env": { + "browser": true, + "commonjs": true, + "jasmine": true, + "jest": true, + "es6": true, + }, + "rules": { + "arrow-parens": [ + "error", + "as-needed", + { "requireForBlockBody": true } + ], + "class-methods-use-this": "off", + "comma-dangle": "off", + "consistent-return": "off", + "func-names": "off", + "import/extensions": "off", + "import/no-extraneous-dependencies": "off", + "import/no-unresolved": [ + "error", + { "ignore": ["handsontable", "walkontable"] } + ], + "indent": [ + "error", + 2, + { + "SwitchCase": 1, + "FunctionDeclaration": { "parameters": "first" }, + "FunctionExpression": { "parameters": "first" } + } + ], + "max-len": [ + "error", + { + "code": 170, + "ignoreComments": true + } + ], + "newline-per-chained-call": "off", + "no-constant-condition": [ + "error", + { "checkLoops": false } + ], + "no-eq-null": "error", + "no-mixed-operators": [ + "error", + { "groups": [["+", "-", "*", "/", "%", "**"]] } + ], + "no-multiple-empty-lines": [ + "error", + { "max": 1 } + ], + "no-param-reassign": "off", + "no-plusplus": [ + "error", + { "allowForLoopAfterthoughts": true } + ], + "no-restricted-globals": [ + "error", + "Handsontable", + { + "name": "console", + "message": "Using the `console` object is not allowed within Handsontable. Please use one of the helpers from the `console.js` file instead." + } + ], + "no-underscore-dangle": "off", + "no-use-before-define": [ + "error", + { + "functions": false, + "classes": false + } + ], + "no-void": "off", + "padded-blocks": "off", + "quotes": [ "error", "single" ], + "space-before-function-paren": ["error", "never"], + }, + "overrides": [ + { + "files": ["test/**", "src/3rdparty/walkontable/test/**", "*.unit.js", "*.e2e.js", "src/plugins/**/test/helpers/**"], + "rules": { + "no-restricted-globals": "off", + "no-undef": "off", + } + } + ], +} diff --git a/dist/handsontable.css b/dist/handsontable.css index 196b5057..3433c5de 100644 --- a/dist/handsontable.css +++ b/dist/handsontable.css @@ -20,8 +20,8 @@ * RELIABILITY AND PERFORMANCE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE * UNINTERRUPTED OR ERROR FREE. * - * Version: 5.0.1 - * Release date: 16/08/2018 (built at 16/08/2018 12:38:43) + * Version: 5.0.2 + * Release date: 12/09/2018 (built at 12/09/2018 12:36:00) */ /** * Fix for bootstrap styles diff --git a/dist/handsontable.full.css b/dist/handsontable.full.css index 41f25a69..6efa1e12 100644 --- a/dist/handsontable.full.css +++ b/dist/handsontable.full.css @@ -20,8 +20,8 @@ * RELIABILITY AND PERFORMANCE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE * UNINTERRUPTED OR ERROR FREE. * - * Version: 5.0.1 - * Release date: 16/08/2018 (built at 16/08/2018 12:38:43) + * Version: 5.0.2 + * Release date: 12/09/2018 (built at 12/09/2018 12:36:00) */ /** * Fix for bootstrap styles diff --git a/dist/handsontable.full.js b/dist/handsontable.full.js index cd4f0c21..fd6e1b07 100644 --- a/dist/handsontable.full.js +++ b/dist/handsontable.full.js @@ -20,8 +20,8 @@ * RELIABILITY AND PERFORMANCE WILL MEET YOUR REQUIREMENTS OR THAT THE OPERATION OF THE SOFTWARE WILL BE * UNINTERRUPTED OR ERROR FREE. * - * Version: 5.0.1 - * Release date: 16/08/2018 (built at 16/08/2018 12:38:43) + * Version: 5.0.2 + * Release date: 12/09/2018 (built at 12/09/2018 12:36:00) */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') @@ -125,7 +125,7 @@ function to2dArray(arr) { while (i < ilen) { arr[i] = [arr[i]]; - i++; + i += 1; } } @@ -135,7 +135,7 @@ function extendArray(arr, extension) { while (i < ilen) { arr.push(extension[i]); - i++; + i += 1; } } @@ -177,6 +177,7 @@ function pivot(arr) { function arrayReduce(array, iteratee, accumulator, initFromArray) { var index = -1; var iterable = array; + var result = accumulator; if (!Array.isArray(array)) { iterable = Array.from(array); @@ -184,13 +185,18 @@ function arrayReduce(array, iteratee, accumulator, initFromArray) { var length = iterable.length; if (initFromArray && length) { - accumulator = iterable[++index]; + index += 1; + result = iterable[index]; } - while (++index < length) { - accumulator = iteratee(accumulator, iterable[index], index, iterable); + + index += 1; + + while (index < length) { + result = iteratee(result, iterable[index], index, iterable); + index += 1; } - return accumulator; + return result; } /** @@ -204,7 +210,7 @@ function arrayReduce(array, iteratee, accumulator, initFromArray) { * @returns {Array} Returns the new filtered array. */ function arrayFilter(array, predicate) { - var index = -1; + var index = 0; var iterable = array; if (!Array.isArray(array)) { @@ -215,12 +221,15 @@ function arrayFilter(array, predicate) { var result = []; var resIndex = -1; - while (++index < length) { + while (index < length) { var value = iterable[index]; if (predicate(value, index, iterable)) { - result[++resIndex] = value; + resIndex += 1; + result[resIndex] = value; } + + index += 1; } return result; @@ -235,7 +244,7 @@ function arrayFilter(array, predicate) { * @returns {Array} Returns the new filtered array. */ function arrayMap(array, iteratee) { - var index = -1; + var index = 0; var iterable = array; if (!Array.isArray(array)) { @@ -246,10 +255,12 @@ function arrayMap(array, iteratee) { var result = []; var resIndex = -1; - while (++index < length) { + while (index < length) { var value = iterable[index]; - result[++resIndex] = iteratee(value, index, iterable); + resIndex += 1; + result[resIndex] = iteratee(value, index, iterable); + index += 1; } return result; @@ -266,7 +277,7 @@ function arrayMap(array, iteratee) { * @returns {Array} Returns `array`. */ function arrayEach(array, iteratee) { - var index = -1; + var index = 0; var iterable = array; if (!Array.isArray(array)) { @@ -275,10 +286,12 @@ function arrayEach(array, iteratee) { var length = iterable.length; - while (++index < length) { + while (index < length) { if (iteratee(iterable[index], index, iterable) === false) { break; } + + index += 1; } return array; @@ -546,15 +559,17 @@ function mixin(Base) { if (typeof value === 'function') { Base.prototype[key] = value; } else { - var getter = function _getter(propertyName, initialValue) { - propertyName = '_' + propertyName; + var getter = function _getter(property, initialValue) { + var propertyName = '_' + property; var initValue = function initValue(newValue) { - if (Array.isArray(newValue) || isObject(newValue)) { - newValue = deepClone(newValue); + var result = newValue; + + if (Array.isArray(result) || isObject(result)) { + result = deepClone(result); } - return newValue; + return result; }; return function () { @@ -565,8 +580,8 @@ function mixin(Base) { return this[propertyName]; }; }; - var setter = function _setter(propertyName) { - propertyName = '_' + propertyName; + var setter = function _setter(property) { + var propertyName = '_' + property; return function (newValue) { this[propertyName] = newValue; @@ -622,6 +637,7 @@ function defineGetter(object, property, value, options) { * @returns {Object} Returns `object`. */ function objectEach(object, iteratee) { + // eslint-disable-next-line no-restricted-syntax for (var key in object) { if (!object.hasOwnProperty || object.hasOwnProperty && Object.prototype.hasOwnProperty.call(object, key)) { if (iteratee(object[key], key, object) === false) { @@ -675,7 +691,7 @@ function deepObjectSize(object) { result += recursObjLen(key); }); } else { - result++; + result += 1; } return result; @@ -785,7 +801,7 @@ exports.isOutsideInput = isOutsideInput; var _browser = __webpack_require__(50); -var _feature = __webpack_require__(42); +var _feature = __webpack_require__(41); function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } @@ -801,18 +817,19 @@ function getParent(element) { var iteration = -1; var parent = null; + var elementToCheck = element; - while (element != null) { + while (elementToCheck !== null) { if (iteration === level) { - parent = element; + parent = elementToCheck; break; } - if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { - element = element.host; + if (elementToCheck.host && elementToCheck.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + elementToCheck = elementToCheck.host; } else { - iteration++; - element = element.parentNode; + iteration += 1; + elementToCheck = elementToCheck.parentNode; } } @@ -829,14 +846,16 @@ function getParent(element) { * @returns {HTMLElement|null} */ function closest(element, nodes, until) { - while (element != null && element !== until) { - if (element.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(element.nodeName) > -1 || nodes.indexOf(element) > -1)) { - return element; + var elementToCheck = element; + + while (elementToCheck !== null && elementToCheck !== until) { + if (elementToCheck.nodeType === Node.ELEMENT_NODE && (nodes.indexOf(elementToCheck.nodeName) > -1 || nodes.indexOf(elementToCheck) > -1)) { + return elementToCheck; } - if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { - element = element.host; + if (elementToCheck.host && elementToCheck.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + elementToCheck = elementToCheck.host; } else { - element = element.parentNode; + elementToCheck = elementToCheck.parentNode; } } @@ -853,19 +872,20 @@ function closest(element, nodes, until) { */ function closestDown(element, nodes, until) { var matched = []; + var elementToCheck = element; - while (element) { - element = closest(element, nodes, until); + while (elementToCheck) { + elementToCheck = closest(elementToCheck, nodes, until); - if (!element || until && !until.contains(element)) { + if (!elementToCheck || until && !until.contains(elementToCheck)) { break; } - matched.push(element); + matched.push(elementToCheck); - if (element.host && element.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { - element = element.host; + if (elementToCheck.host && elementToCheck.nodeType === Node.DOCUMENT_FRAGMENT_NODE) { + elementToCheck = elementToCheck.host; } else { - element = element.parentNode; + elementToCheck = elementToCheck.parentNode; } } var length = matched.length; @@ -891,7 +911,7 @@ function isChildOf(child, parent) { queriedParents.push(parent); } - while (node != null) { + while (node !== null) { if (queriedParents.indexOf(node) > -1) { return true; } @@ -916,7 +936,7 @@ function isChildOfWebComponentTable(element) { return testElement.nodeType === Node.ELEMENT_NODE && testElement.nodeName === hotTableName.toUpperCase(); } - while (parentNode != null) { + while (parentNode !== null) { if (isHotTable(parentNode)) { result = true; break; @@ -934,6 +954,8 @@ function isChildOfWebComponentTable(element) { return result; } +/* global Polymer wrap unwrap */ + /** * Wrap element into polymer/webcomponent container if exists * @@ -941,7 +963,6 @@ function isChildOfWebComponentTable(element) { * @returns {*} */ function polymerWrap(element) { - /* global Polymer */ return typeof Polymer !== 'undefined' && typeof wrap === 'function' ? wrap(element) : element; } @@ -952,7 +973,6 @@ function polymerWrap(element) { * @returns {*} */ function polymerUnwrap(element) { - /* global Polymer */ return typeof Polymer !== 'undefined' && typeof unwrap === 'function' ? unwrap(element) : element; } @@ -967,11 +987,12 @@ function polymerUnwrap(element) { */ function index(element) { var i = 0; + var elementToCheck = element; - if (element.previousSibling) { + if (elementToCheck.previousSibling) { /* eslint-disable no-cond-assign */ - while (element = element.previousSibling) { - ++i; + while (elementToCheck = elementToCheck.previousSibling) { + i += 1; } } @@ -1006,7 +1027,7 @@ function filterEmptyClassNames(classNames) { while (classNames[len]) { result.push(classNames[len]); - len++; + len += 1; } return result; @@ -1029,7 +1050,9 @@ if (classListSupport) { return element.classList.contains(className); }; - _addClass = function _addClass(element, className) { + _addClass = function _addClass(element, classes) { + var className = classes; + if (typeof className === 'string') { className = className.split(' '); } @@ -1046,13 +1069,15 @@ if (classListSupport) { while (className && className[len]) { element.classList.add(className[len]); - len++; + len += 1; } } } }; - _removeClass = function _removeClass(element, className) { + _removeClass = function _removeClass(element, classes) { + var className = classes; + if (typeof className === 'string') { className = className.split(' '); } @@ -1069,7 +1094,7 @@ if (classListSupport) { while (className && className[len]) { element.classList.remove(className[len]); - len++; + len += 1; } } } @@ -1084,9 +1109,10 @@ if (classListSupport) { return element.className !== void 0 && createClassNameRegExp(className).test(element.className); }; - _addClass = function _addClass(element, className) { + _addClass = function _addClass(element, classes) { var len = 0; var _className = element.className; + var className = classes; if (typeof className === 'string') { className = className.split(' '); @@ -1098,15 +1124,16 @@ if (classListSupport) { if (!createClassNameRegExp(className[len]).test(_className)) { _className += ' ' + className[len]; } - len++; + len += 1; } } element.className = _className; }; - _removeClass = function _removeClass(element, className) { + _removeClass = function _removeClass(element, classes) { var len = 0; var _className = element.className; + var className = classes; if (typeof className === 'string') { className = className.split(' '); @@ -1114,7 +1141,7 @@ if (classListSupport) { while (className && className[len]) { // String.prototype.trim is defined in polyfill.js _className = _className.replace(createClassNameRegExp(className[len]), ' ').trim(); - len++; + len += 1; } if (element.className !== _className) { element.className = _className; @@ -1268,37 +1295,36 @@ function isVisible(elem) { * @return {Object} Returns object with `top` and `left` props */ function offset(elem) { + var docElem = document.documentElement; + var elementToCheck = elem; var offsetLeft = void 0; var offsetTop = void 0; var lastElem = void 0; - var docElem = void 0; var box = void 0; - docElem = document.documentElement; - - if ((0, _feature.hasCaptionProblem)() && elem.firstChild && elem.firstChild.nodeName === 'CAPTION') { + if ((0, _feature.hasCaptionProblem)() && elementToCheck.firstChild && elementToCheck.firstChild.nodeName === 'CAPTION') { // fixes problem with Firefox ignoring
-1){t.indexOf(" "+o.marker)>-1&&(H=" "),t=t.replace(H+o.marker,""),i=y(e,o.suffixes,o.scale),e=i.value,H+=i.suffix;break}if(t.indexOf("o")>-1&&(t.indexOf(" o")>-1?(j=" ",t=t.replace(" o","")):t=t.replace("o",""),k[A].ordinal&&(j+=k[A].ordinal(e))),t.indexOf("[.]")>-1&&(T=!0,t=t.replace("[.]",".")),g=t.split(".")[1],w=t.indexOf(","),g){var z=[];if(-1!==g.indexOf("*")?(V=e.toString(),z=V.split("."),z.length>1&&(V=c(e,z[1].length,n))):g.indexOf("[")>-1?(g=g.replace("]",""),g=g.split("["),V=c(e,g[0].length+g[1].length,n,g[1].length)):V=c(e,g.length,n),z=V.split("."),d=z[0],z.length>1&&z[1].length){V=(r?R+r:k[A].delimiters.decimal)+z[1]}else V="";T&&0===Number(V.slice(1))&&(V="")}else d=c(e,0,n);return d.indexOf("-")>-1&&(d=d.slice(1),W=!0),d.length<_&&(d=l(_-d.length)+d),w>-1&&(d=d.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+k[A].delimiters.thousands)),0===t.indexOf(".")&&(d=""),b=t.indexOf("("),C=t.indexOf("-"),U=bi;)l=f,f=e.add(e.multiply(c,l),u),h++;return f},householder:function(n){for(var r,o,i,a,s,l=n.length,u=n[0].length,c=0,f=[],h=[];c