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 #299

Merged
merged 2 commits into from
Apr 23, 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
342 changes: 216 additions & 126 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
"@vitest/coverage-v8": "^1.4.0",
"chokidar-cli": "^3.0.0",
"deep-freeze-es6": "^1.4.1",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-no-unsanitized": "^4.0.2",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-unicorn": "^45.0.2",
Expand All @@ -96,7 +96,7 @@
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.1",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.6.1",
Expand Down
2 changes: 1 addition & 1 deletion pages/dnd/engine-page-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function EnginePageTemplate({
}
if (removedItem) {
setPaletteItems((prev) =>
[...prev, removedItem].sort((a, b) => a.data.title.localeCompare(b.data.title))
[...prev, removedItem].sort((a, b) => a.data.title.localeCompare(b.data.title)),
);
}
}}
Expand Down
53 changes: 28 additions & 25 deletions pages/dnd/items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,29 +228,32 @@ export const demoPaletteItems: readonly ItemsPaletteProps.Item<ItemData>[] = Obj
data: widget?.data ?? createDefaultWidget(key),
}));

export const letterWidgets = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].reduce((acc, letter) => {
const definitions: { [letter: string]: BoardItemDefinitionBase["definition"] } = {
R: { defaultRowSpan: 1, defaultColumnSpan: 2, minRowSpan: 1, minColumnSpan: 2 },
S: { defaultRowSpan: 1, defaultColumnSpan: 2, minRowSpan: 1, minColumnSpan: 2 },
T: { defaultRowSpan: 1, defaultColumnSpan: 2, minRowSpan: 1, minColumnSpan: 2 },
U: { defaultRowSpan: 4, defaultColumnSpan: 1, minRowSpan: 4, minColumnSpan: 1 },
V: { defaultRowSpan: 4, defaultColumnSpan: 1, minRowSpan: 4, minColumnSpan: 1 },
W: { defaultRowSpan: 4, defaultColumnSpan: 1, minRowSpan: 4, minColumnSpan: 1 },
X: { defaultRowSpan: 4, defaultColumnSpan: 2, minRowSpan: 4, minColumnSpan: 2 },
Y: { defaultRowSpan: 4, defaultColumnSpan: 2, minRowSpan: 4, minColumnSpan: 2 },
Z: { defaultRowSpan: 4, defaultColumnSpan: 2, minRowSpan: 4, minColumnSpan: 2 },
};
acc[letter] = {
id: letter,
definition: definitions[letter],
data: {
title: `Widget ${letter}`,
description: "Empty widget",
content: "",
},
};
return acc;
}, {} as { [id: string]: BoardItemDefinitionBase<ItemData> });
export const letterWidgets = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"].reduce(
(acc, letter) => {
const definitions: { [letter: string]: BoardItemDefinitionBase["definition"] } = {
R: { defaultRowSpan: 1, defaultColumnSpan: 2, minRowSpan: 1, minColumnSpan: 2 },
S: { defaultRowSpan: 1, defaultColumnSpan: 2, minRowSpan: 1, minColumnSpan: 2 },
T: { defaultRowSpan: 1, defaultColumnSpan: 2, minRowSpan: 1, minColumnSpan: 2 },
U: { defaultRowSpan: 4, defaultColumnSpan: 1, minRowSpan: 4, minColumnSpan: 1 },
V: { defaultRowSpan: 4, defaultColumnSpan: 1, minRowSpan: 4, minColumnSpan: 1 },
W: { defaultRowSpan: 4, defaultColumnSpan: 1, minRowSpan: 4, minColumnSpan: 1 },
X: { defaultRowSpan: 4, defaultColumnSpan: 2, minRowSpan: 4, minColumnSpan: 2 },
Y: { defaultRowSpan: 4, defaultColumnSpan: 2, minRowSpan: 4, minColumnSpan: 2 },
Z: { defaultRowSpan: 4, defaultColumnSpan: 2, minRowSpan: 4, minColumnSpan: 2 },
};
acc[letter] = {
id: letter,
definition: definitions[letter],
data: {
title: `Widget ${letter}`,
description: "Empty widget",
content: "",
},
};
return acc;
},
{} as { [id: string]: BoardItemDefinitionBase<ItemData> },
);

export function createLetterItems(grid: null | string[][], palette?: string[]) {
if (!grid) {
Expand All @@ -261,15 +264,15 @@ export function createLetterItems(grid: null | string[][], palette?: string[]) {

const usedLetterItems = new Set(boardItems.map((item) => item.id));
const paletteItems = Object.values(letterWidgets).filter(
(item) => !usedLetterItems.has(item.id) && (!palette || palette.includes(item.id))
(item) => !usedLetterItems.has(item.id) && (!palette || palette.includes(item.id)),
);

return { boardItems, paletteItems };
}

function applyLayout<D>(
layout: GridLayout,
sourceItems: readonly (BoardItemDefinitionBase<D> | BoardItemDefinition<D>)[]
sourceItems: readonly (BoardItemDefinitionBase<D> | BoardItemDefinition<D>)[],
): readonly BoardItemDefinition<D>[] {
const itemById = new Map(sourceItems.map((item) => [item.id, item]));
const getItem = (itemId: string) => {
Expand Down
8 changes: 4 additions & 4 deletions pages/dnd/revenue-chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ export function RevenueChart({ height }: { height: number }) {
return Math.abs(value) >= 1e9
? (value / 1e9).toFixed(1).replace(/\.0$/, "") + "G"
: Math.abs(value) >= 1e6
? (value / 1e6).toFixed(1).replace(/\.0$/, "") + "M"
: Math.abs(value) >= 1e3
? (value / 1e3).toFixed(1).replace(/\.0$/, "") + "K"
: value.toFixed(2);
? (value / 1e6).toFixed(1).replace(/\.0$/, "") + "M"
: Math.abs(value) >= 1e3
? (value / 1e3).toFixed(1).replace(/\.0$/, "") + "K"
: value.toFixed(2);
},
}}
ariaLabel="Single data series bar chart"
Expand Down
2 changes: 1 addition & 1 deletion pages/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import App from "./app";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<StrictMode>
<App />
</StrictMode>
</StrictMode>,
);
2 changes: 1 addition & 1 deletion pages/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const pagesMap = Object.fromEntries(
Object.entries(pagesRaw).map(([path, dynamicImport]) => {
const match = getPage(path);
return [match, lazy(dynamicImport as ComponentFactory)];
})
}),
);
4 changes: 2 additions & 2 deletions pages/shared/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const itemsPaletteI18nStrings: ItemsPaletteProps.I18nStrings<ItemData> =
function createAnnouncement(
operationAnnouncement: string,
conflicts: readonly BoardProps.Item<ItemData>[],
disturbed: readonly BoardProps.Item<ItemData>[]
disturbed: readonly BoardProps.Item<ItemData>[],
) {
const conflictsAnnouncement =
conflicts.length > 0 ? `Conflicts with ${conflicts.map((c) => c.data.title).join(", ")}.` : "";
Expand All @@ -91,7 +91,7 @@ export const boardI18nStrings: BoardProps.I18nStrings<ItemData> = {
return createAnnouncement(
`Item moved to ${op.direction === "horizontal" ? columns : rows}.`,
op.conflicts,
op.disturbed
op.disturbed,
);
},
liveAnnouncementDndItemResized(op) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ writeFile(
`${basePath}.js`,
Object.entries(values)
.map(([key, value]) => `export var ${key} = ${JSON.stringify(value)};`)
.join("\n")
.join("\n"),
);
writeFile(
`${basePath}.d.ts`,
Object.keys(values)
.map((key) => `export const ${key}: string;`)
.join("\n")
.join("\n"),
);

function writeFile(filepath, content) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/prepare-package-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function unlock(packages) {
delete packages[dependencyName];
} else if (dependency.resolved && dependency.resolved.includes("codeartifact.us-west-2.amazonaws.com")) {
throw Error(
"package-lock.json file contains a reference to CodeArtifact. Use regular npm to update the packages."
"package-lock.json file contains a reference to CodeArtifact. Use regular npm to update the packages.",
);
}
});
Expand Down
4 changes: 2 additions & 2 deletions scripts/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { globbySync } from "globby";
import { pascalCase, writeSourceFile } from "./utils.js";

const components = globbySync(["src/test-utils/dom/**/index.ts", "!src/test-utils/dom/index.ts"]).map((fileName) =>
fileName.replace("src/test-utils/dom/", "").replace("/index.ts", "")
fileName.replace("src/test-utils/dom/", "").replace("/index.ts", ""),
);

generateSelectorUtils();
Expand Down Expand Up @@ -71,7 +71,7 @@ function generateIndexFileContent({ testUtilType, buildFinderInterface }) {
// casting to 'any' is needed to avoid this issue with generics
// https://github.com/microsoft/TypeScript/issues/29132
return (this as any).findComponent(selector ? appendSelector(selector, rootSelector) : rootSelector, ${pascalCase(
componentName
componentName,
)}Wrapper);
};`;
}),
Expand Down
4 changes: 2 additions & 2 deletions scripts/themeable-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function copyStyles() {
path.join(stylesTargetDir, file),
content.replace(
/@use "(\.\.\/)+node_modules\/@cloudscape-design\/design-tokens\/index.scss"/,
'@use "awsui:tokens"'
'@use "awsui:tokens"',
),
"utf-8"
"utf-8",
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function listPublicDirs(baseDir) {
elem !== "internal" &&
elem !== "index.tsx" &&
elem !== "index.ts" &&
elem !== "test-utils"
elem !== "test-utils",
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/board-item/__tests__/board-item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe("WidgetContainer", () => {
<BoardItem header="Header" footer="Footer" settings="Settings" i18nStrings={i18nStrings}>
Content
</BoardItem>
</div>
</div>,
);
const itemWrapper = createWrapper().findBoardItem()!;
expect(itemWrapper.findHeader()!.getElement().textContent).toBe("Header");
Expand Down
4 changes: 2 additions & 2 deletions src/board/__tests__/board-acquisition.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ test("renders acquired item", () => {
draggableItem,
collisionRect: { top: 0, bottom: 0, left: 0, right: 0 },
coordinates: new Coordinates({ x: 0, y: 0 }),
} as DragAndDropData)
} as DragAndDropData),
);

act(() =>
mockController.acquire({
droppableId: "awsui-placeholder-1-0",
draggableItem,
renderAcquiredItem: () => <div data-testid="acquired-item"></div>,
})
}),
);
expect(screen.queryByTestId("acquired-item")).toBeInTheDOM();

Expand Down
8 changes: 4 additions & 4 deletions src/board/__tests__/board.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ describe("Board", () => {
{ id: "1", data: { title: "Item 1" }, columnOffset: { 1: 0 } },
],
},
})
}),
);
});

Expand All @@ -188,7 +188,7 @@ describe("Board", () => {
{ id: "2", data: { title: "Item 2" }, columnOffset: { 1: 0 } },
],
},
})
}),
);
});

Expand All @@ -207,8 +207,8 @@ describe("Board", () => {
removedItem: expect.objectContaining({ id: "1" }),
items: [{ id: "2", data: { title: "Item 2" }, columnOffset: { 1: 0 } }],
},
})
)
}),
),
);
});
});
6 changes: 3 additions & 3 deletions src/board/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ export function InternalBoard<D>({
state={transition ? (transition.collisionIds?.has(placeholder.id) ? "hover" : "active") : "default"}
gridContext={gridContext}
columns={itemsLayout.columns}
/>
)
/>,
),
);

items.forEach((item) => {
Expand Down Expand Up @@ -293,7 +293,7 @@ export function InternalBoard<D>({
{item.id === acquiredItem?.id && acquiredItemElement
? () => acquiredItemElement
: () => renderItem(item, { removeItem: () => removeItemAction(item) })}
</ItemContainer>
</ItemContainer>,
);
});

Expand Down
6 changes: 3 additions & 3 deletions src/board/transition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@

function updateTransitionWithPointerEvent<D>(
state: TransitionState<D>,
{ collisionIds, positionOffset, draggableRect }: UpdateWithPointerAction
{ collisionIds, positionOffset, draggableRect }: UpdateWithPointerAction,

Check warning on line 203 in src/board/transition.ts

View check run for this annotation

Codecov / codecov/patch

src/board/transition.ts#L203

Added line #L203 was not covered by tests
): TransitionState<D> {
const { transition } = state;

Expand Down Expand Up @@ -255,7 +255,7 @@

function updateTransitionWithKeyboardEvent<D>(
state: TransitionState<D>,
{ direction }: UpdateWithKeyboardAction
{ direction }: UpdateWithKeyboardAction,
): TransitionState<D> {
const { transition } = state;

Expand Down Expand Up @@ -311,7 +311,7 @@

function acquireTransitionItem<D>(
state: TransitionState<D>,
{ position, layoutElement, acquiredItemElement }: AcquireItemAction
{ position, layoutElement, acquiredItemElement }: AcquireItemAction,
): TransitionState<D> {
const { transition } = state;

Expand Down
6 changes: 3 additions & 3 deletions src/board/utils/__tests__/layout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getLayoutRows } from "../layout";
function createMockTransition(
operation: Operation,
itemsLayout: GridLayout,
layoutShift: LayoutShift
layoutShift: LayoutShift,
): Transition<null> {
return {
operation,
Expand Down Expand Up @@ -48,7 +48,7 @@ describe("getLayoutRows", () => {
]),
moves: [],
conflicts: [],
}
},
);
const rows = getLayoutRows(transition);
expect(rows).toBe(2);
Expand All @@ -72,7 +72,7 @@ describe("getLayoutRows", () => {
]),
moves: [],
conflicts: [],
}
},
);
const rows = getLayoutRows(transition);
expect(rows).toBe(3);
Expand Down
4 changes: 2 additions & 2 deletions src/board/utils/announcements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
*/
export function createOperationAnnouncement<D>(
transition: Transition<D>,
direction: null | Direction
direction: null | Direction,
): null | DndActionAnnouncement {
const { operation, layoutShift, itemsLayout } = transition;
const targetItem = itemsLayout.items.find((it) => it.id === transition.draggableItem.id) ?? null;
Expand Down Expand Up @@ -63,7 +63,7 @@ export function announcementToString<D>(
announcement: TransitionAnnouncement,
items: readonly BoardProps.Item<D>[],
i18nStrings: BoardProps.I18nStrings<D>,
columns: number
columns: number,
): string {
if (!announcement) {
return "";
Expand Down
2 changes: 1 addition & 1 deletion src/board/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { BoardProps } from "../interfaces";

export function createItemsChangeEvent<D>(
items: readonly BoardProps.Item<D>[],
layoutShift: LayoutShift
layoutShift: LayoutShift,
): CustomEvent<BoardProps.ItemsChangeDetail<D>> {
const insertTarget = layoutShift.moves.find((move) => move.type === "INSERT")?.itemId ?? null;
const moveTarget = layoutShift.moves.find((move) => move.type === "MOVE")?.itemId ?? null;
Expand Down
2 changes: 1 addition & 1 deletion src/board/utils/get-hovered-rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export function getHoveredRect(collisionsIds: readonly ItemId[], placeholders: r
left: Number.POSITIVE_INFINITY,
bottom: Number.NEGATIVE_INFINITY,
right: Number.NEGATIVE_INFINITY,
}
},
);
}
2 changes: 1 addition & 1 deletion src/board/utils/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function getInsertionDirection(cursorOffset: Coordinates): Direction {
export function getLayoutShift<D>(
transition: Transition<D>,
path: readonly Position[],
insertionDirection?: Direction
insertionDirection?: Direction,
): null | LayoutShift {
if (path.length === 0) {
return null;
Expand Down
Loading
Loading