diff --git a/.eslintrc b/.eslintrc index de39549..1a536d5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -21,7 +21,8 @@ "react-hooks", "jsx-a11y", "import", - "unused-imports" + "unused-imports", + "simple-import-sort" ], "settings": { "react": { @@ -32,6 +33,23 @@ "object-shorthand": "error", "no-undef": "off", "no-duplicate-imports": "error", + "import/first": "error", + "import/newline-after-import": "error", + "import/no-duplicates": "error", + "simple-import-sort/exports": "error", + "simple-import-sort/imports": [ + "error", + { + "groups": [ + ["^react", "^@?\\w"], + ["^(@components|@models|@services|@stores|@hooks|@helpers|@utils|@tests)(/.*|$)"], + ["^\\u0000"], + ["^\\.\\.(?!/?$)", "^\\.\\./?$"], + ["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"], + ["^.+\\.s?css$"] + ] + } + ], "@typescript-eslint/consistent-type-imports": [ "error", { @@ -44,22 +62,6 @@ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" } - ], - "import/order": [ - "error", - { - "newlines-between": "always", - "alphabetize": { - "order": "asc" - }, - "groups": [ - "builtin", - "external", - "internal", - "parent", - ["index", "sibling"] - ] - } ] } } diff --git a/package.json b/package.json index 9b5e79b..2509da5 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "eslint:fix": "eslint --fix .", "prettier:check": "prettier --check .", "prettier:write": "prettier --write .", - "test": "DEBUG_PRINT_LIMIT=30000 jest --config tests/jest.config.js", + "test": "DEBUG_PRINT_LIMIT=30000 jest --silent --config tests/jest.config.js", "test:watch": "yarn test --watch", "test:coverage": "yarn test --coverage", "test:clear-cache": "jest --clearCache", @@ -97,6 +97,7 @@ "eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-simple-import-sort": "^12.1.1", "eslint-plugin-unused-imports": "^3.0.0", "husky": "^8.0.3", "jest": "^29.7.0", diff --git a/src/components/App.test.tsx b/src/components/App.test.tsx index dd5cf08..89fa5d3 100644 --- a/src/components/App.test.tsx +++ b/src/components/App.test.tsx @@ -1,9 +1,10 @@ -import { generateCalendarRange } from '@helpers'; -import { getWeeksInMonth } from '@internationalized/date'; -import { act, render } from '@testing-library/react'; import React from 'react'; import { useCalendar } from 'react-aria'; import { useCalendarState } from 'react-stately'; +import { getWeeksInMonth } from '@internationalized/date'; +import { act, render } from '@testing-library/react'; + +import { generateCalendarRange } from '@helpers'; import App from './App'; diff --git a/src/components/App.tsx b/src/components/App.tsx index 80ca566..6669c32 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -1,14 +1,15 @@ +import React from 'react'; +import { Navigate, Route, Routes } from 'react-router-dom'; +import { setDefaultOptions } from 'date-fns'; +import { enGB } from 'date-fns/locale'; + import { + AccountPage, AppHeader, Calendar, - AccountPage, HabitsPage, Snackbars, } from '@components'; -import { setDefaultOptions } from 'date-fns'; -import { enGB } from 'date-fns/locale'; -import React from 'react'; -import { Navigate, Route, Routes } from 'react-router-dom'; import Providers from './Providers'; diff --git a/src/components/Providers.tsx b/src/components/Providers.tsx index 6bd6e0c..375336d 100644 --- a/src/components/Providers.tsx +++ b/src/components/Providers.tsx @@ -1,9 +1,10 @@ -import { supabaseClient } from '@helpers'; -import { NextUIProvider } from '@nextui-org/react'; -import { SessionContextProvider } from '@supabase/auth-helpers-react'; import React, { type ReactNode } from 'react'; import { I18nProvider } from 'react-aria'; import { BrowserRouter, useNavigate } from 'react-router-dom'; +import { NextUIProvider } from '@nextui-org/react'; +import { SessionContextProvider } from '@supabase/auth-helpers-react'; + +import { supabaseClient } from '@helpers'; type ProviderProps = { children: ReactNode; diff --git a/src/components/calendar/Calendar.test.tsx b/src/components/calendar/Calendar.test.tsx index 9cb6d21..7389e94 100644 --- a/src/components/calendar/Calendar.test.tsx +++ b/src/components/calendar/Calendar.test.tsx @@ -1,5 +1,11 @@ import Calendar from './Calendar'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + describe(Calendar.name, () => { it('should be tested', () => { expect(true).toBeTruthy(); diff --git a/src/components/calendar/Calendar.tsx b/src/components/calendar/Calendar.tsx index eac3d52..74d19f2 100644 --- a/src/components/calendar/Calendar.tsx +++ b/src/components/calendar/Calendar.tsx @@ -1,11 +1,12 @@ +import React from 'react'; +import { type AriaButtonProps, useCalendar, useLocale } from 'react-aria'; +import { useCalendarState } from 'react-stately'; +import { CalendarDate, GregorianCalendar } from '@internationalized/date'; + import { generateCalendarRange } from '@helpers'; import { useDocumentTitle } from '@hooks'; -import { CalendarDate, GregorianCalendar } from '@internationalized/date'; import { useOccurrencesStore } from '@stores'; import { capitalizeFirstLetter } from '@utils'; -import React from 'react'; -import { type AriaButtonProps, useCalendar, useLocale } from 'react-aria'; -import { useCalendarState } from 'react-stately'; import CalendarGrid from './CalendarGrid'; import CalendarHeader from './CalendarHeader'; diff --git a/src/components/calendar/CalendarCell.test.tsx b/src/components/calendar/CalendarCell.test.tsx index dc19417..4ef64e5 100644 --- a/src/components/calendar/CalendarCell.test.tsx +++ b/src/components/calendar/CalendarCell.test.tsx @@ -1,5 +1,11 @@ import CalendarCell from './CalendarCell'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + describe(CalendarCell.name, () => { it('should render', () => { expect(true).toBe(true); diff --git a/src/components/calendar/CalendarCell.tsx b/src/components/calendar/CalendarCell.tsx index 014d31e..b1c2e69 100644 --- a/src/components/calendar/CalendarCell.tsx +++ b/src/components/calendar/CalendarCell.tsx @@ -1,11 +1,12 @@ -import { useScreenSize } from '@hooks'; +import React from 'react'; import { CalendarBlank } from '@phosphor-icons/react'; -import { useOccurrencesStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; import clsx from 'clsx'; import { format } from 'date-fns'; import { AnimatePresence, motion } from 'framer-motion'; -import React from 'react'; + +import { useScreenSize } from '@hooks'; +import { useOccurrencesStore } from '@stores'; import OccurrenceChip from './OccurrenceChip'; diff --git a/src/components/calendar/CalendarGrid.test.tsx b/src/components/calendar/CalendarGrid.test.tsx index e0dd002..f20a4c8 100644 --- a/src/components/calendar/CalendarGrid.test.tsx +++ b/src/components/calendar/CalendarGrid.test.tsx @@ -1,5 +1,11 @@ import CalendarGrid from './CalendarGrid'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + describe(CalendarGrid.name, () => { it('should be tested', () => { expect(true).toBeTruthy(); diff --git a/src/components/calendar/CalendarHeader.test.tsx b/src/components/calendar/CalendarHeader.test.tsx index 4646b2d..9f97a4e 100644 --- a/src/components/calendar/CalendarHeader.test.tsx +++ b/src/components/calendar/CalendarHeader.test.tsx @@ -1,8 +1,14 @@ -import { render } from '@testing-library/react'; import React from 'react'; +import { render } from '@testing-library/react'; import CalendarHeader, { type CalendarHeaderProps } from './CalendarHeader'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + describe(CalendarHeader.name, () => { const props: CalendarHeaderProps = { activeMonthLabel: 'January', diff --git a/src/components/calendar/CalendarHeader.tsx b/src/components/calendar/CalendarHeader.tsx index 9f26a51..4cefbc3 100644 --- a/src/components/calendar/CalendarHeader.tsx +++ b/src/components/calendar/CalendarHeader.tsx @@ -1,9 +1,10 @@ -import { useScreenSize } from '@hooks'; -import { Select, SelectItem, Button, SelectSection } from '@nextui-org/react'; +import React from 'react'; +import { Button, Select, SelectItem, SelectSection } from '@nextui-org/react'; import { ArrowFatLeft, ArrowFatRight } from '@phosphor-icons/react'; -import { useTraitsStore, useHabitsStore, useOccurrencesStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; -import React from 'react'; + +import { useScreenSize } from '@hooks'; +import { useHabitsStore, useOccurrencesStore, useTraitsStore } from '@stores'; type NavigationButtonProps = { disabled: boolean; diff --git a/src/components/calendar/CalendarMonthGrid.tsx b/src/components/calendar/CalendarMonthGrid.tsx index 68f694e..18f5960 100644 --- a/src/components/calendar/CalendarMonthGrid.tsx +++ b/src/components/calendar/CalendarMonthGrid.tsx @@ -1,8 +1,8 @@ -import { type CalendarDate, getWeeksInMonth } from '@internationalized/date'; -import clsx from 'clsx'; import React, { type ForwardedRef } from 'react'; import { useLocale } from 'react-aria'; import { type CalendarState } from 'react-stately'; +import { type CalendarDate, getWeeksInMonth } from '@internationalized/date'; +import clsx from 'clsx'; import CalendarCell from './CalendarCell'; diff --git a/src/components/calendar/DayHabitModalDialog.test.tsx b/src/components/calendar/DayHabitModalDialog.test.tsx index c3bd667..c573f9d 100644 --- a/src/components/calendar/DayHabitModalDialog.test.tsx +++ b/src/components/calendar/DayHabitModalDialog.test.tsx @@ -1,9 +1,10 @@ -import { useHabitsStore, useOccurrencesStore } from '@stores'; +import React from 'react'; import { useUser } from '@supabase/auth-helpers-react'; import { fireEvent, render, waitFor } from '@testing-library/react'; -import { makeTestHabit } from '@tests'; import { format } from 'date-fns'; -import React from 'react'; + +import { useHabitsStore, useOccurrencesStore } from '@stores'; +import { makeTestHabit } from '@tests'; import DayHabitModalDialog from './DayHabitModalDialog'; diff --git a/src/components/calendar/DayHabitModalDialog.tsx b/src/components/calendar/DayHabitModalDialog.tsx index c191e74..4389de4 100644 --- a/src/components/calendar/DayHabitModalDialog.tsx +++ b/src/components/calendar/DayHabitModalDialog.tsx @@ -1,17 +1,18 @@ +import React, { type MouseEventHandler } from 'react'; import { Button, Modal, - ModalContent, - ModalHeader, ModalBody, + ModalContent, ModalFooter, + ModalHeader, Select, SelectItem, } from '@nextui-org/react'; -import { useHabitsStore, useOccurrencesStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; import { format } from 'date-fns'; -import React, { type MouseEventHandler } from 'react'; + +import { useHabitsStore, useOccurrencesStore } from '@stores'; type DayHabitModalDialogProps = { open: boolean; diff --git a/src/components/calendar/OccurrenceChip.test.tsx b/src/components/calendar/OccurrenceChip.test.tsx index 4ea371f..92a3cda 100644 --- a/src/components/calendar/OccurrenceChip.test.tsx +++ b/src/components/calendar/OccurrenceChip.test.tsx @@ -1,8 +1,9 @@ -import { useScreenSize } from '@hooks'; +import React from 'react'; import { fireEvent, render, waitFor } from '@testing-library/react'; + +import { useScreenSize } from '@hooks'; import { makeTestOccurrence } from '@tests'; import { getHabitIconUrl } from '@utils'; -import React from 'react'; import OccurrenceChip, { type OccurrenceChipProps } from './OccurrenceChip'; diff --git a/src/components/calendar/OccurrenceChip.tsx b/src/components/calendar/OccurrenceChip.tsx index 1dde957..42f3dee 100644 --- a/src/components/calendar/OccurrenceChip.tsx +++ b/src/components/calendar/OccurrenceChip.tsx @@ -1,8 +1,9 @@ +import React from 'react'; import type { Occurrence } from '@models'; import { Badge, Button, Tooltip } from '@nextui-org/react'; import { Trash } from '@phosphor-icons/react'; + import { getHabitIconUrl } from '@utils'; -import React from 'react'; export type OccurrenceChipProps = { occurrences: Occurrence[]; diff --git a/src/components/calendar/index.ts b/src/components/calendar/index.ts index bb7a69f..3a9e179 100644 --- a/src/components/calendar/index.ts +++ b/src/components/calendar/index.ts @@ -1,5 +1,4 @@ export * from './Calendar'; export { default as Calendar } from './Calendar'; - export * from './OccurrenceChip'; export { default as OccurrenceChip } from './OccurrenceChip'; diff --git a/src/components/common/Alert/Alert.tsx b/src/components/common/Alert/Alert.tsx index 489923a..ff4dc3e 100644 --- a/src/components/common/Alert/Alert.tsx +++ b/src/components/common/Alert/Alert.tsx @@ -1,3 +1,4 @@ +import React, { type ReactNode } from 'react'; import { type ButtonProps } from '@nextui-org/react'; import { BellRinging, @@ -9,7 +10,6 @@ import { WarningCircle, } from '@phosphor-icons/react'; import clsx from 'clsx'; -import React, { type ReactNode } from 'react'; import { type SetRequired, type ValueOf } from 'type-fest'; export type ButtonColor = ValueOf< diff --git a/src/components/common/ConfirmDialog/ConfirmDialog.test.tsx b/src/components/common/ConfirmDialog/ConfirmDialog.test.tsx index 70f3c3c..0d7fd0f 100644 --- a/src/components/common/ConfirmDialog/ConfirmDialog.test.tsx +++ b/src/components/common/ConfirmDialog/ConfirmDialog.test.tsx @@ -1,5 +1,5 @@ -import { render } from '@testing-library/react'; import React from 'react'; +import { render } from '@testing-library/react'; import ConfirmDialog from './ConfirmDialog'; diff --git a/src/components/common/ConfirmDialog/ConfirmDialog.tsx b/src/components/common/ConfirmDialog/ConfirmDialog.tsx index e5e0dc3..39b498c 100644 --- a/src/components/common/ConfirmDialog/ConfirmDialog.tsx +++ b/src/components/common/ConfirmDialog/ConfirmDialog.tsx @@ -1,11 +1,11 @@ +import React from 'react'; import { Button, - ModalBody, - ModalHeader, Modal, + ModalBody, ModalContent, + ModalHeader, } from '@nextui-org/react'; -import React from 'react'; type ConfirmDialogProps = { open: boolean; diff --git a/src/components/common/PasswordInput/PasswordInput.tsx b/src/components/common/PasswordInput/PasswordInput.tsx index cef326a..8f386c4 100644 --- a/src/components/common/PasswordInput/PasswordInput.tsx +++ b/src/components/common/PasswordInput/PasswordInput.tsx @@ -1,6 +1,6 @@ +import React, { type ChangeEventHandler } from 'react'; import { Button, Input } from '@nextui-org/react'; import { Eye, EyeSlash } from '@phosphor-icons/react'; -import React, { type ChangeEventHandler } from 'react'; type PasswordInputProps = { variant?: 'flat' | 'bordered' | 'faded' | 'underlined'; diff --git a/src/components/common/Snackbars/Snackbars.tsx b/src/components/common/Snackbars/Snackbars.tsx index 9add0db..0fc2217 100644 --- a/src/components/common/Snackbars/Snackbars.tsx +++ b/src/components/common/Snackbars/Snackbars.tsx @@ -1,8 +1,9 @@ -import { Alert } from '@components'; +import React from 'react'; import { Button } from '@nextui-org/react'; -import { useSnackbarsStore } from '@stores'; import { AnimatePresence, motion } from 'framer-motion'; -import React from 'react'; + +import { Alert } from '@components'; +import { useSnackbarsStore } from '@stores'; const Snackbars = () => { const { snackbars, hideSnackbar } = useSnackbarsStore(); diff --git a/src/components/common/index.ts b/src/components/common/index.ts index f200806..901c186 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -1,5 +1,5 @@ +export * from './Alert'; export * from './ConfirmDialog'; -export * from './VisuallyHiddenInput'; export * from './PasswordInput'; -export * from './Alert'; export * from './Snackbars'; +export * from './VisuallyHiddenInput'; diff --git a/src/components/habit/add-habit/AddHabitDialogButton.test.tsx b/src/components/habit/add-habit/AddHabitDialogButton.test.tsx index 9766860..d4f7866 100644 --- a/src/components/habit/add-habit/AddHabitDialogButton.test.tsx +++ b/src/components/habit/add-habit/AddHabitDialogButton.test.tsx @@ -1,8 +1,9 @@ -import { StorageBuckets, uploadFile } from '@services'; -import { useSnackbarsStore, useHabitsStore } from '@stores'; +import React from 'react'; import { useUser } from '@supabase/auth-helpers-react'; import { act, fireEvent, render, waitFor } from '@testing-library/react'; -import React from 'react'; + +import { StorageBuckets, uploadFile } from '@services'; +import { useHabitsStore, useSnackbarsStore } from '@stores'; import AddHabitDialogButton from './AddHabitDialogButton'; diff --git a/src/components/habit/add-habit/AddHabitDialogButton.tsx b/src/components/habit/add-habit/AddHabitDialogButton.tsx index 85e642c..94d4ef6 100644 --- a/src/components/habit/add-habit/AddHabitDialogButton.tsx +++ b/src/components/habit/add-habit/AddHabitDialogButton.tsx @@ -1,5 +1,4 @@ -import { AddCustomTraitModal, VisuallyHiddenInput } from '@components'; -import { useTextField, useFileField } from '@hooks'; +import React from 'react'; import { Button, Input, @@ -13,9 +12,11 @@ import { Textarea, } from '@nextui-org/react'; import { CloudArrowUp, Plus } from '@phosphor-icons/react'; -import { useHabitsStore, useTraitsStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; -import React from 'react'; + +import { AddCustomTraitModal, VisuallyHiddenInput } from '@components'; +import { useFileField, useTextField } from '@hooks'; +import { useHabitsStore, useTraitsStore } from '@stores'; const AddHabitDialogButton = () => { const user = useUser(); diff --git a/src/components/habit/add-trait/AddCustomTraitModal.tsx b/src/components/habit/add-trait/AddCustomTraitModal.tsx index aae7135..5f40e1c 100644 --- a/src/components/habit/add-trait/AddCustomTraitModal.tsx +++ b/src/components/habit/add-trait/AddCustomTraitModal.tsx @@ -1,5 +1,5 @@ -import { OccurrenceChip } from '@components'; -import { useTextField } from '@hooks'; +import React from 'react'; +import { HexColorPicker } from 'react-colorful'; import { Button, Input, @@ -10,12 +10,13 @@ import { ModalHeader, Textarea, } from '@nextui-org/react'; -import { useTraitsStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; + +import { OccurrenceChip } from '@components'; +import { useTextField } from '@hooks'; +import { useTraitsStore } from '@stores'; import { makeTestOccurrence } from '@tests'; import { toEventLike } from '@utils'; -import React from 'react'; -import { HexColorPicker } from 'react-colorful'; export type AddCustomTraitModalProps = { open: boolean; diff --git a/src/components/habit/edit-habit/EditHabitDialog.test.tsx b/src/components/habit/edit-habit/EditHabitDialog.test.tsx index 6077d01..38eb9a1 100644 --- a/src/components/habit/edit-habit/EditHabitDialog.test.tsx +++ b/src/components/habit/edit-habit/EditHabitDialog.test.tsx @@ -1,7 +1,8 @@ -import { useHabitsStore, useTraitsStore } from '@stores'; +import React from 'react'; import { act, fireEvent, render, waitFor } from '@testing-library/react'; + +import { useHabitsStore, useTraitsStore } from '@stores'; import { makeTestTrait } from '@tests'; -import React from 'react'; import EditHabitDialog, { type EditHabitDialogProps } from './EditHabitDialog'; diff --git a/src/components/habit/edit-habit/EditHabitDialog.tsx b/src/components/habit/edit-habit/EditHabitDialog.tsx index 179c17f..b6ad913 100644 --- a/src/components/habit/edit-habit/EditHabitDialog.tsx +++ b/src/components/habit/edit-habit/EditHabitDialog.tsx @@ -1,4 +1,4 @@ -import { useTextField } from '@hooks'; +import React from 'react'; import type { Habit } from '@models'; import { Button, @@ -12,10 +12,11 @@ import { SelectItem, Textarea, } from '@nextui-org/react'; -import { useHabitsStore, useTraitsStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; + +import { useTextField } from '@hooks'; +import { useHabitsStore, useTraitsStore } from '@stores'; import { toEventLike } from '@utils'; -import React from 'react'; export type EditHabitDialogProps = { open: boolean; diff --git a/src/components/habit/habits-page/HabitIconCell.tsx b/src/components/habit/habits-page/HabitIconCell.tsx index b50ed9c..3164a95 100644 --- a/src/components/habit/habits-page/HabitIconCell.tsx +++ b/src/components/habit/habits-page/HabitIconCell.tsx @@ -1,10 +1,11 @@ +import React from 'react'; +import { Button, Tooltip } from '@nextui-org/react'; +import { useUser } from '@supabase/auth-helpers-react'; + import { VisuallyHiddenInput } from '@components'; import { type Habit } from '@models'; -import { Button, Tooltip } from '@nextui-org/react'; import { useHabitsStore } from '@stores'; -import { useUser } from '@supabase/auth-helpers-react'; import { getHabitIconUrl } from '@utils'; -import React from 'react'; type HabitIconCellProps = { habit: Habit; diff --git a/src/components/habit/habits-page/HabitLastEntryCell.tsx b/src/components/habit/habits-page/HabitLastEntryCell.tsx index 89c6557..abad521 100644 --- a/src/components/habit/habits-page/HabitLastEntryCell.tsx +++ b/src/components/habit/habits-page/HabitLastEntryCell.tsx @@ -1,8 +1,9 @@ -import { getLatestHabitOccurrenceTimestamp } from '@services'; -import { capitalizeFirstLetter } from '@utils'; +import React from 'react'; import { formatDistanceStrict, formatRelative, isThisWeek } from 'date-fns'; import { enGB } from 'date-fns/locale'; -import React from 'react'; + +import { getLatestHabitOccurrenceTimestamp } from '@services'; +import { capitalizeFirstLetter } from '@utils'; const formatRelativeLocale: Record = { yesterday: `'yesterday'`, diff --git a/src/components/habit/habits-page/HabitLongestStreakCell.tsx b/src/components/habit/habits-page/HabitLongestStreakCell.tsx index 39aa0d7..6bb581e 100644 --- a/src/components/habit/habits-page/HabitLongestStreakCell.tsx +++ b/src/components/habit/habits-page/HabitLongestStreakCell.tsx @@ -1,6 +1,7 @@ -import { getLongestHabitStreak } from '@services'; import React from 'react'; +import { getLongestHabitStreak } from '@services'; + const HabitLongestStreakCell = ({ id }: { id: number }) => { const [longestStreakLength, setLongestStreakLength] = React.useState< number | null diff --git a/src/components/habit/habits-page/HabitsPage.test.tsx b/src/components/habit/habits-page/HabitsPage.test.tsx index 0c73874..15527f8 100644 --- a/src/components/habit/habits-page/HabitsPage.test.tsx +++ b/src/components/habit/habits-page/HabitsPage.test.tsx @@ -1,7 +1,8 @@ -import { useHabitsStore } from '@stores'; +import React from 'react'; import { fireEvent, render, waitFor } from '@testing-library/react'; + +import { useHabitsStore } from '@stores'; import { makeTestHabit } from '@tests'; -import React from 'react'; import HabitsPage from './HabitsPage'; diff --git a/src/components/habit/habits-page/HabitsPage.tsx b/src/components/habit/habits-page/HabitsPage.tsx index 4018d25..b9557c8 100644 --- a/src/components/habit/habits-page/HabitsPage.tsx +++ b/src/components/habit/habits-page/HabitsPage.tsx @@ -1,10 +1,4 @@ -import { - AddHabitDialogButton, - ConfirmDialog, - EditHabitDialog, -} from '@components'; -import { useDocumentTitle } from '@hooks'; -import { type Habit } from '@models'; +import React from 'react'; import { Button, Chip, @@ -17,10 +11,17 @@ import { Tooltip, } from '@nextui-org/react'; import { PencilSimple, TrashSimple } from '@phosphor-icons/react'; -import { useHabitsStore, useOccurrencesStore } from '@stores'; import { useUser } from '@supabase/auth-helpers-react'; import { format } from 'date-fns'; -import React from 'react'; + +import { + AddHabitDialogButton, + ConfirmDialog, + EditHabitDialog, +} from '@components'; +import { useDocumentTitle } from '@hooks'; +import { type Habit } from '@models'; +import { useHabitsStore, useOccurrencesStore } from '@stores'; import HabitIconCell from './HabitIconCell'; import HabitLastEntryCell from './HabitLastEntryCell'; diff --git a/src/components/habit/habits-page/HabitsTotalEntriesCell.tsx b/src/components/habit/habits-page/HabitsTotalEntriesCell.tsx index 6c6aaef..51d8cc0 100644 --- a/src/components/habit/habits-page/HabitsTotalEntriesCell.tsx +++ b/src/components/habit/habits-page/HabitsTotalEntriesCell.tsx @@ -1,6 +1,7 @@ -import { getHabitTotalEntries } from '@services'; import React from 'react'; +import { getHabitTotalEntries } from '@services'; + const HabitsTotalEntriesCell = ({ id }: { id: number }) => { const [entriesCount, setEntriesCount] = React.useState(null); diff --git a/src/components/habit/index.ts b/src/components/habit/index.ts index b3b9fcc..fb06423 100644 --- a/src/components/habit/index.ts +++ b/src/components/habit/index.ts @@ -1,4 +1,4 @@ export * from './add-habit'; +export * from './add-trait'; export * from './edit-habit'; export * from './habits-page'; -export * from './add-trait'; diff --git a/src/components/header/Header.test.tsx b/src/components/header/Header.test.tsx index 2e9d090..b6c1c73 100644 --- a/src/components/header/Header.test.tsx +++ b/src/components/header/Header.test.tsx @@ -1,9 +1,27 @@ -import { render } from '@testing-library/react'; import React from 'react'; import { BrowserRouter } from 'react-router-dom'; +import { render } from '@testing-library/react'; import Header from './Header'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(() => ({ + fetchHabits: jest.fn(), + clearHabits: jest.fn(), + })), + useOccurrencesStore: jest.fn(() => ({ + fetchOccurrences: jest.fn(), + clearOccurrences: jest.fn(), + })), + useTraitsStore: jest.fn(() => ({ + fetchTraits: jest.fn(), + clearTraits: jest.fn(), + })), + useSnackbarsStore: jest.fn(() => ({ + showSnackbar: jest.fn(), + })), +})); + Object.defineProperty(window, 'matchMedia', { writable: true, value: jest.fn().mockImplementation((query) => ({ diff --git a/src/components/header/Header.tsx b/src/components/header/Header.tsx index 7236cd6..c5a0848 100644 --- a/src/components/header/Header.tsx +++ b/src/components/header/Header.tsx @@ -1,9 +1,10 @@ -import { AuthModalButton } from '@components'; -import { useFetchOnAuth, useScreenSize } from '@hooks'; -import { Button, Tooltip } from '@nextui-org/react'; -import { GithubLogo } from '@phosphor-icons/react'; import React from 'react'; import { Link } from 'react-router-dom'; +import { Button, Tooltip } from '@nextui-org/react'; +import { GithubLogo } from '@phosphor-icons/react'; + +import { AuthModalButton } from '@components'; +import { useFetchOnAuth, useScreenSize } from '@hooks'; import ThemeToggle from './ThemeToggle'; diff --git a/src/components/header/ThemeToggle.test.tsx b/src/components/header/ThemeToggle.test.tsx index 66ecdd1..33e87d3 100644 --- a/src/components/header/ThemeToggle.test.tsx +++ b/src/components/header/ThemeToggle.test.tsx @@ -1,5 +1,11 @@ import ThemeToggle from './ThemeToggle'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + describe(ThemeToggle.name, () => { it('should be tested', () => { expect(true).toBeTruthy(); diff --git a/src/components/header/ThemeToggle.tsx b/src/components/header/ThemeToggle.tsx index fe8e7d6..ab73f6b 100644 --- a/src/components/header/ThemeToggle.tsx +++ b/src/components/header/ThemeToggle.tsx @@ -1,14 +1,15 @@ -import { ThemeMode, useScreenSize, useThemeMode } from '@hooks'; -import { ButtonGroup, Button } from '@nextui-org/react'; +import React from 'react'; +import { Button, ButtonGroup } from '@nextui-org/react'; import { - SunDim as SunIcon, Desktop as DesktopIcon, Moon as MoonIcon, + SunDim as SunIcon, } from '@phosphor-icons/react'; import clsx from 'clsx'; -import React from 'react'; import { twMerge } from 'tailwind-merge'; +import { ThemeMode, useScreenSize, useThemeMode } from '@hooks'; + const modesToIcons = { [ThemeMode.LIGHT]: SunIcon, [ThemeMode.SYSTEM]: DesktopIcon, diff --git a/src/components/index.ts b/src/components/index.ts index 7ab0126..dbc42d7 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -1,12 +1,7 @@ export * from './App'; export { default as App } from './App'; - export * from './calendar'; - -export * from './header'; - export * from './common'; - export * from './habit'; - +export * from './header'; export * from './user-account'; diff --git a/src/components/user-account/AccountPage.test.tsx b/src/components/user-account/AccountPage.test.tsx index e41be19..6edfd5b 100644 --- a/src/components/user-account/AccountPage.test.tsx +++ b/src/components/user-account/AccountPage.test.tsx @@ -1,11 +1,16 @@ -import { useUser } from '@supabase/auth-helpers-react'; -import { act, fireEvent, render } from '@testing-library/react'; import React from 'react'; import { BrowserRouter } from 'react-router-dom'; +import { useUser } from '@supabase/auth-helpers-react'; +import { act, fireEvent, render } from '@testing-library/react'; import AccountPage from './AccountPage'; import { useAccountPage } from './use-account-page'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); jest.mock('./use-account-page'); jest.mock('@supabase/auth-helpers-react', () => ({ ...jest.requireActual('@supabase/auth-helpers-react'), diff --git a/src/components/user-account/AccountPage.tsx b/src/components/user-account/AccountPage.tsx index c8d918a..2943558 100644 --- a/src/components/user-account/AccountPage.tsx +++ b/src/components/user-account/AccountPage.tsx @@ -1,10 +1,11 @@ -import { Alert, PasswordInput } from '@components'; -import { useDocumentTitle } from '@hooks'; +import React, { type FormEventHandler } from 'react'; import { Button, Input, Spinner } from '@nextui-org/react'; import clsx from 'clsx'; -import React, { type FormEventHandler } from 'react'; import { twMerge } from 'tailwind-merge'; +import { Alert, PasswordInput } from '@components'; +import { useDocumentTitle } from '@hooks'; + import { useAccountPage } from './use-account-page'; import { useAuthSearchParams } from './use-auth-search-params'; diff --git a/src/components/user-account/AuthForm.test.tsx b/src/components/user-account/AuthForm.test.tsx index ecbc354..c2bd797 100644 --- a/src/components/user-account/AuthForm.test.tsx +++ b/src/components/user-account/AuthForm.test.tsx @@ -1,8 +1,14 @@ -import { act, fireEvent, render, waitFor } from '@testing-library/react'; import React from 'react'; +import { act, fireEvent, render, waitFor } from '@testing-library/react'; import AuthForm from './AuthForm'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + describe(AuthForm.name, () => { it('should call onSubmit with email and password', async () => { const onSubmit = jest.fn(); diff --git a/src/components/user-account/AuthForm.tsx b/src/components/user-account/AuthForm.tsx index d99533f..a0ded20 100644 --- a/src/components/user-account/AuthForm.tsx +++ b/src/components/user-account/AuthForm.tsx @@ -1,8 +1,9 @@ -import { PasswordInput, type AuthMode } from '@components'; -import { useTextField } from '@hooks'; -import { Input, Button } from '@nextui-org/react'; -import clsx from 'clsx'; import React from 'react'; +import { Button, Input } from '@nextui-org/react'; +import clsx from 'clsx'; + +import { type AuthMode, PasswordInput } from '@components'; +import { useTextField } from '@hooks'; type AuthFormProps = { onSubmit: (email: string, password: string, name: string) => void; diff --git a/src/components/user-account/AuthModalButton.test.tsx b/src/components/user-account/AuthModalButton.test.tsx index 188d6e0..fddacb2 100644 --- a/src/components/user-account/AuthModalButton.test.tsx +++ b/src/components/user-account/AuthModalButton.test.tsx @@ -1,9 +1,15 @@ -import { act, fireEvent, render, waitFor } from '@testing-library/react'; import React from 'react'; import { BrowserRouter } from 'react-router-dom'; +import { act, fireEvent, render, waitFor } from '@testing-library/react'; import AuthModalButton from './AuthModalButton'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + jest.mock('@supabase/auth-helpers-react', () => ({ useUser: jest.fn().mockReturnValue({ id: null }), })); diff --git a/src/components/user-account/AuthModalButton.tsx b/src/components/user-account/AuthModalButton.tsx index eb6c793..2c92859 100644 --- a/src/components/user-account/AuthModalButton.tsx +++ b/src/components/user-account/AuthModalButton.tsx @@ -1,4 +1,5 @@ -import { useScreenSize } from '@hooks'; +import React from 'react'; +import { Link } from 'react-router-dom'; import { Button, ButtonGroup, @@ -8,20 +9,20 @@ import { ModalHeader, Tab, Tabs, + Tooltip, useDisclosure, VisuallyHidden, - Tooltip, } from '@nextui-org/react'; import { SignOut as SignOutIcon, User as UserIcon, } from '@phosphor-icons/react'; +import { useUser } from '@supabase/auth-helpers-react'; + +import { useScreenSize } from '@hooks'; import { sendPasswordResetEmail, signIn, signOut, signUp } from '@services'; import { useSnackbarsStore } from '@stores'; -import { useUser } from '@supabase/auth-helpers-react'; import { getErrorMessage } from '@utils'; -import React from 'react'; -import { Link } from 'react-router-dom'; import AuthForm from './AuthForm'; diff --git a/src/components/user-account/index.ts b/src/components/user-account/index.ts index aa7c57e..bdb5d0c 100644 --- a/src/components/user-account/index.ts +++ b/src/components/user-account/index.ts @@ -1,5 +1,4 @@ -export * from './AuthModalButton'; -export { default as AuthModalButton } from './AuthModalButton'; - export * from './AccountPage'; export { default as AccountPage } from './AccountPage'; +export * from './AuthModalButton'; +export { default as AuthModalButton } from './AuthModalButton'; diff --git a/src/components/user-account/use-account-page/useAccountPage.test.ts b/src/components/user-account/use-account-page/useAccountPage.test.ts index f12d9c1..3e07beb 100644 --- a/src/components/user-account/use-account-page/useAccountPage.test.ts +++ b/src/components/user-account/use-account-page/useAccountPage.test.ts @@ -1,11 +1,18 @@ -import { getUserAccountByEmail, updateUserAccount } from '@services'; +import type React from 'react'; import { useUser } from '@supabase/auth-helpers-react'; import { act, renderHook, waitFor } from '@testing-library/react'; + +import { getUserAccountByEmail, updateUserAccount } from '@services'; import { transformClientEntity, transformServerEntities } from '@utils'; -import type React from 'react'; import useAccountPage from './useAccountPage'; +jest.mock('@stores', () => ({ + useHabitsStore: jest.fn(), + useOccurrencesStore: jest.fn(), + useTraitsStore: jest.fn(), +})); + jest.mock('@services', () => ({ getUserAccountByEmail: jest.fn(), updateUserAccount: jest.fn(), diff --git a/src/components/user-account/use-account-page/useAccountPage.ts b/src/components/user-account/use-account-page/useAccountPage.ts index 4166f9a..5702c2a 100644 --- a/src/components/user-account/use-account-page/useAccountPage.ts +++ b/src/components/user-account/use-account-page/useAccountPage.ts @@ -1,8 +1,9 @@ +import React from 'react'; + import { useDataFetch, useTextField } from '@hooks'; import { fetchUser, updateUser } from '@services'; import { useSnackbarsStore } from '@stores'; import { getErrorMessage, toEventLike } from '@utils'; -import React from 'react'; type User = Awaited>; diff --git a/src/components/user-account/use-auth-search-params/useAuthSearchParams.test.ts b/src/components/user-account/use-auth-search-params/useAuthSearchParams.test.ts index 29b1fbb..70902c2 100644 --- a/src/components/user-account/use-auth-search-params/useAuthSearchParams.test.ts +++ b/src/components/user-account/use-auth-search-params/useAuthSearchParams.test.ts @@ -1,6 +1,7 @@ -import { useSnackbarsStore } from '@stores'; -import { renderHook, waitFor } from '@testing-library/react'; import { useSearchParams } from 'react-router-dom'; +import { renderHook, waitFor } from '@testing-library/react'; + +import { useSnackbarsStore } from '@stores'; import useAuthSearchParams from './useAuthSearchParams'; diff --git a/src/components/user-account/use-auth-search-params/useAuthSearchParams.ts b/src/components/user-account/use-auth-search-params/useAuthSearchParams.ts index 621f042..25481e1 100644 --- a/src/components/user-account/use-auth-search-params/useAuthSearchParams.ts +++ b/src/components/user-account/use-auth-search-params/useAuthSearchParams.ts @@ -1,7 +1,8 @@ +import React from 'react'; +import { useLocation, useSearchParams } from 'react-router-dom'; + import { supabaseClient } from '@helpers'; import { useSnackbarsStore } from '@stores'; -import React from 'react'; -import { useSearchParams, useLocation } from 'react-router-dom'; const useAuthSearchParams = () => { const { showSnackbar } = useSnackbarsStore(); diff --git a/src/helpers/index.ts b/src/helpers/index.ts index 6fb40bc..c95f1f4 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -1,3 +1,3 @@ -export * from './supabaseClient'; -export * from './occurrencesCache'; export * from './generateCalendarRange'; +export * from './occurrencesCache'; +export * from './supabaseClient'; diff --git a/src/hooks/index.ts b/src/hooks/index.ts index aecea28..2bfc427 100644 --- a/src/hooks/index.ts +++ b/src/hooks/index.ts @@ -1,9 +1,8 @@ -export * from './useThemeMode'; -export { default as useThemeMode } from './useThemeMode'; - -export { default as useScreenSize } from './useScreenSize'; -export { default as useTextField } from './useTextField'; -export { default as useFileField } from './useFileField'; export { default as useDataFetch } from './useDataFetch'; -export { default as useFetchOnAuth } from './useFetchOnAuth'; export { default as useDocumentTitle } from './useDocumentTitle'; +export { default as useFetchOnAuth } from './useFetchOnAuth'; +export { default as useFileField } from './useFileField'; +export { default as useScreenSize } from './useScreenSize'; +export { default as useTextField } from './useTextField'; +export * from './useThemeMode'; +export { default as useThemeMode } from './useThemeMode'; diff --git a/src/hooks/useDataFetch.ts b/src/hooks/useDataFetch.ts index 12e7ef7..d201951 100644 --- a/src/hooks/useDataFetch.ts +++ b/src/hooks/useDataFetch.ts @@ -1,5 +1,5 @@ -import { useSupabaseClient } from '@supabase/auth-helpers-react'; import React from 'react'; +import { useSupabaseClient } from '@supabase/auth-helpers-react'; type Args = { clear: () => void; diff --git a/src/hooks/useFetchOnAuth.ts b/src/hooks/useFetchOnAuth.ts index ecbf628..33494a2 100644 --- a/src/hooks/useFetchOnAuth.ts +++ b/src/hooks/useFetchOnAuth.ts @@ -1,6 +1,7 @@ -import { useTraitsStore, useHabitsStore, useOccurrencesStore } from '@stores'; -import { useSupabaseClient } from '@supabase/auth-helpers-react'; import React from 'react'; +import { useSupabaseClient } from '@supabase/auth-helpers-react'; + +import { useHabitsStore, useOccurrencesStore, useTraitsStore } from '@stores'; const useFetchOnAuth = () => { const supabase = useSupabaseClient(); diff --git a/src/hooks/useTextField.ts b/src/hooks/useTextField.ts index 8cccf8d..9204138 100644 --- a/src/hooks/useTextField.ts +++ b/src/hooks/useTextField.ts @@ -1,6 +1,7 @@ -import { type ChangeEventLike } from '@utils'; import React from 'react'; +import { type ChangeEventLike } from '@utils'; + type ReturnValue = [string, (event: ChangeEventLike) => void, () => void]; const useTextField = (initialValue = ''): ReturnValue => { diff --git a/src/index.tsx b/src/index.tsx index 327f931..b39c1b8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,8 @@ -import { App } from '@components'; import React from 'react'; import ReactDOM from 'react-dom/client'; +import { App } from '@components'; + import './index.css'; const root = ReactDOM.createRoot( diff --git a/src/models/index.ts b/src/models/index.ts index e77303e..bc14a01 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -1,4 +1,4 @@ -export * from './trait.model'; export * from './habit.model'; export * from './occurrence.model'; +export * from './trait.model'; export * from './user-account.model'; diff --git a/src/models/occurrence.model.ts b/src/models/occurrence.model.ts index 9c931b1..8045c5e 100644 --- a/src/models/occurrence.model.ts +++ b/src/models/occurrence.model.ts @@ -1,6 +1,6 @@ import type { CamelCasedPropertiesDeep } from 'type-fest'; -import type { TablesInsert, Tables } from '../../supabase/database.types'; +import type { Tables, TablesInsert } from '../../supabase/database.types'; import { type Habit } from './habit.model'; import { type Trait } from './trait.model'; diff --git a/src/services/index.ts b/src/services/index.ts index 1b977d4..d2d641a 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,5 +1,5 @@ export * from './habits.service'; export * from './occurrences.service'; -export * from './user-account.service'; export * from './storage.service'; export * from './traits.service'; +export * from './user-account.service'; diff --git a/src/services/occurrences.service.ts b/src/services/occurrences.service.ts index 01984f9..09d1ded 100644 --- a/src/services/occurrences.service.ts +++ b/src/services/occurrences.service.ts @@ -1,5 +1,6 @@ -import { cacheOccurrences, occurrencesCache, supabaseClient } from '@helpers'; import type { Occurrence, OccurrencesInsert } from '@models'; + +import { cacheOccurrences, occurrencesCache, supabaseClient } from '@helpers'; import { transformClientEntity, transformServerEntities, diff --git a/src/services/traits.service.ts b/src/services/traits.service.ts index d293dee..a8d3a36 100644 --- a/src/services/traits.service.ts +++ b/src/services/traits.service.ts @@ -1,5 +1,6 @@ -import { supabaseClient } from '@helpers'; import type { Trait, TraitsInsert } from '@models'; + +import { supabaseClient } from '@helpers'; import { transformClientEntity, transformServerEntities, diff --git a/src/services/user-account.service.ts b/src/services/user-account.service.ts index 067dfb6..496d1c9 100644 --- a/src/services/user-account.service.ts +++ b/src/services/user-account.service.ts @@ -1,6 +1,7 @@ +import { type UserAttributes } from '@supabase/supabase-js'; + import { supabaseClient } from '@helpers'; import { type Account, type AccountUpdate } from '@models'; -import { type UserAttributes } from '@supabase/supabase-js'; import { transformClientEntity, transformServerEntity } from '@utils'; export const fetchUser = async () => { diff --git a/src/stores/habits.store.ts b/src/stores/habits.store.ts index d317e59..ce43931 100644 --- a/src/stores/habits.store.ts +++ b/src/stores/habits.store.ts @@ -1,4 +1,6 @@ import type { Habit, HabitsInsert, HabitsUpdate } from '@models'; +import { create } from 'zustand'; + import { createHabit, deleteFile, @@ -10,9 +12,9 @@ import { } from '@services'; import { makeTestHabit } from '@tests'; import { getErrorMessage } from '@utils'; -import { create } from 'zustand'; -import { useSnackbarsStore, useOccurrencesStore } from './index'; +import useOccurrencesStore from './occurrences.store'; +import useSnackbarsStore from './snackbars.store'; type HabitsState = { habits: Habit[]; diff --git a/src/stores/index.ts b/src/stores/index.ts index c527187..20dafc2 100644 --- a/src/stores/index.ts +++ b/src/stores/index.ts @@ -1,4 +1,4 @@ -export { default as useSnackbarsStore } from './snackbars.store'; -export { default as useTraitsStore } from './traits.store'; export { default as useHabitsStore } from './habits.store'; export { default as useOccurrencesStore } from './occurrences.store'; +export { default as useSnackbarsStore } from './snackbars.store'; +export { default as useTraitsStore } from './traits.store'; diff --git a/src/stores/occurrences.store.ts b/src/stores/occurrences.store.ts index 018bfc2..4977240 100644 --- a/src/stores/occurrences.store.ts +++ b/src/stores/occurrences.store.ts @@ -1,17 +1,21 @@ -import { cacheOccurrence, occurrencesCache, uncacheOccurrence } from '@helpers'; import type { Occurrence, OccurrencesDateMap, OccurrencesInsert, } from '@models'; +import { create } from 'zustand'; + +import { cacheOccurrence, occurrencesCache, uncacheOccurrence } from '@helpers'; import { createOccurrence, destroyOccurrence, listOccurrences, } from '@services'; -import { useHabitsStore, useSnackbarsStore, useTraitsStore } from '@stores'; import { getErrorMessage } from '@utils'; -import { create } from 'zustand'; + +import useHabitsStore from './habits.store'; +import useSnackbarsStore from './snackbars.store'; +import useTraitsStore from './traits.store'; type OccurrenceFilters = { habitIds?: Set; diff --git a/src/stores/snackbars.store.ts b/src/stores/snackbars.store.ts index 00de0a7..6ab9577 100644 --- a/src/stores/snackbars.store.ts +++ b/src/stores/snackbars.store.ts @@ -1,7 +1,8 @@ -import { type AlertProps } from '@components'; import { type ReactNode } from 'react'; import { create } from 'zustand'; +import { type AlertProps } from '@components'; + type SnackbarOptions = Omit & { action?: ReactNode; autoHideDuration?: number; diff --git a/src/stores/traits.store.ts b/src/stores/traits.store.ts index 553cf0a..e6e541d 100644 --- a/src/stores/traits.store.ts +++ b/src/stores/traits.store.ts @@ -1,9 +1,12 @@ import type { Trait, TraitsInsert } from '@models'; -import { listTraits, createTrait } from '@services'; -import { useOccurrencesStore, useSnackbarsStore } from '@stores'; +import { create } from 'zustand'; + +import { createTrait, listTraits } from '@services'; import { makeTestTrait } from '@tests'; import { getErrorMessage } from '@utils'; -import { create } from 'zustand'; + +import useOccurrencesStore from './occurrences.store'; +import useSnackbarsStore from './snackbars.store'; type TraitsState = { traits: Trait[]; diff --git a/src/utils/index.ts b/src/utils/index.ts index 30b086d..6e9b320 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,5 +1,5 @@ export * from './capitalizeFirstLetter'; -export * from './transformEntity'; -export * from './getHabitIconUrl'; export * from './getErrorMessage'; +export * from './getHabitIconUrl'; export * from './toEventLike'; +export * from './transformEntity'; diff --git a/src/utils/transformEntity.test.ts b/src/utils/transformEntity.test.ts index 41aafb7..7841573 100644 --- a/src/utils/transformEntity.test.ts +++ b/src/utils/transformEntity.test.ts @@ -1,8 +1,8 @@ import { - transformClientEntity, - transformServerEntity, transformClientEntities, + transformClientEntity, transformServerEntities, + transformServerEntity, } from './transformEntity'; describe('transformEntity', () => { diff --git a/tests/index.ts b/tests/index.ts index cf4ce72..9277fe7 100644 --- a/tests/index.ts +++ b/tests/index.ts @@ -1,8 +1,6 @@ -export * from './makeTestTrait'; -export { default as makeTestTrait } from './makeTestTrait'; - export * from './makeTestHabit'; export { default as makeTestHabit } from './makeTestHabit'; - export * from './makeTestOccurrence'; export { default as makeTestOccurrence } from './makeTestOccurrence'; +export * from './makeTestTrait'; +export { default as makeTestTrait } from './makeTestTrait'; diff --git a/vite.config.ts b/vite.config.ts index cbebaa8..5c6e818 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,5 @@ -import { resolve } from 'path'; - import react from '@vitejs/plugin-react'; +import { resolve } from 'path'; import { visualizer } from 'rollup-plugin-visualizer'; import { defineConfig, loadEnv, type UserConfig } from 'vite'; diff --git a/yarn.lock b/yarn.lock index 64946f7..8884738 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6113,6 +6113,11 @@ eslint-plugin-react@^7.33.2: semver "^6.3.1" string.prototype.matchall "^4.0.8" +eslint-plugin-simple-import-sort@^12.1.1: + version "12.1.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-12.1.1.tgz#e64bfdaf91c5b98a298619aa634a9f7aa43b709e" + integrity sha512-6nuzu4xwQtE3332Uz0to+TxDQYRLTKRESSc2hefVT48Zc8JthmN23Gx9lnYhu0FtkRSL1oxny3kJ2aveVhmOVA== + eslint-plugin-unused-imports@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-3.1.0.tgz#db015b569d3774e17a482388c95c17bd303bc602"