Skip to content

chore: Remove/Convert a couple files to TS, shared utils Part 2 #3481

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

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useClickAway from 'react-use/lib/useClickAway'
import User from 'old_ui/User'
import { ApiFilterEnum } from 'services/navigation'
import { useUsers } from 'services/users'
import { getOwnerImg } from 'shared/utils'
import { getOwnerImg } from 'shared/utils/ownerHelpers'
import TextInput from 'ui/TextInput'

const styles = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useInView } from 'react-intersection-observer'
import { useParams } from 'react-router-dom'

import { useInfiniteUsers, useUpdateUser } from 'services/users'
import { getOwnerImg } from 'shared/utils'
import { getOwnerImg } from 'shared/utils/ownerHelpers'
import Avatar, { DefaultAuthor } from 'ui/Avatar'
import Button from 'ui/Button'
import Icon from 'ui/Icon'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import { useParams } from 'react-router-dom'

import { useAccountDetails } from 'services/account'
import { Member, useInfiniteUsers } from 'services/users'
import { getOwnerImg } from 'shared/utils'
import { isFreePlan } from 'shared/utils/billing'
import { getOwnerImg } from 'shared/utils/ownerHelpers'
import Avatar, { DefaultAuthor } from 'ui/Avatar'
import Icon from 'ui/Icon'
import Spinner from 'ui/Spinner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { graphql, HttpResponse } from 'msw'
import { setupServer } from 'msw/node'
import { MemoryRouter, Route } from 'react-router-dom'

import { Trend } from 'shared/utils/legacyCharts'
import { Trend } from 'shared/utils/timeseriesCharts'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seemed to be a lingering reference of legacyCharts utils


import { useRepoCoverageTimeseries } from './useRepoCoverageTimeseries'

Expand Down
2 changes: 1 addition & 1 deletion src/services/account/useUpgradePlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function useUpgradePlan({ provider, owner }: useUpgradePlanParams) {
},
}
return Api.patch({ path, provider, body }).then((data) => {
if (data.checkoutSessionId) {
if (data?.checkoutSessionId) {
// redirect to stripe checkout if there is a checkout session id
return redirectToStripe(data.checkoutSessionId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ describe('camelizeKeys', () => {

it('else passes through', () => {
expect(camelizeKeys([1, 2, 3])).toStrictEqual([1, 2, 3])
// @ts-expect-error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept these since it looked like we were testing for these cases?¿

expect(camelizeKeys(1)).toStrictEqual(1)
// @ts-expect-error
expect(camelizeKeys('test')).toStrictEqual('test')
expect(camelizeKeys()).toStrictEqual({})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import camelCase from 'lodash/camelCase'

export function camelizeKeys(obj = {}) {
export function camelizeKeys(
obj: Record<string, any> = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly stricter/more relevant typing than any, hoping this doesn't come back to bite but Ill keep an eye on it

): Record<string, any> {
if (Array.isArray(obj)) {
return obj.map((v) => camelizeKeys(v))
} else if (obj !== null && obj.constructor === Object) {
Expand Down
4 changes: 0 additions & 4 deletions src/shared/utils/exceptions.js

This file was deleted.

14 changes: 0 additions & 14 deletions src/shared/utils/exceptions.test.js

This file was deleted.

2 changes: 0 additions & 2 deletions src/shared/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export * from './ownerHelpers'
export * from './provider'
export * from './exceptions'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not too much work, I feel like we can just get rid of this file completely at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do, I'll remove it in #3461 when I'm done cooking that one (its been a mega pain)

115 changes: 0 additions & 115 deletions src/shared/utils/legacyCharts.js

This file was deleted.

Loading
Loading