diff options
author | 2021-09-14 19:58:52 +0200 | |
---|---|---|
committer | 2021-09-14 19:58:52 +0200 | |
commit | 95df3522a15631abc51a4295cae0ea401a8d4e1e (patch) | |
tree | e5eb0f368c947683f01458e912f21756fb0d99cb /src/components | |
parent | docs: add sad270 as a contributor for bug, userTesting [skip ci] (#1941) (diff) | |
download | ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.gz ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.zst ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.zip |
feat: add eslint-plugin-unicorn (#1936)
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/auth/Invite.js | 10 | ||||
-rw-r--r-- | src/components/settings/SettingsLayout.js | 1 | ||||
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 4 | ||||
-rw-r--r-- | src/components/settings/services/ServicesDashboard.js | 2 | ||||
-rw-r--r-- | src/components/ui/ImageUpload.js | 4 | ||||
-rw-r--r-- | src/components/ui/InfoBar.js | 3 | ||||
-rw-r--r-- | src/components/ui/Infobox.js | 3 | ||||
-rw-r--r-- | src/components/ui/Modal/index.js | 2 | ||||
-rw-r--r-- | src/components/ui/Select.js | 2 | ||||
-rw-r--r-- | src/components/ui/effects/Appear.js | 10 |
10 files changed, 19 insertions, 22 deletions
diff --git a/src/components/auth/Invite.js b/src/components/auth/Invite.js index 519691ede..df8980314 100644 --- a/src/components/auth/Invite.js +++ b/src/components/auth/Invite.js | |||
@@ -65,7 +65,7 @@ class Invite extends Component { | |||
65 | { | 65 | { |
66 | fields: { | 66 | fields: { |
67 | invite: [ | 67 | invite: [ |
68 | ...Array(3).fill({ | 68 | ...Array.from({ length: 3 }).fill({ |
69 | fields: { | 69 | fields: { |
70 | name: { | 70 | name: { |
71 | label: this.props.intl.formatMessage(messages.nameLabel), | 71 | label: this.props.intl.formatMessage(messages.nameLabel), |
@@ -95,19 +95,19 @@ class Invite extends Component { | |||
95 | this.props.intl, | 95 | this.props.intl, |
96 | ); | 96 | ); |
97 | 97 | ||
98 | document.querySelector('input:first-child').focus(); | 98 | document.querySelector('input:first-child')?.focus(); |
99 | } | 99 | } |
100 | 100 | ||
101 | submit(e) { | 101 | submit(e) { |
102 | e.preventDefault(); | 102 | e.preventDefault(); |
103 | 103 | ||
104 | this.form.submit({ | 104 | this.form?.submit({ |
105 | onSuccess: form => { | 105 | onSuccess: form => { |
106 | this.props.onSubmit({ invites: form.values().invite }); | 106 | this.props.onSubmit({ invites: form.values().invite }); |
107 | 107 | ||
108 | this.form.clear(); | 108 | this.form?.clear(); |
109 | // this.form.$('invite.0.name').focus(); // path accepted but does not focus ;( | 109 | // this.form.$('invite.0.name').focus(); // path accepted but does not focus ;( |
110 | document.querySelector('input:first-child').focus(); | 110 | document.querySelector('input:first-child')?.focus(); |
111 | this.setState({ showSuccessInfo: true }); | 111 | this.setState({ showSuccessInfo: true }); |
112 | }, | 112 | }, |
113 | onError: () => {}, | 113 | onError: () => {}, |
diff --git a/src/components/settings/SettingsLayout.js b/src/components/settings/SettingsLayout.js index 0574b3765..71250bd4d 100644 --- a/src/components/settings/SettingsLayout.js +++ b/src/components/settings/SettingsLayout.js | |||
@@ -29,6 +29,7 @@ class SettingsLayout extends Component { | |||
29 | componentWillUnmount() { | 29 | componentWillUnmount() { |
30 | document.removeEventListener( | 30 | document.removeEventListener( |
31 | 'keydown', | 31 | 'keydown', |
32 | // eslint-disable-next-line unicorn/no-invalid-remove-event-listener | ||
32 | this.handleKeyDown.bind(this), | 33 | this.handleKeyDown.bind(this), |
33 | false, | 34 | false, |
34 | ); | 35 | ); |
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index 9a9abeab4..7df6d5c78 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -183,8 +183,8 @@ class EditServiceForm extends Component { | |||
183 | removeTrailingSlash: false, | 183 | removeTrailingSlash: false, |
184 | }); | 184 | }); |
185 | isValid = await recipe.validateUrl(values.customUrl); | 185 | isValid = await recipe.validateUrl(values.customUrl); |
186 | } catch (err) { | 186 | } catch (error) { |
187 | console.warn('ValidateURL', err); | 187 | console.warn('ValidateURL', error); |
188 | isValid = false; | 188 | isValid = false; |
189 | } | 189 | } |
190 | } | 190 | } |
diff --git a/src/components/settings/services/ServicesDashboard.js b/src/components/settings/services/ServicesDashboard.js index 847f2ea06..9272b05c9 100644 --- a/src/components/settings/services/ServicesDashboard.js +++ b/src/components/settings/services/ServicesDashboard.js | |||
@@ -91,7 +91,7 @@ class ServicesDashboard extends Component { | |||
91 | <h1>{intl.formatMessage(messages.headline)}</h1> | 91 | <h1>{intl.formatMessage(messages.headline)}</h1> |
92 | </div> | 92 | </div> |
93 | <div className="settings__body"> | 93 | <div className="settings__body"> |
94 | {(services.length !== 0 || searchNeedle) && !isLoading && ( | 94 | {(services.length > 0 || searchNeedle) && !isLoading && ( |
95 | <SearchInput | 95 | <SearchInput |
96 | placeholder={intl.formatMessage(messages.searchService)} | 96 | placeholder={intl.formatMessage(messages.searchService)} |
97 | onChange={needle => filterServices({ needle })} | 97 | onChange={needle => filterServices({ needle })} |
diff --git a/src/components/ui/ImageUpload.js b/src/components/ui/ImageUpload.js index 8ea31ca40..49aff389b 100644 --- a/src/components/ui/ImageUpload.js +++ b/src/components/ui/ImageUpload.js | |||
@@ -30,14 +30,14 @@ class ImageUpload extends Component { | |||
30 | onDrop(acceptedFiles) { | 30 | onDrop(acceptedFiles) { |
31 | const { field } = this.props; | 31 | const { field } = this.props; |
32 | 32 | ||
33 | acceptedFiles.forEach(file => { | 33 | for (const file of acceptedFiles) { |
34 | const imgPath = isWindows ? file.path.replace(/\\/g, '/') : file.path; | 34 | const imgPath = isWindows ? file.path.replace(/\\/g, '/') : file.path; |
35 | this.setState({ | 35 | this.setState({ |
36 | path: imgPath, | 36 | path: imgPath, |
37 | }); | 37 | }); |
38 | 38 | ||
39 | this.props.field.onDrop(file); | 39 | this.props.field.onDrop(file); |
40 | }); | 40 | } |
41 | 41 | ||
42 | field.set(''); | 42 | field.set(''); |
43 | } | 43 | } |
diff --git a/src/components/ui/InfoBar.js b/src/components/ui/InfoBar.js index f5cbad48b..dc6be10da 100644 --- a/src/components/ui/InfoBar.js +++ b/src/components/ui/InfoBar.js | |||
@@ -5,7 +5,6 @@ import classnames from 'classnames'; | |||
5 | import Loader from 'react-loader'; | 5 | import Loader from 'react-loader'; |
6 | import { defineMessages, injectIntl } from 'react-intl'; | 6 | import { defineMessages, injectIntl } from 'react-intl'; |
7 | 7 | ||
8 | // import { oneOrManyChildElements } from '../../prop-types'; | ||
9 | import Appear from './effects/Appear'; | 8 | import Appear from './effects/Appear'; |
10 | 9 | ||
11 | const messages = defineMessages({ | 10 | const messages = defineMessages({ |
@@ -18,7 +17,7 @@ const messages = defineMessages({ | |||
18 | @observer | 17 | @observer |
19 | class InfoBar extends Component { | 18 | class InfoBar extends Component { |
20 | static propTypes = { | 19 | static propTypes = { |
21 | // eslint-disable-next-line | 20 | // eslint-disable-next-line react/forbid-prop-types |
22 | children: PropTypes.any.isRequired, | 21 | children: PropTypes.any.isRequired, |
23 | onClick: PropTypes.func, | 22 | onClick: PropTypes.func, |
24 | type: PropTypes.string, | 23 | type: PropTypes.string, |
diff --git a/src/components/ui/Infobox.js b/src/components/ui/Infobox.js index 13ae2303b..9e34bf110 100644 --- a/src/components/ui/Infobox.js +++ b/src/components/ui/Infobox.js | |||
@@ -15,7 +15,8 @@ const messages = defineMessages({ | |||
15 | @observer | 15 | @observer |
16 | class Infobox extends Component { | 16 | class Infobox extends Component { |
17 | static propTypes = { | 17 | static propTypes = { |
18 | children: PropTypes.any.isRequired, // eslint-disable-line | 18 | // eslint-disable-next-line react/forbid-prop-types |
19 | children: PropTypes.any.isRequired, | ||
19 | icon: PropTypes.string, | 20 | icon: PropTypes.string, |
20 | type: PropTypes.string, | 21 | type: PropTypes.string, |
21 | ctaOnClick: PropTypes.func, | 22 | ctaOnClick: PropTypes.func, |
diff --git a/src/components/ui/Modal/index.js b/src/components/ui/Modal/index.js index 9e6830b0c..3c7c66c59 100644 --- a/src/components/ui/Modal/index.js +++ b/src/components/ui/Modal/index.js | |||
@@ -54,7 +54,7 @@ class Modal extends Component { | |||
54 | portal={portal} | 54 | portal={portal} |
55 | onRequestClose={close} | 55 | onRequestClose={close} |
56 | shouldCloseOnOverlayClick={shouldCloseOnOverlayClick} | 56 | shouldCloseOnOverlayClick={shouldCloseOnOverlayClick} |
57 | appElement={document.getElementById('root')} | 57 | appElement={document.querySelector('#root')} |
58 | > | 58 | > |
59 | {showClose && close && ( | 59 | {showClose && close && ( |
60 | <button type="button" className={classes.close} onClick={close}> | 60 | <button type="button" className={classes.close} onClick={close}> |
diff --git a/src/components/ui/Select.js b/src/components/ui/Select.js index 15b4c28e7..5ac7ddd6d 100644 --- a/src/components/ui/Select.js +++ b/src/components/ui/Select.js | |||
@@ -49,7 +49,7 @@ class Select extends Component { | |||
49 | let selected = field.value; | 49 | let selected = field.value; |
50 | 50 | ||
51 | if (multiple) { | 51 | if (multiple) { |
52 | if (typeof field.value === 'string' && field.value.substr(0, 1) === '[') { | 52 | if (typeof field.value === 'string' && field.value.slice(0, 1) === '[') { |
53 | // Value is JSON encoded | 53 | // Value is JSON encoded |
54 | selected = JSON.parse(field.value); | 54 | selected = JSON.parse(field.value); |
55 | } else if (typeof field.value === 'object') { | 55 | } else if (typeof field.value === 'object') { |
diff --git a/src/components/ui/effects/Appear.js b/src/components/ui/effects/Appear.js index 1255fce2e..183181f8f 100644 --- a/src/components/ui/effects/Appear.js +++ b/src/components/ui/effects/Appear.js | |||
@@ -1,11 +1,11 @@ | |||
1 | /* eslint-disable react/no-did-mount-set-state */ | ||
2 | import React, { Component } from 'react'; | 1 | import React, { Component } from 'react'; |
3 | import PropTypes from 'prop-types'; | 2 | import PropTypes from 'prop-types'; |
4 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; | 3 | import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; |
5 | 4 | ||
6 | export default class Appear extends Component { | 5 | export default class Appear extends Component { |
7 | static propTypes = { | 6 | static propTypes = { |
8 | children: PropTypes.any.isRequired, // eslint-disable-line | 7 | // eslint-disable-next-line react/forbid-prop-types |
8 | children: PropTypes.any.isRequired, | ||
9 | transitionName: PropTypes.string, | 9 | transitionName: PropTypes.string, |
10 | className: PropTypes.string, | 10 | className: PropTypes.string, |
11 | }; | 11 | }; |
@@ -24,11 +24,7 @@ export default class Appear extends Component { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | render() { | 26 | render() { |
27 | const { | 27 | const { children, transitionName, className } = this.props; |
28 | children, | ||
29 | transitionName, | ||
30 | className, | ||
31 | } = this.props; | ||
32 | 28 | ||
33 | if (!this.state.mounted) { | 29 | if (!this.state.mounted) { |
34 | return null; | 30 | return null; |