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.

[lint] enable correctness and simple auto-fixes (#8990)

Myles Scolnickcb44ec35623b
diff --git a/frontend/.oxlintrc.json b/frontend/.oxlintrc.json
index 1769b43729..fd7a071985 100644
--- a/frontend/.oxlintrc.json
+++ b/frontend/.oxlintrc.json
@@ -14,7 +14,13 @@
"**/e2e-tests/**"
],
"categories": {
- "correctness": "off"
+ "correctness": "error",
+ "nursery": "off",
+ "pedantic": "off",
+ "perf": "warn",
+ "restriction": "warn",
+ "style": "off",
+ "suspicious": "warn"
},
"rules": {
// === Marimo custom rules ===
@@ -23,8 +29,7 @@
"marimo/prefer-object-params": "warn",
"marimo/atom-with-storage-args": "error",
-
- // === ESLint core rules (were delegated to Biome, now oxlint handles them) ===
+ // === Core rules ===
"no-var": "error",
"no-console": "error",
"no-debugger": "error",
@@ -40,8 +45,16 @@
"eqeqeq": ["error", "smart"],
"curly": "error",
"array-callback-return": "warn",
+ // TODO: re-enable
+ "no-control-regex": "warn",
+ // TODO: re-enable
+ "no-unsafe-optional-chaining": "warn",
+ // TODO: re-enable
+ "no-unused-expressions": "warn",
+ // TODO: re-enable
+ "no-unused-vars": "warn",
- // === TypeScript (from ESLint @typescript-eslint) ===
+ // === TypeScript ===
"typescript/consistent-generic-constructors": "error",
"typescript/consistent-type-definitions": "error",
"typescript/no-confusing-non-null-assertion": "error",
@@ -49,8 +62,16 @@
"typescript/prefer-ts-expect-error": "error",
"typescript/no-empty-object-type": "off",
"typescript/no-confusing-void-expression": "error",
- // From Biome: useImportType
"typescript/consistent-type-imports": ["error", { "disallowTypeAnnotations": false }],
+ "typescript/explicit-function-return-type": ["warn", {
+ "allowConciseArrowFunctionExpressionsStartingWithVoid": true,
+ "allowDirectConstAssertionInArrowFunctions": true,
+ "allowExpressions": true,
+ "allowFunctionsWithoutTypeParameters": true,
+ "allowHigherOrderFunctions": true,
+ "allowIIFEs": true,
+ "allowTypedFunctionExpressions": true,
+ }],
// === Unicorn ===
"unicorn/switch-case-braces": ["error", "avoid"],
@@ -59,30 +80,41 @@
"unicorn/no-object-as-default-parameter": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-ternary": "error",
- // From Biome: useIsArray
"unicorn/no-instanceof-array": "error",
// === React ===
"react/jsx-boolean-value": ["error", "always"],
"react/jsx-pascal-case": "error",
- // From Biome: noUselessFragments
+ "react/no-multi-comp": "off",
+ "react/jsx-filename-extension": "off",
// TODO: re-enable as error
"react/jsx-no-useless-fragment": "warn",
- // From Biome: useSelfClosingElements
"react/self-closing-comp": "error",
// === React Hooks ===
- // From Biome: useHookAtTopLevel
"react-hooks/rules-of-hooks": "warn",
+ "react-hooks/exhaustive-deps": "warn",
+
+ // === JSX A11y ===
+ // TODO: re-enable all of these as error
+ "jsx-a11y/click-events-have-key-events": "warn",
+ "jsx-a11y/heading-has-content": "warn",
+ "jsx-a11y/iframe-has-title": "warn",
+ "jsx-a11y/media-has-caption": "warn",
+ "jsx-a11y/no-autofocus": "warn",
+ "jsx-a11y/no-noninteractive-tabindex": "warn",
+ "jsx-a11y/no-static-element-interactions": "warn",
+ "jsx-a11y/prefer-tag-over-role": "warn",
+ "jsx-a11y/role-has-required-aria-props": "warn",
// === Unicorn ===
- // From Biome: useNodejsImportProtocol
"unicorn/prefer-node-protocol": "error",
// === Vitest ===
"vitest/expect-expect": "warn",
"vitest/no-identical-title": "error",
- "vitest/no-commented-out-tests": "warn"
+ "vitest/no-commented-out-tests": "warn",
+ "vitest/require-mock-type-parameters": "warn",
},
"overrides": [
{
diff --git a/frontend/src/components/chat/acp/state.ts b/frontend/src/components/chat/acp/state.ts
index 6233d9c0c3..550ec42388 100644
--- a/frontend/src/components/chat/acp/state.ts
+++ b/frontend/src/components/chat/acp/state.ts
@@ -226,7 +226,7 @@ export function getSessionsByAgent(
): AgentSession[] {
return sessions
.filter((session) => session.agentId === agentId)
- .sort((a, b) => b.lastUsedAt - a.lastUsedAt);
+ .toSorted((a, b) => b.lastUsedAt - a.lastUsedAt);
}
export function getAllAgentIds(): ExternalAgentId[] {
diff --git a/frontend/src/components/chat/chat-history-popover.tsx b/frontend/src/components/chat/chat-history-popover.tsx
index 0d40fb6249..ab3ffa5496 100644
--- a/frontend/src/components/chat/chat-history-popover.tsx
+++ b/frontend/src/components/chat/chat-history-popover.tsx
@@ -33,7 +33,7 @@ export const ChatHistoryPopover: React.FC<ChatHistoryPopoverProps> = ({
const [searchQuery, setSearchQuery] = useState("");
const chats = useMemo(() => {
- return [...chatState.chats.values()].sort(
+ return [...chatState.chats.values()].toSorted(
(a, b) => b.updatedAt - a.updatedAt,
);
}, [chatState.chats]);
diff --git a/frontend/src/components/data-table/pagination.tsx b/frontend/src/components/data-table/pagination.tsx
index 2b76283b91..5efcaa4289 100644
--- a/frontend/src/components/data-table/pagination.tsx
+++ b/frontend/src/components/data-table/pagination.tsx
@@ -71,7 +71,7 @@ export const DataTablePagination = <TData,>({
// Ensure unique page sizes
const pageSizeSet = new Set([5, 10, 25, 50, 100, pageSize]);
- const pageSizes = [...pageSizeSet].sort((a, b) => a - b);
+ const pageSizes = [...pageSizeSet].toSorted((a, b) => a - b);
const renderPageSizeSelector = () => {
return (
diff --git a/frontend/src/components/editor/cell/code/cell-editor.tsx b/frontend/src/components/editor/cell/code/cell-editor.tsx
index 732c902cf4..f541689868 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].reverse()) {
+ 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 b18ad95f8d..585b6f4613 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].reverse()) {
+ for (const section of [...snippet.sections].toReversed()) {
if (section.code) {
createNewCell({
code: section.code,
diff --git a/frontend/src/components/editor/chrome/panels/write-secret-modal.tsx b/frontend/src/components/editor/chrome/panels/write-secret-modal.tsx
index 0121bc42a3..a9b025e75f 100644
--- a/frontend/src/components/editor/chrome/panels/write-secret-modal.tsx
+++ b/frontend/src/components/editor/chrome/panels/write-secret-modal.tsx
@@ -25,7 +25,7 @@ import type { ListSecretKeysResponse } from "@/core/network/types";
// dotenv providers should be at the top
export function sortProviders(providers: ListSecretKeysResponse["keys"]) {
- return providers.sort((a, b) => {
+ return providers.toSorted((a, b) => {
if (a.provider === "env") {
return 1;
}
diff --git a/frontend/src/components/editor/chrome/wrapper/storage.ts b/frontend/src/components/editor/chrome/wrapper/storage.ts
index 7f1aa3b922..dfaa403a73 100644
--- a/frontend/src/components/editor/chrome/wrapper/storage.ts
+++ b/frontend/src/components/editor/chrome/wrapper/storage.ts
@@ -28,7 +28,7 @@ export function createStorage(location: "left" | "bottom"): PanelGroupStorage {
const parsed = schema.parse(JSON.parse(storedValue));
return JSON.stringify(
Objects.mapValues(parsed, (value) => {
- return value.reverse();
+ return value.toReversed();
}),
);
} catch {
@@ -42,7 +42,7 @@ export function createStorage(location: "left" | "bottom"): PanelGroupStorage {
const parsed = schema.parse(JSON.parse(value));
value = JSON.stringify(
Objects.mapValues(parsed, (value) => {
- return value.reverse();
+ return value.toReversed();
}),
);
} catch {
diff --git a/frontend/src/components/editor/connections/database/as-code.ts b/frontend/src/components/editor/connections/database/as-code.ts
index de9c725d2b..dbc041a6d9 100644
--- a/frontend/src/components/editor/connections/database/as-code.ts
+++ b/frontend/src/components/editor/connections/database/as-code.ts
@@ -964,7 +964,7 @@ export function generateDatabaseCode(
...generator.imports,
]);
- const lines = [...imports].sort();
+ const lines = [...imports].toSorted();
lines.push("");
const secrets = secretsContainer.formatSecrets();
if (secrets) {
diff --git a/frontend/src/components/editor/connections/form-renderers.tsx b/frontend/src/components/editor/connections/form-renderers.tsx
index a624ba61ba..b6251e46dd 100644
--- a/frontend/src/components/editor/connections/form-renderers.tsx
+++ b/frontend/src/components/editor/connections/form-renderers.tsx
@@ -72,7 +72,7 @@ export const SecretsProvider = ({ children }: SecretsProviderProps) => {
.map((provider) => provider.name);
return {
- secretKeys: result.secrets.flatMap((secret) => secret.keys).sort(),
+ secretKeys: result.secrets.flatMap((secret) => secret.keys).toSorted(),
providerNames: providerNames,
};
}, []);
diff --git a/frontend/src/components/editor/connections/storage/as-code.ts b/frontend/src/components/editor/connections/storage/as-code.ts
index 49e5d7c41e..014c7d8d9d 100644
--- a/frontend/src/components/editor/connections/storage/as-code.ts
+++ b/frontend/src/components/editor/connections/storage/as-code.ts
@@ -214,7 +214,7 @@ export function generateStorageCode(
}
const allImports = new Set([...secrets.imports, ...result.imports]);
- const lines = [...allImports].sort();
+ const lines = [...allImports].toSorted();
lines.push("");
const secretsStr = secrets.formatSecrets();
if (secretsStr) {
diff --git a/frontend/src/components/editor/links/cell-link-list.tsx b/frontend/src/components/editor/links/cell-link-list.tsx
index b6b8dca50a..8a4f426e5e 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].sort((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/clipboard.ts b/frontend/src/components/editor/navigation/clipboard.ts
index c80bbdaedd..b091a15b36 100644
--- a/frontend/src/components/editor/navigation/clipboard.ts
+++ b/frontend/src/components/editor/navigation/clipboard.ts
@@ -106,7 +106,7 @@ export function useCellClipboard() {
// Create new cells with the copied data before/after the current cell
const currentCellId = cellId;
- const reversedCells = clipboardData.cells.reverse();
+ const reversedCells = clipboardData.cells.toReversed();
for (const cell of reversedCells) {
actions.createNewCell({
cellId: currentCellId,
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 1f2c94ad85..ab94ed2471 100644
--- a/frontend/src/components/editor/navigation/multi-cell-action-toolbar.tsx
+++ b/frontend/src/components/editor/navigation/multi-cell-action-toolbar.tsx
@@ -167,7 +167,8 @@ export function useMultiCellActionButtons(cellIds: CellId[]) {
}
// Move cells in the appropriate order to maintain relative positions
- const sortedCells = direction === "up" ? cellIds : [...cellIds].reverse();
+ const sortedCells =
+ direction === "up" ? cellIds : [...cellIds].toReversed();
sortedCells.forEach((cellId) => {
moveCell({ cellId, before: direction === "up" });
});
@@ -176,7 +177,7 @@ export function useMultiCellActionButtons(cellIds: CellId[]) {
const sendSelectedCellsToTop = useEvent((cellIds: CellId[]) => {
// Send in reverse order to maintain relative positions
- [...cellIds].reverse().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 d3c39058bd..77a3aa4666 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].reverse().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].reverse().forEach((cellId) => {
+ [...cellIds].toReversed().forEach((cellId) => {
actions.sendToTop({ cellId });
});
return true;
diff --git a/frontend/src/components/editor/output/JsonOutput.tsx b/frontend/src/components/editor/output/JsonOutput.tsx
index 6e9362118e..f171d3dd55 100644
--- a/frontend/src/components/editor/output/JsonOutput.tsx
+++ b/frontend/src/components/editor/output/JsonOutput.tsx
@@ -329,7 +329,7 @@ const PYTHON_VALUE_TYPES = [
URL_TYPE,
OBJECT_TYPE,
FALLBACK_RENDERER,
-].reverse();
+].toReversed();
// Last one wins, so we reverse the array.
const JSON_VALUE_TYPES = [
@@ -339,7 +339,7 @@ const JSON_VALUE_TYPES = [
JSON_NONE_TYPE,
JSON_OBJECT_TYPE,
JSON_FALLBACK_RENDERER,
-].reverse();
+].toReversed();
function leafData(leaf: string): string {
return leafDataAndMimeType(leaf)[0];
diff --git a/frontend/src/components/editor/output/console/ConsoleOutput.tsx b/frontend/src/components/editor/output/console/ConsoleOutput.tsx
index 59f6a60685..1bbffbaa0f 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].reverse();
+ const reversedOutputs = [...consoleOutputs].toReversed();
const isPdb = reversedOutputs.some(
(output) =>
typeof output.data === "string" && output.data.includes("(Pdb)"),
diff --git a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx
index 6030b4ae75..1bbb805073 100644
--- a/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx
+++ b/frontend/src/components/editor/renderers/vertical-layout/vertical-layout.tsx
@@ -482,7 +482,7 @@ export function groupCellsByColumn(
});
// Sort columns by index
- return [...cellsByColumn.entries()].sort(([a], [b]) => a - b);
+ return [...cellsByColumn.entries()].toSorted(([a], [b]) => a - b);
}
/**
diff --git a/frontend/src/components/pages/gallery-page.tsx b/frontend/src/components/pages/gallery-page.tsx
index a36f035160..1e8044f5a1 100644
--- a/frontend/src/components/pages/gallery-page.tsx
+++ b/frontend/src/components/pages/gallery-page.tsx
@@ -83,7 +83,7 @@ const GalleryPage: React.FC = () => {
thumbnailUrl,
};
})
- .sort((a, b) => a.relativePath.localeCompare(b.relativePath));
+ .toSorted((a, b) => a.relativePath.localeCompare(b.relativePath));
}, [workspace?.files, workspace?.root]);
const filteredFiles = useMemo(() => {
diff --git a/frontend/src/components/variables/variables-table.tsx b/frontend/src/components/variables/variables-table.tsx
index 199df9e1f0..d7d4ef02f3 100644
--- a/frontend/src/components/variables/variables-table.tsx
+++ b/frontend/src/components/variables/variables-table.tsx
@@ -226,7 +226,7 @@ function sortData({
break;
}
- return sort.desc ? sortedVariables.reverse() : sortedVariables;
+ return sort.desc ? sortedVariables.toReversed() : sortedVariables;
}
export const VariableTable: React.FC<Props> = memo(
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.ts
index d725fc38a3..8a32fd8466 100644
--- a/frontend/src/core/cells/cells.ts
+++ b/frontend/src/core/cells/cells.ts
@@ -1226,7 +1226,7 @@ const {
i--;
}
- const collapseRanges = reversedCollapseRanges.reverse();
+ const collapseRanges = reversedCollapseRanges.toReversed();
return column.collapseAll(collapseRanges);
}),
};
diff --git a/frontend/src/core/codemirror/cells/traceback-decorations.ts b/frontend/src/core/codemirror/cells/traceback-decorations.ts
index 0ad7b93deb..f390158320 100644
--- a/frontend/src/core/codemirror/cells/traceback-decorations.ts
+++ b/frontend/src/core/codemirror/cells/traceback-decorations.ts
@@ -32,7 +32,7 @@ function createErrorDecorations(state: EditorState, errors: TracebackInfos) {
// Filter and sort errors by line number to ensure they're added in order
const relevantErrors = errors
.filter((error) => error.kind === "cell" && error.cellId === cellId)
- .sort((a, b) => a.lineNumber - b.lineNumber);
+ .toSorted((a, b) => a.lineNumber - b.lineNumber);
for (const error of relevantErrors) {
try {
diff --git a/frontend/src/core/codemirror/copilot/getCodes.ts b/frontend/src/core/codemirror/copilot/getCodes.ts
index 9a2433a6c9..83d88bf5a8 100644
--- a/frontend/src/core/codemirror/copilot/getCodes.ts
+++ b/frontend/src/core/codemirror/copilot/getCodes.ts
@@ -27,7 +27,7 @@ export function getOtherCellsCode(otherCode: string) {
return code;
})
.filter(Boolean)
- .sort((a, b) => {
+ .toSorted((a, b) => {
if (a.startsWith("import") && !b.startsWith("import")) {
return -1;
}
diff --git a/frontend/src/core/codemirror/copilot/transport.ts b/frontend/src/core/codemirror/copilot/transport.ts
index a5aca23cfe..8ea846fc76 100644
--- a/frontend/src/core/codemirror/copilot/transport.ts
+++ b/frontend/src/core/codemirror/copilot/transport.ts
@@ -209,6 +209,7 @@ export class LazyWebsocketTransport extends Transport {
Logger.error("Copilot#sendData: Failed to reconnect transport", error);
throw new Error(
"Unable to connect to GitHub Copilot. Please check your settings and try again.",
+ { cause: error },
);
}
diff --git a/frontend/src/core/datasets/state.ts b/frontend/src/core/datasets/state.ts
index 547ef32e6e..8ff2921b99 100644
--- a/frontend/src/core/datasets/state.ts
+++ b/frontend/src/core/datasets/state.ts
@@ -66,7 +66,7 @@ const {
return true;
});
- const sortedTables = dedupedTables.sort((a, b) => {
+ const sortedTables = dedupedTables.toSorted((a, b) => {
return a.name.localeCompare(b.name);
});
diff --git a/frontend/src/core/network/CachingRequestRegistry.ts b/frontend/src/core/network/CachingRequestRegistry.ts
index 6d8eff6672..dfbe7b7e67 100644
--- a/frontend/src/core/network/CachingRequestRegistry.ts
+++ b/frontend/src/core/network/CachingRequestRegistry.ts
@@ -27,7 +27,7 @@ export class CachingRequestRegistry<REQ, RES> {
if (typeof o !== "object" || o === null) {
return String(o);
}
- return JSON.stringify(o, Object.keys(o).sort(), 2);
+ return JSON.stringify(o, Object.keys(o).toSorted(), 2);
};
}
diff --git a/frontend/src/core/runtime/runtime.ts b/frontend/src/core/runtime/runtime.ts
index 53668293d0..9132dd6827 100644
--- a/frontend/src/core/runtime/runtime.ts
+++ b/frontend/src/core/runtime/runtime.ts
@@ -22,6 +22,7 @@ export class RuntimeManager {
} catch (error) {
throw new Error(
`Invalid runtime URL: ${this.config.url}. ${error instanceof Error ? error.message : "Unknown error"}`,
+ { cause: error },
);
}
diff --git a/frontend/src/hooks/__tests__/useDuplicateShortcuts.test.ts b/frontend/src/hooks/__tests__/useDuplicateShortcuts.test.ts
index 6cdd269c71..d4b25c717a 100644
--- a/frontend/src/hooks/__tests__/useDuplicateShortcuts.test.ts
+++ b/frontend/src/hooks/__tests__/useDuplicateShortcuts.test.ts
@@ -145,7 +145,7 @@ describe("findDuplicateShortcuts", () => {
expect(result.duplicates).toHaveLength(2);
// Check that both duplicate groups are detected
- const duplicateKeys = result.duplicates.map((d) => d.key).sort();
+ const duplicateKeys = result.duplicates.map((d) => d.key).toSorted();
expect(duplicateKeys).toEqual(["cmd-b", "cmd-enter"]);
expect(result.hasDuplicate("cell.format")).toBe(true);
diff --git a/frontend/src/plugins/impl/anywidget/__tests__/model.test.ts b/frontend/src/plugins/impl/anywidget/__tests__/model.test.ts
index 0434c0acf6..850369a644 100644
--- a/frontend/src/plugins/impl/anywidget/__tests__/model.test.ts
+++ b/frontend/src/plugins/impl/anywidget/__tests__/model.test.ts
@@ -58,13 +58,13 @@ describe("Model", () => {
describe("public API", () => {
it("should only expose AFM-compliant interface", () => {
// Get all enumerable own properties
- const ownProperties = Object.keys(model).sort();
+ const ownProperties = Object.keys(model).toSorted();
// Get prototype methods (excluding constructor)
const prototypeMethods = Object.getOwnPropertyNames(
Object.getPrototypeOf(model),
)
.filter((name) => name !== "constructor")
- .sort();
+ .toSorted();
// Snapshot the public API to catch accidental leaks of internal methods
expect({ ownProperties, prototypeMethods }).toMatchInlineSnapshot(`
diff --git a/frontend/src/plugins/impl/data-editor/glide-data-editor.tsx b/frontend/src/plugins/impl/data-editor/glide-data-editor.tsx
index df2543d4b0..8e7c8e9022 100644
--- a/frontend/src/plugins/impl/data-editor/glide-data-editor.tsx
+++ b/frontend/src/plugins/impl/data-editor/glide-data-editor.tsx
@@ -218,7 +218,7 @@ export const GlideDataEditor = <T,>({
// Add new rows in order
const sortedNewRows = [...newRows.entries()]
- .sort(([a], [b]) => a - b)
+ .toSorted(([a], [b]) => a - b)
.map(([, row]) => row);
if (sortedNewRows.length > 0) {
diff --git a/frontend/src/plugins/impl/vega/make-selectable.ts b/frontend/src/plugins/impl/vega/make-selectable.ts
index 7695ed8e8f..36c3fa6baa 100644
--- a/frontend/src/plugins/impl/vega/make-selectable.ts
+++ b/frontend/src/plugins/impl/vega/make-selectable.ts
@@ -40,11 +40,11 @@ function getParamSignature(param: TParams): string {
type: select.type,
encodings:
"encodings" in select && select.encodings
- ? [...select.encodings].sort()
+ ? [...select.encodings].toSorted()
: undefined,
fields:
"fields" in select && select.fields
- ? [...select.fields].sort()
+ ? [...select.fields].toSorted()
: undefined,
bind: param.bind,
};
diff --git a/frontend/src/utils/__tests__/multi-map.test.ts b/frontend/src/utils/__tests__/multi-map.test.ts
index e8db2c7c5f..a98e7e532b 100644
--- a/frontend/src/utils/__tests__/multi-map.test.ts
+++ b/frontend/src/utils/__tests__/multi-map.test.ts
@@ -132,7 +132,7 @@ describe("MultiMap", () => {
multiMap.add("key2", 2);
multiMap.add("key3", 3);
const keys = [...multiMap.keys()];
- expect(keys.sort()).toEqual(["key1", "key2", "key3"]);
+ expect(keys.toSorted()).toEqual(["key1", "key2", "key3"]);
});
});
@@ -204,7 +204,7 @@ describe("MultiMap", () => {
multiMap.add("key3", 5);
const flattened = multiMap.flatValues();
- expect(flattened.sort()).toEqual([1, 2, 3, 4, 5]);
+ expect(flattened.toSorted()).toEqual([1, 2, 3, 4, 5]);
});
it("should handle empty arrays in values", () => {
@@ -213,7 +213,7 @@ describe("MultiMap", () => {
multiMap.add("key2", 2);
const flattened = multiMap.flatValues();
- expect(flattened.sort()).toEqual([1, 2]);
+ expect(flattened.toSorted()).toEqual([1, 2]);
});
});
diff --git a/frontend/src/utils/__tests__/versions.test.ts b/frontend/src/utils/__tests__/versions.test.ts
index 786a03c4b7..708a6880b7 100644
--- a/frontend/src/utils/__tests__/versions.test.ts
+++ b/frontend/src/utils/__tests__/versions.test.ts
@@ -9,13 +9,13 @@ import {
describe("semverSort", () => {
it("should sort versions correctly", () => {
const versions = ["1.0.0", "1.0.1", "1.0.10", "1.0.2"];
- const sortedVersions = versions.sort(semverSort);
+ const sortedVersions = versions.toSorted(semverSort);
expect(sortedVersions).toEqual(["1.0.0", "1.0.1", "1.0.2", "1.0.10"]);
});
it("should handle pre-release versions correctly", () => {
const versions = ["1.0.0-alpha", "1.0.0", "1.0.0-beta", "1.0.0-rc.1"];
- const sortedVersions = versions.sort(semverSort);
+ const sortedVersions = versions.toSorted(semverSort);
expect(sortedVersions).toEqual([
"1.0.0-alpha",
"1.0.0-beta",
@@ -26,7 +26,7 @@ describe("semverSort", () => {
it("should handle versions with different number of segments", () => {
const versions = ["1.0", "1.0.0", "1.0.1", "1.0.10"];
- const sortedVersions = versions.sort(semverSort);
+ const sortedVersions = versions.toSorted(semverSort);
expect(sortedVersions).toEqual(["1.0", "1.0.0", "1.0.1", "1.0.10"]);
});
@@ -36,7 +36,7 @@ describe("semverSort", () => {
"1.0.0+20130313144700",
"1.0.0+exp.sha.5114f85",
];
- const sortedVersions = versions.sort(semverSort);
+ const sortedVersions = versions.toSorted(semverSort);
expect(sortedVersions).toEqual([
"1.0.0+001",
"1.0.0+20130313144700",
@@ -46,7 +46,7 @@ describe("semverSort", () => {
it("reverseSemverSort", () => {
const versions = ["1.0.0", "1.0.1", "1.0.10", "1.0.2"];
- const sortedVersions = versions.sort(reverseSemverSort);
+ const sortedVersions = versions.toSorted(reverseSemverSort);
expect(sortedVersions).toEqual(["1.0.10", "1.0.2", "1.0.1", "1.0.0"]);
});
});
diff --git a/frontend/src/utils/arrays.ts b/frontend/src/utils/arrays.ts
index cee9f428c5..d105aa4b8b 100644
--- a/frontend/src/utils/arrays.ts
+++ b/frontend/src/utils/arrays.ts
@@ -85,7 +85,7 @@ export function sortBy<T>(
// Decorate/sort/undecorate to compute keys once per element
return arr
.map((item) => [key(item), item] as const)
- .sort(([ka], [kb]) => {
+ .toSorted(([ka], [kb]) => {
// Nullish values sort last
if (ka == null && kb == null) {
return 0;
diff --git a/frontend/src/utils/mime-types.ts b/frontend/src/utils/mime-types.ts
index 63f5064d8b..ee9bb64d5c 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].sort((a, b) => {
+ return [...entries].toSorted((a, b) => {
const indexA = precedence.get(a[0]) ?? unknownPrecedence;
const indexB = precedence.get(b[0]) ?? unknownPrecedence;
return indexA - indexB;