From 7d25d65b570855a04256ee6af4323d622713c482 Mon Sep 17 00:00:00 2001 From: Kirk Swenson Date: Wed, 31 Jul 2024 12:40:12 -0700 Subject: [PATCH] chore: enable `no-constant-binary-expression` lint rule; fix offending code (#1384) --- v3/.eslintrc.cjs | 1 + .../attribute-menu/edit-attribute-properties-modal.tsx | 6 +++--- .../normal-curve/normal-curve-adornment-component.tsx | 2 +- .../standard-error/standard-error-adornment-component.tsx | 2 +- .../univariate-measure-adornment-simple-component.tsx | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/v3/.eslintrc.cjs b/v3/.eslintrc.cjs index 84c06d351e..59eaace0c1 100644 --- a/v3/.eslintrc.cjs +++ b/v3/.eslintrc.cjs @@ -71,6 +71,7 @@ module.exports = { "keyword-spacing": ["warn"], "max-len": ["warn", { code: 120, ignoreUrls: true }], "no-bitwise": "error", + "no-constant-binary-expression": "error", "no-debugger": "off", "no-duplicate-imports": "error", "no-sequences": "error", diff --git a/v3/src/components/case-table/attribute-menu/edit-attribute-properties-modal.tsx b/v3/src/components/case-table/attribute-menu/edit-attribute-properties-modal.tsx index 126660a636..4b8959838b 100644 --- a/v3/src/components/case-table/attribute-menu/edit-attribute-properties-modal.tsx +++ b/v3/src/components/case-table/attribute-menu/edit-attribute-properties-modal.tsx @@ -53,13 +53,13 @@ export const EditAttributePropertiesModal = ({ attributeId, isOpen, onClose }: I ) attribute.setName(newName) } - if (description !== attribute.description ?? "") { + if (description !== (attribute.description ?? "")) { attribute.setDescription(description || undefined) } - if (units !== attribute.units ?? "") { + if (units !== (attribute.units ?? "")) { attribute.setUnits(units || undefined) } - if (userType !== attribute.userType ?? "none") { + if (userType !== (attribute.userType ?? "none")) { attribute.setUserType(userType === "none" ? undefined : userType) } if (precision !== `${attribute?.precision ?? ""}`) { diff --git a/v3/src/components/graph/adornments/univariate-measures/normal-curve/normal-curve-adornment-component.tsx b/v3/src/components/graph/adornments/univariate-measures/normal-curve/normal-curve-adornment-component.tsx index 69846dcbeb..5026b829f1 100644 --- a/v3/src/components/graph/adornments/univariate-measures/normal-curve/normal-curve-adornment-component.tsx +++ b/v3/src/components/graph/adornments/univariate-measures/normal-curve/normal-curve-adornment-component.tsx @@ -116,7 +116,7 @@ export const NormalCurveAdornmentComponent = observer( const labelSelection = select(labelRef.current) const labelCoords = measure.labelCoords const lineHeight = 20 - const topOffset = lineHeight * adornmentsStore?.getLabelLinesAboveAdornment(model) ?? 0 + const topOffset = lineHeight * (adornmentsStore?.getLabelLinesAboveAdornment(model) ?? 0) const labelLeft = labelCoords ? labelCoords.x / cellCounts.x : isVertical.current diff --git a/v3/src/components/graph/adornments/univariate-measures/standard-error/standard-error-adornment-component.tsx b/v3/src/components/graph/adornments/univariate-measures/standard-error/standard-error-adornment-component.tsx index 718fa88377..83b6f1ce8b 100644 --- a/v3/src/components/graph/adornments/univariate-measures/standard-error/standard-error-adornment-component.tsx +++ b/v3/src/components/graph/adornments/univariate-measures/standard-error/standard-error-adornment-component.tsx @@ -84,7 +84,7 @@ export const StandardErrorAdornmentComponent = observer( const labelSelection = select(labelRef.current) const labelCoords = measure.labelCoords const lineHeight = 20 - const topOffset = lineHeight * adornmentsStore?.getLabelLinesAboveAdornment(model, isGaussianFit) ?? 0 + const topOffset = lineHeight * (adornmentsStore?.getLabelLinesAboveAdornment(model, isGaussianFit) ?? 0) const labelLeft = labelCoords ? labelCoords.x / cellCounts.x : isVertical.current diff --git a/v3/src/components/graph/adornments/univariate-measures/univariate-measure-adornment-simple-component.tsx b/v3/src/components/graph/adornments/univariate-measures/univariate-measure-adornment-simple-component.tsx index 6d6642b6c1..1ce71524d1 100644 --- a/v3/src/components/graph/adornments/univariate-measures/univariate-measure-adornment-simple-component.tsx +++ b/v3/src/components/graph/adornments/univariate-measures/univariate-measure-adornment-simple-component.tsx @@ -64,7 +64,7 @@ export const UnivariateMeasureAdornmentSimpleComponent = observer( const lineHeight = 20 // We have to pass isGaussianFit to getLabelLinesAboveAdornment because the Gaussian fit is a special case where // if there is a gaussianFit (not just a normal curve), we need to add an extra line for the adornment title. - const topOffset = lineHeight * adornmentsStore?.getLabelLinesAboveAdornment(model, isGaussianFit) ?? 0 + const topOffset = lineHeight * (adornmentsStore?.getLabelLinesAboveAdornment(model, isGaussianFit) ?? 0) let labelLeft = labelCoords ? labelCoords.x / cellCounts.x : isVertical.current