From 73dfab9d0e0137b8c12e9937004f313c2ed4b64f Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Mon, 15 Jan 2018 16:06:34 +0100 Subject: [PATCH 1/5] Update eslint and eslint-plugins --- package-lock.json | 191 ++++++++++++++++++++++++++++++---------------- package.json | 10 +-- 2 files changed, 131 insertions(+), 70 deletions(-) diff --git a/package-lock.json b/package-lock.json index ac9098fbd..9a9d95743 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "chayns-components", - "version": "2.0.1", + "version": "2.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3189,33 +3189,33 @@ } }, "eslint": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.6.1.tgz", - "integrity": "sha1-3cf8f9cL+TIFsLNEm7FqHp59SVA=", + "version": "4.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-4.15.0.tgz", + "integrity": "sha512-zEO/Z1ZUxIQ+MhDVKkVTUYpIPDTEJLXGMrkID+5v1NeQHtCz6FZikWuFRgxE1Q/RV2V4zVl1u3xmpPADHhMZ6A==", "dev": true, "requires": { - "ajv": "5.2.2", + "ajv": "5.5.2", "babel-code-frame": "6.26.0", - "chalk": "2.1.0", + "chalk": "2.3.0", "concat-stream": "1.6.0", "cross-spawn": "5.1.0", - "debug": "2.6.8", - "doctrine": "2.0.0", + "debug": "3.1.0", + "doctrine": "2.1.0", "eslint-scope": "3.7.1", - "espree": "3.5.0", + "eslint-visitor-keys": "1.0.0", + "espree": "3.5.2", "esquery": "1.0.0", - "estraverse": "4.2.0", "esutils": "2.0.2", "file-entry-cache": "2.0.0", "functional-red-black-tree": "1.0.1", "glob": "7.1.2", - "globals": "9.18.0", + "globals": "11.1.0", "ignore": "3.3.5", "imurmurhash": "0.1.4", "inquirer": "3.2.3", "is-resolvable": "1.0.0", "js-yaml": "3.10.0", - "json-stable-stringify": "1.0.1", + "json-stable-stringify-without-jsonify": "1.0.1", "levn": "0.3.0", "lodash": "4.17.4", "minimatch": "3.0.4", @@ -3223,7 +3223,7 @@ "natural-compare": "1.4.0", "optionator": "0.8.2", "path-is-inside": "1.0.2", - "pluralize": "4.0.0", + "pluralize": "7.0.0", "progress": "2.0.0", "require-uncached": "1.0.3", "semver": "5.4.1", @@ -3233,6 +3233,24 @@ "text-table": "0.2.0" }, "dependencies": { + "acorn": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", + "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==", + "dev": true + }, + "ajv": { + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", + "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "dev": true, + "requires": { + "co": "4.6.0", + "fast-deep-equal": "1.0.0", + "fast-json-stable-stringify": "2.0.0", + "json-schema-traverse": "0.3.1" + } + }, "ansi-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", @@ -3249,14 +3267,42 @@ } }, "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, "requires": { "ansi-styles": "3.2.0", "escape-string-regexp": "1.0.5", - "supports-color": "4.4.0" + "supports-color": "4.5.0" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "doctrine": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", + "dev": true, + "requires": { + "esutils": "2.0.2" + } + }, + "espree": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.2.tgz", + "integrity": "sha512-sadKeYwaR/aJ3stC2CdvgXu1T16TdYN+qwCpcWbMnGJ8s0zNWemzrvb2GbD4OhmJ/fwpJjudThAlLobGbWZbCQ==", + "dev": true, + "requires": { + "acorn": "5.3.0", + "acorn-jsx": "3.0.1" } }, "esprima": { @@ -3265,6 +3311,12 @@ "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", "dev": true }, + "globals": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.1.0.tgz", + "integrity": "sha512-uEuWt9mqTlPDwSqi+sHjD4nWU/1N+q0fiWI9T1mZpD2UENqX20CFD5T/ziLZvztPaBKl7ZylUi1q6Qfm7E2CiQ==", + "dev": true + }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", @@ -3281,6 +3333,12 @@ "esprima": "4.0.0" } }, + "pluralize": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", + "integrity": "sha512-ARhBOdzS3e41FbkW/XWrTEtukqqLoK5+Z/4UeDaLuSW+39JPeFgs4gCGqsrJHVZX0fUrx//4OF0K1CUGwlIFow==", + "dev": true + }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -3291,9 +3349,9 @@ } }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, "requires": { "has-flag": "2.0.0" @@ -3302,21 +3360,23 @@ } }, "eslint-config-airbnb": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-15.1.0.tgz", - "integrity": "sha512-m0q9fiMBzDAIbirlGnpJNWToIhdhJmXXnMG+IFflYzzod9231ZhtmGKegKg8E9T8F1YuVaDSU1FnCm5b9iXVhQ==", + "version": "16.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb/-/eslint-config-airbnb-16.1.0.tgz", + "integrity": "sha512-zLyOhVWhzB/jwbz7IPSbkUuj7X2ox4PHXTcZkEmDqTvd0baJmJyuxlFPDlZOE/Y5bC+HQRaEkT3FoHo9wIdRiw==", "dev": true, "requires": { - "eslint-config-airbnb-base": "11.3.2" - } - }, - "eslint-config-airbnb-base": { - "version": "11.3.2", - "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-11.3.2.tgz", - "integrity": "sha512-/fhjt/VqzBA2SRsx7ErDtv6Ayf+XLw9LIOqmpBuHFCVwyJo2EtzGWMB9fYRFBoWWQLxmNmCpenNiH0RxyeS41w==", - "dev": true, - "requires": { - "eslint-restricted-globals": "0.1.1" + "eslint-config-airbnb-base": "12.1.0" + }, + "dependencies": { + "eslint-config-airbnb-base": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/eslint-config-airbnb-base/-/eslint-config-airbnb-base-12.1.0.tgz", + "integrity": "sha512-/vjm0Px5ZCpmJqnjIzcFb9TKZrKWz0gnuG/7Gfkt0Db1ELJR51xkZth+t14rYdqWgX836XbuxtArbIHlVhbLBA==", + "dev": true, + "requires": { + "eslint-restricted-globals": "0.1.1" + } + } } }, "eslint-import-resolver-node": { @@ -3370,9 +3430,9 @@ } }, "eslint-plugin-import": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.7.0.tgz", - "integrity": "sha512-HGYmpU9f/zJaQiKNQOVfHUh2oLWW3STBrCgH0sHTX1xtsxYlH1zjLh8FlQGEIdZSdTbUMaV36WaZ6ImXkenGxQ==", + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.8.0.tgz", + "integrity": "sha512-Rf7dfKJxZ16QuTgVv1OYNxkZcsu/hULFnC+e+w0Gzi6jMC3guQoWQgxYxc54IDRinlb6/0v5z/PxxIKmVctN+g==", "dev": true, "requires": { "builtin-modules": "1.1.1", @@ -3400,9 +3460,9 @@ } }, "eslint-plugin-jsx-a11y": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.0.2.tgz", - "integrity": "sha1-ZZJ3p1iwNsMFp+ShMFfDAc075z8=", + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.0.3.tgz", + "integrity": "sha1-VFg9GuRCSDFi4EDhPMMYZUZRAOU=", "dev": true, "requires": { "aria-query": "0.7.0", @@ -3411,13 +3471,24 @@ "axobject-query": "0.1.0", "damerau-levenshtein": "1.0.4", "emoji-regex": "6.5.1", - "jsx-ast-utils": "1.4.1" + "jsx-ast-utils": "2.0.1" + }, + "dependencies": { + "jsx-ast-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz", + "integrity": "sha1-6AGxs5mF4g//yHtA43SAgOLcrH8=", + "dev": true, + "requires": { + "array-includes": "3.0.3" + } + } } }, "eslint-plugin-react": { - "version": "7.3.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.3.0.tgz", - "integrity": "sha512-7L6QEOxm7XhcDoe+U9Qt7GJjU6KeQOX9jCLGE8EPGF6FQbwZ9LgcBzsjXIZv9oYvNQlvQZmLjJs76xEeWsI4QA==", + "version": "7.5.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.5.1.tgz", + "integrity": "sha512-YGSjB9Qu6QbVTroUZi66pYky3DfoIPLdHQ/wmrBGyBRnwxQsBXAov9j2rpXt/55i8nyMv6IRWJv2s4d4YnduzQ==", "dev": true, "requires": { "doctrine": "2.0.0", @@ -3459,16 +3530,6 @@ "integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ==", "dev": true }, - "espree": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/espree/-/espree-3.5.0.tgz", - "integrity": "sha1-mDWGJb3QVYYeon4oZ+pyn69GPY0=", - "dev": true, - "requires": { - "acorn": "5.1.2", - "acorn-jsx": "3.0.1" - } - }, "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", @@ -3633,6 +3694,12 @@ "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", "dev": true }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", @@ -5058,6 +5125,12 @@ "jsonify": "0.0.0" } }, + "json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", @@ -5108,12 +5181,6 @@ } } }, - "jsx-ast-utils": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", - "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=", - "dev": true - }, "killable": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.0.tgz", @@ -6438,12 +6505,6 @@ "find-up": "2.1.0" } }, - "pluralize": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-4.0.0.tgz", - "integrity": "sha1-WbcIwcAZCi9pLxx2GMRGsFL9F2I=", - "dev": true - }, "portfinder": { "version": "1.0.13", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.13.tgz", diff --git a/package.json b/package.json index 33a4ba3fc..764196a32 100644 --- a/package.json +++ b/package.json @@ -28,11 +28,11 @@ "babel-preset-react": "^6.23.0", "babel-preset-stage-0": "^6.22.0", "css-loader": "^0.28.8", - "eslint": "^4.5.0", - "eslint-config-airbnb": "^15.1.0", - "eslint-plugin-import": "^2.7.0", - "eslint-plugin-jsx-a11y": "^6.0.2", - "eslint-plugin-react": "^7.3.0", + "eslint": "^4.15.0", + "eslint-config-airbnb": "^16.1.0", + "eslint-plugin-import": "^2.8.0", + "eslint-plugin-jsx-a11y": "^6.0.3", + "eslint-plugin-react": "^7.5.1", "html-webpack-plugin": "^2.30.1", "node-sass": "^4.7.2", "react-hot-loader": "^1.3.1", From 468f414a1e7b4eee945a110ad8439f881b9d8f72 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Mon, 15 Jan 2018 16:59:42 +0100 Subject: [PATCH 2/5] Fix eslint-errors --- src/polyfills/is-finite.js | 4 ++ .../component/Accordion.jsx | 11 +++- .../component/AmountControl.jsx | 15 +++++- .../component/AmountInput.jsx | 10 +++- .../component/ControlButton.jsx | 7 ++- .../InspectElement/InspectElement.jsx | 9 +++- .../component/InspectElement/Modal.jsx | 36 ++++++++++--- src/react-chayns-button/component/Button.jsx | 11 +++- .../component/ChooseButton.jsx | 51 ++++++++----------- .../component/Checkbox.jsx | 11 +++- .../component/ContextMenu.jsx | 21 +++++--- .../component/ContextMenuItem.jsx | 1 + .../component/EmojiInput.jsx | 8 +-- src/react-chayns-input/component/Input.jsx | 15 +++++- .../component/Mode.jsx | 1 + .../component/ModeSwitch.jsx | 4 +- .../component/PersonFinder.jsx | 2 +- .../component/RadioButton.jsx | 12 ++++- .../component/SelectButton.jsx | 17 +++++-- .../component/SelectList.jsx | 9 +++- .../component/internal/SelectItemInternal.jsx | 9 +++- .../component/SetupWizard.jsx | 2 + .../component/SharingBar.jsx | 2 +- src/react-chayns-swiper/component/Slider.jsx | 5 +- src/react-refuel/component/Refuel.jsx | 48 ++++++++--------- src/react-refuel/component/RefuelCounter.jsx | 1 + src/react-weather/component/Weather.jsx | 3 ++ src/react-weather/utils/Astronomy.js | 1 + src/react-weather/utils/utils.js | 6 ++- src/utils/equalizer.js | 4 +- src/utils/fetch.js | 3 ++ 31 files changed, 240 insertions(+), 99 deletions(-) create mode 100644 src/polyfills/is-finite.js diff --git a/src/polyfills/is-finite.js b/src/polyfills/is-finite.js new file mode 100644 index 000000000..09eb69c67 --- /dev/null +++ b/src/polyfills/is-finite.js @@ -0,0 +1,4 @@ +Number.isFinite = Number.isFinite || function (value) { + // eslint-disable-next-line no-restricted-globals + return typeof value === 'number' && isFinite(value); +}; diff --git a/src/react-chayns-accordion/component/Accordion.jsx b/src/react-chayns-accordion/component/Accordion.jsx index 4b26127a7..0a6075f13 100644 --- a/src/react-chayns-accordion/component/Accordion.jsx +++ b/src/react-chayns-accordion/component/Accordion.jsx @@ -105,7 +105,12 @@ class Accordion extends React.Component { } _renderHead() { - const { badge, badgeStyle, right, head } = this.props; + const { + badge, + badgeStyle, + right, + head, + } = this.props; if (!badge && !right) { return head; @@ -132,7 +137,9 @@ class Accordion extends React.Component { key="badge" className="badge accordion--trigger" style={badgeStyle} - >{badge} + > + {badge} + )} ]; diff --git a/src/react-chayns-amountcontrol/component/AmountControl.jsx b/src/react-chayns-amountcontrol/component/AmountControl.jsx index e999a7af6..677aab78e 100644 --- a/src/react-chayns-amountcontrol/component/AmountControl.jsx +++ b/src/react-chayns-amountcontrol/component/AmountControl.jsx @@ -107,7 +107,20 @@ export default class AmountControl extends React.Component { }; render() { - const { amount, buttonText, equalize, disabled, disableInput, disableAdd, disableRemove, className, autoInput, buttonFormatHandler, showInput, shopStyle } = this.props; + const { + amount, + buttonText, + equalize, + disabled, + disableInput, + disableAdd, + disableRemove, + className, + autoInput, + buttonFormatHandler, + showInput, + shopStyle, + } = this.props; if(window.debugLevel >= 3) { console.debug('render amount-control component', this.props, this.state); diff --git a/src/react-chayns-amountcontrol/component/AmountInput.jsx b/src/react-chayns-amountcontrol/component/AmountInput.jsx index edb829927..c53aa513c 100644 --- a/src/react-chayns-amountcontrol/component/AmountInput.jsx +++ b/src/react-chayns-amountcontrol/component/AmountInput.jsx @@ -143,7 +143,15 @@ export default class AmountInput extends React.Component { } render() { - const { amount, equalize, disabled, disableInput, autoInput, showInput: showInputProp, shopStyle } = this.props; + const { + amount, + equalize, + disabled, + disableInput, + autoInput, + showInput: showInputProp, + shopStyle, + } = this.props; const { showInput } = this.state; if(((!autoInput || amount <= AUTO_HIDE_INPUT_MAX_AMOUNT) && !showInput && !showInputProp) || disableInput || disabled) { diff --git a/src/react-chayns-amountcontrol/component/ControlButton.jsx b/src/react-chayns-amountcontrol/component/ControlButton.jsx index 8ca221525..5c42eb547 100644 --- a/src/react-chayns-amountcontrol/component/ControlButton.jsx +++ b/src/react-chayns-amountcontrol/component/ControlButton.jsx @@ -3,7 +3,12 @@ import PropTypes from 'prop-types'; import { ChooseButton } from '../../index'; -const ControlButton = ({ icon, onClick, className, disabled }) => { +const ControlButton = ({ + icon, + onClick, + className, + disabled, +}) => { return( diff --git a/src/react-chayns-animations/component/InspectElement/Modal.jsx b/src/react-chayns-animations/component/InspectElement/Modal.jsx index c01972e27..4316ae5b5 100644 --- a/src/react-chayns-animations/component/InspectElement/Modal.jsx +++ b/src/react-chayns-animations/component/InspectElement/Modal.jsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; @@ -33,7 +34,12 @@ export default class Modal extends React.Component { } getModalWidth() { - const { width, left, right, direction } = this.props; + const { + width, + left, + right, + direction, + } = this.props; if(direction === Constants.DIRECTION_LEFT) { return `${parseFloat(width) + (2 * parseFloat(right))}px`; @@ -44,7 +50,14 @@ export default class Modal extends React.Component { getWidth() { const { width, expandedWidth } = this.props; - const { didLeave, willEnter, willEnterActive, didEnter, willLeave, willLeaveActive } = this.state; + const { + didLeave, + willEnter, + willEnterActive, + didEnter, + willLeave, + willLeaveActive, + } = this.state; if(!didLeave && !didEnter && !willEnterActive && !willEnter && !willLeave && !willLeaveActive) { @@ -110,8 +123,8 @@ export default class Modal extends React.Component { if(this._content) { - const bottom = this._content.getBoundingClientRect().bottom; - const height = document.body.getBoundingClientRect().height; + const { bottom } = this._content.getBoundingClientRect(); + const { height } = document.body.getBoundingClientRect(); const newPadding = (bottom - height) + 25; const tapp = document.querySelector('.tapp') || document.body; @@ -164,8 +177,19 @@ export default class Modal extends React.Component { } render() { - const { top, renderComponent, closeOverlay, direction } = this.props; - const { willEnter, willEnterActive, willLeave, willLeaveActive, didEnter } = this.state; + const { + top, + renderComponent, + closeOverlay, + direction, + } = this.props; + const { + willEnter, + willEnterActive, + willLeave, + willLeaveActive, + didEnter, + } = this.state; if(window.debugLevel >= 2) { console.debug('render inspect-element (Modal) component', this.props, this.state); diff --git a/src/react-chayns-button/component/Button.jsx b/src/react-chayns-button/component/Button.jsx index 411aea6ef..8392a6695 100644 --- a/src/react-chayns-button/component/Button.jsx +++ b/src/react-chayns-button/component/Button.jsx @@ -31,7 +31,16 @@ export default class Button extends React.Component { }; render() { - const { chooseButton, disabled, children, className, style, buttonRef, onClick, ...other } = this.props; + const { + chooseButton, + disabled, + children, + className, + style, + buttonRef, + onClick, + ...other + } = this.props; const classNames = classnames({ button: !chooseButton, diff --git a/src/react-chayns-button/component/ChooseButton.jsx b/src/react-chayns-button/component/ChooseButton.jsx index 45cc56945..4fc50a0b3 100644 --- a/src/react-chayns-button/component/ChooseButton.jsx +++ b/src/react-chayns-button/component/ChooseButton.jsx @@ -2,35 +2,28 @@ import React from 'react'; import PropTypes from 'prop-types'; import Button from './Button'; -export default class ChooseButton extends React.Component { - static propTypes = { - children: PropTypes.node.isRequired, - disabled: PropTypes.bool, - onClick: PropTypes.func, - className: PropTypes.string, - style: PropTypes.object - }; +const ChooseButton = ({ children, ...props }) => ( + +); - static defaultProps = { - style: null, - className: null, - onClick: null, - disabled: false, - }; +ChooseButton.propTypes = { + children: PropTypes.node.isRequired, + disabled: PropTypes.bool, + onClick: PropTypes.func, + className: PropTypes.string, + style: PropTypes.object +}; - render() { - const { - children, - ...props - } = this.props; +ChooseButton.defaultProps = { + style: null, + className: null, + onClick: null, + disabled: false, +}; - return( - - ); - } -} +export default ChooseButton; diff --git a/src/react-chayns-checkbox/component/Checkbox.jsx b/src/react-chayns-checkbox/component/Checkbox.jsx index 096f40eee..b767f19a3 100644 --- a/src/react-chayns-checkbox/component/Checkbox.jsx +++ b/src/react-chayns-checkbox/component/Checkbox.jsx @@ -59,7 +59,16 @@ export default class Checkbox extends React.Component { }; render() { - const { className, style, disabled, children, label, checked, defaultChecked, dangerouslySetLabel } = this.props; + const { + className, + style, + disabled, + children, + label, + checked, + defaultChecked, + dangerouslySetLabel, + } = this.props; const classNames = classnames({ [className]: className }); diff --git a/src/react-chayns-contextmenu/component/ContextMenu.jsx b/src/react-chayns-contextmenu/component/ContextMenu.jsx index 0e79fbe25..55f9025f6 100644 --- a/src/react-chayns-contextmenu/component/ContextMenu.jsx +++ b/src/react-chayns-contextmenu/component/ContextMenu.jsx @@ -1,9 +1,16 @@ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import PropTypes from 'prop-types'; import ContextMenuItem from './ContextMenuItem'; -const ContextMenu = ({ hide, onLayerClick, x, y, items }) => { +const ContextMenu = ({ + hide, + onLayerClick, + x, + y, + items, +}) => { const contextMenuClass = hide ? 'context-menu' : 'context-menu context-menu--active'; return ( @@ -50,13 +57,11 @@ ContextMenu.propTypes = { onLayerClick: PropTypes.func, x: PropTypes.number, y: PropTypes.number, - items: PropTypes.arrayOf( - PropTypes.shape({ - className: PropTypes.string, - onClick: PropTypes.func, - text: PropTypes.string - }) - ) + items: PropTypes.arrayOf(PropTypes.shape({ + className: PropTypes.string, + onClick: PropTypes.func, + text: PropTypes.string + })) }; export default ContextMenu; diff --git a/src/react-chayns-contextmenu/component/ContextMenuItem.jsx b/src/react-chayns-contextmenu/component/ContextMenuItem.jsx index df1e21c93..f33d1f312 100644 --- a/src/react-chayns-contextmenu/component/ContextMenuItem.jsx +++ b/src/react-chayns-contextmenu/component/ContextMenuItem.jsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import PropTypes from 'prop-types'; diff --git a/src/react-chayns-emoji_input/component/EmojiInput.jsx b/src/react-chayns-emoji_input/component/EmojiInput.jsx index 6abaf143e..ee965d7c2 100644 --- a/src/react-chayns-emoji_input/component/EmojiInput.jsx +++ b/src/react-chayns-emoji_input/component/EmojiInput.jsx @@ -87,8 +87,8 @@ export default class EmojiInput extends React.Component { getActiveChildNode = () => { const inputDiv = this.input; const selection = window.getSelection(); - const anchorNode = selection.anchorNode; - const childNodes = inputDiv.childNodes; + const { anchorNode } = selection; + const { childNodes } = inputDiv; let activeChildNode = -1; if (anchorNode && anchorNode !== inputDiv) { @@ -96,6 +96,7 @@ export default class EmojiInput extends React.Component { let curNode = childNodes[i]; if (chayns.env.isIOS && curNode.nodeName.toUpperCase() === 'I') { + // eslint-disable-next-line prefer-destructuring curNode = curNode.childNodes[0]; } @@ -308,8 +309,7 @@ export default class EmojiInput extends React.Component { if (activeElem) { this.cursorPos = EmojiInput.getCaretCharacterOffsetWithin(activeElem); - const scrollTop = inputDiv.scrollTop; - const scrollHeight = inputDiv.scrollHeight; + const { scrollTop, scrollHeight } = inputDiv.scrollTop; inputDiv.innerHTML = newHtml; diff --git a/src/react-chayns-input/component/Input.jsx b/src/react-chayns-input/component/Input.jsx index 07d3b0e34..856a47816 100644 --- a/src/react-chayns-input/component/Input.jsx +++ b/src/react-chayns-input/component/Input.jsx @@ -84,7 +84,20 @@ export default class Input extends React.Component { } render() { - const { value, defaultValue, placeholder, className, style, responsive, regExp, inputRef, onChange, onBlur, onKeyUp, ...other } = this.props; + const { + value, + defaultValue, + placeholder, + className, + style, + responsive, + regExp, + inputRef, + onChange, + onBlur, + onKeyUp, + ...other + } = this.props; const { isValid } = this.state; const classNames = classnames({ diff --git a/src/react-chayns-modeswitch/component/Mode.jsx b/src/react-chayns-modeswitch/component/Mode.jsx index 454e22c1c..77c96b0d8 100644 --- a/src/react-chayns-modeswitch/component/Mode.jsx +++ b/src/react-chayns-modeswitch/component/Mode.jsx @@ -31,6 +31,7 @@ export default class Mode extends React.Component { ModeSwitchHelper.onChange(this.updatedMode); this.setState({ + // eslint-disable-next-line react/no-unused-state group: ModeSwitchHelper.getCurrentMode().id }); } diff --git a/src/react-chayns-modeswitch/component/ModeSwitch.jsx b/src/react-chayns-modeswitch/component/ModeSwitch.jsx index 4577df125..2824fc4bd 100644 --- a/src/react-chayns-modeswitch/component/ModeSwitch.jsx +++ b/src/react-chayns-modeswitch/component/ModeSwitch.jsx @@ -5,9 +5,7 @@ import ModeSwitchHelper from './ModeSwitchHelper'; class ModeSwitch extends React.Component { static propTypes = { - groups: PropTypes.arrayOf( - PropTypes.oneOfType([PropTypes.number, PropTypes.object]) - ), + groups: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.object])), save: PropTypes.bool, onChange: PropTypes.func, defaultMode: PropTypes.number diff --git a/src/react-chayns-personfinder/component/PersonFinder.jsx b/src/react-chayns-personfinder/component/PersonFinder.jsx index 702a9fa7e..d1bbf88fd 100644 --- a/src/react-chayns-personfinder/component/PersonFinder.jsx +++ b/src/react-chayns-personfinder/component/PersonFinder.jsx @@ -27,7 +27,7 @@ export default class PersonFinder extends React.Component { this._node.setAttribute('finder', 'person'); this._node.addEventListener('finderChange', (data) => { - const user = data.user; + const { user } = data; this.props.onChange({ user, node: this._node }); }); diff --git a/src/react-chayns-radiobutton/component/RadioButton.jsx b/src/react-chayns-radiobutton/component/RadioButton.jsx index 615c8c9a5..65d795721 100644 --- a/src/react-chayns-radiobutton/component/RadioButton.jsx +++ b/src/react-chayns-radiobutton/component/RadioButton.jsx @@ -28,7 +28,6 @@ export default class RadioButton extends Component { disabled: false, children: null, value: undefined, - tooltip: null, className: null }; @@ -59,7 +58,16 @@ export default class RadioButton extends Component { * @returns {XML} */ render() { - const { checked, id, children, disabled, name, className, onChange, ...props } = this.props; + const { + checked, + id, + children, + disabled, + name, + className, + onChange, + ...props + } = this.props; return (
diff --git a/src/react-chayns-selectbutton/component/SelectButton.jsx b/src/react-chayns-selectbutton/component/SelectButton.jsx index f26f9b27a..9945f2758 100644 --- a/src/react-chayns-selectbutton/component/SelectButton.jsx +++ b/src/react-chayns-selectbutton/component/SelectButton.jsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; @@ -46,6 +47,7 @@ export default class SelectButton extends React.Component { constructor(props) { super(props); this.state = { + // eslint-disable-next-line react/no-unused-state selected: [] }; @@ -55,7 +57,7 @@ export default class SelectButton extends React.Component { onSelect(selected) { const { onSelect } = this.props; - const selection = selected.selection; + const { selection } = selected; if(selection.length === 1) { this.setLabel(selection[0].name); @@ -67,7 +69,15 @@ export default class SelectButton extends React.Component { } onClick() { - const { quickFind, multiSelect, title, description, list, listKey, listValue } = this.props; + const { + quickFind, + multiSelect, + title, + description, + list, + listKey, + listValue, + } = this.props; const _list = SelectButton.getDialogList(list, listKey, listValue); chayns.dialog.select({ @@ -85,8 +95,7 @@ export default class SelectButton extends React.Component { getReturnList(selected) { const { list, listKey } = this.props; - const selectedItems = selected.selection; - const buttonType = selected.buttonType; + const { buttonType, selection: selectedItems } = selected; const result = []; selectedItems.map((item) => { diff --git a/src/react-chayns-selectlist/component/SelectList.jsx b/src/react-chayns-selectlist/component/SelectList.jsx index 45830e1be..ce607d35b 100644 --- a/src/react-chayns-selectlist/component/SelectList.jsx +++ b/src/react-chayns-selectlist/component/SelectList.jsx @@ -111,7 +111,7 @@ export default class SelectList extends React.Component { _selectFirstItem(children) { for(let i = 0, z = children.length; i < z; i += 1) { - const props = children[i].props; + const { props } = children[i]; if(!props.disabled) { this._changeActiveItem(props.id); @@ -125,7 +125,12 @@ export default class SelectList extends React.Component { const { selectedId } = this.state; return children.map((child) => { - const { id, disabled, className, name } = child.props; + const { + id, + disabled, + className, + name, + } = child.props; return ( { if(elements[i].dataset && elements[i].dataset.callbackid) { - const callbackid = elements[i].dataset.callbackid; + const { callbackid } = elements[i].dataset; if(callbackid && window.react && window.react.slider && window.react.slider.callbacks && window.react.slider.callbacks[callbackid]) { window.react.slider.callbacks[callbackid](event); @@ -102,7 +103,7 @@ export default class App extends React.Component { _onResize() { if(this._swiperElement) { - const width = this._swiperElement.getBoundingClientRect().width; + const { width } = this._swiperElement.getBoundingClientRect(); const height = this._getHeight(width); this._swiperElement.style.height = `${height}px`; diff --git a/src/react-refuel/component/Refuel.jsx b/src/react-refuel/component/Refuel.jsx index 30add4687..35357c2f8 100644 --- a/src/react-refuel/component/Refuel.jsx +++ b/src/react-refuel/component/Refuel.jsx @@ -122,29 +122,31 @@ export default class Refuel extends React.Component { render() { if(this._refuel) { - return (
- { - this._refuel.map((element) => { - let name = element.fuelId; - if (name === 2) { - name = 'Super'; - } else if (name === 1) { - name = 'Diesel'; - } else if (name === 3) { - name = 'Super E10'; - } - - return ( - - ); - }) - } -
); + return ( +
+ { + this._refuel.map((element) => { + let name = element.fuelId; + if (name === 2) { + name = 'Super'; + } else if (name === 1) { + name = 'Diesel'; + } else if (name === 3) { + name = 'Super E10'; + } + + return ( + + ); + }) + } +
+ ); } diff --git a/src/react-refuel/component/RefuelCounter.jsx b/src/react-refuel/component/RefuelCounter.jsx index f73762b3f..1735cf08e 100644 --- a/src/react-refuel/component/RefuelCounter.jsx +++ b/src/react-refuel/component/RefuelCounter.jsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import PropTypes from 'prop-types'; diff --git a/src/react-weather/component/Weather.jsx b/src/react-weather/component/Weather.jsx index 9718c0929..bc440d3f4 100644 --- a/src/react-weather/component/Weather.jsx +++ b/src/react-weather/component/Weather.jsx @@ -1,3 +1,4 @@ +/* eslint-disable jsx-a11y/click-events-have-key-events */ import React from 'react'; import PropTypes from 'prop-types'; @@ -74,6 +75,7 @@ export default class Weather extends React.Component { const lng = this.props.longitude; this.setState({ + // eslint-disable-next-line react/no-unused-state isFetching: true }); @@ -103,6 +105,7 @@ export default class Weather extends React.Component { } }).then(() => { this.setState({ + // eslint-disable-next-line react/no-unused-state isFetching: false }); }); diff --git a/src/react-weather/utils/Astronomy.js b/src/react-weather/utils/Astronomy.js index d201ebfa1..234726612 100644 --- a/src/react-weather/utils/Astronomy.js +++ b/src/react-weather/utils/Astronomy.js @@ -3,6 +3,7 @@ import WorldWeatherOnline from './WorldWeatherOnline'; export default class Astronomy { constructor(jsonObject, parent) { if (jsonObject[0]) { + // eslint-disable-next-line prefer-destructuring this._info = jsonObject[0]; } diff --git a/src/react-weather/utils/utils.js b/src/react-weather/utils/utils.js index 3cd0649ca..6b68390f6 100644 --- a/src/react-weather/utils/utils.js +++ b/src/react-weather/utils/utils.js @@ -1,12 +1,14 @@ +import '../../polyfills/is-finite'; + export function isInteger(value) { return typeof value === 'number' && - isFinite(value) && + Number.isFinite(value) && Math.floor(value) === value; } export function stringEndsWith(subjectString, searchString, position) { let pos = position; - if (typeof pos !== 'number' || !isFinite(pos) || Math.floor(pos) !== pos || pos > subjectString.length) { + if (typeof pos !== 'number' || !Number.isFinite(pos) || Math.floor(pos) !== pos || pos > subjectString.length) { pos = subjectString.length; } pos -= searchString.length; diff --git a/src/utils/equalizer.js b/src/utils/equalizer.js index 393516855..30430168f 100644 --- a/src/utils/equalizer.js +++ b/src/utils/equalizer.js @@ -13,9 +13,9 @@ const dimension = { * @param [d2=d] Dimension that should be set */ function equalize(elements, d, d2) { - let max = 0; - const length = elements.length; + const { length } = elements; const dimensionToSet = d2 || d; + let max = 0; if (length > 1) { let currentDim; diff --git a/src/utils/fetch.js b/src/utils/fetch.js index 90c273619..59d54f4f9 100644 --- a/src/utils/fetch.js +++ b/src/utils/fetch.js @@ -2,12 +2,15 @@ function extractDomain(url) { let domain; // find & remove protocol (http, ftp, etc.) and get domain if(url.indexOf('://') > -1) { + // eslint-disable-next-line prefer-destructuring domain = url.split('/')[2]; } else { + // eslint-disable-next-line prefer-destructuring domain = url.split('/')[0]; } // find & remove port number + // eslint-disable-next-line prefer-destructuring domain = domain.split(':')[0]; return domain; From 922fa660ba4527243e9012bc2e25aa2a5894e1de Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Mon, 15 Jan 2018 17:37:10 +0100 Subject: [PATCH 3/5] Fix calendar-example --- examples/react-chayns-calendar/Example.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/react-chayns-calendar/Example.jsx b/examples/react-chayns-calendar/Example.jsx index a661c0a75..ebbaafe2b 100644 --- a/examples/react-chayns-calendar/Example.jsx +++ b/examples/react-chayns-calendar/Example.jsx @@ -17,14 +17,14 @@ export default class Example extends React.Component { render() { return( -
+

Option 1:

Calendar
-
+
From 60849c557f86119ea33228f2d9e104a40e197715 Mon Sep 17 00:00:00 2001 From: Carl Philipp Sporon Date: Tue, 16 Jan 2018 12:03:37 +0100 Subject: [PATCH 4/5] Change behaviour for native apps --- src/react-chayns-modeswitch/component/ModeSwitchHelper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/react-chayns-modeswitch/component/ModeSwitchHelper.js b/src/react-chayns-modeswitch/component/ModeSwitchHelper.js index 207d47013..7b99e99f1 100644 --- a/src/react-chayns-modeswitch/component/ModeSwitchHelper.js +++ b/src/react-chayns-modeswitch/component/ModeSwitchHelper.js @@ -115,7 +115,7 @@ export default class ModeSwitchHelper { const managerGroup = ModeSwitchHelper.findManagerGroup(groups); - if(managerGroup && data && data.AppUser.AdminMode) { + if(managerGroup && data && data.AppUser.AdminMode && !chayns.env.isApp) { groupObject = getGroupObject(managerGroup.id, managerGroup.name, managerGroup.uacIds); isChaynsIdAdmin = true; } else { @@ -153,7 +153,7 @@ export default class ModeSwitchHelper { const uacIds = getUacIds(groups[i]); const allowedUacs = getAllowedUacIdsFromArray(uacIds); - if (allowedUacs.length > 0 && !(allowedUacs.find(uac => uac === 1))) { + if (allowedUacs.length > 0 && !(allowedUacs.find(uac => uac === 1) && !chayns.env.isApp)) { const addGroupObject = getGroupObject(groups[i].id, groups[i].name, allowedUacs); allowedGroups.push(addGroupObject); From f07ffd6f8874bda0ed86457da608e83466ca5d20 Mon Sep 17 00:00:00 2001 From: Michael Braun Date: Tue, 16 Jan 2018 12:28:33 +0100 Subject: [PATCH 5/5] Update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 764196a32..ea6376b63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chayns-components", - "version": "2.0.2", + "version": "2.0.3", "description": "some standalone react components", "main": "lib/index.js", "scripts": {