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.

Add linting rule to prefer options object over multiple positional args (#5578)

Trevor Manzaf56ce797139
diff --git a/biome.jsonc b/biome.jsonc
index fa2c30b7af..7fdd63eff6 100644
--- a/biome.jsonc
+++ b/biome.jsonc
@@ -2,7 +2,8 @@
"$schema": "frontend/node_modules/@biomejs/biome/configuration_schema.json",
"plugins": [
"frontend/lint/addEventListenerObject.grit",
- "frontend/lint/removeEventListenerObject.grit"
+ "frontend/lint/removeEventListenerObject.grit",
+ "frontend/lint/preferObjectParams.grit"
],
"files": {
"includes": [
diff --git a/frontend/lint/preferObjectParams.grit b/frontend/lint/preferObjectParams.grit
new file mode 100644
index 0000000000..59fabab9e4
--- /dev/null
+++ b/frontend/lint/preferObjectParams.grit
@@ -0,0 +1,23 @@
+// Prefer object parameters pattern: fn(), fn(options), or fn(arg, options)
+// This rule enforces using objects for multiple parameters instead of positional arguments
+`$declaration` where {
+ $declaration <: or {
+ // Regular functions
+ `function $name($p1, $p2, $p3, $...) { $body }`,
+ // Async functions
+ `async function $name($p1, $p2, $p3, $...) { $body }`,
+ // Generator functions
+ `function* $name($p1, $p2, $p3, $...) { $body }`,
+ // Arrow functions
+ `const $name = ($p1, $p2, $p3, $...) => $body`,
+ // Function expressions
+ `const $name = function($p1, $p2, $p3, $...) { $body }`,
+ // Methods
+ `$name($p1, $p2, $p3, $...) { $body }`
+ },
+ register_diagnostic(
+ span=$name,
+ message="Avoid multiple positional arguments. Prefer an options object instead, e.g., fn(options) or fn(arg, options).",
+ severity="warn"
+ )
+}