Skip to content

Commit

Permalink
Fix ESLint warnings (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Sep 26, 2023
1 parent 4997390 commit 31bd867
Show file tree
Hide file tree
Showing 64 changed files with 207 additions and 291 deletions.
1 change: 1 addition & 0 deletions ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/build/
/release/
/src/components/SampleView/jsmpeg.min.js
2 changes: 1 addition & 1 deletion ui/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/build/
/public/

/src/components/SampleView/jsmpeg.min.js
2 changes: 2 additions & 0 deletions ui/cypress/e2e/app.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global Cypress, cy, it, describe, beforeEach */

describe('login', () => {
it("can't login with invalid credentials", () => {
cy.login('idte0', '0000');
Expand Down
1 change: 1 addition & 0 deletions ui/cypress/support.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global Cypress, cy */
import '@testing-library/cypress/add-commands';

Cypress.Commands.add('login', (username = 'idtest0', password = '0000') => {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/actions/beamline.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function sendGetAllhardwareObjects() {
fetch(url, {
method: 'GET',
headers: {
Accept: 'application/json',
Accept: 'application/json', // eslint-disable-line sonarjs/no-duplicate-string
'Content-type': 'application/json',
},
credentials: 'include',
Expand Down
1 change: 1 addition & 0 deletions ui/src/actions/beamlineActions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { RUNNING } from '../constants';
import { checkStatus, parseJSON } from '../requests';
Expand Down
3 changes: 2 additions & 1 deletion ui/src/actions/general.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { assign } from 'lodash';
import { unselectShapes } from './sampleview';
Expand Down Expand Up @@ -328,7 +329,7 @@ export function getInitialState(userInControl) {
});
}

prom.then(() => {
void prom.then(() => {
dispatch(applicationFetched(true));
});
};
Expand Down
9 changes: 6 additions & 3 deletions ui/src/actions/login.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { showErrorPanel, setLoading, getInitialState } from './general';
import { serverIO } from '../serverIO';
Expand Down Expand Up @@ -54,7 +55,7 @@ export function postProposal(number) {

export function sendSelectProposal(number, navigate) {
return function (dispatch) {
postProposal(number).then((response) => {
void postProposal(number).then((response) => {
if (response.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to select proposal'));
navigate('/login');
Expand Down Expand Up @@ -140,7 +141,7 @@ export function signIn(proposal, password, navigate) {
(res) => {
if (res.code === 'ok') {
dispatch(showErrorPanel(false));
dispatch(getLoginInfo())
void dispatch(getLoginInfo())
.then((response) => response)
.then((resp) => {
if (resp.loginType === 'User') {
Expand Down Expand Up @@ -183,7 +184,9 @@ export function doSignOut(navigate) {
}).then(() => {
dispatch(signOut());
dispatch(getLoginInfo());
navigate && navigate('/login');
if (navigate) {
navigate('/login');
}
});
};
}
19 changes: 10 additions & 9 deletions ui/src/actions/queue.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { showErrorPanel } from './general';
import { loadSample } from './sampleChanger';
Expand Down Expand Up @@ -100,7 +101,7 @@ export function addSamplesToQueue(sampleDataList) {
return function (dispatch) {
dispatch(queueLoading(true));

sendAddQueueItem(sampleDataList)
void sendAddQueueItem(sampleDataList)
.then((response) => {
if (response.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to add sample'));
Expand All @@ -120,7 +121,7 @@ export function addSampleAndMount(sampleData) {
return function (dispatch) {
dispatch(
loadSample(sampleData, () => {
sendAddQueueItem([sampleData])
void sendAddQueueItem([sampleData])
.then((response) => {
if (response.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to add sample'));
Expand Down Expand Up @@ -252,7 +253,7 @@ export function moveTask(sampleID, oldIndex, newIndex) {
return function (dispatch) {
dispatch(queueLoading(true));

sendMoveTask(sampleID, oldIndex, newIndex).then((response) => {
void sendMoveTask(sampleID, oldIndex, newIndex).then((response) => {
if (response.status >= 400) {
dispatch(changeTaskOrderAction(sampleID, newIndex, oldIndex));
dispatch(showErrorPanel(true, 'Could not move task'));
Expand Down Expand Up @@ -393,7 +394,7 @@ export function setEnabledSample(sampleIDList, value) {
(sampleID) => state.sampleGrid.sampleList[sampleID].queueID,
);

sendSetEnabledQueueItem(qidList, value)
void sendSetEnabledQueueItem(qidList, value)
.then((response) => {
if (response.status >= 400) {
dispatch(
Expand Down Expand Up @@ -428,7 +429,7 @@ export function deleteTask(sampleID, taskIndex) {

if (task.state === TASK_UNCOLLECTED) {
dispatch(queueLoading(true));
sendDeleteQueueItem([[sampleID, taskIndex]])
void sendDeleteQueueItem([[sampleID, taskIndex]])
.then((response) => {
if (response.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to delete task'));
Expand Down Expand Up @@ -460,7 +461,7 @@ export function deleteTaskList(sampleIDList) {
});
});
dispatch(queueLoading(true));
sendDeleteQueueItem(itemPosList)
void sendDeleteQueueItem(itemPosList)
.then((response) => {
if (response.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to delete task'));
Expand Down Expand Up @@ -498,7 +499,7 @@ export function updateTask(sampleID, taskIndex, params, runNow) {
};
dispatch(queueLoading(true));

sendUpdateQueueItem(
void sendUpdateQueueItem(
sampleGrid.sampleList[sampleID].queueID,
taskData.queueID,
taskData,
Expand Down Expand Up @@ -591,7 +592,7 @@ export function addTask(sampleIDs, parameters, runNow) {

dispatch(queueLoading(true));

sendAddQueueItem(samples)
void sendAddQueueItem(samples)
.then((response) => {
if (response.status >= 400) {
dispatch(
Expand Down Expand Up @@ -669,7 +670,7 @@ export function deleteSamplesFromQueue(sampleIDList) {
return [sampleID, undefined];
});

sendDeleteQueueItem(itemPostList)
void sendDeleteQueueItem(itemPostList)
.then((response) => {
if (response.status >= 400) {
dispatch(showErrorPanel(true, 'Server refused to delete sample'));
Expand Down
1 change: 1 addition & 0 deletions ui/src/actions/remoteAccess.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import { getLoginInfo } from './login';

export function showObserverDialog(show = true) {
Expand Down
9 changes: 5 additions & 4 deletions ui/src/actions/sampleChanger.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { showErrorPanel } from './general';
import { clearCurrentSample } from './queue';
Expand Down Expand Up @@ -66,7 +67,7 @@ export function refresh() {
throw new Error('Error refreshing sample changer contents');
}

response.json().then((contents) => {
void response.json().then((contents) => {
dispatch(setContents(contents));
});
});
Expand All @@ -83,7 +84,7 @@ export function refresh() {
throw new Error('Error refreshing sample changer contents');
}

response.json().then((loadedSample) => {
void response.json().then((loadedSample) => {
dispatch(setLoadedSample(loadedSample));
});
});
Expand All @@ -106,7 +107,7 @@ export function select(address) {
);
}

response.json().then((contents) => {
void response.json().then((contents) => {
dispatch(setContents(contents));
});
});
Expand All @@ -127,7 +128,7 @@ export function scan(address) {
throw new Error(`Error while scanning sample changer @ ${address}`);
}

response.json().then((contents) => {
void response.json().then((contents) => {
dispatch(setContents(contents));
});
});
Expand Down
3 changes: 2 additions & 1 deletion ui/src/actions/sampleGrid.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { setLoading, showErrorPanel } from './general';
import { setQueue } from './queue';
Expand Down Expand Up @@ -186,7 +187,7 @@ export function syncWithCrims() {
),
);
}
response.json().then((crystalList) => {
void response.json().then((crystalList) => {
dispatch(updateCrystalList(crystalList));
});
});
Expand Down
1 change: 1 addition & 0 deletions ui/src/actions/sampleview.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import fetch from 'isomorphic-fetch';
import { showErrorPanel } from './general';

Expand Down
1 change: 1 addition & 0 deletions ui/src/components/Equipment/PlateManipulator.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React from 'react';
import {
Row,
Expand Down
3 changes: 1 addition & 2 deletions ui/src/components/Login/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,4 @@ function LoginComponent(props) {
);
}

LoginComponent = withRouter(LoginComponent);
export default LoginComponent;
export default withRouter(LoginComponent);
8 changes: 3 additions & 5 deletions ui/src/components/Login/SelectProposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ class SelectProposal extends React.Component {
}
}

SelectProposal = reduxForm({
const SelectProposalForm = reduxForm({
form: 'proposals',
})(SelectProposal);

SelectProposal = connect((state) => ({
export default connect((state) => ({
initialValues: { ...state.login.data },
}))(SelectProposal);

export default SelectProposal;
}))(SelectProposalForm);
4 changes: 2 additions & 2 deletions ui/src/components/MXNavbar/MXNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ class MXNavbar extends React.Component {
);
}
}
MXNavbar = withRouter(MXNavbar);
export default MXNavbar;

export default withRouter(MXNavbar);
2 changes: 1 addition & 1 deletion ui/src/components/MachInfo/MachInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class MachInfo extends React.Component {
};

for (propname in this.props.info) {
if (this.props.info.hasOwnProperty(propname)) {
if (propname in this.props.info) {
if (propname === 'attention') {
continue;
}
Expand Down
6 changes: 2 additions & 4 deletions ui/src/components/Main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Main extends React.Component {
}

componentDidMount() {
getAllChatMessages().then((json) => {
void getAllChatMessages().then((json) => {
json.messages.forEach((entry) => {
if (entry.username === this.props.login.user.username) {
addUserMessage(`${entry.date} **You:** \n\n ${entry.message} \n\n`);
Expand Down Expand Up @@ -149,6 +149,4 @@ function mapDispatchToProps(dispatch) {
};
}

Main = withRouter(Main);

export default connect(mapStateToProps, mapDispatchToProps)(Main);
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Main));
11 changes: 2 additions & 9 deletions ui/src/components/RemoteAccess/ObserverDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export class ObserverDialog extends React.Component {
}
}

onHide() {}

show() {
return (
!this.props.login.user.inControl && this.props.login.user.nickname === ''
Expand Down Expand Up @@ -55,12 +53,7 @@ export class ObserverDialog extends React.Component {

render() {
return (
<Modal
backdrop="static"
show={this.show()}
onHide={this.onHide}
style={{ zIndex: 10_001 }}
>
<Modal backdrop="static" show={this.show()} style={{ zIndex: 10_001 }}>
<Modal.Header>
<Modal.Title>{this.title()}</Modal.Title>
</Modal.Header>
Expand Down Expand Up @@ -112,7 +105,7 @@ function mapStateToProps(state) {

function mapDispatchToProps(dispatch) {
return {
hide: bindActionCreators(showObserverDialog.bind(this, false), dispatch),
hide: bindActionCreators(showObserverDialog.bind(null, false), dispatch),
sendUpdateNickname: bindActionCreators(sendUpdateNickname, dispatch),
};
}
Expand Down
9 changes: 1 addition & 8 deletions ui/src/components/RemoteAccess/PassControlDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export class PassControlDialog extends React.Component {
this.getObserver = this.getObserver.bind(this);
}

onHide() {}

getObserver() {
let observer = { name: '', message: '', requestsControl: false };

Expand Down Expand Up @@ -52,12 +50,7 @@ export class PassControlDialog extends React.Component {
const observer = this.getObserver();

return (
<Modal
show={this.show()}
backdrop="static"
onHide={this.onHide}
style={{ zIndex: 10_001 }}
>
<Modal show={this.show()} backdrop="static" style={{ zIndex: 10_001 }}>
<Modal.Header>
<Modal.Title>{observer.nickname} is asking for control</Modal.Title>
</Modal.Header>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/SampleQueue/CharacterisationTaskItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Expand Down Expand Up @@ -81,7 +82,7 @@ export default class TaskItem extends Component {
getDiffPlan(data) {
let diffPlan = [];
if (
data.hasOwnProperty('diffractionPlan') &&
'diffractionPlan' in data &&
Object.keys(data.diffractionPlan).length > 0
) {
// it can be empty
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleQueue/EnergyScanTaskItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleQueue/QueueControl.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React from 'react';
import './app.css';
import { Button, Navbar, Nav } from 'react-bootstrap';
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleQueue/TaskItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleQueue/WorkflowTaskItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleQueue/XRFTaskItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
Expand Down
Loading

0 comments on commit 31bd867

Please sign in to comment.