📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
(improvement) Unused files / exports / dependencies validation (knip) (#429)
Andrii Romasiune9aaa32bf4c4
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.ymlindex b249d10ab..62e689d5b 100644--- a/.github/workflows/pull_request.yml+++ b/.github/workflows/pull_request.yml@@ -37,3 +37,6 @@ jobs:- name: TypeScript validationrun: npm run typecheck++ - name: Knip validation+ run: npm run knipdiff --git a/app/api/index.ts b/app/api/index.tsindex 7dc72e35a..9656ee6b1 100644--- a/app/api/index.ts+++ b/app/api/index.ts@@ -100,22 +100,6 @@ export const logoutAllApi = () =>throw new Error(error.respon)})-export const refreshToken = () =>- api- .post('v1/auth/refresh-token')- .then(- (- response,- ): {- access_token: string- refreshToken: string- } => response.data,- )- .catch((error) => {- debug('%s', error)- throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message- })-export const login = (credentials: { email: string; password: string }) =>api.post('v1/auth/login', credentials)@@ -843,15 +827,6 @@ export const getInstalledExtensions = (limit = 100, offset = 0) =>throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message})-export const setTheme = (theme: string) =>- api- .put('user/theme', { theme })- .then((response) => response.data)- .catch((error) => {- debug('%s', error)- throw _isEmpty(error.response.data?.message) ? error.response.data : error.response.data.message- })-export interface IGetLiveVisitorsInfo {dv: stringbr: stringdiff --git a/app/components/Header/index.tsx b/app/components/Header/index.tsxindex a1a84787d..a4bcb447f 100644--- a/app/components/Header/index.tsx+++ b/app/components/Header/index.tsx@@ -362,7 +362,7 @@ const ProfileMenu = ({<MenuItem key={lng}><spanclassName='block cursor-pointer px-4 py-2 text-sm text-gray-700 hover:bg-gray-200 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-gray-600'- role='MenuItem'+ role='menuitem'tabIndex={0}onClick={() => onLanguageChange(lng)}>@@ -961,7 +961,7 @@ const Header: React.FC<IHeader> = ({ ssrTheme, authenticated, refPage, transpare<MenuItem key={lng}><spanclassName='block cursor-pointer px-4 py-2 text-sm text-gray-700 hover:bg-gray-200 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-gray-600'- role='MenuItem'+ role='menuitem'tabIndex={0}onClick={() => onLanguageChange(lng)}>diff --git a/app/hooks/useLocalStorage.ts b/app/hooks/useLocalStorage.tsdeleted file mode 100644index 505e39240..000000000--- a/app/hooks/useLocalStorage.ts+++ /dev/null@@ -1,21 +0,0 @@-import { useEffect, useState } from 'react'--const useLocalStorage = (key: string) => {- const [state, setState] = useState(null)-- useEffect(() => {- const localState = localStorage.getItem(key)-- if (localState) {- setState(JSON.parse(localState))- }- }, [key])-- const setWithLocalStorage = (nextState: any) => {- setState(nextState)- }-- return [state, setWithLocalStorage]-}--export default useLocalStoragediff --git a/app/pages/Captcha/View/Panels.tsx b/app/pages/Captcha/View/Panels.tsxindex 8bf717d8a..113f3d45d 100644--- a/app/pages/Captcha/View/Panels.tsx+++ b/app/pages/Captcha/View/Panels.tsx@@ -1,6 +1,5 @@import React, { memo, useState, useEffect, useMemo, Fragment } from 'react'import type i18next from 'i18next'-import { ArrowSmallUpIcon, ArrowSmallDownIcon } from '@heroicons/react/24/solid'import {FunnelIcon,MapIcon,@@ -27,14 +26,12 @@ import _slice from 'lodash/slice'import _sum from 'lodash/sum'import Progress from 'ui/Progress'-import PulsatingCircle from 'ui/icons/PulsatingCircle'import Modal from 'ui/Modal'import Chart from 'ui/Chart'import Button from 'ui/Button'import { IEntry } from 'redux/models/IEntry'-import LiveVisitorsDropdown from './components/LiveVisitorsDropdown'import InteractiveMap from '../../Project/View/components/InteractiveMap'import { iconClassName } from './ViewCaptcha.helpers'@@ -133,129 +130,6 @@ const PanelContainer = ({</div>)-// First tab with stats-const Overview = ({- overall,- chartData,- activePeriod,- t,- live,- sessionDurationAVG,- projectId,-}: {- overall: any- chartData: any- activePeriod: any- t: typeof i18next.t- live: number | string- sessionDurationAVG: number- projectId: string-}) => {- const pageviewsDidGrowUp = overall.percChange >= 0- const uniqueDidGrowUp = overall.percChangeUnique >= 0- const pageviews = _sum(chartData?.visits) || 0- const uniques = _sum(chartData?.uniques) || 0- let bounceRate = 0-- if (pageviews > 0) {- bounceRate = _round((uniques * 100) / pageviews, 1)- }-- return (- <PanelContainer name={t('project.overview')} noSwitch type=''>- <div className='flex justify-between text-lg'>- <div className='flex items-center dark:text-gray-50'>- <PulsatingCircle className='mr-1.5' type='big' />- {t('dashboard.liveVisitors')}:- </div>- <LiveVisitorsDropdown projectId={projectId} live={live} />- </div>- {!_isEmpty(chartData) && (- <>- <p className='text-lg font-semibold dark:text-gray-50'>- {t('project.statsFor')}- <span className='lowercase'>- - {activePeriod.label}- </span>- </p>-- <div className='flex justify-between'>- <p className='text-lg dark:text-gray-50'>{t('dashboard.pageviews')}:</p>- <p className='mr-2 h-5 text-xl text-gray-900 dark:text-gray-50'>{pageviews}</p>- </div>-- <div className='flex justify-between'>- <p className='text-lg dark:text-gray-50'>{t('dashboard.unique')}:</p>- <p className='mr-2 h-5 text-xl text-gray-900 dark:text-gray-50'>{uniques}</p>- </div>-- <div className='flex justify-between'>- <p className='text-lg dark:text-gray-50'>{t('dashboard.bounceRate')}:</p>- <p className='mr-2 h-5 text-xl text-gray-900 dark:text-gray-50'>{bounceRate}%</p>- </div>- <div className='flex justify-between'>- <p className='text-lg dark:text-gray-50'>{t('dashboard.sessionDuration')}:</p>- <p className='mr-2 h-5 text-xl text-gray-900 dark:text-gray-50'>{sessionDurationAVG}</p>- </div>- <hr className='my-2 border-gray-200 dark:border-gray-600' />- </>- )}- <p className='text-lg font-semibold dark:text-gray-50'>{t('project.weeklyStats')}</p>- <div className='flex justify-between'>- <p className='text-lg dark:text-gray-50'>{t('dashboard.pageviews')}:</p>- <dd className='flex items-baseline'>- <p className='mr-2 h-5 text-lg text-gray-900 dark:text-gray-50'>{overall.thisWeek}</p>- <p- className={cx('-ml-1 flex items-baseline text-sm', {- 'text-green-600': pageviewsDidGrowUp,- 'text-red-600': !pageviewsDidGrowUp,- })}- >- {pageviewsDidGrowUp ? (- <>- <ArrowSmallUpIcon className='h-4 w-4 flex-shrink-0 self-center text-green-500' />- <span className='sr-only'>{t('dashboard.inc')}</span>- </>- ) : (- <>- <ArrowSmallDownIcon className='h-4 w-4 flex-shrink-0 self-center text-red-500' />- <span className='sr-only'>{t('dashboard.dec')}</span>- </>- )}- {overall.percChange}%- </p>- </dd>- </div>- <div className='flex justify-between'>- <p className='text-lg dark:text-gray-50'>{t('dashboard.unique')}:</p>- <dd className='flex items-baseline'>- <p className='mr-2 h-5 text-lg text-gray-900 dark:text-gray-50'>{overall.thisWeekUnique}</p>- <p- className={cx('-ml-1 flex items-baseline text-sm', {- 'text-green-600': uniqueDidGrowUp,- 'text-red-600': !uniqueDidGrowUp,- })}- >- {uniqueDidGrowUp ? (- <>- <ArrowSmallUpIcon className='h-4 w-4 flex-shrink-0 self-center text-green-500' />- <span className='sr-only'>{t('dashboard.inc')}</span>- </>- ) : (- <>- <ArrowSmallDownIcon className='h-4 w-4 flex-shrink-0 self-center text-red-500' />- <span className='sr-only'>{t('dashboard.dec')}</span>- </>- )}- {overall.percChangeUnique}%- </p>- </dd>- </div>- </PanelContainer>- )-}-// Options for circle chart showing the stats of dataconst getPieOptions = (customs: any, uniques: number, t: any) => {const tQuantity = t('project.quantity')@@ -642,7 +516,6 @@ const Panel = ({}const PanelMemo = memo(Panel)-const OverviewMemo = memo(Overview)const CustomEventsMemo = memo(CustomEvents)-export { PanelMemo as Panel, OverviewMemo as Overview, CustomEventsMemo as CustomEvents }+export { PanelMemo as Panel, CustomEventsMemo as CustomEvents }diff --git a/app/pages/Captcha/View/ViewCaptcha.helpers.tsx b/app/pages/Captcha/View/ViewCaptcha.helpers.tsxindex 92c37ba6f..667b12aaa 100644--- a/app/pages/Captcha/View/ViewCaptcha.helpers.tsx+++ b/app/pages/Captcha/View/ViewCaptcha.helpers.tsx@@ -13,8 +13,6 @@ import {import dayjs from 'dayjs'import { area, bar } from 'billboard.js'import _map from 'lodash/map'-import _split from 'lodash/split'-import _replace from 'lodash/replace'import _size from 'lodash/size'import {@@ -31,12 +29,6 @@ import { nFormatter } from 'utils/generic'const PANELS_ORDER = ['cc', 'br', 'os', 'dv']-const getExportFilename = (prefix: string) => {- // turn something like 2022-03-02T19:31:00.100Z into 2022-03-02- const date = _split(_replace(_split(new Date().toISOString(), '.')[0], /:/g, '-'), 'T')[0]- return `${prefix}-${date}.zip`-}-const CHART_METRICS_MAPPING = {results: 'results',}@@ -236,7 +228,6 @@ export {validTimeBacket,noRegionPeriods,getSettings,- getExportFilename,getColumns,CHART_METRICS_MAPPING,PANELS_ORDER,diff --git a/app/pages/Captcha/View/components/LiveVisitorsDropdown.tsx b/app/pages/Captcha/View/components/LiveVisitorsDropdown.tsxdeleted file mode 100644index 6096c53d8..000000000--- a/app/pages/Captcha/View/components/LiveVisitorsDropdown.tsx+++ /dev/null@@ -1,74 +0,0 @@-import React, { useState, useEffect } from 'react'-import _map from 'lodash/map'-import { useTranslation } from 'react-i18next'-// @ts-ignore-import OutsideClickHandler from 'react-outside-click-handler'-import { ChevronDownIcon, ChevronUpIcon, XMarkIcon } from '@heroicons/react/24/outline'-import Flag from 'react-flagkit'--import { getLiveVisitorsInfo, IGetLiveVisitorsInfo } from 'api'--const LiveVisitorsDropdown = ({ live, projectId }: { live: number | string; projectId: string }): JSX.Element => {- const { t } = useTranslation()- const [show, setShow] = useState<boolean>(false)- const [liveInfo, setLiveInfo] = useState<IGetLiveVisitorsInfo[]>([])- const [loading, setLoading] = useState<boolean>(true)-- const getLiveVisitors = async () => {- await getLiveVisitorsInfo(projectId)- .then((res) => {- setLiveInfo(res)- })- .catch((err) => {- console.log(err)- })- .finally(() => {- setLoading(false)- })- }-- useEffect(() => {- if (show) {- getLiveVisitors()- }- }, [show]) // eslint-disable-line react-hooks/exhaustive-deps-- return (- <OutsideClickHandler onOutsideClick={() => setShow(false)}>- <p className='mr-2 h-5 cursor-pointer text-xl text-gray-900 dark:text-gray-50' onClick={() => setShow(!show)}>- {live} {show ? <ChevronUpIcon className='inline h-5 w-5' /> : <ChevronDownIcon className='inline h-5 w-5' />}- </p>- {show && (- <div className='absolute right-0 top-20 z-10 mt-2 max-h-[200px] min-w-[250px] overflow-auto rounded-md border border-gray-200 bg-white text-gray-900 shadow-lg dark:border-slate-700/50 dark:bg-slate-900'>- <div className='flex w-full flex-col p-2'>- <p className='text-sm font-semibold text-gray-900 dark:text-gray-50'>{t('dashboard.liveVisitors')}</p>- {loading ? (- <p className='text-sm text-gray-900 dark:text-gray-50'>{t('common.loading')}</p>- ) : (- _map(liveInfo, ({ dv, br, os, cc }, index) => (- <div- key={`${dv}${br}${os}${cc}${index}`}- className='mt-2 flex w-full flex-row items-center justify-between rounded-md bg-gray-100 p-2 text-sm text-gray-900 dark:bg-slate-800 dark:text-gray-50'- >- <div className='flex flex-row items-center'>- <Flag className='mr-2 rounded-sm' country={cc} size={21} alt='' aria-hidden='true' />- <p className='mr-2'>{os}</p>- <p className='mr-2'>{br}</p>- <p className='mr-2 capitalize'>{dv}</p>- </div>- <p className='text-xs font-semibold text-green-500'>{t('dashboard.live')}</p>- </div>- ))- )}- </div>- <XMarkIcon- className='absolute right-2 top-2 h-5 w-5 cursor-pointer rounded-md text-gray-900 hover:bg-gray-200 dark:text-gray-50 hover:dark:bg-slate-800 '- onClick={() => setShow(!show)}- />- </div>- )}- </OutsideClickHandler>- )-}--export default LiveVisitorsDropdowndiff --git a/app/pages/CrashHandler/index.tsx b/app/pages/CrashHandler/index.tsxdeleted file mode 100644index edba6e7f1..000000000--- a/app/pages/CrashHandler/index.tsx+++ /dev/null@@ -1,117 +0,0 @@-import React from 'react'-import _toString from 'lodash/toString'-import { ExclamationTriangleIcon, ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'-import { CONTACT_EMAIL, PAGE_FORCE_REFRESHED, isBrowser } from 'redux/constants'--interface CrashHandlerProps {- children: JSX.Element-}--interface CrashHandlerState {- appCrashed: boolean- crashStack: string- errorMessage: string- crashStackShown: boolean-}--const retryPageLoading = () => {- if (!isBrowser) {- return null- }-- const wasPageForceRefreshed = sessionStorage.getItem(PAGE_FORCE_REFRESHED) === 'true'-- if (!wasPageForceRefreshed) {- sessionStorage.setItem(PAGE_FORCE_REFRESHED, 'true')- return window.location.reload()- }-- return null-}--class CrashHandler extends React.Component<CrashHandlerProps, CrashHandlerState> {- constructor(props: CrashHandlerProps) {- super(props)- this.state = {- appCrashed: false,- crashStack: '',- errorMessage: '',- crashStackShown: false,- }- }-- componentDidCatch() {- retryPageLoading()- }-- static getDerivedStateFromError(error: Error) {- return {- errorMessage: _toString(error),- crashStack: error?.stack,- appCrashed: true,- }- }-- onCrashStackClick = () => {- this.setState((prevState) => ({- crashStackShown: !prevState.crashStackShown,- }))- }-- render() {- const { appCrashed, crashStack, errorMessage, crashStackShown } = this.state- const { children } = this.props-- if (appCrashed) {- return (- // Using style because for some reason min-h-screen doesn't work- <div style={{ minHeight: '100vh' }} className='flex flex-col bg-gray-50 pb-12 pt-16 dark:bg-slate-900'>- <div className='mx-auto flex w-full max-w-7xl flex-grow flex-col justify-center px-4 sm:px-6 lg:px-8'>- <div className='flex flex-shrink-0 justify-center'>- <ExclamationTriangleIcon className='h-24 w-auto text-yellow-400 dark:text-yellow-600' />- </div>- <div className='py-8'>- <div className='text-center'>- <h1 className='text-4xl font-extrabold tracking-tight text-gray-900 dark:text-gray-50 sm:text-5xl'>- Uh-oh..- </h1>- <p className='mt-2 text-base font-medium text-gray-800 dark:text-gray-300'>- The app has crashed. We are sorry about that :(- <br />- Please, tell us about it at {CONTACT_EMAIL}- </p>- <p className='mt-6 text-base font-medium text-gray-800 dark:text-gray-300'>- {errorMessage}- <br />- <span- onClick={this.onCrashStackClick}- className='flex cursor-pointer items-center justify-center text-base text-gray-800 hover:underline dark:text-gray-300'- >- {crashStackShown ? (- <>- Hide crash stack- <ChevronUpIcon className='ml-2 h-4 w-4' />- </>- ) : (- <>- Show crash stack- <ChevronDownIcon className='ml-2 h-4 w-4' />- </>- )}- </span>- {crashStackShown && (- <span className='whitespace-pre-line text-sm text-gray-600 dark:text-gray-400'>{crashStack}</span>- )}- </p>- </div>- </div>- </div>- </div>- )- }-- return children- }-}--export default CrashHandlerdiff --git a/app/pages/ErrorTracking/index.tsx b/app/pages/ErrorTracking/index.tsxindex e6dd6135d..22c55f1b4 100644--- a/app/pages/ErrorTracking/index.tsx+++ b/app/pages/ErrorTracking/index.tsx@@ -17,7 +17,7 @@ import BackgroundSvg from 'ui/icons/BackgroundSvg'import Header from 'components/Header'import Pricing from '../MainPage/Pricing'-export const Lines = (): JSX.Element => (+const Lines = (): JSX.Element => (<div className='pointer-events-none relative'><div className='absolute right-[-48rem] top-[32rem] h-px w-[800%] rotate-6 bg-gradient-to-l from-slate-600 opacity-10 dark:from-slate-400' /><div className='absolute -left-60 top-[22.26rem] ml-[-0.5px] h-96 w-[2px] rotate-[96deg] rounded-full bg-gradient-to-t from-red-600 opacity-50 dark:from-red-700 xl:top-[23.5rem]' />diff --git a/app/pages/Performance/index.tsx b/app/pages/Performance/index.tsxindex d7fc0f2ef..8f8ae1b5d 100644--- a/app/pages/Performance/index.tsx+++ b/app/pages/Performance/index.tsx@@ -17,7 +17,7 @@ import BackgroundSvg from 'ui/icons/BackgroundSvg'import Header from 'components/Header'import Pricing from '../MainPage/Pricing'-export const Lines = (): JSX.Element => (+const Lines = (): JSX.Element => (<div className='pointer-events-none relative'><div className='absolute right-[-48rem] top-[32rem] h-px w-[800%] rotate-6 bg-gradient-to-l from-slate-600 opacity-10 dark:from-slate-400' /><div className='absolute -left-60 top-[22.26rem] ml-[-0.5px] h-96 w-[2px] rotate-[96deg] rounded-full bg-gradient-to-t from-orange-600 opacity-50 dark:from-orange-700 xl:top-[23.5rem]' />diff --git a/app/pages/Project/View/ViewProject.helpers.tsx b/app/pages/Project/View/ViewProject.helpers.tsxindex 0e301974c..66dbc25c0 100644--- a/app/pages/Project/View/ViewProject.helpers.tsx+++ b/app/pages/Project/View/ViewProject.helpers.tsx@@ -1581,12 +1581,10 @@ export {validTimeBacket,noRegionPeriods,getSettings,- getExportFilename,getColumns,onCSVExportClick,CHART_METRICS_MAPPING,CHART_METRICS_MAPPING_PERF,- getColumnsPerf,getSettingsPerf,transformAIChartData,FILTER_CHART_METRICS_MAPPING_FOR_COMPARE,diff --git a/app/pages/Project/View/components/Filters.tsx b/app/pages/Project/View/components/Filters.tsxindex f5d2d7aaf..47848a7b5 100644--- a/app/pages/Project/View/components/Filters.tsx+++ b/app/pages/Project/View/components/Filters.tsx@@ -110,16 +110,7 @@ interface IFilters {tnMapping: Record<string, string>}-/**- * This component is used for rendering the filter panel.- *- * @param {array} filters - Active filters.- * @param {function} onRemoveFilter - Callback to remove a filter.- * @param {function} onChangeExclusive - Callback to change the exclusive status of a filter.- * @param {object} tnMapping - Mapping of column names to translated names.- * @returns {JSX.Element}- */-export const Filters = ({ filters, onRemoveFilter, onChangeExclusive, tnMapping }: IFilters) => {+const Filters = ({ filters, onRemoveFilter, onChangeExclusive, tnMapping }: IFilters) => {const {t,i18n: { language },diff --git a/app/pages/Project/View/components/FunnelsList.tsx b/app/pages/Project/View/components/FunnelsList.tsxindex c1df2c742..3f4e5a0a8 100644--- a/app/pages/Project/View/components/FunnelsList.tsx+++ b/app/pages/Project/View/components/FunnelsList.tsx@@ -102,12 +102,6 @@ const AddFunnel = ({ openFunnelSettings }: IAddFunnel): JSX.Element => {)}-/**- * Component to render a list of funnels.- *- * @param {string} name - Row name to override country name with.- * @returns {JSX.Element}- */const FunnelsList = ({funnels,openFunnelSettings,diff --git a/app/redux/constants/index.ts b/app/redux/constants/index.tsindex 0e9099e4c..5bb6b6a18 100644--- a/app/redux/constants/index.ts+++ b/app/redux/constants/index.ts@@ -391,7 +391,7 @@ export const isSelfhosted = Boolean(isBrowser ? window.REMIX_ENV?.SELFHOSTED : pexport const API_URL = isSelfhosted || !isStaging ? PRODUCTION_API_URL : STAGING_API_URLexport const AIAPI_URL = isBrowser ? window.REMIX_ENV?.AIAPI_URL : process.env.AIAPI_URLexport const CDN_URL = isBrowser ? window.REMIX_ENV?.CDN_URL : process.env.CDN_URL-export const NODE_ENV = isBrowser ? window.REMIX_ENV?.NODE_ENV : process.env.NODE_ENV+const NODE_ENV = isBrowser ? window.REMIX_ENV?.NODE_ENV : process.env.NODE_ENVexport const isDevelopment = !NODE_ENV || NODE_ENV === 'development'@@ -447,7 +447,6 @@ export const TOKEN: string = 'access_token'export const REFRESH_TOKEN: string = 'refresh_token'// LocalStorage-export const PAGE_FORCE_REFRESHED = 'page-force-refreshed'export const PROJECTS_PROTECTED = 'projects_protected'export const IS_ACTIVE_COMPARE = 'is-active-compare'@@ -891,11 +890,6 @@ export const chartTypes = Object.freeze({bar: 'bar',})-export const SSO_ACTIONS = Object.freeze({- LINK: 'link',- AUTH: 'auth',-})-export const SSO_PROVIDERS = Object.freeze({GOOGLE: 'google',GITHUB: 'github',diff --git a/app/redux/models/IAnalytics.ts b/app/redux/models/IAnalytics.tsdeleted file mode 100644index 7429ef710..000000000--- a/app/redux/models/IAnalytics.ts+++ /dev/null@@ -1,3 +0,0 @@-// export interface IAnalytics {--// }diff --git a/app/redux/models/IProject.ts b/app/redux/models/IProject.tsindex 0c8f6b342..f34ddde46 100644--- a/app/redux/models/IProject.ts+++ b/app/redux/models/IProject.ts@@ -35,11 +35,7 @@ export interface IOverallPerformanceObject {networkChange: number}-export interface IOverallPerformance {- [key: string]: IOverallPerformanceObject-}--export interface IUserShareProject {+interface IUserShareProject {email: string}diff --git a/app/redux/reducers/ui/cache.ts b/app/redux/reducers/ui/cache.tsindex 56ba9de1f..393918b41 100644--- a/app/redux/reducers/ui/cache.ts+++ b/app/redux/reducers/ui/cache.ts@@ -13,7 +13,7 @@ import {import { IUserFlow } from 'redux/models/IUserFlow'import { filterInvalidViewPrefs } from 'pages/Project/View/ViewProject.helpers'-export const getInitialViewPrefs = (LS_VIEW: string) => {+const getInitialViewPrefs = (LS_VIEW: string) => {if (!isBrowser) {return {}}diff --git a/app/redux/sagas/auth/workers/sso_link.ts b/app/redux/sagas/auth/workers/sso_link.tsindex 680b22c03..a5ea1c995 100644--- a/app/redux/sagas/auth/workers/sso_link.ts+++ b/app/redux/sagas/auth/workers/sso_link.ts@@ -12,7 +12,7 @@ const AUTH_WINDOW_HEIGHT = 800const HASH_CHECK_FREQUENCY = 1000 // 1 second-export interface ISSOLink {+interface ISSOLink {payload: {callback: (isSuccess: boolean) => voidt: typeof i18next.tdiff --git a/app/redux/sagas/auth/workers/sso_unlink.ts b/app/redux/sagas/auth/workers/sso_unlink.tsindex 129fede69..6092f8c22 100644--- a/app/redux/sagas/auth/workers/sso_unlink.ts+++ b/app/redux/sagas/auth/workers/sso_unlink.ts@@ -9,7 +9,7 @@ import { alertsActions } from 'redux/reducers/alerts'import { SSO_PROVIDERS } from 'redux/constants'const { unlinkSSO, authMe } = require('api')-export interface ISSOUnlink {+interface ISSOUnlink {payload: {provider: stringt: typeof i18next.tdiff --git a/app/redux/store/index.ts b/app/redux/store/index.tsindex b7dd088d8..2f436f181 100644--- a/app/redux/store/index.ts+++ b/app/redux/store/index.ts@@ -35,7 +35,6 @@ export const store = configureStore({sagaMiddleware.run(rootSaga)-export type RootState = ReturnType<typeof rootReducer>export type AppDispatch = typeof store.dispatchexport const useAppDispatch: () => AppDispatch = useDispatchexport type StateType = ReturnType<typeof store.getState>diff --git a/app/routes/project.transfer.cancel.tsx b/app/routes/project.transfer.cancel.tsxindex c7613b21f..d1a1f2d6d 100644--- a/app/routes/project.transfer.cancel.tsx+++ b/app/routes/project.transfer.cancel.tsx@@ -1,4 +1,4 @@-import TransferProjectConfirm from 'pages/Project/Settings/TransferProject/TransferProjectConfirm'+import TransferProjectReject from 'pages/Project/Settings/TransferProject/TransferProjectReject'import type { SitemapFunction } from 'remix-sitemap'export const sitemap: SitemapFunction = () => ({@@ -6,5 +6,5 @@ export const sitemap: SitemapFunction = () => ({})export default function Index() {- return <TransferProjectConfirm />+ return <TransferProjectReject />}diff --git a/app/utils/analytics.ts b/app/utils/analytics.tsindex de24210c2..cb82a5f45 100644--- a/app/utils/analytics.ts+++ b/app/utils/analytics.ts@@ -153,4 +153,4 @@ const trackCustom = (ev: string, meta?: any) => {}}-export { trackViews, trackCustom, trackErrors, SWETRIX_PID }+export { trackViews, trackCustom, trackErrors }diff --git a/app/utils/generic.ts b/app/utils/generic.tsindex 0d42e5d15..a220f79b2 100644--- a/app/utils/generic.ts+++ b/app/utils/generic.ts@@ -43,10 +43,6 @@ export const secondsTillNextMonth = () => {return 0 | ((date - now) / 1000)}-export const convertMsToSeconds = (ms: any) => {- return ms / 1000-}-// Returns an object like { h: 0, m: 0, s: 0 } based on the seconds parameter providedexport const getTimeFromSeconds = (seconds: any) => {const negative = seconds < 0@@ -102,13 +98,6 @@ export const loadScript = (url: string) => {document.body.appendChild(script)}-/**- * Returns the % change of one number relative to the other- *- * @param oldVal The initial value- * @param newVal The value that changed- * @param round Numbers after floating point- */export const calculateRelativePercentage = (oldVal: number, newVal: number, round = 2) => {if (oldVal === newVal) return 0if (oldVal === 0) return 100@@ -121,7 +110,7 @@ export const calculateRelativePercentage = (oldVal: number, newVal: number, rounreturn _round((1 - newVal / oldVal) * -100, round)}-export const displayNamesPolyfill = {+const displayNamesPolyfill = {of: (name: string) => name,}diff --git a/app/utils/getPosts.ts b/app/utils/getPosts.tsindex 278f087ce..60a55ef44 100644--- a/app/utils/getPosts.ts+++ b/app/utils/getPosts.ts@@ -15,15 +15,6 @@ renderer.link = (href: string, title: string | null | undefined, text: string) =return `<a href="${url.toString()}" referrerpolicy="strict-origin-when-cross-origin" target="_blank" rel="noopener noreferrer">${text}</a>`}-export type PostMarkdownAttributes = {- title: string- intro?: string- date: string- author: string- nickname: string- hidden?: boolean-}-// Removes first 10 characters from the string (i.e. 2023-10-07-)export const getSlugFromFilename = (filename: string) => filename.substring(11)export const getDateFromFilename = (filename: string) => filename.substring(0, 10)diff --git a/app/utils/server.ts b/app/utils/server.tsindex 04abdbb2e..54d4d677a 100644--- a/app/utils/server.ts+++ b/app/utils/server.ts@@ -5,19 +5,8 @@ import _split from 'lodash/split'import _startsWith from 'lodash/startsWith'import { TITLE_SUFFIX, SUPPORTED_THEMES, ThemeType } from 'redux/constants'-export const hasAuthCookies = (request: Request) => {- const cookie = request.headers.get('Cookie')- const accessToken = cookie?.match(/(?<=access_token=)[^;]*/)?.[0]- const refreshToken = cookie?.match(/(?<=refresh_token=)[^;]*/)?.[0]-- return accessToken && refreshToken-}-/*** Function detects theme based on user's browser hints and cookies- *- * @param request- * @returns [theme, storeToCookie]*/export function detectTheme(request: Request): [ThemeType, boolean] {// Stage 1: Check if theme is set via `theme` query param@@ -47,22 +36,10 @@ export function detectTheme(request: Request): [ThemeType, boolean] {return ['light', false]}-/**- * Function detects theme based on the query- *- * @param request- * @returns boolean- */export function isEmbedded(request: Request): boolean {return new URL(request.url).searchParams.get('embedded') === 'true'}-/**- * Function returns project tabs from query- *- * @param request- * @returns string[]- */export function getProjectTabs(request: Request): string[] {const tabs = new URL(request.url).searchParams.get('tabs')@@ -73,17 +50,11 @@ export function getProjectTabs(request: Request): string[] {return _split(tabs, ',')}-/**- * Function returns password from query- *- * @param request- * @returns boolean- */export function getProjectPassword(request: Request): string | null {return new URL(request.url).searchParams.get('password')}-export function getAccessToken(request: Request): string | null {+function getAccessToken(request: Request): string | null {const cookie = request.headers.get('Cookie')const accessToken = cookie?.match(/(?<=access_token=)[^;]*/)?.[0]diff --git a/knip.jsonc b/knip.jsoncnew file mode 100644index 000000000..7410c901b--- /dev/null+++ b/knip.jsonc@@ -0,0 +1,5 @@+{+ "$schema": "https://unpkg.com/knip@5/schema.json",+ "ignoreDependencies": ["eslint-plugin-jsx-a11y", "@typescript-eslint/typescript-estree", "@typescript-eslint/parser"],+ "ignoreBinaries": ["flyctl"]+}diff --git a/package.json b/package.jsonindex e4150521d..8df7a05e7 100644--- a/package.json+++ b/package.json@@ -14,13 +14,13 @@"lint:fix": "eslint app --fix","lint:tsc": "tsc --noEmit","format": "prettier --check --ignore-unknown ./app ./public",- "format:fix": "prettier --write --ignore-unknown ./app ./public"+ "format:fix": "prettier --write --ignore-unknown ./app ./public",+ "knip": "knip"},"dependencies": {"@blaumaus/react-alert": "^7.0.7","@headlessui/react": "^2.0.4","@heroicons/react": "^2.1.3",- "@nivo/core": "^0.87.0","@nivo/sankey": "^0.87.0","@reduxjs/toolkit": "^1.9.7","@remix-run/node": "^2.9.2",@@ -137,11 +137,10 @@"@tailwindcss/typography": "^0.5.13","@types/debug": "^4.1.12","@types/lodash": "^4.17.4",- "@types/node": "^20.12.12",+ "@types/node": "^20.14.2","@types/react": "^18.3.3","@types/react-dom": "^18.3.0","@types/react-flatpickr": "^3.8.11",- "@types/redux-mock-store": "^1.0.6","@typescript-eslint/parser": "^7.10.0","@typescript-eslint/typescript-estree": "^7.10.0","autoprefixer": "^10.4.19",@@ -150,9 +149,9 @@"eslint-plugin-jsx-a11y": "^6.8.0","eslint-plugin-lodash": "^7.4.0","eslint-plugin-react-hooks": "^4.6.2",+ "knip": "^5.18.2","postcss": "^8.4.38","prettier": "^3.2.5",- "resize-observer-polyfill": "^1.5.1","tailwindcss": "^3.4.3","typescript": "^5.4.5"},