Repository navigation
functions: move lint to Biome and fix every warning - #1709
Merged
Merged
Conversation
The functions lint script was empty: ESLint 9 no longer reads the .eslintrc.js config, and eslint-config-google is unmaintained. Move functions/ to Biome like the frontend (#1700), with its own config since functions/ is a standalone package. `npm run lint` checks lint and format and fails on warnings; CI runs it, and lint-staged formats staged files. Drop the dead tslint.json and tsconfig.dev.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- import types with `import type` - replace `any` with real types: a typed AggregatedVote (count or text votes) read through getAggregatedTextVotes, send() resolving to a Response, FastifyInstance and vi.mocked() in specs, typed test stubs - turn the static-only DAO classes into plain objects (same call sites) - optional chains, template literals, node: protocol, unused parameters - drop the stale eslint-disable comments No runtime behaviour change; vote.spec.ts pins the vote aggregation paths the AggregatedVote typing touched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review follow-ups: - tsconfig.test.json (unused since the move to vitest) now typechecks the specs and test utilities the build excludes, with bundler resolution like vitest; `npm run typecheck` runs in CI. Fix the 4 spec type errors it reports (firestore-vitest typings gaps). - The lint-staged hook fails on warnings like CI and the predeploy do. - The test SDK passes the document name for empty event data: the firestore stub now returns a missing document instead of throwing. - Use FastifyError, FakeFirestoreDatabase and WriteResult instead of hand-made or unknown types; drop the redundant applyInvites promise wrapper and the `instanceof Response` checks send() made redundant. - getAggregatedTextVotes ignores a null vote item. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Preview for 8088002 (sandbox project open-feedback-hugo, expires in 7 days): https://open-feedback-hugo--pr-1709-rlyyhrft.web.app |
open-feedback
|
||||||||||||||||||||||||||||
| Project |
open-feedback
|
| Branch Review |
claude/issue-1406-functions-lint-4d2805
|
| Run status |
|
| Run duration | 02m 26s |
| Commit |
|
| Committer | Hugo Gresse |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
15
|
| View all changes introduced in this branch ↗︎ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1406
Why
npm run lintinfunctions/did nothing: the script was"". ESLint 9 no longer reads.eslintrc.js, andeslint-config-googleis no longer maintained. Running the old config by hand found about 120 warnings and 200 errors, many of them from rules that no longer exist.#1700 moved the frontend to Biome, so
functions/now uses Biome too.Tooling
functions/biome.jsonuses the recommended preset with no rules turned off, and the same formatter settings as the rootbiome.jsonc.root: trueconfig becausefunctions/is a standalone package, and the root config excludes it.npm run lintrunsbiome check --error-on-warnings(lint and format).npm run formatwrites the formatting.npm run typechecktype-checks the specs and test utilities, which the build excludes.build.ymlgains alint functions/step and atypecheck functions/ specsstep. Both fail on any new warning or type error.functions/package.jsongets alint-stagedentry. lint-staged uses the nearest config, so staged functions files are now formatted and linted, with the same--error-on-warningsas CI..eslintrc.js, the deadtslint.jsonandtsconfig.dev.json. The unusedtsconfig.test.jsonis reused as the spec typecheck config, with bundler resolution like vitest.Warnings fixed
Biome reported 184 diagnostics: 3 errors, 177 warnings and 4 infos. All are fixed with real code changes, and nothing is disabled.
useImportTypeimport type(safe autofix; the emitted JS is identical)noExplicitAnynoUnusedFunctionParameters/noUnusedVariables_-prefixed where the position is fixed (Fastify handlers, SDK hooks)useOptionalChain?.(same results for every value the types allow)noStaticOnlyClass*Daoclasses are now plain objects. Call sites andvi.spyOn(XDao, …)are unchanged.useTemplate,useNodejsImportProtocol,useConst,noTsIgnore,noNonNullAssertion,noImplicitAnyLet,useIterableCallbackReturn,noExportsInTestThe
anyfixes:AggregatedVoteis now typed. Each vote item holds either a count or text votes keyed by vote id. It is read throughgetAggregatedTextVotes, whichvote.tsuses for the up-vote and deletion checks.send()resolves to aResponse. It never resolved to anError, so the redundantinstanceof Responsechecks are gone.FastifyError.applyInvitesresults are typed asWriteResult, and a redundant promise wrapper is removed.FastifyInstance,vi.mocked(send)and firestore-vitest'sFakeFirestoreDatabase.The new spec typecheck also found 4 type errors that already existed in
mutations.spec.tsandresources.spec.ts. They come from gaps in the firestore-vitest typings and are fixed, with a comment each.Behaviour
No runtime change is intended:
mainand this branch were both compiled. The JS differs only where expected: object-literal DAOs, optional chains, template literals,node:crypto,Object.entries, and the vote helper.vote.spec.tscovers the vote aggregation paths touched by theAggregatedVotetyping. ItsVotecases also pass againstmain's logic.Checks
On Node 24, from
functions/:npm run lint: 0 diagnostics.npm run typecheck: clean, and it does report an error deliberately added to a spec.npm run build: passes.npx vitest run: 17 files, 272 tests pass, through both the functions config and the root config.The Firestore rules specs in
config/were not run locally because the emulator port was taken. They are untouched./code-review maxwas run, and its findings are fixed in the last commit.Needs a decision
firebase.jsonfunctionspredeployrunsnpm run lint, so a functions deploy now stops on any lint warning. Before, it ran nothing.--error-on-warningsignores info-level suggestions such asuseTemplate. Making them fail would mean raising those rules' severity infunctions/biome.json.functions/pins Biome 2.6.4 while the root uses 2.5.15. Dependabot's grouped monthly PR could go red if a new minor release adds a warning-level rule.UserDao.getUsersByIdsswallows read errors with no log, the same as before. Adding aconsole.warnwould change runtime output, so it is left out.sendContactEmailanswers a failed send with HTTP 500 andsuccess: true. It also puts unescaped form input into the email HTML.exportEventVotesreads the session votes with its own casts, so it could shareAggregatedVoteonce the type moves tofunctions/src/types.firebase-toolsis loaded eagerly bydeleteProject, about 1.2s on every cold start.🤖 Generated with Claude Code