Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

remove redundant spread operators before toSorted/toReversed (#8995)

Shahmir Varqha2d7546c078ee
diff --git a/frontend/src/components/editor/cell/code/cell-editor.tsx b/frontend/src/components/editor/cell/code/cell-editor.tsx
index f541689868..6388bb36bb 100644
--- a/frontend/src/components/editor/cell/code/cell-editor.tsx
+++ b/frontend/src/components/editor/cell/code/cell-editor.tsx
@@ -186,7 +186,7 @@ const CellEditorInternal = ({
deleteCell: handleDelete,
saveNotebook: saveOrNameNotebook,
createManyBelow: (cells) => {
- for (const code of [...cells].toReversed()) {
+ for (const code of cells.toReversed()) {
cellActions.createNewCell({
code,
before: false,
diff --git a/frontend/src/components/editor/chrome/panels/snippets-panel.tsx b/frontend/src/components/editor/chrome/panels/snippets-panel.tsx
index 585b6f4613..088c6a25b1 100644
--- a/frontend/src/components/editor/chrome/panels/snippets-panel.tsx
+++ b/frontend/src/components/editor/chrome/panels/snippets-panel.tsx
@@ -125,7 +125,7 @@ const SnippetViewer: React.FC<{ snippet: Snippet; onClose: () => void }> = ({
const handleInsertSnippet = () => {
// Add below last focused cell in reverse order
- for (const section of [...snippet.sections].toReversed()) {
+ for (const section of snippet.sections.toReversed()) {
if (section.code) {
createNewCell({
code: section.code,
diff --git a/frontend/src/components/editor/links/cell-link-list.tsx b/frontend/src/components/editor/links/cell-link-list.tsx
index 8a4f426e5e..9dd6b38ced 100644
--- a/frontend/src/components/editor/links/cell-link-list.tsx
+++ b/frontend/src/components/editor/links/cell-link-list.tsx
@@ -24,7 +24,7 @@ export const CellLinkList: React.FC<Props> = ({
skipScroll,
}) => {
const cellIndex = useCellIds();
- const sortedCellIds = [...cellIds].toSorted((a, b) => {
+ const sortedCellIds = cellIds.toSorted((a, b) => {
return cellIndex.inOrderIds.indexOf(a) - cellIndex.inOrderIds.indexOf(b);
});
diff --git a/frontend/src/components/editor/navigation/multi-cell-action-toolbar.tsx b/frontend/src/components/editor/navigation/multi-cell-action-toolbar.tsx
index ab94ed2471..5a26220576 100644
--- a/frontend/src/components/editor/navigation/multi-cell-action-toolbar.tsx
+++ b/frontend/src/components/editor/navigation/multi-cell-action-toolbar.tsx
@@ -167,8 +167,7 @@ export function useMultiCellActionButtons(cellIds: CellId[]) {
}
// Move cells in the appropriate order to maintain relative positions
- const sortedCells =
- direction === "up" ? cellIds : [...cellIds].toReversed();
+ const sortedCells = direction === "up" ? cellIds : cellIds.toReversed();
sortedCells.forEach((cellId) => {
moveCell({ cellId, before: direction === "up" });
});
@@ -177,7 +176,7 @@ export function useMultiCellActionButtons(cellIds: CellId[]) {
const sendSelectedCellsToTop = useEvent((cellIds: CellId[]) => {
// Send in reverse order to maintain relative positions
- [...cellIds].toReversed().forEach((cellId) => {
+ cellIds.toReversed().forEach((cellId) => {
sendToTop({ cellId });
});
});
diff --git a/frontend/src/components/editor/navigation/navigation.ts b/frontend/src/components/editor/navigation/navigation.ts
index 77a3aa4666..4e23446527 100644
--- a/frontend/src/components/editor/navigation/navigation.ts
+++ b/frontend/src/components/editor/navigation/navigation.ts
@@ -401,7 +401,7 @@ export function useCellNavigationProps(
}
// Move cells in the appropriate order to maintain relative positions
- [...cellIds].toReversed().forEach((cellId) => {
+ cellIds.toReversed().forEach((cellId) => {
actions.moveCell({ cellId, before: false });
});
return true;
@@ -480,7 +480,7 @@ export function useCellNavigationProps(
}),
"cell.sendToTop": addSingleHandler((cellIds) => {
// Send in reverse order to maintain relative positions
- [...cellIds].toReversed().forEach((cellId) => {
+ cellIds.toReversed().forEach((cellId) => {
actions.sendToTop({ cellId });
});
return true;
diff --git a/frontend/src/components/editor/output/console/ConsoleOutput.tsx b/frontend/src/components/editor/output/console/ConsoleOutput.tsx
index 1bbffbaa0f..3c3c6b8b1c 100644
--- a/frontend/src/components/editor/output/console/ConsoleOutput.tsx
+++ b/frontend/src/components/editor/output/console/ConsoleOutput.tsx
@@ -167,7 +167,7 @@ const ConsoleOutputInternal = (props: Props): React.ReactNode => {
return null;
}
- const reversedOutputs = [...consoleOutputs].toReversed();
+ const reversedOutputs = consoleOutputs.toReversed();
const isPdb = reversedOutputs.some(
(output) =>
typeof output.data === "string" && output.data.includes("(Pdb)"),
diff --git a/frontend/src/utils/mime-types.ts b/frontend/src/utils/mime-types.ts
index ee9bb64d5c..53c3ea0b1b 100644
--- a/frontend/src/utils/mime-types.ts
+++ b/frontend/src/utils/mime-types.ts
@@ -151,7 +151,7 @@ export function sortByPrecedence<T>(
): [MimeType, T][] {
const unknownPrecedence = precedence.size;
- return [...entries].toSorted((a, b) => {
+ return entries.toSorted((a, b) => {
const indexA = precedence.get(a[0]) ?? unknownPrecedence;
const indexB = precedence.get(b[0]) ?? unknownPrecedence;
return indexA - indexB;