Skip to content

chore(biome): tighten useMaxParams from 3 to 2#2049

Merged
andrew-bierman merged 3 commits into
developmentfrom
chore/biome-max-params-flip
Apr 11, 2026
Merged

chore(biome): tighten useMaxParams from 3 to 2#2049
andrew-bierman merged 3 commits into
developmentfrom
chore/biome-max-params-flip

Conversation

@andrew-bierman
Copy link
Copy Markdown
Collaborator

Summary

Tightens useMaxParams from max: 3 to max: 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 useMaxParams rule 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 — Hono basicAuth verifyUser(user, pass, c)
  • packages/api/src/services/r2-bucket.ts — Cloudflare R2Bucket.put / uploadPart contract
  • packages/api/src/services/etl/processCatalogEtl.ts.reduce((acc, header, idx))
  • packages/api/test/{guides.test,setup}.ts — R2 put mocks mirroring the interface

Application-code refactors

  • apps/expo/features/trail-conditions/hooks/useTrailConditionReports.tswriteCachedReports / readCachedReports now take an opts object ({ userId, trailName? }) instead of positional userId, trailName?.

Out of scope

convertWeight(weight, from, to) in apps/expo/utils/weight.ts and packages/api/src/utils/weight.ts has ~24 call sites across the monorepo. Refactoring is its own PR, so it's exempted for now.

Test plan

  • bun biome check passes at max: 2 (0 useMaxParams errors)
  • bun run check-types clean
  • bun lint clean (same 186 warnings / 7 infos as baseline, no new errors)

…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.
Copilot AI review requested due to automatic review settings April 11, 2026 05:48
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 11, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 679b5124-0207-4baf-a0a5-5557b18b4314

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/biome-max-params-flip

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/useMaxParams max params to 2 in Biome config.
  • Added Biome overrides to disable useMaxParams for 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.

Comment thread biome.json
Comment on lines +49 to +70
"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"
}
}
}
}
],
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines 19 to +36
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));
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@andrew-bierman andrew-bierman merged commit ad8864c into development Apr 11, 2026
9 of 11 checks passed
@andrew-bierman andrew-bierman deleted the chore/biome-max-params-flip branch April 11, 2026 06:10
andrew-bierman added a commit that referenced this pull request Apr 11, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants