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

chore: add eslint import order rule #781

Merged
merged 3 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = [
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'import/no-unused-modules': 'error',
'import/order': 'error',
'prettier/prettier': [
'error',
{
Expand Down
47 changes: 47 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
Expand Down
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import './App.scss'
import 'leaflet/dist/leaflet.css'
import 'moment/locale/he'
import router from './routes'
import { RouterProvider } from 'react-router-dom'
import { Suspense } from 'react'
import Preloader from './shared/Preloader'
import moment from 'moment-timezone'
import Preloader from './shared/Preloader'
import router from './routes'
import 'moment/dist/locale/he'

moment.tz.setDefault('Asia/Jerusalem')
Expand Down
2 changes: 1 addition & 1 deletion src/api/gapsService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import moment, { Moment } from 'moment-timezone'
import { GapsList } from '../model/gaps'
import axios, { CancelTokenSource } from 'axios'
import { GapsList } from '../model/gaps'
import { BASE_PATH } from './apiConfig'

type RawGapsList = {
Expand Down
2 changes: 1 addition & 1 deletion src/api/groupByService.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BASE_PATH } from './apiConfig'
import agencyList from 'open-bus-stride-client/agencies/agencyList'
import { Moment } from 'moment'
import { useQuery } from '@tanstack/react-query'
import { BASE_PATH } from './apiConfig'

type groupByField =
| 'gtfs_route_date'
Expand Down
4 changes: 2 additions & 2 deletions src/api/siriService.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { SiriApi, SiriVehicleLocationWithRelatedPydanticModel } from 'open-bus-stride-client'
import moment, { Moment } from 'moment'
import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client/openapi/models/SiriRideWithRelatedPydanticModel'
import { API_CONFIG, MAX_HITS_COUNT } from 'src/api/apiConfig'
import { BusStop } from 'src/model/busStop'
import moment, { Moment } from 'moment'
import { geoLocationBoundary, nearestLocation } from 'src/api/geoService'
import { Coordinates } from 'src/model/location'
import { BusRoute } from 'src/model/busRoute'
import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client/openapi/models/SiriRideWithRelatedPydanticModel'

const SIRI_API = new SiriApi(API_CONFIG)
const LOCATION_DELTA_METERS = 500
Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'
import App from './App'
import ReactGA from 'react-ga4'
import './locale/allTranslations'
import { QueryClient } from '@tanstack/react-query'
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister'
import App from './App'

const persister = createSyncStoragePersister({
storage: window.localStorage,
Expand Down
4 changes: 2 additions & 2 deletions src/layout/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Layout } from 'antd'
import { useContext } from 'react'
import { MenuOutlined } from '@ant-design/icons'
import cn from 'classnames'
import { LayoutContextInterface, LayoutCtx } from '../LayoutContext'
import { useTheme } from '../ThemeContext'
import { MenuOutlined } from '@ant-design/icons'
import './Header.css'
import cn from 'classnames'
import ToggleThemeButton from './ToggleThemeButton'
import { DonationButton } from './DonationButton'
import HeaderLinks from './HeaderLinks/HeaderLinks'
Expand Down
6 changes: 3 additions & 3 deletions src/layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Layout } from 'antd'
import MainHeader from './header/Header'
import SideBar from './sidebar/SideBar'
import styled from 'styled-components'
import LayoutContext from './LayoutContext'
import { Link, Outlet } from 'react-router-dom'
import { Suspense } from 'react'
import MainHeader from './header/Header'
import SideBar from './sidebar/SideBar'
import LayoutContext from './LayoutContext'
import Preloader from 'src/shared/Preloader'
import { EasterEgg } from 'src/pages/EasterEgg/EasterEgg'
import { Envelope } from 'src/pages/EasterEgg/Envelope'
Expand Down
6 changes: 3 additions & 3 deletions src/layout/sidebar/SideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Menu from './menu/Menu'
import './sidebar.scss'
import { Drawer, Layout } from 'antd'
import { useContext, useState } from 'react'
import { LayoutContextInterface, LayoutCtx } from '../LayoutContext'
import { Link } from 'react-router-dom'
import { PAGES } from 'src/routes'
import { LayoutContextInterface, LayoutCtx } from '../LayoutContext'
import Menu from './menu/Menu'
import { Logo } from './logo'
import { PAGES } from 'src/routes'
const { Sider } = Layout

const CollapsedLogo = () => <h1 className={'sidebar-logo-collapsed'}>🚌</h1>
Expand Down
2 changes: 1 addition & 1 deletion src/layout/sidebar/logo.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next'
import { useTheme } from '../ThemeContext'
import cn from 'classnames'
import { useTheme } from '../ThemeContext'

export function Logo() {
const { isDarkTheme } = useTheme()
Expand Down
2 changes: 1 addition & 1 deletion src/layout/sidebar/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React, { useEffect, useState, useContext } from 'react'
import { Link, useLocation } from 'react-router-dom'
import './menu.scss'
import { useTranslation } from 'react-i18next'
import { PAGES } from 'src/routes'

import type { MenuProps } from 'antd'
import { Menu } from 'antd'
import { PAGES } from 'src/routes'
import { LayoutContextInterface, LayoutCtx } from 'src/layout/LayoutContext'
type MenuItem = Required<MenuProps>['items'][number]
function getItem(
Expand Down
4 changes: 2 additions & 2 deletions src/model/pageState.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { BusRoute } from './busRoute'
import { BusStop } from './busStop'
import { createContext, Dispatch } from 'react'
import moment from 'moment'
import {
GtfsRideStopPydanticModel,
SiriVehicleLocationWithRelatedPydanticModel,
} from 'open-bus-stride-client'
import { BusStop } from './busStop'
import { BusRoute } from './busRoute'
import { Coordinates } from './location'

export type PageSearchState = {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/DataResearch/DataResearch.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useMemo, useState } from 'react'
import { useGroupBy } from 'src/api/groupByService'
import Widget from 'src/shared/Widget'
import { useDate } from '../components/DateTimePicker'
import moment from 'moment'
import { Grid } from '@mui/material'
import { DateSelector } from '../components/DateSelector'
import { useTranslation } from 'react-i18next'
import { Skeleton } from 'antd'
import {
Expand All @@ -16,10 +12,14 @@ import {
XAxis,
YAxis,
} from 'recharts'
import { DateSelector } from '../components/DateSelector'
import { useDate } from '../components/DateTimePicker'
import { PageContainer } from '../components/PageContainer'
import { getColorName } from '../dashboard/AllLineschart/OperatorHbarChart/OperatorHbarChart'
import './DataResearch.scss'
import OperatorSelector from '../components/OperatorSelector'
import { useGroupBy } from 'src/api/groupByService'
import Widget from 'src/shared/Widget'

const now = moment()
const unique: (value: string, index: number, self: string[]) => boolean = (value, index, self) =>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/about/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import styled from 'styled-components'
import SlackIcon from '../../resources/slack-icon.svg'
import { Trans, useTranslation } from 'react-i18next'
import Widget from 'src/shared/Widget'
import Typography from '@mui/material/Typography'
import Stack from '@mui/material/Stack'
import './About.scss'
import { useQuery } from '@tanstack/react-query'
import SlackIcon from '../../resources/slack-icon.svg'
import Widget from 'src/shared/Widget'

const pageName = 'aboutPage'
const About = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/DateSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState, useMemo } from 'react'
import { DatePicker } from '@mui/x-date-pickers/DatePicker'
import { useTranslation } from 'react-i18next'
import { DataAndTimeSelectorProps } from './utils/dateAndTime'
import { DateValidationError } from '@mui/x-date-pickers'
import { DataAndTimeSelectorProps } from './utils/dateAndTime'

export function DateSelector({ time, onChange, customLabel, minDate }: DataAndTimeSelectorProps) {
const [error, setError] = useState<DateValidationError | null>(null)
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/LineSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useCallback, useLayoutEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import debounce from 'lodash.debounce'
import { TextField } from '@mui/material'
import classNames from 'classnames'
import ClearButton from './ClearButton'
import './Selector.scss'
import classNames from 'classnames'

type LineSelectorProps = {
lineNumber: string | undefined
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/MinuteSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useTranslation } from 'react-i18next'
import { TextField } from '@mui/material'
import classNames from 'classnames'
import ClearButton from './ClearButton'
import './Selector.scss'
import classNames from 'classnames'

type MinuteSelectorProps = {
num: number
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/OperatorSelector.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react'
import '../../shared/shared.css'
import OperatorSelector from './OperatorSelector'
import { useState } from 'react'
import OperatorSelector from './OperatorSelector'
import { MAJOR_OPERATORS } from 'src/model/operator'

const OperatorSelectorStory = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/components/OperatorSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Operator, getOperators } from 'src/model/operator'
import { Autocomplete, TextField } from '@mui/material'
import { Operator, getOperators } from 'src/model/operator'

type OperatorSelectorProps = {
operatorId?: string
Expand Down
4 changes: 2 additions & 2 deletions src/pages/components/RouteSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { formatted } from 'src/locale/utils'
import { BusRoute } from 'src/model/busRoute'
import { Autocomplete, TextField } from '@mui/material'
import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { TFunction } from 'i18next'
import { BusRoute } from 'src/model/busRoute'
import { formatted } from 'src/locale/utils'

type RouteSelectorProps = {
routes: BusRoute[]
Expand Down
4 changes: 2 additions & 2 deletions src/pages/components/StopSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { formatted } from 'src/locale/utils'
import { BusStop } from 'src/model/busStop'
import { Autocomplete, TextField } from '@mui/material'
import { useTranslation } from 'react-i18next'
import { formatted } from 'src/locale/utils'
import { BusStop } from 'src/model/busStop'

type StopSelectorProps = {
stops: BusStop[]
Expand Down
4 changes: 2 additions & 2 deletions src/pages/components/map-related/MapContent.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { t } from 'i18next'
import { useRef } from 'react'
import { Marker, Polyline, Popup, TileLayer, useMap } from 'react-leaflet'
import { Icon, IconOptions, Marker as LeafletMarker } from 'leaflet'
import { useAgencyList } from 'src/api/agencyList'
import { busIcon, busIconPath } from '../utils/BusIcon'
import { BusToolTip } from './MapLayers/BusToolTip'
import { t } from 'i18next'
import '../../Map.scss'
import { MapProps } from './map-types'
import { useRecenterOnDataChange } from './useRecenterOnDataChange'
import { MapIndex } from './MapIndex'
import MapFooterButtons from './MapFooterButtons/MapFooterButtons'
import { useAgencyList } from 'src/api/agencyList'

export function MapContent({ positions, plannedRouteStops, showNavigationButtons }: MapProps) {
useRecenterOnDataChange({ positions, plannedRouteStops })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react'
import { BusToolTip, BusToolTipProps } from './BusToolTip'
import { BrowserRouter } from 'react-router-dom'
import { BusToolTip, BusToolTipProps } from './BusToolTip'

const meta = {
title: 'Components/MapLayers/BusToolTip',
Expand Down
4 changes: 2 additions & 2 deletions src/pages/components/map-related/MapLayers/BusToolTip.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ReactNode, useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import { Point } from 'src/pages/timeBasedMap'
import { Button } from '@mui/material'
import moment from 'moment-timezone'
import './BusToolTip.scss'
import { getSiriRideWithRelated } from 'src/api/siriService'
import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client/openapi/models/SiriRideWithRelatedPydanticModel'
import { useTranslation } from 'react-i18next'
import CircularProgress from '@mui/material/CircularProgress'
import cn from 'classnames'
import CustomTreeView from '../../CustomTreeView'
import { getSiriRideWithRelated } from 'src/api/siriService'
import { Point } from 'src/pages/timeBasedMap'

export type BusToolTipProps = { position: Point; icon: string; children?: ReactNode }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MapContainer } from 'react-leaflet'
import { Point } from 'src/pages/timeBasedMap'
import { useCallback, useState } from 'react'
import IconButton from '@mui/material/IconButton'
import OpenInFullRoundedIcon from '@mui/icons-material/OpenInFullRounded'
import { MapProps } from './map-types'
import { useCallback, useState } from 'react'
import '../../Map.scss'
import { MapContent } from './MapContent'
import { Point } from 'src/pages/timeBasedMap'

const position: Point = {
loc: [32.3057988, 34.85478613], // arbitrary default value... Netanya - best city to live & die in
Expand Down
Loading
Loading