Skip to content

Commit

Permalink
Fix ESLint warnings (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc authored and marcus-oscarsson committed Sep 28, 2023
1 parent 83925bf commit 3d15334
Show file tree
Hide file tree
Showing 64 changed files with 177 additions and 263 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
1 change: 1 addition & 0 deletions 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
5 changes: 4 additions & 1 deletion 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 @@ -183,7 +184,9 @@ export function doSignOut(navigate) {
}).then(() => {
dispatch(signOut());
dispatch(getLoginInfo());
navigate && navigate('/login');
if (navigate) {
navigate('/login');
}
});
};
}
1 change: 1 addition & 0 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
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
1 change: 1 addition & 0 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
1 change: 1 addition & 0 deletions 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
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
4 changes: 1 addition & 3 deletions ui/src/components/Main.jsx
Original file line number Diff line number Diff line change
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
14 changes: 8 additions & 6 deletions ui/src/components/SampleView/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ export default class ContextMenu extends React.Component {
// that already have a line [P1, P2, L1]
// we do not want to add a DC/Char to a line

const points = sid.filter((x) => x.match(/P*/)[0]);
const points = sid.filter((x) => x.match(/P*/u)[0]);
const containsPoints = points.length > 0;
const lines = sid.filter((x) => x.match(/L*/)[0]);
const lines = sid.filter((x) => x.match(/L*/u)[0]);
const containsLine = lines.length > 0;

if (containsPoints && containsLine) {
Expand Down Expand Up @@ -419,9 +419,11 @@ export default class ContextMenu extends React.Component {
this.props.sampleActions.sendAbortCentring();
}

this.props.sampleActions.sendDeleteShape(this.props.shape.id).then(() => {
this.props.sampleActions.showContextMenu(false);
});
voithis.props.sampleActions
.sendDeleteShape(this.props.shape.id)
.then(() => {
this.props.sampleActions.showContextMenu(false);
});
}

measureDistance() {
Expand Down Expand Up @@ -454,7 +456,7 @@ export default class ContextMenu extends React.Component {
const { shape } = this.props;
const sid = shape.id;

const lines = sid.filter((x) => x.match(/L*/)[0]);
const lines = sid.filter((x) => x.match(/L*/u)[0]);
const containsLine = lines.length > 0;

if (containsLine) {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/SampleView/DrawGridPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export default class DrawGridPlugin {
let { result } = gd;

// Use selected result type if it exists
if (gd.result !== null && gd.result.hasOwnProperty(this.resultType)) {
if (gd.result !== null && this.resultType in gd.result) {
result = gd.result[this.resultType];
}

Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleView/SampleControls.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import './SampleView.css';
import React from 'react';
import { OverlayTrigger, Button, Dropdown } from 'react-bootstrap';
Expand Down
1 change: 0 additions & 1 deletion ui/src/components/SampleView/jsmpeg.min.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/*eslint-disable */
export const JSMpeg = {
Player: null,
VideoElement: null,
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/SampleView/shapes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable sonarjs/no-duplicate-string */
import 'fabric';

const { fabric } = window;
Expand Down
8 changes: 3 additions & 5 deletions ui/src/components/Tasks/Characterisation.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,15 +463,15 @@ class Characterisation extends React.Component {
}
}

Characterisation = reduxForm({
const CharacterisationForm = reduxForm({
form: 'characterisation',
validate,
warn,
})(Characterisation);

const selector = formValueSelector('characterisation');

Characterisation = connect((state) => {
export default connect((state) => {
const subdir = selector(state, 'subdir');
let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID;
if (typeof position === 'object') {
Expand Down Expand Up @@ -524,6 +524,4 @@ Characterisation = connect((state) => {
: toFixed(state, 'diffractometer.phi'),
},
};
})(Characterisation);

export default Characterisation;
})(CharacterisationForm);
8 changes: 3 additions & 5 deletions ui/src/components/Tasks/DataCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,15 @@ class DataCollection extends React.Component {
}
}

DataCollection = reduxForm({
const DataCollectionForm = reduxForm({
form: 'datacollection',
validate,
warn,
})(DataCollection);

const selector = formValueSelector('datacollection');

DataCollection = connect((state) => {
export default connect((state) => {
const subdir = selector(state, 'subdir');

let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID;
Expand Down Expand Up @@ -392,6 +392,4 @@ DataCollection = connect((state) => {
: toFixed(state, 'diffractometer.phi'),
},
};
})(DataCollection);

export default DataCollection;
})(DataCollectionForm);
8 changes: 3 additions & 5 deletions ui/src/components/Tasks/EnergyScan.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,14 @@ class EnergyScan extends React.Component {
}
}

EnergyScan = reduxForm({
const EnergyScanForm = reduxForm({
form: 'workflow',
validate,
})(EnergyScan);

const selector = formValueSelector('workflow');

EnergyScan = connect((state) => {
export default connect((state) => {
const subdir = selector(state, 'subdir');
const element = selector(state, 'element');
const edge = selector(state, 'edge');
Expand Down Expand Up @@ -196,6 +196,4 @@ EnergyScan = connect((state) => {
: state.beamline.hardwareObjects.transmission.value,
},
};
})(EnergyScan);

export default EnergyScan;
})(EnergyScanForm);
8 changes: 3 additions & 5 deletions ui/src/components/Tasks/GenericTaskForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ class GenericTaskForm extends React.Component {
}
}

GenericTaskForm = reduxForm({
const GenericTaskFormForm = reduxForm({
form: 'GenericTaskForm',
validate,
warn,
})(GenericTaskForm);

const selector = formValueSelector('GenericTaskForm');

GenericTaskForm = connect((state) => {
export default connect((state) => {
const subdir = selector(state, 'subdir');
const experimentNameSelector = selector(state, 'experimentName');
let position = state.taskForm.pointID === '' ? 'PX' : state.taskForm.pointID;
Expand Down Expand Up @@ -392,6 +392,4 @@ GenericTaskForm = connect((state) => {
osc_start: state.taskForm.taskData.parameters.osc_start,
},
};
})(GenericTaskForm);

export default GenericTaskForm;
})(GenericTaskFormForm);
Loading

0 comments on commit 3d15334

Please sign in to comment.