diff --git a/components/Flag.js b/components/Flag.js index 94702460..26a435c4 100644 --- a/components/Flag.js +++ b/components/Flag.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types' import React from 'react' import styled from 'styled-components' -var supportedCountryCodes = [ +const supportedCountryCodes = [ 'ad', 'ae', 'af', diff --git a/components/Header.js b/components/Header.js index 945efe55..66269d5b 100644 --- a/components/Header.js +++ b/components/Header.js @@ -7,7 +7,7 @@ const Header = () => { const { asPath, locale, defaultLocale } = useRouter() const lang = locale === defaultLocale ? '' : `/${locale}` - const canonical = 'https://explorer.ooni.org' + lang + asPath.split('?')[0] + const canonical = `https://explorer.ooni.org${lang}${asPath.split('?')[0]}` const intl = useIntl() const description = intl.formatMessage({ id: 'Home.Meta.Description' }) diff --git a/components/MATChart.js b/components/MATChart.js index d7941db8..6dd82cfc 100644 --- a/components/MATChart.js +++ b/components/MATChart.js @@ -101,10 +101,10 @@ const MATChart = ({ query, showFilters = true }) => { <> {data?.data?.result?.length > 0 ? ( - {data && data.data.dimension_count == 0 && ( + {data && data.data.dimension_count === 0 && ( )} - {data && data.data.dimension_count == 1 && ( + {data && data.data.dimension_count === 1 && ( )} {data && data.data.dimension_count > 1 && ( diff --git a/components/NavBar.js b/components/NavBar.js index 981cd057..8e47a5e9 100644 --- a/components/NavBar.js +++ b/components/NavBar.js @@ -144,6 +144,7 @@ export const NavBar = ({ color }) => { logout() } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { setShowMenu(false) }, [pathname]) diff --git a/components/ThirdPartyDataChart.js b/components/ThirdPartyDataChart.js index 1db36431..95c1f58e 100644 --- a/components/ThirdPartyDataChart.js +++ b/components/ThirdPartyDataChart.js @@ -58,6 +58,7 @@ const ThirdPartyDataChart = ({ since, until, country, asn, ...props }) => { return [from, to] }, [since, until]) + // biome-ignore lint/correctness/useExhaustiveDependencies: const cloudflareData = useEffect(() => { if (!since && !until) return diff --git a/components/aggregation/Debug.js b/components/aggregation/Debug.js index 7e97f9e0..7c33c18c 100644 --- a/components/aggregation/Debug.js +++ b/components/aggregation/Debug.js @@ -113,7 +113,10 @@ export const Debug = ({ query, children, ...rest }) => { - updateNoOpState(performance.now())}> + updateNoOpState(performance.now())} + > refresh diff --git a/components/aggregation/DebugContext.js b/components/aggregation/DebugContext.js index fdda6bb3..e94c63aa 100644 --- a/components/aggregation/DebugContext.js +++ b/components/aggregation/DebugContext.js @@ -1,10 +1,10 @@ import React, { - useState, createContext, - useContext, useCallback, + useContext, useEffect, useRef, + useState, } from 'react' export const DebugContext = createContext() @@ -58,6 +58,7 @@ export const DebugProvider = ({ children }) => { scrollStartRef.current = timestamp }, []) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { // when API query is initiated, reset timestamps console.debug('Query changed. Resetting timers') diff --git a/components/aggregation/mat/ChartHeader.js b/components/aggregation/mat/ChartHeader.js index c91c8814..cc47143d 100644 --- a/components/aggregation/mat/ChartHeader.js +++ b/components/aggregation/mat/ChartHeader.js @@ -2,10 +2,10 @@ import { Box, Flex, Heading, Text } from 'ooni-components' import OONILogo from 'ooni-components/svgs/logos/OONI-HorizontalMonochrome.svg' import { useIntl } from 'react-intl' -import { testGroups, testNames } from '/components/test-info' import CountryNameLabel from './CountryNameLabel' import { useMATContext } from './MATContext' import { colorMap } from './colorMap' +import { testGroups, testNames } from '/components/test-info' const Legend = ({ label, color }) => { return ( @@ -29,9 +29,9 @@ const getTestNameGroupName = (testNameArray) => { return [testNames[testNameArray[0]]?.id || testNameArray[0]] const testGroup = new Set() - testNameArray.forEach((t) => { + for (const t of testNameArray) { testNames[t]?.group && testGroup.add(testNames[t]?.group) - }) + } // if all test names belong to a single group, show group name if (testGroup.size === 1) { const testGroupName = testGroups[[...testGroup][0]].id @@ -50,9 +50,9 @@ export const SubtitleStr = ({ query }) => { ? query.test_name : [query.test_name] const testNames = getTestNameGroupName(testNameQuery) - testNames.forEach((testName) => { + for (const testName of testNames) { params.add(intl.formatMessage({ id: testName, defaultMessage: '' })) - }) + } } if (query.domain) { params.add(query.domain.split(',').join(', ')) @@ -104,25 +104,25 @@ export const ChartHeader = ({ options = {} }) => { )} diff --git a/components/aggregation/mat/CustomTooltip.js b/components/aggregation/mat/CustomTooltip.js index 10fdc886..21d17a19 100644 --- a/components/aggregation/mat/CustomTooltip.js +++ b/components/aggregation/mat/CustomTooltip.js @@ -60,7 +60,7 @@ export const generateSearchQuery = (data, query) => { if (query.time_grain !== 'hour') { untilFilter = untilFilter.split('T')[0] } else { - untilFilter = untilFilter.split('.')[0] + 'Z' + untilFilter = `${untilFilter.split('.')[0]}Z` } } diff --git a/components/aggregation/mat/Filters.js b/components/aggregation/mat/Filters.js index 24fbe182..9320dd77 100644 --- a/components/aggregation/mat/Filters.js +++ b/components/aggregation/mat/Filters.js @@ -354,7 +354,7 @@ const Filters = ({ data = [], tableData, setDataForCharts, query }) => { ]) useEffect(() => { - if (state.globalFilter == undefined && resetTableRef.current === true) { + if (state.globalFilter === undefined && resetTableRef.current === true) { resetTableRef.current = false toggleAllRowsSelected(false) } @@ -387,10 +387,12 @@ const Filters = ({ data = [], tableData, setDataForCharts, query }) => { {headerGroups.map((headerGroup, i) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {headerGroup.headers.map((column, i) => { return ( key={i} {...column.getHeaderProps([ { @@ -457,6 +459,7 @@ const Filters = ({ data = [], tableData, setDataForCharts, query }) => { {row.cells.map((cell, i) => { return ( key={i} {...cell.getCellProps([ { diff --git a/components/aggregation/mat/Form.js b/components/aggregation/mat/Form.js index bf7f94c2..0b71a054 100644 --- a/components/aggregation/mat/Form.js +++ b/components/aggregation/mat/Form.js @@ -95,6 +95,7 @@ const filterAxisOptions = ( .map(([option]) => option) } +// biome-ignore lint/style/useDefaultParameterLast: function isValidFilterForTestname(testName = 'XX', arrayWithMapping) { // whether the dependent filter is valid to show along with `testName` return arrayWithMapping.includes(testName) @@ -138,17 +139,17 @@ export const Form = ({ onSubmit, query }) => { } }, [defaultValues, reset, router.isReady]) - const [since, setSince] = useState(defaultValues['since']) - const [until, setUntil] = useState(defaultValues['until']) - const [countryValue, setCountryValue] = useState(defaultValues['probe_cc']) - const [testNameValue, setTestNameValue] = useState(defaultValues['test_name']) + const [since, setSince] = useState(defaultValues.since) + const [until, setUntil] = useState(defaultValues.until) + const [countryValue, setCountryValue] = useState(defaultValues.probe_cc) + const [testNameValue, setTestNameValue] = useState(defaultValues.test_name) useEffect(() => { const subscription = watch((value, { name, type }) => { - if (name === 'since') setSince(value['since']) - if (name === 'until') setUntil(value['until']) - if (name === 'probe_cc') setCountryValue(value['probe_cc']) - if (name === 'test_name') setTestNameValue(value['test_name']) + if (name === 'since') setSince(value.since) + if (name === 'until') setUntil(value.until) + if (name === 'probe_cc') setCountryValue(value.probe_cc) + if (name === 'test_name') setTestNameValue(value.test_name) }) return () => subscription.unsubscribe() }, [watch]) @@ -258,12 +259,14 @@ export const Form = ({ onSubmit, query }) => { if (!availableValues.includes(getValues('time_grain'))) setValue('time_grain', 'hour') return availableValues - } else if (diff >= 8 && diff < 31) { + } + if (diff >= 8 && diff < 31) { const availableValues = ['day', 'week'] if (!availableValues.includes(getValues('time_grain'))) setValue('time_grain', 'day') return availableValues - } else if (diff >= 31) { + } + if (diff >= 31) { const availableValues = ['day', 'week', 'month'] if (!availableValues.includes(getValues('time_grain'))) setValue('time_grain', 'day') @@ -296,6 +299,7 @@ export const Form = ({ onSubmit, query }) => { {intl.formatMessage({ id: 'MAT.Form.AllCountries' })} {sortedCountries.map((c, idx) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {c.localisedCountryName} @@ -372,6 +376,7 @@ export const Form = ({ onSubmit, query }) => { width={1} > {timeGrainOptions.map((option, idx) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {intl.formatMessage(messages[option])} @@ -391,6 +396,7 @@ export const Form = ({ onSubmit, query }) => { width={1} > {xAxisOptionsFiltered.map((option, idx) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {option.length > 0 ? intl.formatMessage(messages[option]) @@ -412,6 +418,7 @@ export const Form = ({ onSubmit, query }) => { width={1} > {yAxisOptionsFiltered.map((option, idx) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {option.length > 0 ? intl.formatMessage(messages[option]) @@ -484,6 +491,7 @@ export const Form = ({ onSubmit, query }) => { {categoryCodes .sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0)) .map(([code, label], idx) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {intl.formatMessage({ id: `CategoryCode.${code}.Name`, diff --git a/components/aggregation/mat/GridChart.js b/components/aggregation/mat/GridChart.js index f98f634f..52930b65 100644 --- a/components/aggregation/mat/GridChart.js +++ b/components/aggregation/mat/GridChart.js @@ -45,7 +45,7 @@ export const prepareDataForGridChart = (data, query, locale) => { const rowLabels = {} const reshapedData = {} - data.forEach((item) => { + for (const item of data) { // Convert non-string keys (e.g `probe_asn`) to string // because they get casted to strings during Object transformations const key = String(item[query.axis_y]) @@ -56,7 +56,7 @@ export const prepareDataForGridChart = (data, query, locale) => { reshapedData[key] = [item] rowLabels[key] = getRowLabel(key, query.axis_y, locale) } - }) + } const reshapedDataWithoutHoles = fillDataHoles(reshapedData, query) diff --git a/components/aggregation/mat/HeatMapChart.js b/components/aggregation/mat/HeatMapChart.js index 870833b0..d8ec7d0c 100644 --- a/components/aggregation/mat/HeatMapChart.js +++ b/components/aggregation/mat/HeatMapChart.js @@ -76,6 +76,7 @@ const CustomHeatMapCell = ({ let prevHeight = 0 return ( + // biome-ignore lint/a11y/useKeyWithMouseEvents: {value !== undefined && barsData.map(([barLabel, barColor], index) => { - const barHeight = - height * (value[barLabel] / value['measurement_count']) // ((index + 1) / 10) + const barHeight = height * (value[barLabel] / value.measurement_count) // ((index + 1) / 10) const barY = prevHeight === 0 ? height * -0.5 : height * -0.5 + prevHeight prevHeight = prevHeight + barHeight return ( key={index} x={width * -0.5} y={barY} diff --git a/components/aggregation/mat/MATContext.js b/components/aggregation/mat/MATContext.js index 60902e1b..88269627 100644 --- a/components/aggregation/mat/MATContext.js +++ b/components/aggregation/mat/MATContext.js @@ -54,6 +54,7 @@ export const MATContextProvider = ({ [initialContext], ) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { stateReducer(MATquery) }, [MATquery]) diff --git a/components/aggregation/mat/TableView.js b/components/aggregation/mat/TableView.js index 70f2f9d2..e06d98b1 100644 --- a/components/aggregation/mat/TableView.js +++ b/components/aggregation/mat/TableView.js @@ -30,11 +30,11 @@ const prepareDataforTable = (data, query, locale) => { measurement_count: 0, } - rowData.forEach((d) => { - countKeys.forEach((countKey) => { + for (const d of rowData) { + for (const countKey of countKeys) { row[countKey] = row[countKey] + d[countKey] - }) - }) + } + } table.push(row) } diff --git a/components/aggregation/mat/XAxis.js b/components/aggregation/mat/XAxis.js index 915e264d..f78c427a 100644 --- a/components/aggregation/mat/XAxis.js +++ b/components/aggregation/mat/XAxis.js @@ -26,7 +26,7 @@ export const XAxis = ({ data }) => { return ( - + { + for (const col of missingCols) { // use any (first) column data to popuplate yAxis value e.g `input` | `probe_cc` // and then overwrite with zero-data for that missing date newData.splice([...domain].indexOf(col), 0, { @@ -75,7 +75,7 @@ export function fillRowHoles(data, query, locale) { measurement_count: 0, ok_count: 0, }) - }) + } return newData } diff --git a/components/aggregation/mat/timeScaleXAxis.js b/components/aggregation/mat/timeScaleXAxis.js index 39977c73..175db5fc 100644 --- a/components/aggregation/mat/timeScaleXAxis.js +++ b/components/aggregation/mat/timeScaleXAxis.js @@ -6,7 +6,7 @@ import { getDatesBetween } from './computations' const defaultCount = 20 const getIntervalTicks = (data, count = defaultCount) => { - if (!(data && data.length)) return [] + if (!data?.length) return [] const start = data[0] const end = data[data.length - 1] @@ -37,8 +37,9 @@ export function getXAxisTicks(query, count = defaultCount) { if (query.time_grain === 'hour') { return Array.from(xAxisTickValues).map( - (d) => d.toISOString().split('.')[0] + 'Z', + (d) => `${d.toISOString().split('.')[0]}Z`, ) + // biome-ignore lint/style/noUselessElse: } else if (query.time_grain === 'week') { return dateDomain.length < 30 ? Array.from(dateDomain).map((d) => d.toISOString().split('T')[0]) diff --git a/components/as/Calendar.js b/components/as/Calendar.js index f779064c..a9c2145c 100644 --- a/components/as/Calendar.js +++ b/components/as/Calendar.js @@ -82,13 +82,14 @@ const Calendar = React.memo(function Calendar({ data }) { display: 'inline-block', marginRight: '3px', }} - > + /> {item.range} ))} {yearsOptions.map((year) => ( + // biome-ignore lint/a11y/useKeyWithClickEvents: { setShowDatePicker(false) } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { // trigger submit only when the dates are valid if ( diff --git a/components/chart/Slices.js b/components/chart/Slices.js index 2855f5ad..67e3dbe4 100644 --- a/components/chart/Slices.js +++ b/components/chart/Slices.js @@ -4,6 +4,7 @@ import { createElement, useCallback } from 'react' const SlicesItem = ({ slice, axis, debug, tooltip, isCurrent, setCurrent }) => { const { showTooltipFromEvent, hideTooltip } = useTooltip() + // biome-ignore lint/correctness/useExhaustiveDependencies: const handleMouseEnter = useCallback( (event) => { showTooltipFromEvent( @@ -16,6 +17,7 @@ const SlicesItem = ({ slice, axis, debug, tooltip, isCurrent, setCurrent }) => { [showTooltipFromEvent, tooltip, slice], ) + // biome-ignore lint/correctness/useExhaustiveDependencies: const handleMouseMove = useCallback( (event) => { showTooltipFromEvent( @@ -27,6 +29,7 @@ const SlicesItem = ({ slice, axis, debug, tooltip, isCurrent, setCurrent }) => { [showTooltipFromEvent, tooltip, slice], ) + // biome-ignore lint/correctness/useExhaustiveDependencies: const handleMouseLeave = useCallback(() => { hideTooltip() setCurrent(null) @@ -67,12 +70,12 @@ const Slices = (props) => { const map = new Map() - points.forEach((point) => { + for (const point of points) { if (point.data.x === null || point.data.y === null) return if (new Date(point.data.x).getMinutes() !== 0) return if (!map.has(point.x)) map.set(point.x, [point]) else map.get(point.x).push(point) - }) + } const slices = Array.from(map.entries()) .sort((a, b) => a[0] - b[0]) diff --git a/components/country/ConfirmedBlockedCategory.js b/components/country/ConfirmedBlockedCategory.js index 0ad76be4..3262e976 100644 --- a/components/country/ConfirmedBlockedCategory.js +++ b/components/country/ConfirmedBlockedCategory.js @@ -43,6 +43,7 @@ const ConfirmedBlockedCategory = () => { swrOptions, ) + // biome-ignore lint/correctness/useExhaustiveDependencies: const blockedCategoriesData = useMemo(() => { if (!data) { return null @@ -72,13 +73,12 @@ const ConfirmedBlockedCategory = () => { ) : ( - {blockedCategoriesData && - blockedCategoriesData.map((category) => ( - - ))} + {blockedCategoriesData?.map((category) => ( + + ))} )} diff --git a/components/country/Overview.js b/components/country/Overview.js index 1ba63ef3..5fb042b7 100644 --- a/components/country/Overview.js +++ b/components/country/Overview.js @@ -59,11 +59,11 @@ const messages = defineMessages({ const getStatus = (count, formattedMessageId) => { if (count === null) { return messages[`${formattedMessageId}NoData`] - } else if (count > 0) { + } + if (count > 0) { return messages[`${formattedMessageId}Blocked`] - } else { - return messages[`${formattedMessageId}Normal`] } + return messages[`${formattedMessageId}Normal`] } const ooniBlogBaseURL = 'https://ooni.org' @@ -172,6 +172,7 @@ const Overview = ({ ) : ( {featuredArticles.map((article, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: diff --git a/components/country/OverviewCharts.js b/components/country/OverviewCharts.js index e9134870..9675f8aa 100644 --- a/components/country/OverviewCharts.js +++ b/components/country/OverviewCharts.js @@ -160,7 +160,8 @@ class TestsByGroup extends React.Component { ) const renderCharts = () => { - let testCoverageMaxima, networkCoverageMaxima + let testCoverageMaxima + let networkCoverageMaxima const selectedTestGroups = Object.keys(this.state).filter( (testGroup) => this.state[testGroup], ) @@ -187,14 +188,14 @@ class TestsByGroup extends React.Component { ...testCoverageByDay[day], })) - networkCoverage.forEach((d) => { + for (const d of networkCoverage) { if ( typeof networkCoverageMaxima === 'undefined' || networkCoverageMaxima < d.count ) { networkCoverageMaxima = d.count } - }) + } const networkCoverageTick = (t) => Math.round(t * networkCoverageMaxima) const ntIncrement = Math.round(networkCoverageMaxima / 4) @@ -227,20 +228,21 @@ class TestsByGroup extends React.Component { {selectedTestGroups.map((testGroup, index) => { const maybeLabels = {} if (index === 0) { - maybeLabels['labels'] = (d) => { + maybeLabels.labels = (d) => { let s = new Date(d.test_day).toLocaleDateString() - selectedTestGroups.forEach((name) => { + for (const name of selectedTestGroups) { s += `\n${d[name]} ${testGroupNames[name]}` - }) + } return s } - maybeLabels['labelComponent'] = ( + maybeLabels.labelComponent = ( ) } return ( key={index} name={testGroup} data={testCoverageArray} @@ -290,6 +292,7 @@ class TestsByGroup extends React.Component { {supportedTestGroups.map((testGroup, index) => ( key={index} testGroup={testGroup} onClick={this.onTestGroupClick} diff --git a/components/dashboard/Form.js b/components/dashboard/Form.js index ba40c8ac..e0b64425 100644 --- a/components/dashboard/Form.js +++ b/components/dashboard/Form.js @@ -95,6 +95,7 @@ export const Form = ({ onChange, query, availableCountries }) => { onChange(cleanedUpData(getValues())) } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { const subscription = watch((value, { name, type }) => { if (name === 'probe_cc' && type === 'change') diff --git a/components/domain/Form.js b/components/domain/Form.js index 57d9ca3e..d290a1e3 100644 --- a/components/domain/Form.js +++ b/components/domain/Form.js @@ -43,6 +43,7 @@ const Form = ({ onSubmit, availableCountries = [] }) => { defaultValues: query2formValues, }) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { reset(query2formValues) }, [query]) @@ -57,17 +58,18 @@ const Form = ({ onSubmit, availableCountries = [] }) => { setShowDatePicker(false) } + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { const subscription = watch((value, { name, type }) => { if ( value[name] !== query[name] && - dayjs(value['since'], 'YYYY-MM-DD', true).isValid() && - dayjs(value['until'], 'YYYY-MM-DD', true).isValid() + dayjs(value.since, 'YYYY-MM-DD', true).isValid() && + dayjs(value.until, 'YYYY-MM-DD', true).isValid() ) { onSubmit({ - since: value['since'], - until: value['until'], - probe_cc: value['probe_cc'], + since: value.since, + until: value.until, + probe_cc: value.probe_cc, }) } }) @@ -75,6 +77,7 @@ const Form = ({ onSubmit, availableCountries = [] }) => { return () => subscription.unsubscribe() }, [watch]) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { if (Object.keys(query).length < 3) { const today = dayjs.utc().add(1, 'day') diff --git a/components/findings/Form.js b/components/findings/Form.js index 87368b53..e987bc25 100644 --- a/components/findings/Form.js +++ b/components/findings/Form.js @@ -21,9 +21,9 @@ import { Controller, useForm } from 'react-hook-form' import { useIntl } from 'react-intl' import { localisedCountries } from 'utils/i18nCountries' import * as yup from 'yup' -import { testNames } from '/components/test-info' import useUser from '../../hooks/useUser' import FindingDisplay from './FindingDisplay' +import { testNames } from '/components/test-info' const elements = [ defineMetadata({ @@ -70,7 +70,7 @@ const schema = yup.object({ ASNs: yup.array().test({ name: 'ASNsError', message: 'Only numeric values allowed', - test: (val) => val.every((v) => !isNaN(v.value)), + test: (val) => val.every((v) => !Number.isNaN(v.value)), }), start_time: yup.string().required(), end_time: yup @@ -99,9 +99,8 @@ const schema = yup.object({ .map((obj) => obj.messages.map((m) => m.message).join(', ')) .join(', ') return context.createError({ message, path: 'text' }) - } else { - return true } + return true }, }), }) diff --git a/components/landing/HighlightsSection.js b/components/landing/HighlightsSection.js index 582d0341..68de5df3 100644 --- a/components/landing/HighlightsSection.js +++ b/components/landing/HighlightsSection.js @@ -34,6 +34,7 @@ const HighlightSection = ({ title, highlights, description }) => { {/* HighlightBoxes */} {highlights.map((item, index) => ( key={index} title={item.title ? intl.formatMessage({ id: item.title }) : ''} text={item.text ? intl.formatMessage({ id: item.text }) : ''} diff --git a/components/landing/Stats.js b/components/landing/Stats.js index 26c1d71d..1c68b2d1 100644 --- a/components/landing/Stats.js +++ b/components/landing/Stats.js @@ -21,11 +21,11 @@ import { ChartLoader } from './ChartLoader' const getMaxima = (data) => { let maxima - data.forEach((d) => { + for (const d of data) { if (typeof maxima === 'undefined' || maxima < d.value) { maxima = d.value } - }) + } return maxima } @@ -60,9 +60,9 @@ const CoverageChart = () => { const intl = useIntl() if (data) { - const countryCoverage = data.countries_by_month.slice(0, -1), - networkCoverage = data.networks_by_month.slice(0, -1), - measurementsByMonth = data.measurements_by_month.slice(0, -1) + const countryCoverage = data.countries_by_month.slice(0, -1) + const networkCoverage = data.networks_by_month.slice(0, -1) + const measurementsByMonth = data.measurements_by_month.slice(0, -1) // API responses are ordered by date, with most recent month at the end const lastMonth = { @@ -118,9 +118,11 @@ const CoverageChart = () => { labels={(d) => { if (d.childName === 'countryCoverage') { return `${d.date}\n \nCountries: ${d.value}` - } else if (d.childName === 'networkCoverage') { + } + if (d.childName === 'networkCoverage') { return `Networks: ${d.value}` - } else if (d.childName === 'measurementsByMonth') { + } + if (d.childName === 'measurementsByMonth') { return `Measurements: ${d.value}` } }} @@ -245,9 +247,8 @@ const CoverageChart = () => { > ) - } else { - return } + return } export default CoverageChart diff --git a/components/measurement/CommonDetails.js b/components/measurement/CommonDetails.js index bc484c4d..48b186bd 100644 --- a/components/measurement/CommonDetails.js +++ b/components/measurement/CommonDetails.js @@ -69,7 +69,7 @@ const CommonDetails = ({ let engine = unavailable let platform = unavailable - if (annotations && annotations.engine_name) { + if (annotations?.engine_name) { engine = annotations.engine_name if (annotations.engine_version) { @@ -77,7 +77,7 @@ const CommonDetails = ({ } } - if (annotations && annotations.platform) { + if (annotations?.platform) { platform = annotations.platform } diff --git a/components/measurement/DetailsBox.js b/components/measurement/DetailsBox.js index f8fc97f9..ba5adf07 100644 --- a/components/measurement/DetailsBox.js +++ b/components/measurement/DetailsBox.js @@ -1,6 +1,6 @@ import { Box, Flex, Heading, Text } from 'ooni-components' import PropTypes from 'prop-types' -import React, { useState, useCallback } from 'react' +import React, { useCallback, useState } from 'react' import { FormattedMessage } from 'react-intl' import styled from 'styled-components' import { CollapseTrigger } from '../CollapseTrigger' @@ -18,6 +18,7 @@ export const DetailsBoxTable = ({ title, items, bg }) => ( title={title} bg={bg} content={items.map((item, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {item.label} @@ -63,6 +64,7 @@ export const DetailsBox = ({ }) => { const [isOpen, setIsOpen] = useState(!collapsed) + // biome-ignore lint/correctness/useExhaustiveDependencies: const onToggle = useCallback(() => { setIsOpen(!isOpen) }, [isOpen, setIsOpen]) diff --git a/components/measurement/FeedbackBox.js b/components/measurement/FeedbackBox.js index 6112c255..927f6c56 100644 --- a/components/measurement/FeedbackBox.js +++ b/components/measurement/FeedbackBox.js @@ -76,6 +76,7 @@ const FeedbackBox = ({ const feedbackLevels = previousFeedback.split('.') return feedbackLevels.reduce((acc, current, i) => { return { + // biome-ignore lint/performance/noAccumulatingSpread: ...acc, ...{ [radioLevels[i]]: feedbackLevels.slice(0, i + 1).join('.') }, } @@ -146,10 +147,12 @@ const FeedbackBox = ({ const firstLevelRadio = watch(radioLevels[0]) const secondLevelRadio = watch(radioLevels[1]) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { if (initialLoadFirst.current) return setValue(radioLevels[1], null) initialLoadFirst.current = true }, [firstLevelRadio]) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { if (initialLoadSecond.current) return setValue(radioLevels[2], null) initialLoadSecond.current = true @@ -231,8 +234,9 @@ const FeedbackBox = ({ name={radioLevels[0]} render={({ field }) => ( - {blockedValues.map(({ top, sub }) => ( - <> + {blockedValues.map(({ top, sub }, i) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: + ( - {sub.map(({ top, sub }) => ( - <> + {sub.map(({ top, sub }, subI) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: + )} - > + ))} )} /> )} - > + ))} )} diff --git a/components/measurement/PerformanceDetails.js b/components/measurement/PerformanceDetails.js index 395f95d6..105b2a68 100644 --- a/components/measurement/PerformanceDetails.js +++ b/components/measurement/PerformanceDetails.js @@ -36,7 +36,7 @@ const PerformanceDetails = ({ value: `${mss}`, }) - packetLoss != undefined && + packetLoss !== undefined && items.push({ label: isNdt7 ? intl.formatMessage({ @@ -50,14 +50,14 @@ const PerformanceDetails = ({ //Only add outOfOrder and timeouts if NDT4/5 measurement if (!isNdt7) { - outOfOrder != undefined && + outOfOrder !== undefined && items.push({ label: intl.formatMessage({ id: 'Measurement.Details.Performance.Label.OutOfOrder', }), - value: outOfOrder.toString() + '%', + value: `${outOfOrder.toString()}%`, }) - timeouts != undefined && + timeouts !== undefined && items.push({ label: intl.formatMessage({ id: 'Measurement.Details.Performance.Label.Timeouts', diff --git a/components/measurement/nettests/Dash.js b/components/measurement/nettests/Dash.js index 72e69d49..7b1023fa 100644 --- a/components/measurement/nettests/Dash.js +++ b/components/measurement/nettests/Dash.js @@ -51,12 +51,13 @@ const minimumBitrateForVideo = [ const getOptimalQualityForBitrate = (testKeys) => { let optimalQuality = minimumBitrateForVideo[0] - minimumBitrateForVideo.forEach((rate) => { + for (const rate of minimumBitrateForVideo) { // Note: we use SFR rather than HFR because SFR is more common - if (testKeys.simple.median_bitrate >= rate['sfr_min_bitrate']) { + if (testKeys.simple.median_bitrate >= rate.sfr_min_bitrate) { optimalQuality = rate } - }) + } + return optimalQuality } diff --git a/components/measurement/nettests/FacebookMessenger.js b/components/measurement/nettests/FacebookMessenger.js index 5c33748c..94b99f98 100644 --- a/components/measurement/nettests/FacebookMessenger.js +++ b/components/measurement/nettests/FacebookMessenger.js @@ -117,6 +117,7 @@ export const FacebookMessengerDetails = ({ measurement, render }) => { {Array.isArray(tcpConnections) && tcpConnections.length > 0 && ( <> {tcpConnections.map((connection, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: diff --git a/components/measurement/nettests/HTTPHeaderFieldManipulation.js b/components/measurement/nettests/HTTPHeaderFieldManipulation.js index 8c1fe0f7..804f9294 100644 --- a/components/measurement/nettests/HTTPHeaderFieldManipulation.js +++ b/components/measurement/nettests/HTTPHeaderFieldManipulation.js @@ -8,14 +8,14 @@ export const HttpHeaderFieldManipulationDetails = ({ measurement, render }) => { let isAnomaly = false let isFailed = true const tampering = testKeys?.tampering || {} - Object.keys(tampering).forEach((key) => { + for (const key of Object.keys(tampering)) { if (tampering[key] === true) { isAnomaly = true } if (tampering[key] !== null) { isFailed = false } - }) + } const messages = defineMessages({ middleboxes: { diff --git a/components/measurement/nettests/Ndt.js b/components/measurement/nettests/Ndt.js index 17bb9089..b84ab452 100644 --- a/components/measurement/nettests/Ndt.js +++ b/components/measurement/nettests/Ndt.js @@ -24,7 +24,12 @@ const NdtDetails = ({ measurement, render }) => { const failure = testKeys.failure const isNdt7 = testKeys.protocol === 7 - let packetLoss, minRTT, maxRTT, mss, outOfOrder, timeouts + let packetLoss + let minRTT + let maxRTT + let mss + let outOfOrder + let timeouts const simple = (isNdt7 ? testKeys.summary : testKeys.simple) || {} @@ -32,7 +37,7 @@ const NdtDetails = ({ measurement, render }) => { // ex. use kbit/s if the speed is low and gbit/s if it's high const downloadMbit = simple.download && (simple.download / 1000).toFixed(2) const uploadMbit = simple.upload && (simple.upload / 1000).toFixed(2) - const ping = simple.ping && simple.ping.toFixed(1) + const ping = simple?.ping.toFixed(1) let performanceDetails = null if (!isFailed) { @@ -42,21 +47,21 @@ const NdtDetails = ({ measurement, render }) => { // Summary packetLoss = summary.retransmit_rate && (summary.retransmit_rate * 100).toFixed(3) - minRTT = summary.min_rtt && summary.min_rtt.toFixed(0) - maxRTT = summary.max_rtt && summary.max_rtt.toFixed(0) + minRTT = summary?.min_rtt.toFixed(0) + maxRTT = summary?.max_rtt.toFixed(0) mss = summary.mss outOfOrder = null timeouts = null } else { const advanced = testKeys.advanced || null // Advanced - delete advanced['out_of_order'] + advanced.out_of_order = undefined packetLoss = advanced.packet_loss && (advanced.packet_loss * 100).toFixed(3) outOfOrder = advanced.out_of_order && (advanced.out_of_order * 100).toFixed(1) - minRTT = advanced.min_rtt && advanced.min_rtt.toFixed(0) - maxRTT = advanced.max_rtt && advanced.max_rtt.toFixed(0) + minRTT = advanced?.min_rtt.toFixed(0) + maxRTT = advanced?.max_rtt.toFixed(0) mss = advanced?.mss timeouts = advanced?.timeouts } diff --git a/components/measurement/nettests/Psiphon.js b/components/measurement/nettests/Psiphon.js index 094bf782..6c255738 100644 --- a/components/measurement/nettests/Psiphon.js +++ b/components/measurement/nettests/Psiphon.js @@ -2,8 +2,7 @@ import { Container, Flex } from 'ooni-components' import PropTypes from 'prop-types' import React from 'react' import { MdTimer } from 'react-icons/md' -import { FormattedMessage } from 'react-intl' -import { defineMessages } from 'react-intl' +import { FormattedMessage, defineMessages } from 'react-intl' import AccessPointStatus from '../AccessPointStatus' @@ -23,7 +22,10 @@ const PsiphonDetails = ({ measurement, render }) => { }, }) - let status, hint, summaryText, metaText + let status + let hint + let summaryText + let metaText // https://github.com/ooni/spec/blob/master/nettests/ts-015-psiphon.md#possible-conclusions // Determine if psiphon is blocked and if the probe could bootstrap psiphon diff --git a/components/measurement/nettests/Telegram.js b/components/measurement/nettests/Telegram.js index 630920d7..57544977 100644 --- a/components/measurement/nettests/Telegram.js +++ b/components/measurement/nettests/Telegram.js @@ -1,10 +1,8 @@ import { Box, Container, Flex, Heading, Text } from 'ooni-components' import PropTypes from 'prop-types' import React from 'react' -import { MdPhoneAndroid } from 'react-icons/md' -import { MdWebAsset } from 'react-icons/md' -import { FormattedMessage } from 'react-intl' -import { defineMessages } from 'react-intl' +import { MdPhoneAndroid, MdWebAsset } from 'react-icons/md' +import { FormattedMessage, defineMessages } from 'react-intl' import AccessPointStatus from '../AccessPointStatus' import { DetailsBox } from '../DetailsBox' @@ -96,6 +94,7 @@ const TelegramDetails = ({ measurement, render }) => { collapsed={false} > {tcp_connect.map((connection, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: diff --git a/components/measurement/nettests/Tor.js b/components/measurement/nettests/Tor.js index d4c8c626..8b39b191 100644 --- a/components/measurement/nettests/Tor.js +++ b/components/measurement/nettests/Tor.js @@ -1,7 +1,7 @@ import { Container, Flex, Text, theme } from 'ooni-components' import { Cross, Tick } from 'ooni-components/icons' import PropTypes from 'prop-types' -import React, { useMemo, useCallback } from 'react' +import React, { useCallback, useMemo } from 'react' import { FaClipboard } from 'react-icons/fa' import { FormattedMessage, defineMessages } from 'react-intl' import { useSortBy, useTable } from 'react-table' @@ -91,10 +91,15 @@ const Table = ({ columns, data }) => { /* eslint-disable react/jsx-key */ - {headerGroups.map((headerGroup) => ( - - {headerGroup.headers.map((column) => ( - + {headerGroups.map((headerGroup, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: + + {headerGroup.headers.map((column, i) => ( + + key={i} + {...column.getHeaderProps(column.getSortByToggleProps())} + > {column.render('Header')} {/* Sort order indicator */} @@ -106,12 +111,18 @@ const Table = ({ columns, data }) => { ))} - {rows.map((row) => { + {rows.map((row, ri) => { prepareRow(row) return ( - - {row.cells.map((cell) => { - return {cell.render('Cell')} + // biome-ignore lint/suspicious/noArrayIndexKey: + + {row.cells.map((cell, ci) => { + return ( + // biome-ignore lint/suspicious/noArrayIndexKey: + + {cell.render('Cell')} + + ) })} ) @@ -147,7 +158,9 @@ const ConnectionStatusCell = ({ cell: { value } }) => { const TorDetails = ({ isAnomaly, isFailure, measurement, render }) => { // https://github.com/ooni/spec/blob/master/nettests/ts-023-tor.md#possible-conclusions - let status, hint, summaryText + let status + let hint + let summaryText if (isFailure) { status = 'error' diff --git a/components/measurement/nettests/TorSnowflake.js b/components/measurement/nettests/TorSnowflake.js index 302cb52c..4a63c9ac 100644 --- a/components/measurement/nettests/TorSnowflake.js +++ b/components/measurement/nettests/TorSnowflake.js @@ -26,7 +26,10 @@ const TorSnowflakeDetails = ({ isAnomaly, isFailure, measurement, render }) => { test_keys: { bootstrap_time, failure }, } = measurement - let status, hint, summaryText, metaText + let status + let hint + let summaryText + let metaText if (isFailure) { status = 'error' diff --git a/components/measurement/nettests/WebConnectivity.js b/components/measurement/nettests/WebConnectivity.js index 057d1aa3..f6ac3ac4 100644 --- a/components/measurement/nettests/WebConnectivity.js +++ b/components/measurement/nettests/WebConnectivity.js @@ -1,9 +1,10 @@ import bufferFrom from 'buffer-from' import NLink from 'next/link' -import url from 'node:url' import { Box, Flex, Heading, Text } from 'ooni-components' import PropTypes from 'prop-types' import React from 'react' +// biome-ignore lint/style/useNodejsImportProtocol: +import url from 'url' import deepmerge from 'deepmerge' import { Cross, Tick } from 'ooni-components/icons' diff --git a/components/measurement/nettests/WhatsApp.js b/components/measurement/nettests/WhatsApp.js index b53a58f9..eea81863 100644 --- a/components/measurement/nettests/WhatsApp.js +++ b/components/measurement/nettests/WhatsApp.js @@ -1,9 +1,7 @@ import { Box, Flex, Heading, Text } from 'ooni-components' import PropTypes from 'prop-types' import React from 'react' -import { MdPhoneAndroid } from 'react-icons/md' -import { MdWebAsset } from 'react-icons/md' -import { MdPersonAdd } from 'react-icons/md' +import { MdPersonAdd, MdPhoneAndroid, MdWebAsset } from 'react-icons/md' import { FormattedMessage, defineMessages } from 'react-intl' import styled from 'styled-components' @@ -20,7 +18,9 @@ const BugBox = styled(Box)` const WhatsAppDetails = ({ isAnomaly, scores, measurement, render }) => { const testKeys = measurement.test_keys const tcp_connect = testKeys.tcp_connect - let registrationServerAccessible, webAccessible, endpointsAccessible + let registrationServerAccessible + let webAccessible + let endpointsAccessible try { registrationServerAccessible = scores.analysis.registration_server_accessible @@ -112,6 +112,7 @@ const WhatsAppDetails = ({ isAnomaly, scores, measurement, render }) => { content={ <> {tcp_connect.map((connection, index) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: diff --git a/components/measurement/useTestKeyController.js b/components/measurement/useTestKeyController.js index a1fbbe7c..ad6a88d8 100644 --- a/components/measurement/useTestKeyController.js +++ b/components/measurement/useTestKeyController.js @@ -17,7 +17,7 @@ return ( */ import { Flex } from 'ooni-components' -import React, { useState, useCallback } from 'react' +import React, { useCallback, useState } from 'react' const setValues = (input, value = true) => { // Maps each key in `test_keys` to a boolean value, by default true @@ -35,6 +35,7 @@ export const useTestKeyController = (testKeysInitial) => { const [keysMap, setKeysMap] = useState(setValues(testKeysInitial)) const TestKeyController = () => { + // biome-ignore lint/correctness/useExhaustiveDependencies: const onChange = useCallback( (event) => { const { name, checked } = event.target @@ -64,6 +65,7 @@ export const useTestKeyController = (testKeysInitial) => { return ( {Object.keys(keysMap).map((k, i) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: { {categoryCodes .sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0)) .map(([code, label], idx) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: {intl.formatMessage({ id: `CategoryCode.${code}.Name` })} @@ -75,6 +76,7 @@ const testsWithAnomalyStatus = [ const testsWithConfirmedStatus = ['XX', 'web_connectivity'] +// biome-ignore lint/style/useDefaultParameterLast: function isValidFilterForTestname(testName = 'XX', arrayWithMapping) { // Should domain filter be shown for `testsWithValidDomain`? return arrayWithMapping.includes(testName) @@ -240,6 +242,7 @@ const FilterSidebar = ({ > {countryOptions.map((v, idx) => { return ( + // biome-ignore lint/suspicious/noArrayIndexKey: {v.name} diff --git a/components/search/Loader.js b/components/search/Loader.js index 80fe9ad8..626f446a 100644 --- a/components/search/Loader.js +++ b/components/search/Loader.js @@ -27,6 +27,7 @@ export const Loader = ({ rows = 10 }) => ( {Array(rows) .fill('') .map((e, i) => ( + // biome-ignore lint/suspicious/noArrayIndexKey: ))} > diff --git a/components/search/ResultsList.js b/components/search/ResultsList.js index 717209c7..35a460b8 100644 --- a/components/search/ResultsList.js +++ b/components/search/ResultsList.js @@ -1,4 +1,3 @@ -import url from 'url' import NLink from 'next/link' import { Box, Flex, Text } from 'ooni-components' import PropTypes from 'prop-types' @@ -6,8 +5,9 @@ import React from 'react' import { defineMessages, useIntl } from 'react-intl' import dayjs from 'services/dayjs' import styled from 'styled-components' +// biome-ignore lint/style/useNodejsImportProtocol: +import url from 'url' -import { testNames } from '/components/test-info' import Flag from '../Flag' import { colorAnomaly, @@ -15,6 +15,7 @@ import { colorError, colorNormal, } from '../colors' +import { testNames } from '/components/test-info' const StyledResultTag = styled.div` border-radius: 16px; @@ -269,15 +270,15 @@ const getIndicators = ({ failure, intl, }) => { - let color = '', - tag = null + let color = '' + let tag = null if (testsWithStates.includes(test_name)) { if (imTests.includes(test_name) && Object.entries(scores).length === 0) { return [color, tag] } const computedMessageIdPrefix = `Search.${test_name}.Results` - const blockingType = scores.analysis && scores.analysis.blocking_type + const blockingType = scores?.analysis?.blocking_type if (failure === true) { color = colorError @@ -438,6 +439,7 @@ const ResultsList = ({ results }) => { {results.map((msmt, idx) => { + // biome-ignore lint/suspicious/noArrayIndexKey: return })} diff --git a/components/utils.js b/components/utils.js index f2748c20..4b203aa3 100644 --- a/components/utils.js +++ b/components/utils.js @@ -14,10 +14,10 @@ export const getTestMetadata = (testName) => { return metadata } const group = testGroups[test.group] - metadata['name'] = test.name - metadata['groupName'] = group.name - metadata['icon'] = group.icon - metadata['color'] = group.color - metadata['info'] = test.info + metadata.name = test.name + metadata.groupName = group.name + metadata.icon = group.icon + metadata.color = group.color + metadata.info = test.info return metadata } diff --git a/cypress/e2e/mat.e2e.cy.js b/cypress/e2e/mat.e2e.cy.js index 132cf775..1c7fe0fa 100644 --- a/cypress/e2e/mat.e2e.cy.js +++ b/cypress/e2e/mat.e2e.cy.js @@ -6,7 +6,7 @@ describe('MAT Tests', () => { '?probe_cc=IR&test_name=web_connectivity&category_code=NEWS&since=2022-03-01&until=2022-04-01&axis_x=measurement_start_day&axis_y=probe_asn' const search2Obj = (url) => { - const u = new URL('http://localhost/' + url) + const u = new URL(`http://localhost/${url}`) return Object.fromEntries(u.searchParams.entries()) } cy.visit(testPath + testParams) @@ -29,6 +29,7 @@ describe('MAT Tests', () => { cy.get('h1').contains('Measurement Aggregation Toolkit') }) + // biome-ignore lint/suspicious/noFocusedTests: it.only('Clicking Submit button loads table and charts', () => { cy.get('button[data-test-id=mat-form-submit]').click() cy.contains('Web Connectivity Test') diff --git a/pages/404.js b/pages/404.js index e57e31a5..ab8438dd 100644 --- a/pages/404.js +++ b/pages/404.js @@ -42,6 +42,7 @@ const Custom404 = () => { {(message) => ( + // biome-ignore lint/a11y/useValidAnchor: { diff --git a/pages/_document.js b/pages/_document.js index cc3cb56b..fea53aeb 100644 --- a/pages/_document.js +++ b/pages/_document.js @@ -2,8 +2,8 @@ import { getDirection } from 'components/withIntl' // updated based on documentation: https://github.com/vercel/next.js/blob/canary/examples/with-styled-components/pages/_document.tsx import Document, { DocumentContext, - Html, Head, + Html, Main, NextScript, } from 'next/document' @@ -38,7 +38,7 @@ export default class MyDocument extends Document { src="https://eu.umami.is/script.js" data-website-id="6c9769aa-4b46-4d8d-82a9-a5a6d77206c4" data-domains="explorer.ooni.org" - > + /> diff --git a/pages/api/cloudflare.js b/pages/api/cloudflare.js index f57d8dc8..7449baf3 100644 --- a/pages/api/cloudflare.js +++ b/pages/api/cloudflare.js @@ -51,8 +51,8 @@ const cloudflareHandler = (req, res) => { const diff = dayjs(dateEnd).diff(dayjs(dateStart), 'day') const aggInterval = diff <= 30 ? '1h' : '1d' const targetParam = asn ? `asn=${asn}` : `location=${country}` - const formattedFrom = dateStart.split('.')[0] + 'Z' - const formattedTo = dateEnd.split('.')[0] + 'Z' + const formattedFrom = `${dateStart.split('.')[0]}Z` + const formattedTo = `${dateEnd.split('.')[0]}Z` return axios({ method: 'get', diff --git a/pages/api/ioda.js b/pages/api/ioda.js index 894e24b2..b64aae5d 100644 --- a/pages/api/ioda.js +++ b/pages/api/ioda.js @@ -1,4 +1,3 @@ -import https from 'https' import axios from 'axios' import dayjs from 'services/dayjs' @@ -44,12 +43,13 @@ const iodaHandler = (req, res) => { .map((item, i) => { const max = Math.max(...item.values) const values = item.values.map((val, i) => { - const time = + const time = `${ dayjs(item.from * 1000) .add(item.step * i, 'second') .utc() .toISOString() - .split('.')[0] + 'Z' + .split('.')[0] + }Z` return { x: time, y: val ? val / max : null } }) return { datasource: item.datasource, values } diff --git a/pages/country/[countryCode].js b/pages/country/[countryCode].js index 932daff1..8eab14a0 100644 --- a/pages/country/[countryCode].js +++ b/pages/country/[countryCode].js @@ -74,7 +74,7 @@ const Country = ({ }) => { return ( <> - {!!error ? ( + {error ? ( ) : ( { { since, until }, )} - {!!blockedCountries?.length ? ( + {blockedCountries?.length ? ( <> {intl.formatMessage({ id: 'Domain.CountriesBlocking.Subtitle' })} diff --git a/pages/findings/index.js b/pages/findings/index.js index 934f35f3..75946fc9 100644 --- a/pages/findings/index.js +++ b/pages/findings/index.js @@ -3,14 +3,12 @@ import HighlightBox from 'components/landing/HighlightBox' import SpinLoader from 'components/vendor/SpinLoader' import useFilterWithSort from 'hooks/useFilterWithSort' import useUser from 'hooks/useUser' -import Head from 'next/head' import NLink from 'next/link' import { Box, Button, Container, Flex, - Heading, Input, Select, Text, diff --git a/pages/index.js b/pages/index.js index 0f8f52f4..8162e669 100644 --- a/pages/index.js +++ b/pages/index.js @@ -2,7 +2,6 @@ import axios from 'axios' import Head from 'next/head' import NLink from 'next/link' -import Router from 'next/router' import { Box, Button, diff --git a/pages/measurement/[[...report_id]].js b/pages/measurement/[[...report_id]].js index e1b6abee..8d774037 100644 --- a/pages/measurement/[[...report_id]].js +++ b/pages/measurement/[[...report_id]].js @@ -28,7 +28,7 @@ export async function getServerSideProps({ query }) { full: true, } if (query.input) { - params['input'] = query.input + params.input = query.input } let response diff --git a/pages/search.js b/pages/search.js index fedc8f7f..cb09e43e 100644 --- a/pages/search.js +++ b/pages/search.js @@ -9,12 +9,12 @@ import dayjs from 'services/dayjs' import styled from 'styled-components' import dynamic from 'next/dynamic' +import { sortByKey } from '../utils' import FormattedMarkdown from '/components/FormattedMarkdown' import FilterSidebar, { queryToFilterMap, } from '/components/search/FilterSidebar' import ResultsList from '/components/search/ResultsList' -import { sortByKey } from '../utils' const Loader = dynamic(() => import('/components/search/Loader'), { ssr: false, @@ -53,8 +53,8 @@ export const getServerSideProps = async ({ query }) => { } const queryToParams = ({ query }) => { - let params = {}, - show = 50 + const params = {} + let show = 50 const supportedParams = [ 'probe_cc', 'domain', @@ -70,11 +70,11 @@ const queryToParams = ({ query }) => { if (query.show) { show = Number.parseInt(query.show) } - params['limit'] = show + params.limit = show // Allow only `failure=false`. `true` results in showing only failures - if ('failure' in query && query['failure'] === false) { - params['failure'] = false + if ('failure' in query && query.failure === false) { + params.failure = false } for (const p of supportedParams) { @@ -84,9 +84,9 @@ const queryToParams = ({ query }) => { } if (query.only) { if (query.only === 'anomalies') { - params['anomaly'] = true + params.anomaly = true } else if (query.only === 'confirmed') { - params['confirmed'] = true + params.confirmed = true } } return params @@ -125,7 +125,7 @@ const StyledPre = styled.pre` const ErrorBox = ({ error }) => { if (!error) { - return + return } const { stack, ...restOfError } = error @@ -182,6 +182,7 @@ const Search = ({ countries, query: queryProp }) => { const [results, setResults] = useState([]) const [error, setError] = useState(null) + // biome-ignore lint/correctness/useExhaustiveDependencies: useEffect(() => { const q = query || queryProp const href = { @@ -275,7 +276,7 @@ const Search = ({ countries, query: queryProp }) => { if (queryParam in query) { delete query[queryParam] } - } else if (key === 'onlyFilter' && state[key] == 'all') { + } else if (key === 'onlyFilter' && state[key] === 'all') { // If the onlyFilter is not set to 'confirmed' or 'anomalies' // remove it from the path if (queryParam in query) {