Skip to content

Commit

Permalink
upgrade Prettier to 3.x (#598)
Browse files Browse the repository at this point in the history
[#185995187]
  • Loading branch information
uraniumanchor authored Sep 7, 2023
1 parent 021f18e commit 579a026
Show file tree
Hide file tree
Showing 21 changed files with 62 additions and 56 deletions.
7 changes: 4 additions & 3 deletions bundles/admin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ function DropdownMenu({ name, path }) {
const match = useRouteMatch();

const events = useSelector(state => state.models.event);
const sortedEvents = React.useMemo(() => [...(events || [])].sort((a, b) => b.datetime.localeCompare(a.datetime)), [
events,
]);
const sortedEvents = React.useMemo(
() => [...(events || [])].sort((a, b) => b.datetime.localeCompare(a.datetime)),
[events],
);

return (
<Dropdown closeOnClick={true} label={name}>
Expand Down
29 changes: 19 additions & 10 deletions bundles/admin/interstitials/Editor/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,33 @@ export default React.memo(function Body({ sortedItems, saveItem, canEdit }: Body
editing={editing === fullKey(item)}
saveItem={
canEdit(item)
? cachedCallback((fields: ModelFields) => {
saveItem(fullKey(item), fields);
setEditing(null);
}, `save-${fullKey(item)}`)
? cachedCallback(
(fields: ModelFields) => {
saveItem(fullKey(item), fields);
setEditing(null);
},
`save-${fullKey(item)}`,
)
: null
}
editItem={
canEdit(item)
? cachedCallback(() => {
setEditing(fullKey(item));
}, `edit-${fullKey(item)}`)
? cachedCallback(
() => {
setEditing(fullKey(item));
},
`edit-${fullKey(item)}`,
)
: null
}
cancelEdit={
canEdit(item)
? cachedCallback(() => {
setEditing(null);
}, `cancel-${fullKey(item)}`)
? cachedCallback(
() => {
setEditing(null);
},
`cancel-${fullKey(item)}`,
)
: null
}
/>
Expand Down
3 changes: 1 addition & 2 deletions bundles/processing/modules/processing/ConnectionStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ const STATUS_CONTENT = {
},
disconnected: {
heading: 'Socket Disconnected',
body:
'You can still take action on donations, but you will not see new donations in real time. Please refresh the page to reconnect.',
body: 'You can still take action on donations, but you will not see new donations in real time. Please refresh the page to reconnect.',
},
};

Expand Down
7 changes: 4 additions & 3 deletions bundles/processing/pages/ReadDonations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ export default function ReadDonations() {
useDonationGroupSyncOnLoad();

const groups = useDonationGroupsStore(state => state.groups);
const groupItems = React.useMemo(() => groups.map((group): GroupTabItem => ({ type: 'group', id: group.id })), [
groups,
]);
const groupItems = React.useMemo(
() => groups.map((group): GroupTabItem => ({ type: 'group', id: group.id })),
[groups],
);

const [selectedTab, setSelectedTab] = React.useState<FilterGroupTabItem>(FILTER_ITEMS[0]);
const tabDonations = useDonationsForFilterGroupTab(selectedTab, READING_DONATION_STATE);
Expand Down
2 changes: 1 addition & 1 deletion bundles/public/hooks/useCachedCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type MemoDict<R1> = {

export function useCachedCallback<R1>(callback: (...args: any[]) => R1, dependencies: any[], key = JSONKey) {
/* eslint-disable react-hooks/exhaustive-deps */
const memo = useMemo(() => ({} as MemoDict<R1>), dependencies);
const memo = useMemo(() => ({}) as MemoDict<R1>, dependencies);
const keyFunc = useRef(key);
return useCallback(
(...bound: any[]) => {
Expand Down
8 changes: 1 addition & 7 deletions bundles/public/hooks/useFetchDonorsSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ const mockStore = configureMockStore([thunk]);
function TestComponent({ eventId }: { eventId: number }) {
const donors = useSelector((state: any) => state.models.donors);
useFetchDonors(eventId);
return (
<div>
{donors?.map((d: any) => (
<div key={d.pk}>{d.public}</div>
))}
</div>
);
return <div>{donors?.map((d: any) => <div key={d.pk}>{d.public}</div>)}</div>;
}

describe('useFetchDonors', () => {
Expand Down
2 changes: 1 addition & 1 deletion bundles/public/util/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const get = (url: string, queryParams?: object, opts: GetOptions = {}) =>

type PostOptions = {
headers?: { [header: string]: any };
encoder?: typeof Encoders[keyof typeof Encoders];
encoder?: (typeof Encoders)[keyof typeof Encoders];
};

export const post = (url: string, data: object, opts: PostOptions = {}) => {
Expand Down
7 changes: 4 additions & 3 deletions bundles/tracker/donation/components/Donate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ const Donate = (props: DonateProps) => {
[updateDonation],
);
const updateAmount = React.useCallback((amount: number) => updateDonation({ amount }), [updateDonation]);
const updateAmountPreset = useCachedCallback(amountPreset => updateDonation({ amount: amountPreset }), [
updateDonation,
]);
const updateAmountPreset = useCachedCallback(
amountPreset => updateDonation({ amount: amountPreset }),
[updateDonation],
);
const updateComment = React.useCallback((comment: string) => updateDonation({ comment }), [updateDonation]);

return (
Expand Down
6 changes: 3 additions & 3 deletions bundles/uikit/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const ButtonSizes = {
};

type ButtonProps = {
color?: typeof ButtonColors[keyof typeof ButtonColors];
size?: typeof ButtonSizes[keyof typeof ButtonSizes];
look?: typeof ButtonLooks[keyof typeof ButtonLooks];
color?: (typeof ButtonColors)[keyof typeof ButtonColors];
size?: (typeof ButtonSizes)[keyof typeof ButtonSizes];
look?: (typeof ButtonLooks)[keyof typeof ButtonLooks];
fullwidth?: boolean;
disabled?: boolean;
tabIndex?: -1 | 0;
Expand Down
2 changes: 1 addition & 1 deletion bundles/uikit/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const CheckboxHeader = (props: CheckboxHeaderProps) => {
};

type CheckboxProps = {
look?: typeof CheckboxLooks[keyof typeof CheckboxLooks];
look?: (typeof CheckboxLooks)[keyof typeof CheckboxLooks];
label?: React.ReactNode;
name?: string;
checked: boolean;
Expand Down
2 changes: 1 addition & 1 deletion bundles/uikit/Container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const ContainerSizes = {
};

type ContainerProps = {
size?: typeof ContainerSizes[keyof typeof ContainerSizes];
size?: (typeof ContainerSizes)[keyof typeof ContainerSizes];
className?: string;
children: React.ReactNode;
};
Expand Down
4 changes: 2 additions & 2 deletions bundles/uikit/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const HeaderColors = {
};

type HeaderProps = {
size?: typeof HeaderSizes[keyof typeof HeaderSizes];
color?: typeof HeaderColors[keyof typeof HeaderColors];
size?: (typeof HeaderSizes)[keyof typeof HeaderSizes];
color?: (typeof HeaderColors)[keyof typeof HeaderColors];
marginless?: boolean;
oneline?: boolean;
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion bundles/uikit/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react';
import { IconTypes } from './IconTypes';

type IconProps = {
name: typeof IconTypes[keyof typeof IconTypes];
name: (typeof IconTypes)[keyof typeof IconTypes];
color?: string;
className?: string;
};
Expand Down
2 changes: 1 addition & 1 deletion bundles/uikit/InputWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const InputWrapperSizes = {
};

type InputWrapperProps = {
size?: typeof InputWrapperSizes[keyof typeof InputWrapperSizes];
size?: (typeof InputWrapperSizes)[keyof typeof InputWrapperSizes];
label?: React.ReactNode;
name: string;
required?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion bundles/uikit/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const RadioItem = (props: RadioItemProps) => {
};

type RadioGroupProps = {
look?: typeof RadioGroupLooks[keyof typeof RadioGroupLooks];
look?: (typeof RadioGroupLooks)[keyof typeof RadioGroupLooks];
options: any[];
value: any;
className?: string;
Expand Down
4 changes: 2 additions & 2 deletions bundles/uikit/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const TextColors = {
};

type TextProps = {
size?: typeof TextSizes[keyof typeof TextSizes];
color?: typeof TextColors[keyof typeof TextColors];
size?: (typeof TextSizes)[keyof typeof TextSizes];
color?: (typeof TextColors)[keyof typeof TextColors];
marginless?: boolean;
oneline?: boolean;
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion bundles/uikit/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TextInputTypes = {
};

type TextInputProps = InputWrapperPassthroughProps & {
type?: typeof TextInputTypes[keyof typeof TextInputTypes];
type?: (typeof TextInputTypes)[keyof typeof TextInputTypes];
value?: string;
placeholder?: string;
multiline?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions design/generated/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ export const rawColors = {
export type RawColorName = keyof typeof rawColors;

export const Themes = ['dark', 'light'] as const;
export type Theme = typeof Themes[number];
export type Theme = (typeof Themes)[number];

export const Accents = ['purple', 'blue'] as const;
export type Accent = typeof Accents[number];
export type Accent = (typeof Accents)[number];

export type ThemeTokenValue = { rawColor: string; opacity: number; rgba: string; hsla: string };

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"karma-chrome-launcher": "^3.1.0",
"karma-jasmine": "^2.0.1",
"karma-webpack": "^5.0.0",
"prettier": "^2.1.2",
"prettier": "^3.0.3",
"process": "^0.11.10",
"puppeteer": "^19.8.5",
"react-refresh": "^0.14.0",
Expand Down
1 change: 1 addition & 0 deletions prettier.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
...require('@gamesdonequick/prettier-config'),
bracketSameLine: true,
arrowParens: 'avoid',
};
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9763,7 +9763,7 @@ __metadata:
postcss-loader: ^7.2.4
postcss-nesting: ^11.2.2
postcss-preset-env: ^8.3.0
prettier: ^2.1.2
prettier: ^3.0.3
process: ^0.11.10
prop-types: ^15.8.1
puppeteer: ^19.8.5
Expand Down Expand Up @@ -17460,15 +17460,6 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^2.1.2":
version: 2.1.2
resolution: "prettier@npm:2.1.2"
bin:
prettier: bin-prettier.js
checksum: 7bc5a2ff5e6caf585b003fbdb1645719d5f5fcd2a03b08bae75a5608a7155fd6f84bda146104b3b6b0d9dc06720ffbfab716eade2eaae771ce4817bcee745928
languageName: node
linkType: hard

"prettier@npm:^2.8.3":
version: 2.8.8
resolution: "prettier@npm:2.8.8"
Expand All @@ -17478,6 +17469,15 @@ __metadata:
languageName: node
linkType: hard

"prettier@npm:^3.0.3":
version: 3.0.3
resolution: "prettier@npm:3.0.3"
bin:
prettier: bin/prettier.cjs
checksum: e10b9af02b281f6c617362ebd2571b1d7fc9fb8a3bd17e371754428cda992e5e8d8b7a046e8f7d3e2da1dcd21aa001e2e3c797402ebb6111b5cd19609dd228e0
languageName: node
linkType: hard

"pretty-error@npm:^2.1.1":
version: 2.1.1
resolution: "pretty-error@npm:2.1.1"
Expand Down

0 comments on commit 579a026

Please sign in to comment.