chore(biome): tighten useMaxParams from 3 to 2#2049
Conversation
…tures
Prep for flipping useMaxParams from max: 3 to max: 2. Biome counts callback
arity naively, so functions that must match a framework contract (Jotai write
atoms, Hono basicAuth verifyUser, Cloudflare R2Bucket.put / uploadPart,
Array.reduce callbacks) cannot be refactored without breaking the interface.
Exempts:
- apps/expo/atoms/atomWith*.ts (Jotai write atom (get, set, update))
- apps/expo/features/weather/atoms/locationsAtoms.ts (Jotai write atom)
- packages/api/src/routes/admin/index.ts (Hono basicAuth verifyUser)
- packages/api/src/services/r2-bucket.ts (R2Bucket.put / uploadPart)
- packages/api/src/services/etl/processCatalogEtl.ts (Array.reduce callback)
- packages/api/test/{guides.test,setup}.ts (R2 put mocks mirroring interface)
- apps/{expo,packages/api}/utils/weight.ts (convertWeight, out of scope -
~24 call sites across the monorepo; refactoring is its own PR)
writeCachedReports and readCachedReports each took (userId, trailName?) plus (for write) a leading reports array. Consolidate the identifier args into a single opts object so both helpers stay under the upcoming useMaxParams max: 2.
Makes "one positional + one typed options object" the canonical function shape for new code. Follows #2042 (which did the bulk of the refactoring prep work) and the preceding overrides / trail-conditions refactor in this branch. Framework-required signatures remain exempted via the overrides added in the prior commit.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Tightens Biome’s useMaxParams lint rule from 3 to 2 parameters, standardizing on “one positional arg + one options object” for new/updated code while exempting framework-required 3-arity callbacks via config overrides.
Changes:
- Set
complexity/useMaxParamsmax params to 2 in Biome config. - Added Biome overrides to disable
useMaxParamsfor specific framework/interface-constrained files. - Refactored trail conditions cache helpers to accept an options object instead of multiple positional params.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| biome.json | Tightens useMaxParams and introduces per-path overrides to exempt framework-required arities. |
| apps/expo/features/trail-conditions/hooks/useTrailConditionReports.ts | Refactors caching helpers to use { userId, trailName? } options objects to comply with the new max-params rule. |
| "overrides": [ | ||
| { | ||
| "includes": [ | ||
| "apps/expo/atoms/atomWith*.ts", | ||
| "apps/expo/features/weather/atoms/locationsAtoms.ts", | ||
| "packages/api/src/routes/admin/index.ts", | ||
| "packages/api/src/services/r2-bucket.ts", | ||
| "packages/api/src/services/etl/processCatalogEtl.ts", | ||
| "packages/api/test/guides.test.ts", | ||
| "packages/api/test/setup.ts", | ||
| "apps/expo/utils/weight.ts", | ||
| "packages/api/src/utils/weight.ts" | ||
| ], | ||
| "linter": { | ||
| "rules": { | ||
| "complexity": { | ||
| "useMaxParams": "off" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ], |
There was a problem hiding this comment.
Biome override selectors use the key "include" (not "includes"). With "includes", these overrides likely won’t apply, so the lint rule won’t be disabled for the intended files and CI may fail. Rename "includes" to "include" (and keep the array value as-is).
| async function writeCachedReports( | ||
| reports: TrailConditionReport[], | ||
| userId: string, | ||
| trailName?: string, | ||
| opts: { userId: string; trailName?: string }, | ||
| ) { | ||
| try { | ||
| await AsyncStorage.setItem(cacheKey(userId, trailName), JSON.stringify(reports)); | ||
| await AsyncStorage.setItem(cacheKey(opts.userId, opts.trailName), JSON.stringify(reports)); | ||
| } catch { | ||
| // Best-effort — swallow write errors silently | ||
| } | ||
| } | ||
|
|
||
| /** Read previously-cached reports from AsyncStorage. */ | ||
| async function readCachedReports( | ||
| userId: string, | ||
| trailName?: string, | ||
| ): Promise<TrailConditionReport[] | undefined> { | ||
| async function readCachedReports(opts: { | ||
| userId: string; | ||
| trailName?: string; | ||
| }): Promise<TrailConditionReport[] | undefined> { | ||
| try { | ||
| const raw = await AsyncStorage.getItem(cacheKey(userId, trailName)); | ||
| const raw = await AsyncStorage.getItem(cacheKey(opts.userId, opts.trailName)); |
There was a problem hiding this comment.
The options-object type is duplicated with two different inline shapes (single-line vs multi-line). Consider introducing a shared type alias (e.g., "type CacheReportsOpts = { userId: string; trailName?: string }") and using it for both functions to keep the signatures consistent and reduce future drift.
The biome.json had two top-level `overrides` arrays. Per JSON spec the second replaces the first, silently dropping the useMaxParams exclusion list added in #2049. That promoted 12 useMaxParams errors in files meant to be excluded. Merge the overrides into one array and add the two lint tooling scripts (no-raw-regex, no-raw-typeof) to the exclusion.
Summary
Tightens
useMaxParamsfrommax: 3tomax: 2, making "one positional + one typed options object" the canonical function shape for new code.Follows #2042, which did the bulk of the refactoring prep work.
Framework-required signatures exempted via override
Biome's
useMaxParamsrule counts callback arity naively, so the following paths are exempted where the 3rd arg is framework-required:apps/expo/atoms/atomWith*.ts— Jotai write atom(get, set, update)apps/expo/features/weather/atoms/locationsAtoms.ts— Jotai write atom(get, set, newActiveId)packages/api/src/routes/admin/index.ts— HonobasicAuthverifyUser(user, pass, c)packages/api/src/services/r2-bucket.ts— CloudflareR2Bucket.put/uploadPartcontractpackages/api/src/services/etl/processCatalogEtl.ts—.reduce((acc, header, idx))packages/api/test/{guides.test,setup}.ts— R2 put mocks mirroring the interfaceApplication-code refactors
apps/expo/features/trail-conditions/hooks/useTrailConditionReports.ts—writeCachedReports/readCachedReportsnow take anoptsobject ({ userId, trailName? }) instead of positionaluserId, trailName?.Out of scope
convertWeight(weight, from, to)inapps/expo/utils/weight.tsandpackages/api/src/utils/weight.tshas ~24 call sites across the monorepo. Refactoring is its own PR, so it's exempted for now.Test plan
bun biome checkpasses at max: 2 (0 useMaxParams errors)bun run check-typescleanbun lintclean (same 186 warnings / 7 infos as baseline, no new errors)