Skip to content

Commit

Permalink
Adding eslint spacing rule and update deps (#897)
Browse files Browse the repository at this point in the history
* Adding eslint spacing rule and update deps

* Cleaning up imports

* Remove unused Device wrapper

* Removing Today page

* Removing Today reference
  • Loading branch information
devinmatte committed Dec 17, 2023
1 parent 2a07bcb commit 39c00a4
Show file tree
Hide file tree
Showing 38 changed files with 641 additions and 470 deletions.
14 changes: 14 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,21 @@ module.exports = {
'import/no-self-import': 'error',
'import/no-default-export': 'warn',
'import/order': 'error',
'import/newline-after-import': 'error',
'import/no-unused-modules': ['warn', { unusedExports: true }],
'import/no-useless-path-segments': [
'error',
{
noUselessIndex: true,
},
],
'import/max-dependencies': [
'warn',
{
max: 20,
ignoreTypeImports: false,
},
],
'prettier/prettier': 'error',
'react/prop-types': 'warn',
'react/jsx-no-target-blank': 'warn',
Expand Down
2 changes: 1 addition & 1 deletion common/api/datadashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type {
SingleDayAPIOptions,
BusOrSubway,
} from '../types/api';
import { APP_DATA_BASE_PATH } from '../../common/utils/constants';
import { APP_DATA_BASE_PATH } from '../utils/constants';
import { getCurrentDate } from '../utils/date';
import type { AggregateDataResponse, SingleDayDataPoint } from '../types/charts';
import { ONE_MINUTE } from '../constants/time';
Expand Down
6 changes: 1 addition & 5 deletions common/api/slowzones.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
DayDelayTotals,
SlowZoneResponse,
SpeedRestriction,
} from '../../common/types/dataPoints';
import type { DayDelayTotals, SlowZoneResponse, SpeedRestriction } from '../types/dataPoints';
import type { FetchSpeedRestrictionsOptions, FetchSpeedRestrictionsResponse } from '../types/api';
import { getGtfsRailLineId } from '../utils/lines';
import { apiFetch } from './utils/fetch';
Expand Down
2 changes: 1 addition & 1 deletion common/components/charts/AggregateLineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, { useMemo, useRef } from 'react';
import ChartjsPluginWatermark from 'chartjs-plugin-watermark';
import type { AggregateDataPoint, AggregateLineProps } from '../../types/charts';
import { prettyDate } from '../../utils/date';
import { CHART_COLORS } from '../../../common/constants/colors';
import { CHART_COLORS } from '../../constants/colors';
import { DownloadButton } from '../buttons/DownloadButton';
import { useBreakpoint } from '../../hooks/useBreakpoint';
import { watermarkLayout } from '../../constants/charts';
Expand Down
1 change: 1 addition & 0 deletions common/components/charts/CarouselGraphDiv.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

interface CarouselGraphDivProps {
children: React.ReactNode;
}
Expand Down
1 change: 1 addition & 0 deletions common/components/charts/ChartDiv.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import classNames from 'classnames';
import React from 'react';

interface ChartDivProps {
children: React.ReactNode;
isMobile?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions common/components/charts/SingleDayLineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { enUS } from 'date-fns/locale';
import React, { useMemo, useRef } from 'react';
import ChartjsPluginWatermark from 'chartjs-plugin-watermark';
import type { DataPoint } from '../../types/dataPoints';
import { CHART_COLORS, COLORS } from '../../../common/constants/colors';
import { CHART_COLORS, COLORS } from '../../constants/colors';
import { useAlertStore } from '../../../modules/tripexplorer/AlertStore';
import type { SingleDayLineProps } from '../../../common/types/charts';
import type { SingleDayLineProps } from '../../types/charts';
import { getAlertAnnotations } from '../../../modules/service/utils/graphUtils';
import { prettyDate } from '../../utils/date';
import { DownloadButton } from '../buttons/DownloadButton';
Expand Down
4 changes: 2 additions & 2 deletions common/components/charts/TimeSeriesChart/TimeSeriesChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ export const TimeSeriesChart = <Data extends Dataset[]>(props: Props<Data>) => {
'granularity' in providedTimeAxis
? providedTimeAxis.granularity
: 'agg' in providedTimeAxis && providedTimeAxis.agg
? getGranularityForAgg(providedTimeAxis.agg)
: null;
? getGranularityForAgg(providedTimeAxis.agg)
: null;
return { ...getDefaultTimeAxis(providedGranularity ?? null), ...providedTimeAxis };
}, [providedTimeAxis]);

Expand Down
4 changes: 2 additions & 2 deletions common/components/charts/TimeSeriesChart/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ export const getFillProps = (style: AppliedDisplayStyle<DataPoint>) => {
fillPattern === 'solid'
? resolvedFillColor
: fillPattern === 'slightly-transparent'
? hexWithAlpha(resolvedFillColor, 0.8)
: pattern.draw('diagonal', 'transparent', resolvedFillColor, 5);
? hexWithAlpha(resolvedFillColor, 0.8)
: pattern.draw('diagonal', 'transparent', resolvedFillColor, 5);
return {
fill: true,
backgroundColor,
Expand Down
12 changes: 0 additions & 12 deletions common/components/general/Device/Device.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions common/components/general/Device/index.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions common/components/maps/LineMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ export const LineMap: React.FC<LineMapProps> = ({
tooltipSide === 'top'
? `translate(-50%, -100%)`
: tooltipSide === 'left'
? `translate(-100%, -50%)`
: `translateY(-50%)`,
? `translate(-100%, -50%)`
: `translateY(-50%)`,
}}
>
{tooltipContents}
Expand Down
1 change: 1 addition & 0 deletions common/components/nav/BusRouteSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useRouter } from 'next/navigation';
import React, { Fragment } from 'react';
import { getBusRoutes } from '../../constants/stations';
import { getBusRouteSelectionItemHref, useDelimitatedRoute } from '../../utils/router';

export const BusRouteSelection: React.FC = () => {
const route = useDelimitatedRoute();
const router = useRouter();
Expand Down
1 change: 1 addition & 0 deletions common/components/nav/NavSectionHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

interface NavSectionHeaderProps {
title: string;
}
Expand Down
1 change: 1 addition & 0 deletions common/components/widgets/internal/UnitText.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import classNames from 'classnames';
import React from 'react';

export interface UnitTextProps {
text: string;
isLarge?: boolean;
Expand Down
11 changes: 0 additions & 11 deletions common/constants/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export type Page = keyof typeof PAGES;

export enum PAGES {
landing = 'landing',
today = 'today',
overview = 'overview',
speed = 'speed',
predictions = 'predictions',
Expand Down Expand Up @@ -62,14 +61,6 @@ export const ALL_PAGES: PageMap = {
icon: faHouse,
dateStoreSection: 'landing',
},
today: {
key: 'today',
path: '/',
name: 'Today',
lines: ['line-red', 'line-blue', 'line-green', 'line-orange'],
icon: faHouse,
dateStoreSection: 'today',
},
singleTrips: {
key: 'singleTrips',
path: '/trips/single',
Expand Down Expand Up @@ -159,8 +150,6 @@ export const ALL_PAGES: PageMap = {
/* Groups of pages for tab sections */
export const TRIP_PAGES = [ALL_PAGES.singleTrips, ALL_PAGES.multiTrips];

export const TODAY = [ALL_PAGES.today];

export const BUS_OVERVIEW = [ALL_PAGES.ridership];

export const OVERVIEW_PAGE = [ALL_PAGES.overview];
Expand Down
1 change: 1 addition & 0 deletions common/layouts/LandingLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

interface LandingLayoutProps {
children: React.ReactNode;
}
Expand Down
5 changes: 3 additions & 2 deletions common/layouts/Layouts.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ReactNode } from 'react';
import { DashboardLayout } from '../layouts/DashboardLayout';
import { LandingLayout } from '../layouts/LandingLayout';
import { DashboardLayout } from './DashboardLayout';
import { LandingLayout } from './LandingLayout';
import type { LayoutNames } from './layoutTypes';

export const Layouts: { [key in LayoutNames]: ({ children }) => ReactNode } = {
Landing: LandingLayout,
Dashboard: DashboardLayout,
Expand Down
1 change: 1 addition & 0 deletions common/types/basicWidgets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import duration from 'dayjs/plugin/duration';
import { getFormattedTimeValue, getTimeUnit } from '../utils/time';
import { WidgetText } from '../components/widgets/internal/WidgetText';
import { UnitText } from '../components/widgets/internal/UnitText';

dayjs.extend(duration);

export interface WidgetValueInterface {
Expand Down
9 changes: 2 additions & 7 deletions common/utils/slowZoneUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ import utc from 'dayjs/plugin/utc';
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import { useMemo } from 'react';
import type { Station } from '../../common/types/stations';
import type {
DayDelayTotals,
Direction,
SlowZone,
SlowZoneResponse,
} from '../../common/types/dataPoints';
import type { Station } from '../types/stations';
import type { DayDelayTotals, Direction, SlowZone, SlowZoneResponse } from '../types/dataPoints';
import { TODAY_MIDNIGHT } from '../constants/dates';
import type { LineShort } from '../types/lines';
import { getParentStationForStopId } from './stations';
Expand Down
6 changes: 3 additions & 3 deletions common/utils/stations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Line, LineShort } from '../../common/types/lines';
import { isLineMap, type Station } from '../../common/types/stations';
import type { Line, LineShort } from '../types/lines';
import { isLineMap, type Station } from '../types/stations';
import type { Location } from '../types/charts';
import type { Direction } from '../types/dataPoints';
import { stations, rtStations, busStations } from './../constants/stations';
import { stations, rtStations, busStations } from '../constants/stations';

export const optionsForField = (
type: 'from' | 'to',
Expand Down
1 change: 1 addition & 0 deletions common/utils/time.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import duration from 'dayjs/plugin/duration';

import { WidgetText } from '../components/widgets/internal/WidgetText';
import { UnitText } from '../components/widgets/internal/UnitText';

dayjs.extend(duration);

export const getTimeUnit = (value: number) => {
Expand Down
1 change: 1 addition & 0 deletions copy/landingCopy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import type { LandingCharts } from '../modules/landing/types';

const DESCRIPTION_STYLE = 'text-stone-900 text-lg';
const BASELINE_STYLE = 'text-stone-900 italic text-xs text-center';

Expand Down
54 changes: 0 additions & 54 deletions modules/dashboard/Today.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions modules/dashboard/TodayContainer.tsx

This file was deleted.

1 change: 1 addition & 0 deletions modules/landing/LandingChartDiv.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';

interface LandingChartDivProps {
children: React.ReactElement[];
}
Expand Down
1 change: 1 addition & 0 deletions modules/landing/LineButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classNames from 'classnames';
import type { Line } from '../../common/types/lines';
import { lineColorBackground, lineColorBorder } from '../../common/styles/general';
import { LINE_OBJECTS } from '../../common/constants/lines';

interface LineButtonProps {
children: React.ReactNode;
line: Line;
Expand Down
1 change: 1 addition & 0 deletions modules/predictions/PredictionsDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Accordion } from '../../common/components/accordion/Accordion';
import { lineToDefaultRouteId } from './utils/utils';
import { PredictionsGraphWrapper } from './charts/PredictionsGraphWrapper';
import { PredictionsBinsGraphWrapper } from './charts/PredictionsBinsGraphWrapper';

dayjs.extend(utc);

enum GreenLineBranchOptions {
Expand Down
1 change: 1 addition & 0 deletions modules/ridership/RidershipGraphWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { BusRoute, Line } from '../../common/types/lines';
import { NoDataNotice } from '../../common/components/notices/NoDataNotice';
import { getRidershipWidgetValues } from './utils/utils';
import { RidershipGraph } from './RidershipGraph';

interface RidershipGraphWrapperProps {
data: RidershipCount[];
line?: Line;
Expand Down
1 change: 1 addition & 0 deletions modules/service/ServiceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { WidgetTitle } from '../dashboard/WidgetTitle';
import { ServiceGraphWrapper } from './ServiceGraphWrapper';
import { PercentageServiceGraphWrapper } from './PercentageServiceGraphWrapper';
import { ServiceHoursGraph } from './ServiceHoursGraph';

dayjs.extend(utc);

export function ServiceDetails() {
Expand Down
1 change: 1 addition & 0 deletions modules/service/ServiceGraphWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { CarouselGraphDiv } from '../../common/components/charts/CarouselGraphDi
import { NoDataNotice } from '../../common/components/notices/NoDataNotice';
import { getServiceWidgetValues } from './utils/utils';
import { ServiceGraph } from './ServiceGraph';

interface ServiceGraphWrapperProps {
data: DeliveredTripMetrics[];
predictedData: ScheduledService;
Expand Down
1 change: 1 addition & 0 deletions modules/slowzones/SlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { TotalSlowTimeWrapper } from './TotalSlowTimeWrapper';
import { SlowZonesMap } from './map';
import { DirectionObject } from './constants/constants';
import { SlowZonesWidgetTitle } from './SlowZonesWidgetTitle';

dayjs.extend(utc);

export function SlowZonesDetails() {
Expand Down
1 change: 1 addition & 0 deletions modules/slowzones/SlowZonesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useSlowzoneDelayTotalData } from '../../common/api/hooks/slowzones';
import { WidgetDiv } from '../../common/components/widgets/WidgetDiv';
import { OVERVIEW_OPTIONS } from '../../common/constants/dates';
import { TotalSlowTimeWrapper } from './TotalSlowTimeWrapper';

dayjs.extend(utc);

export const SlowZonesWidget: React.FC = () => {
Expand Down
1 change: 1 addition & 0 deletions modules/slowzones/charts/LineSegments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { watermarkLayout } from '../../../common/constants/charts';
import { stopIdsForStations } from '../../../common/utils/stations';
import { ALL_PAGES } from '../../../common/constants/pages';
import type { QueryParams } from '../../../common/types/router';

dayjs.extend(utc);
dayjs.extend(minMax);

Expand Down
4 changes: 2 additions & 2 deletions modules/slowzones/map/SlowSegmentLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const SlowZoneLabel: React.FC<SlowZoneLabelProps> = ({
? '❮'
: '▲'
: isHorizontal
? '❯'
: '▼';
? '❯'
: '▼';
const fractionOverBaseline = -1 + (delay + baseline) / baseline;
const isBold = fractionOverBaseline >= 0.5;

Expand Down
Loading

0 comments on commit 39c00a4

Please sign in to comment.