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 warnings

Blue Mouse7c6bdc594bf8
diff --git a/src/api/index.js b/src/api/index.js
index ed558dc2f..5c2790b60 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -4,6 +4,7 @@ import { store } from 'redux/store'
import Debug from 'debug'
import _map from 'lodash/map'
import _isEmpty from 'lodash/isEmpty'
+import _isArray from 'lodash/isArray'
import { authActions } from 'redux/actions/auth'
import { getAccessToken, removeAccessToken } from 'utils/accessToken'
@@ -68,7 +69,7 @@ export const signup = (data) =>
.then((response) => response.data)
.catch((error) => {
const errorsArray = error.response.data.message
- if (Array.isArray(errorsArray)) {
+ if (_isArray(errorsArray)) {
throw errorsArray
}
throw new Error(errorsArray)
@@ -88,7 +89,7 @@ export const changeUserDetails = (data) =>
.then((response) => response.data)
.catch((error) => {
const errorsArray = error.response.data.message
- if (Array.isArray(errorsArray)) {
+ if (_isArray(errorsArray)) {
throw errorsArray
}
throw new Error(errorsArray)
@@ -133,7 +134,7 @@ export const createNewPassword = (id, password) =>
.then((response) => response.data)
.catch((error) => {
const errorsArray = error.response.data.message
- if (Array.isArray(errorsArray)) {
+ if (_isArray(errorsArray)) {
throw errorsArray
}
throw new Error(errorsArray)
diff --git a/src/hoc/ScrollToTop.jsx b/src/hoc/ScrollToTop.jsx
index 027878420..36da0dc0f 100644
--- a/src/hoc/ScrollToTop.jsx
+++ b/src/hoc/ScrollToTop.jsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react'
+import { useEffect } from 'react'
import { useHistory } from 'react-router-dom'
/**
diff --git a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
index ff1498c0a..046f2a954 100644
--- a/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
+++ b/src/pages/Auth/CreateNewPassword/CreateNewPassword.jsx
@@ -2,6 +2,8 @@ import React, { useState, useEffect, memo } from 'react'
import { Link, useHistory, useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import _size from 'lodash/size'
+import _keys from 'lodash/keys'
+import _isEmpty from 'lodash/isEmpty'
import { createNewPassword } from 'api'
import { withAuthentication, auth } from 'hoc/protected'
@@ -41,7 +43,7 @@ const CreateNewPassword = ({
allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_CHARS })
}
- const valid = Object.keys(allErrors).length === 0
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
index 79e31eba0..cfc1509da 100644
--- a/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
+++ b/src/pages/Auth/ForgotPassword/ForgotPassword.jsx
@@ -1,6 +1,8 @@
import React, { useState, useEffect, memo } from 'react'
import { Link, useHistory } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
+import _keys from 'lodash/keys'
+import _isEmpty from 'lodash/isEmpty'
import { forgotPassword } from 'api'
import Title from 'components/Title'
@@ -30,7 +32,7 @@ const ForgotPassword = ({
allErrors.email = t('auth.common.badEmailError')
}
- const valid = Object.keys(allErrors).length === 0
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/pages/Auth/Signin/Signin.jsx b/src/pages/Auth/Signin/Signin.jsx
index cfb02528b..f0640c2ed 100644
--- a/src/pages/Auth/Signin/Signin.jsx
+++ b/src/pages/Auth/Signin/Signin.jsx
@@ -2,6 +2,8 @@ import React, { useState, useEffect, memo } from 'react'
import { Link } from 'react-router-dom'
import PropTypes from 'prop-types'
import { useTranslation } from 'react-i18next'
+import _keys from 'lodash/keys'
+import _isEmpty from 'lodash/isEmpty'
import Title from 'components/Title'
import { withAuthentication, auth } from 'hoc/protected'
@@ -37,7 +39,7 @@ const Signin = ({ login }) => {
allErrors.password = t('auth.common.xCharsError', { amount: MIN_PASSWORD_CHARS })
}
- const valid = Object.keys(allErrors).length === 0
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/pages/Auth/Signup/BasicSignup.jsx b/src/pages/Auth/Signup/BasicSignup.jsx
index d65589194..62af0c391 100644
--- a/src/pages/Auth/Signup/BasicSignup.jsx
+++ b/src/pages/Auth/Signup/BasicSignup.jsx
@@ -3,6 +3,8 @@ import { useDispatch } from 'react-redux'
import { authActions } from 'redux/actions/auth'
import { useTranslation, Trans } from 'react-i18next'
import _size from 'lodash/size'
+import _keys from 'lodash/keys'
+import _isEmpty from 'lodash/isEmpty'
import Input from 'ui/Input'
import Button from 'ui/Button'
@@ -57,7 +59,7 @@ const BasicSignup = () => {
allErrors.password = t('auth.common.passwordTooLong', { amount: MAX_PASSWORD_CHARS })
}
- const valid = Object.keys(allErrors).length === 0
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/pages/Auth/Signup/Signup.jsx b/src/pages/Auth/Signup/Signup.jsx
index e56289dc6..d92fd2760 100644
--- a/src/pages/Auth/Signup/Signup.jsx
+++ b/src/pages/Auth/Signup/Signup.jsx
@@ -3,6 +3,8 @@ import { Link } from 'react-router-dom'
import PropTypes from 'prop-types'
import { useTranslation, Trans } from 'react-i18next'
import _size from 'lodash/size'
+import _keys from 'lodash/keys'
+import _isEmpty from 'lodash/isEmpty'
import Title from 'components/Title'
import { withAuthentication, auth } from 'hoc/protected'
@@ -54,7 +56,7 @@ const Signup = ({ signup }) => {
allErrors.tos = t('auth.common.tosError')
}
- const valid = Object.keys(allErrors).length === 0
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/pages/Auth/VerifyEmail/index.jsx b/src/pages/Auth/VerifyEmail/index.jsx
index 67e743c5b..843d95069 100644
--- a/src/pages/Auth/VerifyEmail/index.jsx
+++ b/src/pages/Auth/VerifyEmail/index.jsx
@@ -3,6 +3,7 @@ import { useDispatch } from 'react-redux'
import { useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { CheckCircleIcon, XCircleIcon } from '@heroicons/react/solid'
+import _split from 'lodash/split'
import Title from 'components/Title'
import { authActions } from 'redux/actions/auth'
@@ -17,7 +18,7 @@ const VerifyEmail = () => {
useEffect(() => {
setLoading(true)
- const path = window.location.pathname.split('/')[1]
+ const path = _split(window.location.pathname, '/')[1]
dispatch(
authActions.emailVerifyAsync(
diff --git a/src/pages/Billing/index.jsx b/src/pages/Billing/index.jsx
index f996816d9..526347b6c 100644
--- a/src/pages/Billing/index.jsx
+++ b/src/pages/Billing/index.jsx
@@ -1,4 +1,4 @@
-/* eslint-disable jsx-a11y/anchor-has-content */
+/* eslint-disable jsx-a11y/anchor-has-content, lodash/prefer-lodash-method */
import React, { memo } from 'react'
import { useTranslation, Trans } from 'react-i18next'
import { useSelector } from 'react-redux'
diff --git a/src/pages/Dashboard/Dashboard.jsx b/src/pages/Dashboard/Dashboard.jsx
index 0c6f2904c..a06a629b8 100644
--- a/src/pages/Dashboard/Dashboard.jsx
+++ b/src/pages/Dashboard/Dashboard.jsx
@@ -6,6 +6,7 @@ import dayjs from 'dayjs'
import PropTypes from 'prop-types'
import _isEmpty from 'lodash/isEmpty'
import _isNumber from 'lodash/isNumber'
+import _replace from 'lodash/replace'
import _map from 'lodash/map'
import _filter from 'lodash/filter'
import { useTranslation } from 'react-i18next'
@@ -189,7 +190,7 @@ const Dashboard = ({
isPublic={isPublic}
overall={overall}
live={_isNumber(live) ? live : 'N/A'}
- url={routes.project.replace(':id', id)}
+ url={_replace(routes.project, ':id', id)}
/>
))}
</ul>
diff --git a/src/pages/Project/Settings/ProjectSettings.jsx b/src/pages/Project/Settings/ProjectSettings.jsx
index 0fc4aef85..9f6ea455d 100644
--- a/src/pages/Project/Settings/ProjectSettings.jsx
+++ b/src/pages/Project/Settings/ProjectSettings.jsx
@@ -11,6 +11,7 @@ import _find from 'lodash/find'
import _join from 'lodash/join'
import _isString from 'lodash/isString'
import _split from 'lodash/split'
+import _keys from 'lodash/keys'
import PropTypes from 'prop-types'
import Title from 'components/Title'
@@ -132,7 +133,7 @@ const ProjectSettings = ({
allErrors.origins = t('project.settings.oxCharsError', { amount: MAX_ORIGINS_LENGTH })
}
- const valid = Object.keys(allErrors).length === 0
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 6cf476107..2736dcac1 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -1,4 +1,4 @@
-/* eslint-disable react/forbid-prop-types, react/no-unstable-nested-components */
+/* eslint-disable react/forbid-prop-types, react/no-unstable-nested-components, react/display-name */
import React, {
useState, useEffect, useMemo, memo, useRef,
} from 'react'
diff --git a/src/pages/UserSettings/UserSettings.jsx b/src/pages/UserSettings/UserSettings.jsx
index 71511c1a9..44b815bfc 100644
--- a/src/pages/UserSettings/UserSettings.jsx
+++ b/src/pages/UserSettings/UserSettings.jsx
@@ -6,6 +6,7 @@ import _size from 'lodash/size'
import _isEmpty from 'lodash/isEmpty'
import _findIndex from 'lodash/findIndex'
import _map from 'lodash/map'
+import _keys from 'lodash/keys'
import { MailIcon } from '@heroicons/react/outline'
import { reportFrequencies, DEFAULT_TIMEZONE } from 'redux/constants'
@@ -56,7 +57,7 @@ const UserSettings = ({
allErrors.repeat = t('auth.common.noMatchError')
}
- const valid = _isEmpty(Object.keys(allErrors))
+ const valid = _isEmpty(_keys(allErrors))
setErrors(allErrors)
setValidated(valid)
diff --git a/src/ui/Progress.jsx b/src/ui/Progress.jsx
index f0ed3e5a4..e0d641db7 100644
--- a/src/ui/Progress.jsx
+++ b/src/ui/Progress.jsx
@@ -1,4 +1,5 @@
import React, { memo } from 'react'
+import PropTypes from 'prop-types'
const Progress = ({ now }) => (
<div className='relative'>
@@ -8,4 +9,8 @@ const Progress = ({ now }) => (
</div>
)
+Progress.propTypes = {
+ now: PropTypes.number.isRequired,
+}
+
export default memo(Progress)
diff --git a/src/ui/TimezonePicker.jsx b/src/ui/TimezonePicker.jsx
index 1b2159ff5..cd7e992f8 100644
--- a/src/ui/TimezonePicker.jsx
+++ b/src/ui/TimezonePicker.jsx
@@ -5,11 +5,14 @@ import { allTimezones } from 'react-timezone-select'
import { useTranslation } from 'react-i18next'
import PropTypes from 'prop-types'
import _find from 'lodash/find'
+import _reduce from 'lodash/reduce'
+import _includes from 'lodash/includes'
import Select from './Select'
-const options = Object.entries(allTimezones)
- .reduce((selectOptions, zone) => {
+const options = _reduce(
+ Object.entries(allTimezones),
+ (selectOptions, zone) => {
const now = spacetime.now(zone[0])
const tz = now.timezone()
const tzStrings = soft(zone[0])
@@ -20,7 +23,7 @@ const options = Object.entries(allTimezones)
const min = tz.current.offset * 60
// eslint-disable-next-line prefer-template
const hr = `${(min / 60) ^ 0}:` + (min % 60 === 0 ? '00' : Math.abs(min % 60))
- const label = `(GMT${hr.includes('-') ? hr : `+${hr}`}) ${zone[1]}`
+ const label = `(GMT${_includes(hr, '-') ? hr : `+${hr}`}) ${zone[1]}`
selectOptions.push({
value: tz.name,
@@ -31,7 +34,9 @@ const options = Object.entries(allTimezones)
})
return selectOptions
- }, [])
+ },
+ [],
+)
.sort((a, b) => a.offset - b.offset)
const TimezoneSelect = ({
diff --git a/src/utils/generic.js b/src/utils/generic.js
index f14637dcb..b6472d4fb 100644
--- a/src/utils/generic.js
+++ b/src/utils/generic.js
@@ -1,4 +1,5 @@
import _find from 'lodash/find'
+import _replace from 'lodash/replace'
const rx = /\.0+$|(\.[0-9]*[1-9])0+$/
@@ -12,7 +13,7 @@ export const nFormatter = (num, digits) => {
const item = _find(lookup.slice().reverse(), ({ value }) => num >= value)
- return item ? (num / item.value).toFixed(digits).replace(rx, '$1') + item.symbol : '0'
+ return item ? _replace((num / item.value).toFixed(digits), rx, '$1') + item.symbol : '0'
}
export const secondsTillNextMonth = () => {