Skip to content

πŸ“ˆ 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!

fixed linting errors

Blue Mouse15cf8d6a9733
diff --git a/app/App.tsx b/app/App.tsx
index c05519440..76fe3f594 100644
--- a/app/App.tsx
+++ b/app/App.tsx
@@ -166,9 +166,8 @@ const App: React.FC<IApp> = ({ ssrTheme }) => {
const isMinimalFooter = _some(minimalFooterPages, (page) => _includes(pathname, page))
- return (
- <>
- {(!accessToken || !loading) && (
+ if (!accessToken || !loading) {
+ return (
// eslint-disable-next-line react/jsx-no-useless-fragment
<Suspense fallback={<></>}>
{pathname !== routesPath.main && (
@@ -184,9 +183,10 @@ const App: React.FC<IApp> = ({ ssrTheme }) => {
</ScrollToTop>
<Footer minimal={isMinimalFooter} authenticated={authenticated} />
</Suspense>
- )}
- </>
- )
+ )
+ }
+
+ return null
}
export default App
diff --git a/app/components/Header/index.tsx b/app/components/Header/index.tsx
index 3ab235389..68898f4a5 100644
--- a/app/components/Header/index.tsx
+++ b/app/components/Header/index.tsx
@@ -585,10 +585,11 @@ const Header: React.FC<IHeader> = ({ ssrTheme }): JSX.Element => {
const dispatch = useAppDispatch()
const _dispatch = useDispatch()
const { authenticated, user } = useSelector((state: StateType) => state.auth)
- const theme = isBrowser ? useSelector((state: StateType) => state.ui.theme.theme) : ssrTheme
+ const reduxTheme = useSelector((state: StateType) => state.ui.theme.theme)
const { pathname } = useLocation()
// @ts-ignore
const buttonRef: MutableRefObject<HTMLButtonElement> = useRef<HTMLButtonElement>()
+ const theme = isBrowser ? reduxTheme : ssrTheme
const [rawStatus, status] = useMemo(() => {
const { trialEndDate } = (user || {})
diff --git a/app/entry.server.tsx b/app/entry.server.tsx
index e7b462133..55db3ab86 100644
--- a/app/entry.server.tsx
+++ b/app/entry.server.tsx
@@ -1,6 +1,6 @@
import type { EntryContext } from '@remix-run/node'
import { PassThrough } from 'node:stream'
-import { resolve } from 'node:path'
+import { resolve as feResolve } from 'node:path'
import { createInstance } from 'i18next'
import { I18nextProvider, initReactI18next } from 'react-i18next'
import FSBackend from 'i18next-fs-backend'
@@ -45,7 +45,7 @@ export default async function handleRequest(
lng,
ns,
backend: {
- loadPath: resolve('./public/locales/{{lng}}.json'),
+ loadPath: feResolve('./public/locales/{{lng}}.json'),
},
})
diff --git a/app/hoc/ScrollToTop.tsx b/app/hoc/ScrollToTop.tsx
index 6dd385362..6abc0d7e1 100644
--- a/app/hoc/ScrollToTop.tsx
+++ b/app/hoc/ScrollToTop.tsx
@@ -1,19 +1,22 @@
-import React, { useEffect } from 'react'
-import { useNavigate } from '@remix-run/react'
-import _isEmpty from 'lodash/isEmpty'
+// import React, { useEffect } from 'react'
+import React from 'react'
+// import { useNavigate, useLocation } from '@remix-run/react'
+// import _isEmpty from 'lodash/isEmpty'
interface IScrollToTop {
children: JSX.Element
}
-interface StateType {
- scrollToTopDisable?: boolean
-}
+// interface StateType {
+// scrollToTopDisable?: boolean
+// }
-interface IHistoryListener {
- hash: string
- state?: StateType | null
-}
+// interface IHistoryListener {
+// hash: string
+// state?: StateType | null
+// }
+
+// TODO: FIX THIS HOC
/**
* A HOC which listens to history changes and scrolls to top of the page when triggered.
@@ -29,29 +32,26 @@ interface IHistoryListener {
* @param {HTMLElement} children The children covered by the listener.
*/
const ScrollToTop: React.FC<IScrollToTop> = ({ children }) => {
- const history = useNavigate()
+ // const location = useLocation()
// useEffect(() => {
- // const unlisten = useNavigate.listen((location: any) => {
- // const { hash, state } = location as IHistoryListener
-
- // if (!_isEmpty(state) && state?.scrollToTopDisable) {
- // return
- // }
-
- // if (hash !== '') {
- // return
- // }
-
- // setTimeout(() => {
- // window.scrollTo({
- // top: 0,
- // behavior: 'smooth',
- // })
- // }, 0)
- // })
- // return unlisten
- // }, [history])
+ // const { hash, state } = location
+
+ // if (!_isEmpty(state) && state?.scrollToTopDisable) {
+ // return
+ // }
+
+ // if (hash !== '') {
+ // return
+ // }
+
+ // setTimeout(() => {
+ // window.scrollTo({
+ // top: 0,
+ // behavior: 'smooth',
+ // })
+ // }, 0)
+ // }, [location])
return children
}
diff --git a/app/hoc/Selfhosted.tsx b/app/hoc/Selfhosted.tsx
index 8faed016f..ae71ef644 100644
--- a/app/hoc/Selfhosted.tsx
+++ b/app/hoc/Selfhosted.tsx
@@ -27,6 +27,8 @@ const Selfhosted: React.FC<ISelfhosted> = ({ children }): JSX.Element => {
navigate(DEFAULT_PAGE)
}
}
+ // TODO: Investigate this later. https://github.com/remix-run/react-router/discussions/8465
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [location])
return children
diff --git a/app/hoc/protected.tsx b/app/hoc/protected.tsx
index 49c9ce046..5d44cd940 100644
--- a/app/hoc/protected.tsx
+++ b/app/hoc/protected.tsx
@@ -34,6 +34,8 @@ export const withAuthentication = <P extends PropsType>(WrappedComponent: any, a
if (!selector) {
navigate(authParam.redirectPath)
}
+ // TODO: Investigate this later. https://github.com/remix-run/react-router/discussions/8465
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [selector])
// if (!selector) {
diff --git a/app/pages/MainPage/index.tsx b/app/pages/MainPage/index.tsx
index 1b72c3829..bcb99329f 100644
--- a/app/pages/MainPage/index.tsx
+++ b/app/pages/MainPage/index.tsx
@@ -16,7 +16,9 @@ import _isEmpty from 'lodash/isEmpty'
import routesPath from 'routesPath'
import { nFormatterSeparated } from 'utils/generic'
-import { GITHUB_URL, MARKETPLACE_URL, LIVE_DEMO_URL, isBrowser } from 'redux/constants'
+import {
+ GITHUB_URL, MARKETPLACE_URL, LIVE_DEMO_URL, isBrowser,
+} from 'redux/constants'
import { StateType } from 'redux/store/index'
import BackgroundSvg from 'ui/icons/BackgroundSvg'
import Webflow from 'ui/icons/Webflow'
@@ -34,7 +36,6 @@ import Gatsby from 'ui/icons/Gatsby'
import Wix from 'ui/icons/Wix'
import Header from 'components/Header'
-import { detectTheme } from 'utils/server'
import SignUp from '../Auth/Signup/BasicSignup'
import Pricing from './Pricing'
@@ -149,9 +150,10 @@ const Main: React.FC<IMain> = ({ ssrTheme }): JSX.Element => {
language: string
},
} = useTranslation('common')
- const theme = isBrowser ? useSelector((state: StateType) => state.ui.theme.theme) : ssrTheme
+ const reduxTheme = useSelector((state: StateType) => state.ui.theme.theme)
const { authenticated } = useSelector((state: StateType) => state.auth)
const { stats, lastBlogPost } = useSelector((state: StateType) => state.ui.misc)
+ const theme = isBrowser ? reduxTheme : ssrTheme
const events = nFormatterSeparated(Number(stats.events))
const users = nFormatterSeparated(Number(stats.users))
diff --git a/app/pages/Project/View/ViewProject.tsx b/app/pages/Project/View/ViewProject.tsx
index 6282a50cc..c0bda1171 100644
--- a/app/pages/Project/View/ViewProject.tsx
+++ b/app/pages/Project/View/ViewProject.tsx
@@ -384,7 +384,8 @@ const ViewProject = ({
// { name } is a project name from project
const { name } = project
- const pageTitle = user?.showLiveVisitorsInTitle ? `πŸ‘€ ${liveStats[id]} - ${name}` : name
+ // TODO: DISPLAY PAGE TITLE IN TABS LATER
+ // const pageTitle = user?.showLiveVisitorsInTitle ? `πŸ‘€ ${liveStats[id]} - ${name}` : name
// sharedRoles is a role for shared project
const sharedRoles = useMemo(() => _find(user.sharedProjects, p => p.project.id === id)?.role || {}, [user, id])
diff --git a/app/redux/reducers/ui/theme.ts b/app/redux/reducers/ui/theme.ts
index 1fbd0f600..53152ca7a 100644
--- a/app/redux/reducers/ui/theme.ts
+++ b/app/redux/reducers/ui/theme.ts
@@ -1,8 +1,9 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
import _includes from 'lodash/includes'
import { setCookie, getCookie } from 'utils/cookie'
-import { isBrowser } from 'redux/constants'
-import { LS_THEME_SETTING, SUPPORTED_THEMES, THEME_TYPE } from 'redux/constants'
+import {
+ isBrowser, LS_THEME_SETTING, SUPPORTED_THEMES, THEME_TYPE,
+} from 'redux/constants'
const setThemeToDOM = (theme: string) => {
if (!isBrowser) {
diff --git a/app/redux/sagas/actions/index.ts b/app/redux/sagas/actions/index.ts
index a3a1292fe..83c4c276d 100644
--- a/app/redux/sagas/actions/index.ts
+++ b/app/redux/sagas/actions/index.ts
@@ -1,11 +1,11 @@
/* eslint-disable no-unused-vars */
import types from 'redux/sagas/actions/types'
import { getRefreshToken, removeRefreshToken } from 'utils/refreshToken'
-// import { logoutApi } from 'api'
import { removeAccessToken } from 'utils/accessToken'
import { removeItem } from 'utils/localstorage'
import { LS_VIEW_PREFS_SETTING, LS_CAPTCHA_VIEW_PREFS_SETTING } from 'redux/constants'
import { IUser } from '../../models/IUser'
+const { logoutApi } = require('api')
const loadProjects = (take?: number, skip?: number) => ({
type: types.LOAD_PROJECTS,
@@ -98,7 +98,7 @@ const updateUserProfileAsync = (data: Partial<IUser>, callback = (item: any) =>
const deleteAccountAsync = (errorCallback?: (e: string) => {}, successCallback?: (str?: string) => void, t?: (str: string) => {}) => {
const refreshToken = getRefreshToken()
- // logoutApi(refreshToken)
+ logoutApi(refreshToken)
return {
type: types.DELETE_ACCOUNT_ASYNC,
@@ -118,7 +118,7 @@ const shareVerifyAsync = (data: {
const logout = (basedOn401Error: boolean) => {
const refreshToken = getRefreshToken()
- // logoutApi(refreshToken)
+ logoutApi(refreshToken)
removeAccessToken()
removeRefreshToken()
removeItem(LS_VIEW_PREFS_SETTING)
diff --git a/app/redux/sagas/auth/workers/logout.ts b/app/redux/sagas/auth/workers/logout.ts
index 37f9ede9a..4f7b537f4 100644
--- a/app/redux/sagas/auth/workers/logout.ts
+++ b/app/redux/sagas/auth/workers/logout.ts
@@ -2,8 +2,8 @@ import { call, put } from 'redux-saga/effects'
import Debug from 'debug'
import UIActions from 'redux/reducers/ui'
-const { getGeneralStats } = require('api')
import { IStats } from '../../../models/IStats'
+const { getGeneralStats } = require('api')
const debug = Debug('swetrix:rx:s:logout')
diff --git a/app/redux/sagas/ui/load_projects.ts b/app/redux/sagas/ui/load_projects.ts
index b65c32267..1ad5840af 100644
--- a/app/redux/sagas/ui/load_projects.ts
+++ b/app/redux/sagas/ui/load_projects.ts
@@ -8,7 +8,7 @@ import UIActions from 'redux/reducers/ui'
import { ENTRIES_PER_PAGE_DASHBOARD } from 'redux/constants'
import { IOverall } from 'redux/models/IProject'
const {
- getProjects, getOverallStats, getLiveVisitors, getOverallStatsCaptcha, logoutApi,
+ getProjects, getOverallStats, getLiveVisitors, getOverallStatsCaptcha,
} = require('../../../api')
const debug = Debug('swetrix:rx:s:load-projects')
diff --git a/app/routes/$.tsx b/app/routes/$.tsx
index 379bf8ec8..7884ae19e 100644
--- a/app/routes/$.tsx
+++ b/app/routes/$.tsx
@@ -4,7 +4,7 @@ import { json } from '@remix-run/node'
import NotFound from 'pages/NotFound'
export const sitemap: SitemapFunction = () => ({
- exclude: true
+ exclude: true,
})
export const loader: LoaderFunction = () => {
diff --git a/app/routes/share.$id.tsx b/app/routes/share.$id.tsx
index 00193be21..e60ffd052 100644
--- a/app/routes/share.$id.tsx
+++ b/app/routes/share.$id.tsx
@@ -3,7 +3,7 @@ import type { V2_MetaFunction } from '@remix-run/node'
import type { SitemapFunction } from 'remix-sitemap'
export const sitemap: SitemapFunction = () => ({
- exclude: true
+ exclude: true,
})
export const meta: V2_MetaFunction = () => {
diff --git a/app/utils/accessToken.ts b/app/utils/accessToken.ts
index 0ac243a69..8796ca484 100644
--- a/app/utils/accessToken.ts
+++ b/app/utils/accessToken.ts
@@ -8,7 +8,7 @@ const STORE_AUTH_TOKEN_FOR = 8467200
// It's important to first check in cookie, then in session storage, not vice versa.
export const getAccessToken = () => {
if (!isBrowser) {
- return
+ return null
}
let accessToken = getCookie(TOKEN)
@@ -22,12 +22,12 @@ export const getAccessToken = () => {
export const setAccessToken = (token: string, temporary: boolean = false) => {
if (!isBrowser) {
- return
+ return null
}
if (temporary) {
sessionStorage.setItem(TOKEN, token)
- return
+ return null
}
setCookie(TOKEN, token, STORE_AUTH_TOKEN_FOR)
@@ -35,7 +35,7 @@ export const setAccessToken = (token: string, temporary: boolean = false) => {
export const removeAccessToken = () => {
if (!isBrowser) {
- return
+ return null
}
deleteCookie(TOKEN)
diff --git a/app/utils/cookie.ts b/app/utils/cookie.ts
index 1d253f0c1..46f53cee6 100644
--- a/app/utils/cookie.ts
+++ b/app/utils/cookie.ts
@@ -20,7 +20,7 @@ export const getCookie = (key: string) => {
export const setCookie = (key: string, value: string | number | boolean, maxAge = 3600, sameSite = 'strict') => {
if (!isBrowser) {
- return
+ return null
}
document.cookie = `${key}=${value}; max-age=${maxAge}; path=/; SameSite=${sameSite}${COOKIE_SUFFIX}`
@@ -28,7 +28,7 @@ export const setCookie = (key: string, value: string | number | boolean, maxAge
export const deleteCookie = (key: string) => {
if (!isBrowser) {
- return
+ return null
}
document.cookie = `${key}=; max-age=0; path=/; SameSite=strict`
diff --git a/app/utils/refreshToken.ts b/app/utils/refreshToken.ts
index c799f5f91..0793237f5 100644
--- a/app/utils/refreshToken.ts
+++ b/app/utils/refreshToken.ts
@@ -8,7 +8,7 @@ const STORE_REFRESH_TOKEN_FOR = 8467200
export const getRefreshToken = () => {
if (!isBrowser) {
- return
+ return null
}
let refreshToken = getCookie(REFRESH_TOKEN)
@@ -22,7 +22,7 @@ export const getRefreshToken = () => {
export const setRefreshToken = (token: string, temporary: boolean = false) => {
if (!isBrowser) {
- return
+ return null
}
if (temporary) {
@@ -35,7 +35,7 @@ export const setRefreshToken = (token: string, temporary: boolean = false) => {
export const removeRefreshToken = () => {
if (!isBrowser) {
- return
+ return null
}
deleteCookie(REFRESH_TOKEN)
diff --git a/package.json b/package.json
index 2be58fecf..4ef21db43 100644
--- a/package.json
+++ b/package.json
@@ -105,6 +105,7 @@
"lodash/prefer-lodash-method": "warn",
"import/newline-after-import": "off",
"@typescript-eslint/consistent-type-imports": "off",
+ "consistent-return": "off",
"max-len": "off",
"no-console": "off",
"no-bitwise": "off",