diff options
author | 2024-04-18 08:18:36 -0600 | |
---|---|---|
committer | 2024-04-18 08:18:36 -0600 | |
commit | c49723056acec489765acb54bae3889ac07f25af (patch) | |
tree | 58bea705d61a728b060e615ce514b8d4a7936c9e /src/features/workspaces | |
parent | feat: hide all services workspace (#1713) (diff) | |
download | ferdium-app-c49723056acec489765acb54bae3889ac07f25af.tar.gz ferdium-app-c49723056acec489765acb54bae3889ac07f25af.tar.zst ferdium-app-c49723056acec489765acb54bae3889ac07f25af.zip |
refactor: bring down eslint warnings to zero (#1714)
- install `@eslint-react/eslint-plugin` dependency
- configure `@eslint-react/eslint-plugin` in eslint config
- modernize `lint` command in `package.json`
- disable or fix various reported lint issues
- fix `div` being nested in `p` for settings
- replace deprecated `event.keyCode` with `event.key`
- update isEscKeyPress method and unit tests which used deprecated `event.keyCode`
- allow `eslint` v8 as peer dependency for `@eslint-react/eslint-plugin`
Diffstat (limited to 'src/features/workspaces')
7 files changed, 37 insertions, 27 deletions
diff --git a/src/features/workspaces/components/CreateWorkspaceForm.tsx b/src/features/workspaces/components/CreateWorkspaceForm.tsx index 0c365564a..b35ffe4d8 100644 --- a/src/features/workspaces/components/CreateWorkspaceForm.tsx +++ b/src/features/workspaces/components/CreateWorkspaceForm.tsx | |||
@@ -81,6 +81,7 @@ class CreateWorkspaceForm extends Component<IProps> { | |||
81 | className={classes.input} | 81 | className={classes.input} |
82 | showLabel={false} | 82 | showLabel={false} |
83 | // @ts-expect-error Expected 1 arguments, but got 2. | 83 | // @ts-expect-error Expected 1 arguments, but got 2. |
84 | // eslint-disable-next-line react/jsx-no-bind | ||
84 | onEnterKey={this.submitForm.bind(this, form)} | 85 | onEnterKey={this.submitForm.bind(this, form)} |
85 | focus={workspaceStore.isUserAllowedToUseFeature} | 86 | focus={workspaceStore.isUserAllowedToUseFeature} |
86 | /> | 87 | /> |
@@ -89,6 +90,7 @@ class CreateWorkspaceForm extends Component<IProps> { | |||
89 | type="submit" | 90 | type="submit" |
90 | label={intl.formatMessage(messages.submitButton)} | 91 | label={intl.formatMessage(messages.submitButton)} |
91 | // @ts-expect-error Expected 1 arguments, but got 2. | 92 | // @ts-expect-error Expected 1 arguments, but got 2. |
93 | // eslint-disable-next-line react/jsx-no-bind | ||
92 | onClick={this.submitForm.bind(this, form)} | 94 | onClick={this.submitForm.bind(this, form)} |
93 | busy={isSubmitting} | 95 | busy={isSubmitting} |
94 | buttonType={isSubmitting ? 'secondary' : 'primary'} | 96 | buttonType={isSubmitting ? 'secondary' : 'primary'} |
diff --git a/src/features/workspaces/components/EditWorkspaceForm.tsx b/src/features/workspaces/components/EditWorkspaceForm.tsx index 18e7c251e..cc7a2b19b 100644 --- a/src/features/workspaces/components/EditWorkspaceForm.tsx +++ b/src/features/workspaces/components/EditWorkspaceForm.tsx | |||
@@ -92,6 +92,7 @@ class EditWorkspaceForm extends Component<IProps> { | |||
92 | this.form = this.prepareWorkspaceForm(this.props.workspace); | 92 | this.form = this.prepareWorkspaceForm(this.props.workspace); |
93 | } | 93 | } |
94 | 94 | ||
95 | // eslint-disable-next-line @eslint-react/no-unsafe-component-will-receive-props | ||
95 | UNSAFE_componentWillReceiveProps(nextProps): void { | 96 | UNSAFE_componentWillReceiveProps(nextProps): void { |
96 | const { workspace } = this.props; | 97 | const { workspace } = this.props; |
97 | if (workspace.id !== nextProps.workspace.id) { | 98 | if (workspace.id !== nextProps.workspace.id) { |
@@ -178,11 +179,11 @@ class EditWorkspaceForm extends Component<IProps> { | |||
178 | <span className="settings__header-item">{workspace.name}</span> | 179 | <span className="settings__header-item">{workspace.name}</span> |
179 | </div> | 180 | </div> |
180 | <div className="settings__body"> | 181 | <div className="settings__body"> |
181 | {updateWorkspaceRequest.error && ( | 182 | {updateWorkspaceRequest.error ? ( |
182 | <Infobox icon="alert" type="danger"> | 183 | <Infobox icon="alert" type="danger"> |
183 | Error while saving workspace | 184 | Error while saving workspace |
184 | </Infobox> | 185 | </Infobox> |
185 | )} | 186 | ) : null} |
186 | <div className={classes.nameInput}> | 187 | <div className={classes.nameInput}> |
187 | <Input {...form.$('name').bind()} /> | 188 | <Input {...form.$('name').bind()} /> |
188 | <Toggle {...form.$('keepLoaded').bind()} /> | 189 | <Toggle {...form.$('keepLoaded').bind()} /> |
@@ -228,6 +229,7 @@ class EditWorkspaceForm extends Component<IProps> { | |||
228 | buttonType={isDeleting ? 'secondary' : 'danger'} | 229 | buttonType={isDeleting ? 'secondary' : 'danger'} |
229 | className="settings__delete-button" | 230 | className="settings__delete-button" |
230 | disabled={isDeleting} | 231 | disabled={isDeleting} |
232 | // eslint-disable-next-line react/jsx-no-bind | ||
231 | onClick={this.delete.bind(this)} | 233 | onClick={this.delete.bind(this)} |
232 | /> | 234 | /> |
233 | {/* ===== Save Button ===== */} | 235 | {/* ===== Save Button ===== */} |
@@ -237,6 +239,7 @@ class EditWorkspaceForm extends Component<IProps> { | |||
237 | busy={isSaving} | 239 | busy={isSaving} |
238 | className="franz-form__button" | 240 | className="franz-form__button" |
239 | buttonType={isSaving ? 'secondary' : 'primary'} | 241 | buttonType={isSaving ? 'secondary' : 'primary'} |
242 | // eslint-disable-next-line react/jsx-no-bind | ||
240 | onClick={this.save.bind(this, form)} | 243 | onClick={this.save.bind(this, form)} |
241 | // TODO: Need to disable if no services have been added to this workspace | 244 | // TODO: Need to disable if no services have been added to this workspace |
242 | disabled={isSaving} | 245 | disabled={isSaving} |
diff --git a/src/features/workspaces/components/WorkspaceDrawer.tsx b/src/features/workspaces/components/WorkspaceDrawer.tsx index cce333b31..e92bc4b60 100644 --- a/src/features/workspaces/components/WorkspaceDrawer.tsx +++ b/src/features/workspaces/components/WorkspaceDrawer.tsx | |||
@@ -129,6 +129,7 @@ class WorkspaceDrawer extends Component<IProps> { | |||
129 | <div className={`${classes.drawer} workspaces-drawer`}> | 129 | <div className={`${classes.drawer} workspaces-drawer`}> |
130 | <H1 className={classes.headline}> | 130 | <H1 className={classes.headline}> |
131 | {intl.formatMessage(messages.headline)} | 131 | {intl.formatMessage(messages.headline)} |
132 | {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} | ||
132 | <span | 133 | <span |
133 | className={classes.workspacesSettingsButton} | 134 | className={classes.workspacesSettingsButton} |
134 | onKeyDown={noop} | 135 | onKeyDown={noop} |
@@ -179,6 +180,7 @@ class WorkspaceDrawer extends Component<IProps> { | |||
179 | shortcutIndex={index + 1} | 180 | shortcutIndex={index + 1} |
180 | /> | 181 | /> |
181 | ))} | 182 | ))} |
183 | {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} | ||
182 | <div | 184 | <div |
183 | className={classes.addNewWorkspaceLabel} | 185 | className={classes.addNewWorkspaceLabel} |
184 | onClick={() => { | 186 | onClick={() => { |
diff --git a/src/features/workspaces/components/WorkspaceDrawerItem.tsx b/src/features/workspaces/components/WorkspaceDrawerItem.tsx index 1e4b57dba..01a18ffb0 100644 --- a/src/features/workspaces/components/WorkspaceDrawerItem.tsx +++ b/src/features/workspaces/components/WorkspaceDrawerItem.tsx | |||
@@ -111,6 +111,7 @@ class WorkspaceDrawerItem extends Component<IProps> { | |||
111 | const contextMenu = Menu.buildFromTemplate(contextMenuTemplate); | 111 | const contextMenu = Menu.buildFromTemplate(contextMenuTemplate); |
112 | 112 | ||
113 | return ( | 113 | return ( |
114 | // eslint-disable-next-line jsx-a11y/no-static-element-interactions | ||
114 | <div | 115 | <div |
115 | className={classnames([ | 116 | className={classnames([ |
116 | classes.item, | 117 | classes.item, |
diff --git a/src/features/workspaces/components/WorkspaceServiceListItem.tsx b/src/features/workspaces/components/WorkspaceServiceListItem.tsx index 6f61f8a51..a56e5802f 100644 --- a/src/features/workspaces/components/WorkspaceServiceListItem.tsx +++ b/src/features/workspaces/components/WorkspaceServiceListItem.tsx | |||
@@ -42,6 +42,7 @@ class WorkspaceServiceListItem extends Component<IProps> { | |||
42 | const { classes, isInWorkspace, onToggle, service } = this.props; | 42 | const { classes, isInWorkspace, onToggle, service } = this.props; |
43 | return ( | 43 | return ( |
44 | // onclick in below div used to fix bug raised under toggle duplicate component removal | 44 | // onclick in below div used to fix bug raised under toggle duplicate component removal |
45 | // eslint-disable-next-line jsx-a11y/no-static-element-interactions | ||
45 | <div className={classes.listItem} onClick={onToggle} onKeyDown={noop}> | 46 | <div className={classes.listItem} onClick={onToggle} onKeyDown={noop}> |
46 | <ServiceIcon className={classes.serviceIcon} service={service} /> | 47 | <ServiceIcon className={classes.serviceIcon} service={service} /> |
47 | <span | 48 | <span |
diff --git a/src/features/workspaces/components/WorkspacesDashboard.tsx b/src/features/workspaces/components/WorkspacesDashboard.tsx index 8fb2cf923..ad54c6682 100644 --- a/src/features/workspaces/components/WorkspacesDashboard.tsx +++ b/src/features/workspaces/components/WorkspacesDashboard.tsx | |||
@@ -105,33 +105,33 @@ class WorkspacesDashboard extends Component<IProps> { | |||
105 | <div className="settings__body"> | 105 | <div className="settings__body"> |
106 | {/* ===== Workspace updated info ===== */} | 106 | {/* ===== Workspace updated info ===== */} |
107 | {updateWorkspaceRequest.wasExecuted && | 107 | {updateWorkspaceRequest.wasExecuted && |
108 | updateWorkspaceRequest.result && ( | 108 | updateWorkspaceRequest.result ? ( |
109 | <Appear className={classes.appear}> | 109 | <Appear className={classes.appear}> |
110 | <Infobox | 110 | <Infobox |
111 | type="success" | 111 | type="success" |
112 | icon="checkbox-marked-circle-outline" | 112 | icon="checkbox-marked-circle-outline" |
113 | dismissible | 113 | dismissible |
114 | onUnmount={updateWorkspaceRequest.reset} | 114 | onUnmount={updateWorkspaceRequest.reset} |
115 | > | 115 | > |
116 | {intl.formatMessage(messages.updatedInfo)} | 116 | {intl.formatMessage(messages.updatedInfo)} |
117 | </Infobox> | 117 | </Infobox> |
118 | </Appear> | 118 | </Appear> |
119 | )} | 119 | ) : null} |
120 | 120 | ||
121 | {/* ===== Workspace deleted info ===== */} | 121 | {/* ===== Workspace deleted info ===== */} |
122 | {deleteWorkspaceRequest.wasExecuted && | 122 | {deleteWorkspaceRequest.wasExecuted && |
123 | deleteWorkspaceRequest.result && ( | 123 | deleteWorkspaceRequest.result ? ( |
124 | <Appear className={classes.appear}> | 124 | <Appear className={classes.appear}> |
125 | <Infobox | 125 | <Infobox |
126 | type="success" | 126 | type="success" |
127 | icon="checkbox-marked-circle-outline" | 127 | icon="checkbox-marked-circle-outline" |
128 | dismissible | 128 | dismissible |
129 | onUnmount={deleteWorkspaceRequest.reset} | 129 | onUnmount={deleteWorkspaceRequest.reset} |
130 | > | 130 | > |
131 | {intl.formatMessage(messages.deletedInfo)} | 131 | {intl.formatMessage(messages.deletedInfo)} |
132 | </Infobox> | 132 | </Infobox> |
133 | </Appear> | 133 | </Appear> |
134 | )} | 134 | ) : null} |
135 | 135 | ||
136 | {/* ===== Create workspace form ===== */} | 136 | {/* ===== Create workspace form ===== */} |
137 | <div className={classes.createForm}> | 137 | <div className={classes.createForm}> |
@@ -169,7 +169,7 @@ class WorkspacesDashboard extends Component<IProps> { | |||
169 | </p> | 169 | </p> |
170 | </div> | 170 | </div> |
171 | ) : ( | 171 | ) : ( |
172 | <table className={classes.table} role="grid"> | 172 | <table className={classes.table}> |
173 | {/* ===== Workspaces list ===== */} | 173 | {/* ===== Workspaces list ===== */} |
174 | <tbody> | 174 | <tbody> |
175 | {workspaces.map(workspace => ( | 175 | {workspaces.map(workspace => ( |
diff --git a/src/features/workspaces/index.ts b/src/features/workspaces/index.ts index 25975936a..cbe5bb5fd 100644 --- a/src/features/workspaces/index.ts +++ b/src/features/workspaces/index.ts | |||
@@ -3,6 +3,7 @@ import WorkspacesStore from './store'; | |||
3 | export const workspaceStore = new WorkspacesStore(); | 3 | export const workspaceStore = new WorkspacesStore(); |
4 | 4 | ||
5 | export default function initWorkspaces(stores, actions) { | 5 | export default function initWorkspaces(stores, actions) { |
6 | // eslint-disable-next-line no-param-reassign | ||
6 | stores.workspaces = workspaceStore; | 7 | stores.workspaces = workspaceStore; |
7 | workspaceStore.start(stores, actions); | 8 | workspaceStore.start(stores, actions); |
8 | } | 9 | } |