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: adopt stable Oxlint rules (#10771)

Shahmir Varqha333febcc35a2
diff --git a/frontend/.oxlintrc.json b/frontend/.oxlintrc.json
index d6cc0648e0..85d85eb59c 100644
--- a/frontend/.oxlintrc.json
+++ b/frontend/.oxlintrc.json
@@ -66,8 +66,7 @@
"react/jsx-no-literals": "off",
"react/memo-dependencies": "off",
"react/no-deriving-state-in-effects": "off",
- "react/no-object-type-as-default-prop": "off",
- "react/no-unstable-nested-components": "off",
+ "react/no-unstable-nested-components": ["error", { "allowAsProps": true }],
"react/preserve-manual-memoization": "off",
"react/prefer-function-component": "off",
"react/purity": "off",
@@ -78,7 +77,10 @@
"typescript/explicit-member-accessibility": "off",
"vitest/no-conditional-expect": "off",
"vitest/no-disabled-tests": "off",
- "vitest/no-standalone-expect": "off",
+ "vitest/no-standalone-expect": [
+ "error",
+ { "additionalTestBlockFunctions": ["beforeEach"] }
+ ],
"vitest/prefer-snapshot-hint": "off",
"vitest/require-to-throw-message": "off",
"vitest/valid-expect": "off",
diff --git a/frontend/src/components/data-table/__tests__/column-explorer.test.tsx b/frontend/src/components/data-table/__tests__/column-explorer.test.tsx
index 53552c73ec..3adda65d73 100644
--- a/frontend/src/components/data-table/__tests__/column-explorer.test.tsx
+++ b/frontend/src/components/data-table/__tests__/column-explorer.test.tsx
@@ -25,6 +25,7 @@ const FIELD_TYPES: FieldTypesWithExternalType = [
];
type Row = Record<string, unknown>;
+const EMPTY_HIDDEN_COLUMNS: readonly string[] = [];
const TEST_COLUMNS: ColumnDef<Row>[] = [
{ id: "customer_name", accessorKey: "customer_name" },
@@ -34,12 +35,12 @@ const TEST_COLUMNS: ColumnDef<Row>[] = [
interface HarnessProps {
totalColumns?: number;
- initiallyHidden?: string[];
+ initiallyHidden?: readonly string[];
}
function PanelHarness({
totalColumns = 3,
- initiallyHidden = [],
+ initiallyHidden = EMPTY_HIDDEN_COLUMNS,
}: HarnessProps) {
const table = useReactTable<Row>({
data: [],
diff --git a/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx b/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx
index 7d41db2a76..e3afa85c43 100644
--- a/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx
+++ b/frontend/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx
@@ -21,6 +21,7 @@ beforeAll(() => {
});
type Row = Record<string, unknown>;
+const EMPTY_COLUMN_IDS: readonly string[] = [];
// Select, index, and nameless columns are non-hideable in production
// (see columns.tsx), so the harness mirrors that to keep visibility counts
@@ -47,11 +48,14 @@ const TEST_COLUMNS: ColumnDef<Row>[] = [
];
interface HarnessProps {
- initiallyHidden?: string[];
- nonHideable?: string[];
+ initiallyHidden?: readonly string[];
+ nonHideable?: readonly string[];
}
-function Harness({ initiallyHidden = [], nonHideable = [] }: HarnessProps) {
+function Harness({
+ initiallyHidden = EMPTY_COLUMN_IDS,
+ nonHideable = EMPTY_COLUMN_IDS,
+}: HarnessProps) {
const table = useReactTable<Row>({
data: [],
columns: TEST_COLUMNS.map((column) =>
diff --git a/frontend/src/components/editor/connections/secret-combobox.tsx b/frontend/src/components/editor/connections/secret-combobox.tsx
index f4b4e3a42f..872f3ee0f9 100644
--- a/frontend/src/components/editor/connections/secret-combobox.tsx
+++ b/frontend/src/components/editor/connections/secret-combobox.tsx
@@ -68,6 +68,8 @@ interface SecretComboboxProps {
allowCreateSecret?: (search: string) => boolean;
}
+const defaultCustomValueLabel = (custom: string) => `Use "${custom}"`;
+
/**
* Searchable combobox for connection fields that may reference secrets.
*
@@ -84,7 +86,7 @@ export const SecretCombobox: React.FC<SecretComboboxProps> = ({
onCreateSecret,
className,
searchPlaceholder,
- formatCustomValueLabel = (custom) => `Use "${custom}"`,
+ formatCustomValueLabel = defaultCustomValueLabel,
createSecretLabel = "Create a new secret",
allowCustomValue,
allowCreateSecret,
diff --git a/frontend/src/components/editor/file-tree/renderers.tsx b/frontend/src/components/editor/file-tree/renderers.tsx
index f247b4f860..50d780931c 100644
--- a/frontend/src/components/editor/file-tree/renderers.tsx
+++ b/frontend/src/components/editor/file-tree/renderers.tsx
@@ -189,6 +189,8 @@ export const MediaRenderer: React.FC<MediaSource & { mimeType: string }> = ({
* based on MIME type. Used by both the local file viewer and the
* storage file viewer.
*/
+const EMPTY_EXTENSIONS: readonly Extension[] = [];
+
export const FileContentRenderer: React.FC<{
mimeType: string;
filename?: string;
@@ -199,7 +201,7 @@ export const FileContentRenderer: React.FC<{
readOnly?: boolean;
onChange?: (value: string) => void;
/** Additional CodeMirror extensions (e.g. save hotkey). */
- extensions?: Extension[];
+ extensions?: readonly Extension[];
}> = ({
mimeType,
filename,
@@ -207,7 +209,7 @@ export const FileContentRenderer: React.FC<{
mediaSource,
readOnly = true,
onChange,
- extensions = [],
+ extensions = EMPTY_EXTENSIONS,
}) => {
const { theme } = useTheme();
diff --git a/frontend/src/components/forms/form.tsx b/frontend/src/components/forms/form.tsx
index 4f4b1b8fa2..e8b97a9df4 100644
--- a/frontend/src/components/forms/form.tsx
+++ b/frontend/src/components/forms/form.tsx
@@ -60,15 +60,17 @@ interface Props<T extends FieldValues> {
form: UseFormReturn<T>;
schema: z.ZodType;
path?: Path<T>;
- renderers: FormRenderer<T>[] | undefined;
+ renderers: readonly FormRenderer<T>[] | undefined;
children?: React.ReactNode;
}
+const EMPTY_RENDERERS: readonly never[] = [];
+
export const ZodForm = <T extends FieldValues>({
schema,
form,
path = "" as Path<T>,
- renderers = [],
+ renderers = EMPTY_RENDERERS,
children,
}: Props<T>) => {
return (
@@ -83,7 +85,7 @@ export interface RenderZodSchemaOptions<T extends FieldValues, S> {
schema: z.ZodType<S>;
form: UseFormReturn<T>;
path: Path<T>;
- renderers: FormRenderer<T>[];
+ renderers: readonly FormRenderer<T>[];
}
export function renderZodSchema<T extends FieldValues, S>({
@@ -516,7 +518,7 @@ const FormArray = ({
schema: z.ZodType;
form: UseFormReturn<any>;
path: Path<any>;
- renderers: FormRenderer[];
+ renderers: readonly FormRenderer[];
minLength?: number;
}) => {
const { label, description } = FieldOptions.parse(schema.description || "");
diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsx
index 56c7426f65..ef93b3cd41 100644
--- a/frontend/src/components/ui/input.tsx
+++ b/frontend/src/components/ui/input.tsx
@@ -17,6 +17,10 @@ export type InputProps = React.InputHTMLAttributes<HTMLInputElement> & {
endAdornment?: React.ReactNode;
};
+const DEFAULT_SEARCH_ICON = (
+ <SearchIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />
+);
+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, endAdornment, ...props }, ref) => {
const icon = props.icon;
@@ -120,7 +124,7 @@ export const SearchInput = React.forwardRef<
{
className,
rootClassName,
- icon = <SearchIcon className="mr-2 h-4 w-4 shrink-0 opacity-50" />,
+ icon = DEFAULT_SEARCH_ICON,
clearable = true,
...props
},
diff --git a/frontend/src/plugins/core/RenderHTML.tsx b/frontend/src/plugins/core/RenderHTML.tsx
index 31f64a6dfb..b97d767dbe 100644
--- a/frontend/src/plugins/core/RenderHTML.tsx
+++ b/frontend/src/plugins/core/RenderHTML.tsx
@@ -24,6 +24,8 @@ import { sanitizeHtml, useSanitizeHtml } from "./sanitize";
type ReplacementFn = NonNullable<HTMLReactParserOptions["replace"]>;
type TransformFn = NonNullable<HTMLReactParserOptions["transform"]>;
+const EMPTY_REPLACEMENTS: readonly ReplacementFn[] = [];
+
interface Options {
html: string;
/**
@@ -31,7 +33,7 @@ interface Options {
* @default true
*/
alwaysSanitizeHtml?: boolean;
- additionalReplacements?: ReplacementFn[];
+ additionalReplacements?: readonly ReplacementFn[];
}
const replaceValidTags = (domNode: DOMNode) => {
@@ -299,7 +301,7 @@ const CopyableCode = ({ children }: { children: ReactNode }) => {
*/
export const renderHTML = ({
html,
- additionalReplacements = [],
+ additionalReplacements = EMPTY_REPLACEMENTS,
alwaysSanitizeHtml = true,
}: Options) => {
return (
@@ -313,7 +315,7 @@ export const renderHTML = ({
const RenderHTML = ({
html,
- additionalReplacements = [],
+ additionalReplacements = EMPTY_REPLACEMENTS,
alwaysSanitizeHtml,
}: Options) => {
const shouldSanitizeHtml = useSanitizeHtml();
@@ -333,7 +335,7 @@ const RenderHTML = ({
function parseHtml({
html,
- additionalReplacements = [],
+ additionalReplacements = EMPTY_REPLACEMENTS,
}: Pick<Options, "html" | "additionalReplacements">) {
const renderFunctions: ReplacementFn[] = [
replaceValidTags,
diff --git a/frontend/src/plugins/impl/code/any-language-editor.tsx b/frontend/src/plugins/impl/code/any-language-editor.tsx
index bf96b785e6..fffd4628aa 100644
--- a/frontend/src/plugins/impl/code/any-language-editor.tsx
+++ b/frontend/src/plugins/impl/code/any-language-editor.tsx
@@ -27,6 +27,8 @@ export const LANGUAGE_MAP: Record<string, LanguageName | undefined> = {
undefined: "text",
};
+const EMPTY_EXTENSIONS: readonly Extension[] = [];
+
function isSupportedLanguage(
language: string | undefined,
): language is LanguageName {
@@ -43,17 +45,18 @@ function isSupportedLanguage(
* language support.
*/
const AnyLanguageCodeMirror: React.FC<
- ReactCodeMirrorProps & {
+ Omit<ReactCodeMirrorProps, "extensions"> & {
language: string | undefined;
hideUnsupportedLanguageErrors?: boolean;
theme: ResolvedTheme;
showCopyButton?: boolean;
+ extensions?: readonly Extension[];
}
> = ({
language,
hideUnsupportedLanguageErrors,
showCopyButton,
- extensions = [],
+ extensions = EMPTY_EXTENSIONS,
...props
}) => {
// Maybe normalize the language to the extension
@@ -64,7 +67,7 @@ const AnyLanguageCodeMirror: React.FC<
Logger.warn(`Language ${language} not found in CodeMirror.`);
}
- const finalExtensions = useMemo((): Extension[] => {
+ const finalExtensions = useMemo((): readonly Extension[] => {
if (!isSupportedLanguage(language)) {
return extensions;
}
@@ -90,7 +93,7 @@ const AnyLanguageCodeMirror: React.FC<
toastTitle="Copied to clipboard"
/>
)}
- <ReactCodeMirror {...props} extensions={finalExtensions} />
+ <ReactCodeMirror {...props} extensions={[...finalExtensions]} />
</div>
);
};
diff --git a/frontend/src/stories/cell.stories.tsx b/frontend/src/stories/cell.stories.tsx
index 945cbbc17d..ec06fc0dbd 100644
--- a/frontend/src/stories/cell.stories.tsx
+++ b/frontend/src/stories/cell.stories.tsx
@@ -22,18 +22,22 @@ import { TooltipProvider } from "../components/ui/tooltip";
type Story = StoryObj<typeof Cell>;
+interface CellOverrides {
+ runElapsedTimeMs?: Milliseconds;
+ output?: CellRuntimeState["output"];
+ edited?: boolean;
+ interrupted?: boolean;
+ errored?: boolean;
+ status?: CellRuntimeState["status"];
+ staleInputs?: boolean;
+ config?: CellConfig;
+}
+
+const EMPTY_OVERRIDES: Readonly<CellOverrides> = {};
+
const Cell: React.FC<{
- overrides?: {
- runElapsedTimeMs?: Milliseconds;
- output?: CellRuntimeState["output"];
- edited?: boolean;
- interrupted?: boolean;
- errored?: boolean;
- status?: CellRuntimeState["status"];
- staleInputs?: boolean;
- config?: CellConfig;
- };
-}> = ({ overrides = {} }) => {
+ overrides?: CellOverrides;
+}> = ({ overrides = EMPTY_OVERRIDES }) => {
const cid = cellId("1");
const notebook: NotebookState = {
cellData: {