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: upgrade prettier to 3.2.5 (poc for dynamic imports of pure esm) #19876

Merged
merged 16 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 15 additions & 16 deletions api-tests/core/strapi/api/populate/sanitize.test.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,21 @@ const fixtures = {
a: (file) => [{ cover: file.id }],
b:
(file) =>
({ a }) =>
[
{
name: 'one',
number: 1,
restricted: 'restricted',
password: 'password',
relA: a[0].id,
cp: { name: 'cp_one' },
dz: [
{ __component: 'default.cp-a', name: 'cp_two' },
{ __component: 'default.cp-b', title: 'cp_three' },
],
img: file.id,
},
],
({ a }) => [
{
name: 'one',
number: 1,
restricted: 'restricted',
password: 'password',
relA: a[0].id,
cp: { name: 'cp_one' },
dz: [
{ __component: 'default.cp-a', name: 'cp_two' },
{ __component: 'default.cp-b', title: 'cp_three' },
],
img: file.id,
},
],
};

const uploadFile = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ type UseDragAndDropReturn = [
objectRef: React.RefObject<HTMLElement>,
dropRef: ConnectDropTarget,
dragRef: ConnectDragSource,
dragPreviewRef: ConnectDragPreview
dragPreviewRef: ConnectDragPreview,
];

type UseDragAndDrop = (active: boolean, options: UseDragAndDropOptions) => UseDragAndDropReturn;
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"@swc/core": "1.4.8",
"@swc/helpers": "0.5.7",
"@swc/jest": "0.2.36",
"@types/prettier": "2.7.3",
"@types/react": "18.2.66",
"@types/react-dom": "18.2.22",
"@types/react-helmet": "6.1.11",
Expand All @@ -110,14 +109,14 @@
"eslint-config-airbnb": "^19.0.4",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-check-file": "2.6.2",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest-dom": "5.1.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-rxjs": "5.0.3",
Expand All @@ -139,7 +138,7 @@
"lodash": "4.17.21",
"nx": "16.8.1",
"plop": "2.7.6",
"prettier": "2.8.4",
"prettier": "3.2.5",
"qs": "6.11.1",
"rimraf": "3.0.2",
"stream-chain": "2.2.5",
Expand Down
8 changes: 4 additions & 4 deletions packages/core/admin/admin/src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ type FormErrors<TFormValues extends FormValues = FormValues> = {
? FormErrors<TFormValues[Key][number]>[] | string | string[]
: string // this would let us support errors for the dynamic zone or repeatable component not the components within.
: TFormValues[Key] extends object // is it a regular component?
? FormErrors<TFormValues[Key]> // handles nested components
: string; // otherwise its just a field.
? FormErrors<TFormValues[Key]> // handles nested components
: string; // otherwise its just a field.
};

interface FormState<TFormValues extends FormValues = FormValues> {
Expand Down Expand Up @@ -674,8 +674,8 @@ const useField = <TValue = any,>(path: string): FieldValue<TValue | undefined> =
error.values
)
: typeof error === 'string'
? error
: undefined,
? error
: undefined,
onChange: handleChange,
value: value,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const GuidedTourModal = () => {
const sectionKeys = Object.keys(guidedTourState);
const [sectionName, stepName] = currentStep.split('.') as [
keyof GuidedTourContextValue['guidedTourState'],
string
string,
];
const sectionIndex = sectionKeys.indexOf(sectionName);
const stepIndex = Object.keys(guidedTourState[sectionName]).indexOf(stepName);
Expand Down
8 changes: 4 additions & 4 deletions packages/core/admin/admin/src/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ const Links = ({ boundaryCount = 1, siblingCount = 1 }: Pagination.LinksProps) =
...(siblingsStart > boundaryCount + 2
? ['start-ellipsis']
: boundaryCount + 1 < pageCount - boundaryCount
? [boundaryCount + 1]
: []),
? [boundaryCount + 1]
: []),

// Sibling pages
...range(siblingsStart, siblingsEnd),
Expand All @@ -256,8 +256,8 @@ const Links = ({ boundaryCount = 1, siblingCount = 1 }: Pagination.LinksProps) =
...(siblingsEnd < pageCount - boundaryCount - 1
? ['end-ellipsis']
: pageCount - boundaryCount > boundaryCount
? [pageCount - boundaryCount]
: []),
? [pageCount - boundaryCount]
: []),

...endPages,
];
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/src/components/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ const Table = {
namespace Table {
export type Props<
TData extends BaseRow,
THeader extends TableHeader<TData, THeader> = TableHeader<TData, TableHeader>
THeader extends TableHeader<TData, THeader> = TableHeader<TData, TableHeader>,
> = RootProps<TData, THeader>;
export interface ActionBarProps {
children?: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('useKeyboardDragAndDrop', () => {
({
preventDefault: jest.fn(),
key,
} as unknown as KeyboardEvent<HTMLButtonElement>);
}) as unknown as KeyboardEvent<HTMLButtonElement>;

describe('onGrabItem', () => {
it('should be called when the event is the enter key', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DROP_SENSITIVITY = {

interface UseDragAndDropOptions<
TIndex extends number | Array<number> = number,
TItem extends { index: TIndex } = { index: TIndex }
TItem extends { index: TIndex } = { index: TIndex },
> extends UseKeyboardDragAndDropCallbacks<TIndex> {
type?: string;
index: TIndex;
Expand All @@ -52,7 +52,7 @@ type UseDragAndDropReturn<Element extends HTMLElement = HTMLElement> = [
objectRef: React.RefObject<Element>,
dropRef: ConnectDropTarget,
dragRef: ConnectDragSource,
dragPreviewRef: ConnectDragPreview
dragPreviewRef: ConnectDragPreview,
];

type DropCollectedProps = {
Expand All @@ -70,7 +70,7 @@ const useDragAndDrop = <
index: TIndex;
[key: string]: unknown;
},
Element extends HTMLElement = HTMLElement
Element extends HTMLElement = HTMLElement,
>(
active: boolean,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/src/hooks/useEnterprise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const useEnterprise = <
TCEData,
TEEData = TCEData,
TCombinedValue = TEEData,
TDefaultValue = TCEData
TDefaultValue = TCEData,
>(
ceData: TCEData,
eeCallback: () => Promise<TEEData>,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/src/hooks/useInjectionZone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const useInjectionZone = (area: InjectionZoneArea) => {
const [moduleName, page, position] = area.split('.') as [
InjectionZoneModule,
InjectionZoneContainer,
InjectionZoneBlock
InjectionZoneBlock,
];

return getAdminInjectedComponents(moduleName, page, position);
Expand Down
19 changes: 11 additions & 8 deletions packages/core/admin/admin/src/utils/arrays.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ const flattenDeep = <T>(
array?: ArrayOfRecursiveArraysOrValues<T> | null | undefined
): Array<Flat<T>> => {
if (Array.isArray(array)) {
return array.reduce((acc, value) => {
if (Array.isArray(value)) {
acc.push(...flattenDeep(value));
} else {
acc.push(value);
}
return array.reduce(
(acc, value) => {
if (Array.isArray(value)) {
acc.push(...flattenDeep(value));
} else {
acc.push(value);
}

return acc;
}, [] as Array<Flat<T>>);
return acc;
},
[] as Array<Flat<T>>
);
} else {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/admin/tests/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const renderHook = <
Props,
Q extends Queries,
Container extends Element | DocumentFragment = HTMLElement,
BaseElement extends Element | DocumentFragment = Container
BaseElement extends Element | DocumentFragment = Container,
>(
hook: (initialProps: Props) => Result,
options?: RenderHookOptions<Props, Q, Container, BaseElement> &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ export function getStageColorByHex(hex: string) {
lightTheme.colors
).filter(([, value]) => value.toUpperCase() === hex.toUpperCase());

const themeColorName = themeColors.reduce((acc, [name]) => {
if (STAGE_COLORS?.[name]) {
acc = name;
}

return acc;
}, null as keyof typeof STAGE_COLORS | null);
const themeColorName = themeColors.reduce(
(acc, [name]) => {
if (STAGE_COLORS?.[name]) {
acc = name;
}

return acc;
},
null as keyof typeof STAGE_COLORS | null
);

if (!themeColorName) {
return null;
Expand Down
1 change: 0 additions & 1 deletion packages/core/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
"@types/markdown-it-footnote": "3.0.3",
"@types/passport-local": "1.0.36",
"@types/pluralize": "0.0.32",
"@types/prettier": "2.7.3",
"@types/react-window": "1.8.8",
"@types/sanitize-html": "2.11.0",
"@vitejs/plugin-react-swc": "3.6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Admin Controller', () => {
},
uuid: 'testuuid',
environment: 'development',
}[key] || value)
})[key] || value
),
},
EE: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/admin/server/src/domain/action/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type CreateActionPayload = Utils.Intersect<
// Options is filled with default values
'options'
>,
{ uid: string }
{ uid: string },
]
>;

Expand Down
10 changes: 4 additions & 6 deletions packages/core/content-releases/server/src/services/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,8 @@ const createReleaseService = ({ strapi }: { strapi: Core.LoadedStrapi }) => {

return acc;
}, []);
const allReleaseContentTypesDictionary = await this.getContentTypesDataForActions(
contentTypeUids
);
const allReleaseContentTypesDictionary =
await this.getContentTypesDataForActions(contentTypeUids);
const allLocalesDictionary = await this.getLocalesDataForActions();

const formattedData = actions.map((action: ReleaseAction) => {
Expand Down Expand Up @@ -683,9 +682,8 @@ const createReleaseService = ({ strapi }: { strapi: Core.LoadedStrapi }) => {
try {
strapi.log.info(`[Content Releases] Starting to publish release ${lockedRelease.name}`);

const { collectionTypeActions, singleTypeActions } = await getFormattedActions(
releaseId
);
const { collectionTypeActions, singleTypeActions } =
await getFormattedActions(releaseId);

await strapi.db.transaction(async () => {
// First we publish all the singleTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ type GenericIsMinSuperiorThanMax<T extends (string | null) | number> = yup.TestC
>;

const isMinSuperiorThanMax = <
T extends (string | null) | number
T extends (string | null) | number,
>(): GenericIsMinSuperiorThanMax<T> => ({
name: 'isMinSuperiorThanMax',
message: getTrad('error.validation.minSupMax'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface CustomInputProps<TAttribute extends Schema.Attribute.AnyAttribute>
}

interface GenericInputProps<
TAttribute extends Schema.Attribute.AnyAttribute = Schema.Attribute.AnyAttribute
TAttribute extends Schema.Attribute.AnyAttribute = Schema.Attribute.AnyAttribute,
> {
attribute?: TAttribute;
autoComplete?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,22 @@ export const SelectComponents = ({
},
{} as Record<string, Component[]>
);
const options = Object.entries(filteredComponentsGroupedByCategory).reduce((acc, current) => {
const [categoryName, components] = current;
const section = {
label: categoryName,
children: components.map(({ uid, schema: { displayName } }) => {
return { label: displayName, value: uid };
}),
};
const options = Object.entries(filteredComponentsGroupedByCategory).reduce(
(acc, current) => {
const [categoryName, components] = current;
const section = {
label: categoryName,
children: components.map(({ uid, schema: { displayName } }) => {
return { label: displayName, value: uid };
}),
};

acc.push(section);
acc.push(section);

return acc;
}, [] as Array<{ label: string; children: Array<{ label: string; value: string }> }>);
return acc;
},
[] as Array<{ label: string; children: Array<{ label: string; value: string }> }>
);

const displayedValue = formatMessage(
{
Expand Down