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.

chore: eslint to biome partial migration (#6552)

Myles Scolnick7d05021db1a8
diff --git a/biome.jsonc b/biome.jsonc
index da1df29a2a..1b3ea0c754 100644
--- a/biome.jsonc
+++ b/biome.jsonc
@@ -36,13 +36,23 @@
"complexity": {
"noBannedTypes": "off",
"noForEach": "off",
- "useArrowFunction": "error"
+ "noUselessFragments": "error",
+ "noUselessConstructor": "error",
+ "useArrowFunction": "error",
+ "noImportantStyles": {
+ "level": "warn",
+ "fix": "none"
+ }
},
"correctness": {
"noInnerDeclarations": "error",
"noNestedComponentDefinitions": "off",
- "noUnusedFunctionParameters": "warn",
+ "noUnusedFunctionParameters": {
+ "level": "warn",
+ "fix": "none"
+ },
"noUnusedImports": "error",
+ "noUnusedVariables": "off",
"useExhaustiveDependencies": "off",
"useHookAtTopLevel": "info",
"useUniqueElementIds": "warn"
@@ -54,6 +64,12 @@
"noNonNullAssertion": "off",
"noParameterAssign": "off",
"noUnusedTemplateLiteral": "error",
+ "useConst": "error",
+ "useBlockStatements": "error",
+ // This changes a lot of code and should be done in a separate PR
+ // "useConsistentArrayType": "error",
+ "useDefaultParameterLast": "error",
+ "useImportType": "error",
"useNamingConvention": {
"level": "warn",
"options": {
@@ -85,24 +101,26 @@
]
}
},
- "useConsistentArrayType": "off",
- "useImportType": "error",
"useNodejsImportProtocol": "error",
+ "useSelfClosingElements": "error",
"useSingleVarDeclarator": "error",
"useTemplate": "error"
},
"suspicious": {
"noArrayIndexKey": "off",
- "noUnknownAtRules": "off",
- "useIterableCallbackReturn": "warn",
"noAssignInExpressions": "info",
- "noConsole": "off",
+ "noVar": "error",
+ "noConsole": "error",
+ "noDebugger": "error",
"noDoubleEquals": "error",
"noEmptyBlockStatements": "info",
"noExplicitAny": "off",
"noImplicitAnyLet": "error",
"noRedeclare": "info",
- "noShadowRestrictedNames": "error"
+ "useIsArray": "error",
+ "noShadowRestrictedNames": "error",
+ "noUnknownAtRules": "off",
+ "useIterableCallbackReturn": "warn"
}
}
},
@@ -124,5 +142,22 @@
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
- }
+ },
+ "overrides": [
+ {
+ "includes": [
+ "**/e2e-tests/**",
+ "**/__mocks__/**",
+ "**/vite.config.*",
+ "**/stories/**"
+ ],
+ "linter": {
+ "rules": {
+ "suspicious": {
+ "noConsole": "off"
+ }
+ }
+ }
+ }
+ ]
}
diff --git a/frontend/.eslintrc.cjs b/frontend/.eslintrc.cjs
index e43ddc1008..489cece0ee 100644
--- a/frontend/.eslintrc.cjs
+++ b/frontend/.eslintrc.cjs
@@ -47,14 +47,25 @@ module.exports = {
" Copyright 2024 Marimo. All rights reserved. ",
],
+ // Rules disabled because they have Biome equivalents
+ curly: "off", // → useBlockStatements in Biome
+ "default-param-last": "off", // → useDefaultParameterLast in Biome
+ eqeqeq: "off", // → noDoubleEquals in Biome
+ "no-console": "off", // → noConsole in Biome
+ "no-debugger": "off", // → noDebugger in Biome
+ "no-empty": "off", // → noEmptyBlockStatements in Biome
+ "no-inner-declarations": "off", // → noInnerDeclarations in Biome
+ "no-useless-constructor": "off", // → noUselessConstructor in Biome
+ "no-var": "off", // → noVar in Biome
+ "prefer-const": "off", // → useConst in Biome
+ "prefer-template": "off", // → useTemplate in Biome
+
// These rules don't require type information and have autofixes
- "@typescript-eslint/array-type": ["error", { default: "array-simple" }],
"@typescript-eslint/consistent-generic-constructors": "error",
"@typescript-eslint/consistent-type-definitions": "error",
"@typescript-eslint/no-confusing-non-null-assertion": "error",
"@typescript-eslint/no-dynamic-delete": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
- curly: "error",
// Turn off recommended we don't want
"ssr-friendly/no-dom-globals-in-react-fc": "off",
@@ -107,8 +118,6 @@ module.exports = {
"unicorn/prefer-top-level-await": "off",
"unicorn/prevent-abbreviations": "off",
- "no-console": "error",
-
// Would like to turn on, but too many existing errors
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-misused-promises": "off",
@@ -132,7 +141,6 @@ module.exports = {
// These rules aim to reduce bikeshedding during code reviews
// Often there are multiple ways to do something and this forces consistency
- "prefer-template": "error", // Use template literals instead of string concatenation
"unicorn/switch-case-braces": ["error", "avoid"], // Only braces when necessary
"unicorn/consistent-destructuring": "error",
"unicorn/prefer-logical-operator-over-ternary": "error",
@@ -140,12 +148,9 @@ module.exports = {
"unicorn/no-object-as-default-parameter": "error",
"unicorn/prefer-number-properties": "error",
"unicorn/prefer-ternary": "error",
- "unicorn/prefer-array-some": "error",
"react/jsx-boolean-value": ["error", "always"], // Force `={true}` or `={false}` as it's more explicit
"react/hook-use-state": "error",
- "react/jsx-no-useless-fragment": "error",
"react/jsx-pascal-case": "error",
- "react/self-closing-comp": "error",
"react/function-component-definition": [
"error",
{
diff --git a/frontend/e2e-tests/cells.spec.ts b/frontend/e2e-tests/cells.spec.ts
index 130988d6da..303d2819ba 100644
--- a/frontend/e2e-tests/cells.spec.ts
+++ b/frontend/e2e-tests/cells.spec.ts
@@ -38,7 +38,7 @@ test("keeps re-renders from growing", async ({ page }) => {
// It is also ok to decrease the count if we find a way to reduce the number
// of renders.
expect(cellRenderCount).toBeDefined();
- expect(Number.parseInt(cellRenderCount || "")).toBeLessThanOrEqual(6);
+ expect(Number.parseInt(cellRenderCount || "", 10)).toBeLessThanOrEqual(6);
});
/**
diff --git a/frontend/e2e-tests/global-setup.ts b/frontend/e2e-tests/global-setup.ts
index 7a2dc7c199..fca79110bd 100644
--- a/frontend/e2e-tests/global-setup.ts
+++ b/frontend/e2e-tests/global-setup.ts
@@ -1,5 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-/* eslint-disable no-console */
+/** biome-ignore-all lint/suspicious/noConsole: for debugging */
import { chromium, type FullConfig } from "@playwright/test";
import { type ApplicationNames, getAppUrl } from "../playwright.config";
diff --git a/frontend/e2e-tests/global-teardown.ts b/frontend/e2e-tests/global-teardown.ts
index 7eb40d2a44..82abdb7d90 100644
--- a/frontend/e2e-tests/global-teardown.ts
+++ b/frontend/e2e-tests/global-teardown.ts
@@ -1,5 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-/* eslint-disable no-console */
+/** biome-ignore-all lint/suspicious/noConsole: for debugging */
import { exec } from "node:child_process";
import { promisify } from "node:util";
diff --git a/frontend/src/__mocks__/common.ts b/frontend/src/__mocks__/common.ts
index dc1a652893..6db33e6588 100644
--- a/frontend/src/__mocks__/common.ts
+++ b/frontend/src/__mocks__/common.ts
@@ -1,5 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-/* eslint-disable no-console */
+/** biome-ignore-all lint/suspicious/noConsole: for debugging */
import { type Mock, vi } from "vitest";
import { invariant } from "@/utils/invariant";
@@ -108,8 +108,10 @@ export const SetupMocks = {
delete store[key];
}),
clear: vi.fn(() => {
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
- Object.keys(store).forEach((key) => delete store[key]);
+ for (const key of Object.keys(store)) {
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
+ delete store[key];
+ }
}),
key: vi.fn((index: number) => Object.keys(store)[index] || null),
get length() {
diff --git a/frontend/src/components/data-table/data-table.tsx b/frontend/src/components/data-table/data-table.tsx
index 5e7dd0740c..fd822a8ea8 100644
--- a/frontend/src/components/data-table/data-table.tsx
+++ b/frontend/src/components/data-table/data-table.tsx
@@ -264,9 +264,13 @@ const DataTableInternal = <TData,>({
// - Setting styles on the table's direct wrapper ensures the header sticks
// reliably across browsers without changing upstream components.
React.useEffect(() => {
- if (!tableRef.current) return;
+ if (!tableRef.current) {
+ return;
+ }
const wrapper = tableRef.current.parentElement as HTMLDivElement | null;
- if (!wrapper) return;
+ if (!wrapper) {
+ return;
+ }
if (maxHeight) {
wrapper.style.maxHeight = `${maxHeight}px`;
// Ensure wrapper scrolls
diff --git a/frontend/src/components/data-table/range-focus/__tests__/utils.test.ts b/frontend/src/components/data-table/range-focus/__tests__/utils.test.ts
index fccee8443d..49e849dec3 100644
--- a/frontend/src/components/data-table/range-focus/__tests__/utils.test.ts
+++ b/frontend/src/components/data-table/range-focus/__tests__/utils.test.ts
@@ -20,7 +20,7 @@ function createMockCell(id: string, value: unknown): Cell<unknown, unknown> {
function createMockColumn(id: string): Column<unknown> {
return {
id: id,
- getIndex: () => Number.parseInt(id),
+ getIndex: () => Number.parseInt(id, 10),
} as unknown as Column<unknown>;
}
@@ -30,7 +30,7 @@ function createMockRow(
): Row<unknown> {
return {
id,
- index: Number.parseInt(id),
+ index: Number.parseInt(id, 10),
getAllCells: () => cells,
original: {},
depth: 0,
diff --git a/frontend/src/components/editor/ai/transport/chat-transport.tsx b/frontend/src/components/editor/ai/transport/chat-transport.tsx
index ed3370e405..dcca10f92c 100644
--- a/frontend/src/components/editor/ai/transport/chat-transport.tsx
+++ b/frontend/src/components/editor/ai/transport/chat-transport.tsx
@@ -16,7 +16,7 @@ export class StreamingChunkTransport<
private onChunkReceived: (chunk: UIMessageChunk) => void;
constructor(
- options: HttpChatTransportInitOptions<UI_MESSAGE> = {},
+ options: HttpChatTransportInitOptions<UI_MESSAGE>,
onChunkReceived: (chunk: UIMessageChunk) => void,
) {
super(options);
diff --git a/frontend/src/core/cells/logs.ts b/frontend/src/core/cells/logs.ts
index f67ffbad7e..0ed9a2b21b 100644
--- a/frontend/src/core/cells/logs.ts
+++ b/frontend/src/core/cells/logs.ts
@@ -87,7 +87,7 @@ const CellLogLogger = {
? "red"
: "orange";
const status = payload.level.toUpperCase();
- // eslint-disable-next-line no-console
+ /** biome-ignore lint/suspicious/noConsole: for debugging */
console.log(
`%c[${status}]`,
`color:${color}; padding:2px 0; border-radius:2px; font-weight:bold`,
diff --git a/frontend/src/hooks/useCellRenderCount.ts b/frontend/src/hooks/useCellRenderCount.ts
index ade9bb32f4..8006b97e02 100644
--- a/frontend/src/hooks/useCellRenderCount.ts
+++ b/frontend/src/hooks/useCellRenderCount.ts
@@ -8,6 +8,7 @@ export function useCellRenderCount() {
const currentCount = Number.parseInt(
document.body.dataset.cellRenderCount || "0",
+ 10,
);
document.body.dataset.cellRenderCount = (currentCount + 1).toString();
},
diff --git a/frontend/src/hooks/useResizeHandle.ts b/frontend/src/hooks/useResizeHandle.ts
index 639d6f6874..28f8efe967 100644
--- a/frontend/src/hooks/useResizeHandle.ts
+++ b/frontend/src/hooks/useResizeHandle.ts
@@ -29,7 +29,10 @@ export const useResizeHandle = ({
return;
}
- let width = Number.parseInt(window.getComputedStyle(resizableDiv).width);
+ let width = Number.parseInt(
+ window.getComputedStyle(resizableDiv).width,
+ 10,
+ );
let lastX = 0;
let isResizing = false;
let activeDirection: "left" | "right" | null = null;
diff --git a/frontend/src/plugins/core/RenderHTML.tsx b/frontend/src/plugins/core/RenderHTML.tsx
index 19f84d51e5..5393dfe3cf 100644
--- a/frontend/src/plugins/core/RenderHTML.tsx
+++ b/frontend/src/plugins/core/RenderHTML.tsx
@@ -89,7 +89,7 @@ const replaceSrcScripts = (domNode: DOMNode): JSX.Element | undefined => {
script.src = src;
document.head.append(script);
}
- // eslint-disable-next-line react/jsx-no-useless-fragment
+ // biome-ignore lint/complexity/noUselessFragments: this is intentional
return <></>;
}
};
@@ -163,7 +163,6 @@ export const renderHTML = ({ html, additionalReplacements = [] }: Options) => {
return transformed;
}
}
- // eslint-disable-next-line react/jsx-no-useless-fragment
return reactNode as JSX.Element;
},
});
diff --git a/frontend/src/plugins/impl/vega/loader.ts b/frontend/src/plugins/impl/vega/loader.ts
index 1bd4c2b7eb..f784b53190 100644
--- a/frontend/src/plugins/impl/vega/loader.ts
+++ b/frontend/src/plugins/impl/vega/loader.ts
@@ -41,7 +41,7 @@ const BIG_INT_MIDDLEWARE: Middleware = () => {
return result;
}
- const parsedInt = Number.parseInt(v);
+ const parsedInt = Number.parseInt(v, 10);
if (isNumber(parsedInt)) {
const needsBigInt = Math.abs(parsedInt) > Number.MAX_SAFE_INTEGER;
if (!needsBigInt) {
diff --git a/frontend/src/plugins/layout/RoutesPlugin.tsx b/frontend/src/plugins/layout/RoutesPlugin.tsx
index 72cd6020f4..eb27ce8005 100644
--- a/frontend/src/plugins/layout/RoutesPlugin.tsx
+++ b/frontend/src/plugins/layout/RoutesPlugin.tsx
@@ -69,13 +69,12 @@ const RoutesComponent = ({
}, [handleFindMatch]);
if (!matched) {
- // eslint-disable-next-line react/jsx-no-useless-fragment
+ // biome-ignore lint/complexity/noUselessFragments: this is intentional
return <></>;
}
const matchedIndex = routes.indexOf(matched);
const child = React.Children.toArray(children)[matchedIndex];
- // eslint-disable-next-line react/jsx-no-useless-fragment
return <>{child}</>;
};
diff --git a/frontend/src/utils/Logger.ts b/frontend/src/utils/Logger.ts
index 5ae4fefe8d..b45a40c640 100644
--- a/frontend/src/utils/Logger.ts
+++ b/frontend/src/utils/Logger.ts
@@ -1,5 +1,5 @@
/* Copyright 2024 Marimo. All rights reserved. */
-/* eslint-disable no-console */
+/** biome-ignore-all lint/suspicious/noConsole: for debugging */
import { Functions } from "./functions";
diff --git a/frontend/src/utils/traceback.ts b/frontend/src/utils/traceback.ts
index 11c19a25c0..6e15982021 100644
--- a/frontend/src/utils/traceback.ts
+++ b/frontend/src/utils/traceback.ts
@@ -73,6 +73,7 @@ export function getTracebackInfo(domNode: DOMNode): TracebackInfo | null {
)?.[1];
const lineNumber = Number.parseInt(
lineSibling.firstChild.nodeValue || "0",
+ 10,
);
if (cellId && lineNumber) {
return { cellId: cellId as CellId, lineNumber };
diff --git a/frontend/src/utils/tracer.ts b/frontend/src/utils/tracer.ts
index 5b1d1788e1..203076a350 100644
--- a/frontend/src/utils/tracer.ts
+++ b/frontend/src/utils/tracer.ts
@@ -1,7 +1,9 @@
/* Copyright 2024 Marimo. All rights reserved. */
-/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-explicit-any */
+/** biome-ignore-all lint/suspicious/noConsole: for debugging */
+
+import { Logger } from "./Logger";
type SpanStatus = "ok" | "error";
@@ -88,19 +90,19 @@ export class Tracer {
s.startTime < span.endTime,
);
if (childSpans.length > 0) {
- console.log("Child Spans:");
+ Logger.log("Child Spans:");
childSpans.forEach((childSpan) => {
- console.log(` - ${childSpan.name}`);
+ Logger.log(` - ${childSpan.name}`);
});
}
- console.log(`Start Time: ${new Date(span.startTime).toISOString()}`);
+ Logger.log(`Start Time: ${new Date(span.startTime).toISOString()}`);
if (span.endTime) {
- console.log(`End Time: ${new Date(span.endTime).toISOString()}`);
- console.log(`Duration: ${span.endTime - span.startTime}ms`);
+ Logger.log(`End Time: ${new Date(span.endTime).toISOString()}`);
+ Logger.log(`Duration: ${span.endTime - span.startTime}ms`);
}
- console.log(`Status: ${span.status}`);
- console.log(`Attributes: ${JSON.stringify(span.attributes)}`);
- console.log("---");
+ Logger.log(`Status: ${span.status}`);
+ Logger.log(`Attributes: ${JSON.stringify(span.attributes)}`);
+ Logger.log("---");
});
}
}
diff --git a/frontend/vite.config.mts b/frontend/vite.config.mts
index b102584eaf..a25755ad5f 100644
--- a/frontend/vite.config.mts
+++ b/frontend/vite.config.mts
@@ -192,7 +192,7 @@ If the server is already running, make sure it is using port ${SERVER_PORT} with
scripts.forEach((script) => {
const src = script.getAttribute("src");
- if (src && src.startsWith("./assets/")) {
+ if (src?.startsWith("./assets/")) {
return;
}