Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Even more eslint fixes for #101 #334

Closed
wants to merge 13 commits into from
2 changes: 1 addition & 1 deletion src/algorithms/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export function exportSimulation(result: UserResult) {
// TODO: Make the down sampling interval a parameter

const header = keys(result.trajectory[0].current)
const tsvHeader: string[] = header.map((x) => (x == 'critical' ? 'ICU' : x))
const tsvHeader: string[] = header.map((x) => (x === 'critical' ? 'ICU' : x))

const headerCumulative = keys(result.trajectory[0].cumulative)
const tsvHeaderCumulative = headerCumulative.map((x) => `cumulative_${x}`)
Expand Down
14 changes: 4 additions & 10 deletions src/components/Main/Results/AgeBarChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactResizeDetector from 'react-resize-detector'

import { useTranslation } from 'react-i18next'

import { Bar, BarChart, CartesianGrid, Legend, Tooltip, XAxis, YAxis, TooltipPayload } from 'recharts'
import { Bar, BarChart, CartesianGrid, Legend, Tooltip, XAxis, YAxis } from 'recharts'

import { AlgorithmResult } from '../../../algorithms/types/Result.types'

Expand Down Expand Up @@ -34,7 +34,6 @@ export function AgeBarChart({ showHumanized, data, rates }: SimProps) {
return null
}

const formatNumber = numberFormatter(!!showHumanized, false)
const formatNumberRounded = numberFormatter(!!showHumanized, true)

const t = (...args: Parameters<typeof unsafeT>) => {
Expand All @@ -43,7 +42,9 @@ export function AgeBarChart({ showHumanized, data, rates }: SimProps) {
return translation
}

process.env.NODE_ENV !== 'production' && console.warn('Translation incomatible in AgeBarChart.tsx', ...args)
if (process.env.NODE_ENV !== 'production') {
console.warn('Translation incomatible in AgeBarChart.tsx', ...args)
}
return String(translation)
}

Expand All @@ -58,13 +59,6 @@ export function AgeBarChart({ showHumanized, data, rates }: SimProps) {
totalFatalities: Math.round(lastDataPoint.cumulative.fatality[age]),
}))

const tooltipFormatter = (
value: string | number | Array<string | number>,
name: string,
entry: TooltipPayload,
index: number,
) => <span>{formatNumber(Number(value))}</span>

const tickFormatter = (value: number) => formatNumberRounded(value)

return (
Expand Down
9 changes: 5 additions & 4 deletions src/components/Main/Results/DeterministicLinePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ComposedChart,
Legend,
Line,
LineProps as RechartsLineProps,
Label,
ReferenceArea,
Scatter,
Expand All @@ -16,7 +17,6 @@ import {
XAxis,
YAxis,
YAxisProps,
LineProps as RechartsLineProps,
} from 'recharts'

import { useTranslation } from 'react-i18next'
Expand Down Expand Up @@ -97,6 +97,8 @@ function legendFormatter(enabledPlots: string[], value: string, entry: any) {
return <span className={activeClassName}>{value}</span>
}

const verifyPositive = (x: number) => (x > 0 ? x : undefined)

export function DeterministicLinePlot({
data,
userResult,
Expand Down Expand Up @@ -128,8 +130,6 @@ export function DeterministicLinePlot({

const { mitigationIntervals } = mitigation

const verifyPositive = (x: number) => (x > 0 ? x : undefined)

const nHospitalBeds = verifyPositive(data.params.hospitalBeds)
const nICUBeds = verifyPositive(data.params.ICUBeds)

Expand Down Expand Up @@ -215,7 +215,8 @@ export function DeterministicLinePlot({
const tMin = _.minBy(plotData, 'time')!.time // eslint-disable-line @typescript-eslint/no-non-null-assertion
const tMax = _.maxBy(plotData, 'time')!.time // eslint-disable-line @typescript-eslint/no-non-null-assertion

const scatterToPlot: LineProps[] = observations.length
const hasObservations = observations.length > 0
const scatterToPlot: LineProps[] = hasObservations
? [
// Append empirical data
...(countObservations.observedDeaths
Expand Down
4 changes: 2 additions & 2 deletions src/components/Main/Results/ResponsiveTooltipContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ interface TooltipContentProps {
active: boolean
label?: string | number
payload: TooltipItem[]
formatter?: Function
labelFormatter?: Function
formatter?: (value: string | number) => string | number
labelFormatter?: (label: string | number) => string | number
}

function ToolTipContentItem({ name, value, color }: TooltipItem) {
Expand Down
1 change: 0 additions & 1 deletion src/types/Intl.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// merge missing fields for Intl.NumberFormatOptions
// https://github.com/microsoft/TypeScript/issues/36533

// eslint-disable-next-line @typescript-eslint/tslint/config
namespace Intl {
interface NumberFormatOptions {
notation?: string
Expand Down