Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: run prettier format on all codebase #743

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ jobs:
AUTH0_JWKS_URI: https://dhis2.eu.auth0.com/.well-known/jwks.json
AUTH0_MANAGEMENT_AUDIENCE: https://dhis2.eu.auth0.com/api/v2/
AUTH0_MANAGEMENT_SECRET: ${{ secrets.AUTH0_MANAGEMENT_SECRET }}
AUTH0_MANAGEMENT_CLIENT_ID: K4fVnj443Sqid3Xl9yBVTYw9BEjPx3gl
AUTH0_MANAGEMENT_CLIENT_ID: K4fVnj443Sqid3Xl9yBVTYw9BEjPx3gl
2 changes: 1 addition & 1 deletion .huskyrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { config } = require('@dhis2/cli-style')
const husky = require(config.husky)

const tasks = arr => arr.join(' && ')
const tasks = (arr) => arr.join(' && ')

module.exports = {
hooks: {
Expand Down
12 changes: 6 additions & 6 deletions client/config/configResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ function getConfig() {

//Get default config
const configs = defaultConfigs
.map(filename => loadFile(filename))
.filter(config => !!config)
configs.forEach(cfg => merge(config, cfg))
.map((filename) => loadFile(filename))
.filter((config) => !!config)
configs.forEach((cfg) => merge(config, cfg))

//Get environment specific config
if (envConfigNames[nodeEnv]) {
const configs = envConfigNames[nodeEnv]
.map(filename => loadFile(filename))
.filter(config => !!config)
configs.forEach(cfg => merge(config, cfg))
.map((filename) => loadFile(filename))
.filter((config) => !!config)
configs.forEach((cfg) => merge(config, cfg))
}

getConfig.config = config
Expand Down
2 changes: 1 addition & 1 deletion client/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@

const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = on => {
module.exports = (on) => {
on('file:preprocessor', cucumber())
}
4 changes: 2 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"test": "cross-env NODE_ENV=test mocha --config test/.mocharc.js",
"format": "yarn format:js && yarn format:text",
"format:staged": "yarn format:js --staged && yarn format:text --staged",
"format:js": "d2-style js apply",
"format:text": "d2-style text apply"
"format:js": "d2-style apply js",
"format:text": "d2-style apply text"
},
"dependencies": {
"@auth0/auth0-react": "^1.6.0",
Expand Down
2 changes: 1 addition & 1 deletion client/src/actions/actionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as actions from '../constants/actionTypes'

export const loadUser = actionCreator(actions.USER_LOAD)

export const userLoaded = profile =>
export const userLoaded = (profile) =>
actionCreator(actions.USER_LOAD_SUCCESS)({
profile,
})
Expand Down
6 changes: 3 additions & 3 deletions client/src/actions/epics.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { concatMap } from 'rxjs/operators'
import * as api from '../api'
import * as actions from '../constants/actionTypes'

const user = action$ =>
const user = (action$) =>
action$.pipe(
ofType(actions.USER_LOAD),
concatMap(() =>
api
.getMe()
.then(response => ({
.then((response) => ({
type: actions.ME_LOAD_SUCCESS,
payload: response,
}))
.catch(e => ({
.catch((e) => ({
type: actions.ME_LOAD_ERROR,
payload: e,
}))
Expand Down
6 changes: 3 additions & 3 deletions client/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const usePagination = (

const isEmpty = data?.[0].pager.total === 0
// useSWRInfinite gathers all responses with an array entry per request - flatten it
const resultData = data?.flatMap(d => d?.result)
const resultData = data?.flatMap((d) => d?.result)
const isAtEnd = isEmpty || data?.[0].pager.total === resultData?.length
const isLoadingInitial = !data && !error

Expand Down Expand Up @@ -196,7 +196,7 @@ export async function fromApi(url, auth = false, extraOpts) {
}

return fetch(baseURL + url, opts)
.then(async response => {
.then(async (response) => {
if (!response.ok) {
const contentType = response.headers.get('content-type')
const isJson = contentType.includes('application/json')
Expand All @@ -208,7 +208,7 @@ export async function fromApi(url, auth = false, extraOpts) {
}
return response
})
.then(response => response.json())
.then((response) => response.json())
}

export async function getAuthHeaders() {
Expand Down
8 changes: 4 additions & 4 deletions client/src/api/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRef, useEffect, useCallback } from 'react'

const encodeQueryParameter = param => {
const encodeQueryParameter = (param) => {
if (Array.isArray(param)) {
return param.map(encodeQueryParameter).join(',')
}
Expand All @@ -20,7 +20,7 @@ const encodeQueryParameter = param => {
}

export const joinUrlPath = (...paths) => {
const truePaths = paths.filter(path => !!path)
const truePaths = paths.filter((path) => !!path)
return truePaths
.map((path, i) => {
path = typeof path === 'string' ? path : String(path)
Expand All @@ -35,7 +35,7 @@ export const joinUrlPath = (...paths) => {
.join('/')
}

export const queryParametersToQueryString = params =>
export const queryParametersToQueryString = (params) =>
Object.entries(params)
.filter(([, value]) => value)
.map(
Expand All @@ -46,7 +46,7 @@ export const queryParametersToQueryString = params =>

// This is a SWR middleware for keeping the data even if key changes.
// See https://swr.vercel.app/docs/middleware#keep-previous-result
export const laggySWRMiddleware = useSWRNext => {
export const laggySWRMiddleware = (useSWRNext) => {
return (key, fetcher, config) => {
// Use a ref to store previous returned data
const laggyDataRef = useRef()
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/AlertsProvider/AlertsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ let alertId = 0

const AlertsProvider = ({ children }) => {
const [alerts, setAlerts] = useState([])
const removeAlert = id => {
setAlerts(alerts => alerts.filter(alert => alert.id !== id))
const removeAlert = (id) => {
setAlerts((alerts) => alerts.filter((alert) => alert.id !== id))
}
const addAlert = alert => {
const addAlert = (alert) => {
const id = alertId++
setAlerts(alerts => [
setAlerts((alerts) => [
...alerts,
{
...alert,
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Header/DropdownButton/DropdownButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import PropTypes from 'prop-types'
import { useState, useRef } from 'react'
import styles from './DropdownButton.module.css'



const DropdownButton = ({ icon, menu }) => {
const [isOpen, setIsOpen] = useState(false)
const handleToggle = () => setIsOpen(!isOpen)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { useRef, useEffect } from 'react'
import { useHistory } from 'react-router-dom'
import styles from '../DropdownMenuItem/DropdownMenuItem.module.css'

const isModifiedEvent = event =>
const isModifiedEvent = (event) =>
event.metaKey || event.altKey || event.ctrlKey || event.shiftKey

const DropdownMenuItemLink = ({ to, children, initialFocus }) => {
const history = useHistory()
const handleClick = event => {
const handleClick = (event) => {
if (!isModifiedEvent(event)) {
event.preventDefault()
history.push(to)
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ProfileButton = () => {
return <DropdownButton icon={icon} menu={menu} />
}

const NavLink = props => (
const NavLink = (props) => (
<NavLink_ activeClassName={styles.activeNavLink} {...props}></NavLink_>
)

Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Versions/Filters/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Filters = ({
{availableChannels.length > 1 && (
<div className={styles.channelsFilter}>
<h3 className={styles.subheader}>Channel</h3>
{availableChannels.map(channel => (
{availableChannels.map((channel) => (
<ChannelCheckbox
key={channel}
name={channel}
Expand All @@ -38,7 +38,7 @@ const Filters = ({
selected={dhisVersionFilter}
onChange={({ selected }) => setDhisVersionFilter(selected)}
>
{dhisVersions.map(dhisVersion => (
{dhisVersions.map((dhisVersion) => (
<SingleSelectOption
key={dhisVersion}
label={dhisVersion}
Expand Down
8 changes: 2 additions & 6 deletions client/src/components/auth/AuthProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ const AuthProvider = ({ children }) => (
)

const InitializeAuth = ({ children }) => {
const {
user,
isAuthenticated,
isLoading,
getAccessTokenSilently,
} = useAuth0()
const { user, isAuthenticated, isLoading, getAccessTokenSilently } =
useAuth0()
const dispatch = useDispatch()

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/auth/ProtectedRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ProtectedRoute = ({ component, auth, ...rest }) => {
return (
<Route
{...rest}
render={props => {
render={(props) => {
const ProtectedComponent = withAuthenticationRequired(
component,
{
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/form-validators/name-length-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { createCharacterLengthRange } from '@dhis2/ui'

const twoToHundredValidator = createCharacterLengthRange(2, 100)

export const nameLengthValidator = value => twoToHundredValidator(value)
export const nameLengthValidator = (value) => twoToHundredValidator(value)
2 changes: 1 addition & 1 deletion client/src/lib/form-validators/semver-validator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import semver from 'semver'

export const semverValidator = value => {
export const semverValidator = (value) => {
if (!semver.valid(value)) {
return 'Not a valid semantic version, adjust the version numbering'
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/lib/use-alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AlertsContext from 'src/components/AlertsProvider/AlertsContext'
export const useAlert = (message, options = {}) => {
const { addAlert } = useContext(AlertsContext)

const show = props => {
const show = (props) => {
const resolvedMessage =
typeof message === 'function' ? message(props) : message
const resolvedOptions =
Expand All @@ -22,7 +22,7 @@ export const useAlert = (message, options = {}) => {
export const useSuccessAlert = () =>
useAlert(
({ message }) => message,
options => ({
(options) => ({
...options,
success: true,
})
Expand All @@ -31,7 +31,7 @@ export const useSuccessAlert = () =>
export const useErrorAlert = () =>
useAlert(
({ error }) => `An error occured: ${error.message}`,
options => ({
(options) => ({
...options,
critical: true,
})
Expand Down
7 changes: 4 additions & 3 deletions client/src/pages/AppView/AppView.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const AboutSection = ({ appDescription, latestVersion, sourceUrl }) => (
{renderDhisVersionsCompatibility(
latestVersion.minDhisVersion,
latestVersion.maxDhisVersion
)}.
)}
.
</span>
</div>
{sourceUrl && (
Expand Down Expand Up @@ -104,8 +105,8 @@ const AppView = ({ match }) => {
}

const appDeveloper = app.developer.organisation || 'Unspecified'
const logoSrc = app.images.find(img => img.logo)?.imageUrl
const screenshots = app.images.filter(img => !img.logo)
const logoSrc = app.images.find((img) => img.logo)?.imageUrl
const screenshots = app.images.filter((img) => !img.logo)
const versions = app.versions.sort((a, b) => b.created - a.created)
const latestVersion = versions[0]

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Apps/AppCards/AppCards.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const AppCards = ({ isLoading, error, apps }) => {

return (
<div className={styles.appCards}>
{apps.map(app => (
{apps.map((app) => (
<AppCardItem
key={app.id}
id={app.id}
Expand Down
10 changes: 5 additions & 5 deletions client/src/pages/Apps/Apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ const Apps = () => {
})
const { channels, types, dhisVersion, query, page } = queryParams
const [debouncedQuery] = useDebounce(query, 300)
const setChannels = channels => {
const setChannels = (channels) => {
setQueryParams({ channels, page: 1 })
}
const setTypes = types => {
const setTypes = (types) => {
setQueryParams({ types, page: 1 })
}
const setDhisVersion = dhisVersion => {
const setDhisVersion = (dhisVersion) => {
setQueryParams({ dhisVersion, page: 1 })
}
const setQuery = query => {
const setQuery = (query) => {
setQueryParams({ query, page: 1 }, 'replaceIn')
}
const setPage = page => {
const setPage = (page) => {
setQueryParams({ page })
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/Apps/Filters/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const Filters = ({
onDhisVersionFilterChange(selected)
}
>
{dhisVersions.map(dhisVersion => (
{dhisVersions.map((dhisVersion) => (
<SingleSelectOption
key={dhisVersion}
label={dhisVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const OrganisationInvitationCallback = () => {
const [error, setError] = useState(null)

useEffect(() => {
const acceptInvitation = async token => {
const acceptInvitation = async (token) => {
try {
const { organisation } = await api.acceptOrganisationInvitation(
token
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/UserApp/DetailsCard/DetailsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const EditLogo = ({ appId, logo, mutate }) => {
const handleUploadButtonClick = () => {
inputEl.current.click()
}
const handleUpload = async event => {
const handleUpload = async (event) => {
setIsUploading(true)
try {
// TODO: Implement backend API to replace logo so that it can be
Expand Down Expand Up @@ -75,7 +75,7 @@ const EditLogo = ({ appId, logo, mutate }) => {
}

const DetailsCard = ({ app, mutate }) => {
const logo = app.images.find(img => img.logo)
const logo = app.images.find((img) => img.logo)
const appDeveloper = app.developer.organisation || 'Unspecified'
const appType = appTypeToDisplayName[app.appType]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ const DeleteScreenshotModal = ({ appId, imageId, mutate, onClose }) => {
setIsSubmitting(true)
try {
await api.deleteImage(appId, imageId)
mutate(app => ({
mutate((app) => ({
...app,
images: app.images.filter(img => img.id !== imageId),
images: app.images.filter((img) => img.id !== imageId),
}))
successAlert.show({
message: `Successfully deleted screenshot`,
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/UserApp/ScreenshotsCard/ScreenshotsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ const DeleteScreenshotButton = ({ appId, imageId, mutate }) => {
}

const ScreenshotsCard = ({ app, mutate }) => {
const screenshots = app.images.filter(img => !img.logo)
const renderDeleteScreenshotButton = imageId => (
const screenshots = app.images.filter((img) => !img.logo)
const renderDeleteScreenshotButton = (imageId) => (
<DeleteScreenshotButton
appId={app.id}
imageId={imageId}
Expand Down
Loading
Loading