Skip to content

Commit 5d05814

Browse files
committed
Fix linting issues (6) — prefer-destructuring
1 parent f9a0ea1 commit 5d05814

File tree

10 files changed

+19
-28
lines changed

10 files changed

+19
-28
lines changed

Diff for: ui/eslint.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const config = defineConfig([
88
...createConfig(opts),
99
{
1010
rules: {
11-
'prefer-destructuring': 'off',
1211
'jsx-a11y/anchor-is-valid': 'off',
1312
'jsx-a11y/control-has-associated-label': 'off',
1413
'promise/always-return': 'off',

Diff for: ui/src/actions/sampleview.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ export function addShape(shapeData = {}, successCb = null) {
230230
return async (dispatch) => {
231231
try {
232232
const json = await sendAddOrUpdateShapes([shapeData]);
233-
const shape = json.shapes[0];
233+
const [shape] = json.shapes;
234234
dispatch(addShapeAction(shape));
235235

236236
if (successCb) {

Diff for: ui/src/components/PeriodicTable/PeriodicTable.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class PeriodicTable extends React.Component {
1212
onClickHandler(e) {
1313
if (e.target.id) {
1414
const el = document.querySelector(`#${this.state.selectedElement}`);
15-
const cell = e.target.children[0];
15+
const [cell] = e.target.children;
1616

1717
if (el) {
1818
el.children[0].className = styles.element;

Diff for: ui/src/components/SSXChip/SSXChip.jsx

+4-8
Original file line numberDiff line numberDiff line change
@@ -328,20 +328,16 @@ export default class SSXChip extends React.Component {
328328
initChipCanvas() {
329329
const currentChipLayout =
330330
this.props.chipLayoutList[this.props.currentLayoutName];
331-
const chipConfig = currentChipLayout.sections[0];
331+
const [chipConfig] = currentChipLayout.sections;
332332

333333
const numRows = chipConfig.number_of_rows;
334334
const numCols = chipConfig.number_of_collumns;
335-
const blockSizeX = chipConfig.block_size[0];
336-
const blockSizeY = chipConfig.block_size[0];
335+
const [blockSizeX, blockSizeY] = chipConfig.block_size;
337336
const rowLabels = chipConfig.row_labels;
338337
const colLabels = chipConfig.column_lables;
339338

340-
const offset = chipConfig.block_spacing[0];
341-
const spacing = chipConfig.block_spacing[0];
342-
343-
const numTargetsX = chipConfig.targets_per_block[0];
344-
const numTargetsY = chipConfig.targets_per_block[1];
339+
const [offset, spacing] = chipConfig.block_spacing;
340+
const [numTargetsX, numTargetsY] = chipConfig.targets_per_block;
345341

346342
const canvasWidth = numCols * (blockSizeX + spacing) + offset + blockSizeX;
347343
const canvasHeight = numRows * (blockSizeY + spacing) + offset + blockSizeY;

Diff for: ui/src/components/SampleQueue/CharacterisationTaskItem.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default class TaskItem extends Component {
8888
if (tasks.length <= 1) {
8989
delete data.diffractionPlan[0].run_number;
9090
delete data.diffractionPlan[0].sampleID;
91-
const { type, parameters } = data.diffractionPlan[0];
91+
const [{ type, parameters }] = data.diffractionPlan;
9292

9393
this.props.showForm(
9494
type,

Diff for: ui/src/components/SampleView/shapes.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,7 @@ export function makeImageOverlay(iR, ppMm, bP, bSh, bSi, cCP, dP, canvas) {
432432
imageOverlay.push(...makeCross(point, iR, canvas.width, canvas.height));
433433
}
434434
if (dP.length === 2) {
435-
const point1 = dP[0];
436-
const point2 = dP[1];
435+
const [point1, point2] = dP;
437436
imageOverlay.push(...makeDistanceLine(point1, point2, iR, ppMm, 'red', 2));
438437
}
439438
return imageOverlay;

Diff for: ui/src/components/Tasks/validate.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ function validate(values, props) {
6565
}
6666

6767
if (props.acqParametersLimits.exposure_time) {
68-
const exptimemin = props.acqParametersLimits.exposure_time[0];
69-
const exptimemax = props.acqParametersLimits.exposure_time[1];
68+
const [exptimemin, exptimemax] = props.acqParametersLimits.exposure_time;
7069
if (
7170
values.exp_time === '' ||
7271
Number.parseFloat(values.exp_time, 10) > exptimemax ||

Diff for: ui/src/containers/ConfirmCollectDialog.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -303,14 +303,14 @@ export class ConfirmCollectDialog extends React.Component {
303303
</thead>
304304
<tbody id="table-body">
305305
{tasks.map((task) => {
306-
let { parameters } = task;
306+
const { parameters } =
307+
task.type === 'Interleaved'
308+
? task.parameters.wedges[0]
309+
: task;
310+
307311
const sample = this.props.sampleGrid.sampleList[task.sampleID];
308312
const sampleName = `${sample.sampleName} - ${sample.proteinAcronym}`;
309313

310-
if (task.type === 'Interleaved') {
311-
parameters = task.parameters.wedges[0].parameters;
312-
}
313-
314314
return (
315315
<OverlayTrigger
316316
key={task.queueID}

Diff for: ui/src/containers/GphlWorkflowParametersDialog.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ function GphlWorkflowParametersDialog(props) {
9191
dataDict[key] = removeExtraDecimal(value.default, value.type);
9292
});
9393
if (formData.ui_schema.indexing_solution) {
94-
const initIndex =
95-
formData.ui_schema.indexing_solution[uiOptions].select_cell[0];
94+
const [initIndex] =
95+
formData.ui_schema.indexing_solution[uiOptions].select_cell;
9696
setSelected([initIndex]);
9797
dataDict.indexing_solution =
9898
formData.ui_schema.indexing_solution[uiOptions].content[0][initIndex];

Diff for: ui/src/containers/SampleGridTableContainer.jsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ class SampleGridTableContainer extends React.Component {
434434
this.props.showGenericContextMenu(true, contextMenuID, e.pageX, e.pageY);
435435
}
436436

437-
const selectedList = this.getSampleListFilteredByCellPuck(cell, puck)[0];
437+
const [selectedList] = this.getSampleListFilteredByCellPuck(cell, puck);
438438

439439
this.sampleGridItemsSelectedHandler(e, selectedList);
440440
e.stopPropagation();
@@ -443,11 +443,9 @@ class SampleGridTableContainer extends React.Component {
443443
renderItemsControls(cell, puck) {
444444
let icon = <BsSquare size="0.9em" />;
445445
let pickSample = true;
446-
const filterList = this.getSampleListFilteredByCellPuck(cell, puck);
447446

448-
const allPuckSample = filterList[0];
449-
const allPuckSampleCheck = filterList[1];
450-
const puckCode = filterList[2];
447+
const filterList = this.getSampleListFilteredByCellPuck(cell, puck);
448+
const [allPuckSample, allPuckSampleCheck, puckCode] = filterList;
451449

452450
if (allPuckSample.length === allPuckSampleCheck.length) {
453451
icon = <BsCheck2Square size="0.9em" />;

0 commit comments

Comments
 (0)