This repository was archived by the owner on Jun 12, 2026. It is now read-only.
fix: remove all non-null assertions to fix noNonNullAssertion lint warnings - #21
Merged
Conversation
…rnings Replace 20 non-null assertion (!) usages across source and test files with safe alternatives: null guards, fallback values, and optional chaining. Add getSchemaInstance helper in test utils to centralize schema lookup.
Replace ESLint and Prettier with Biome for linting and formatting. Remove eslint.config.mjs, .prettierrc.json, .prettierignore and related devDependencies. Add biome.json configuration and reformat codebase to match Biome's style (double quotes, sorted imports, space indentation).
Comment on lines
+491
to
494
| const foreignSchema = field.foreign[1]; | ||
| dbData[name] = Array.isArray(dbData[name]) | ||
| ? dbData[name].map((entry) => fromDatabase(entry, field.foreign![1]!)) | ||
| ? dbData[name].map((entry) => fromDatabase(entry, foreignSchema)) | ||
| : fromDatabase(dbData[name], field.foreign[1]); |
There was a problem hiding this comment.
Inconsistent use of foreignSchema variable
The foreignSchema local variable was introduced to avoid the double non-null assertion field.foreign![1]! in the array branch, but the else branch still accesses field.foreign[1] directly rather than reusing the variable. For consistency, the else branch should also use foreignSchema.
Suggested change
| const foreignSchema = field.foreign[1]; | |
| dbData[name] = Array.isArray(dbData[name]) | |
| ? dbData[name].map((entry) => fromDatabase(entry, field.foreign![1]!)) | |
| ? dbData[name].map((entry) => fromDatabase(entry, foreignSchema)) | |
| : fromDatabase(dbData[name], field.foreign[1]); | |
| const foreignSchema = field.foreign[1]; | |
| dbData[name] = Array.isArray(dbData[name]) | |
| ? dbData[name].map((entry) => fromDatabase(entry, foreignSchema)) | |
| : fromDatabase(dbData[name], foreignSchema); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/interfaces/data-api/beta/components.ts
Line: 491-494
Comment:
**Inconsistent use of `foreignSchema` variable**
The `foreignSchema` local variable was introduced to avoid the double non-null assertion `field.foreign![1]!` in the array branch, but the `else` branch still accesses `field.foreign[1]` directly rather than reusing the variable. For consistency, the else branch should also use `foreignSchema`.
```suggestion
const foreignSchema = field.foreign[1];
dbData[name] = Array.isArray(dbData[name])
? dbData[name].map((entry) => fromDatabase(entry, foreignSchema))
: fromDatabase(dbData[name], foreignSchema);
```
How can I resolve this? If you propose a fix, please make it concise.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
🔗 Linked issue
N/A
❓ Type of change
📚 Description
Eliminates all 20
lint/style/noNonNullAssertionBiome warnings across 8 files by replacing!(non-null assertion) operators with safe alternatives:Source files (5 fixes):
components.ts—?? ""fallback after.has()guard; earlyreturnguard forfilterValuemetadata.ts— local variable withundefinedcheck for map iteration; null guard with error throw for schema lookupTest files (15 fixes):
getSchemaInstance()helper inutils.tsthat throws on missing schemaSchema.get(...)!.instance()calls withgetSchemaInstance(...)across 6 test filesroutes.test.ts— merged into single optional chain;id ?? ""fallbackmandatory.test.ts— addedif (!id) throwguards in 3 functions, removing 5id!usagesSchemaimports in 4 files📝 Checklist
Greptile Summary
This PR eliminates all 20
noNonNullAssertionBiome lint warnings across 8 files by replacing TypeScript!non-null assertions with safe, explicit alternatives — either null-checks with early throws (which improves error observability), optional chaining with meaningful fallbacks, or the newgetSchemaInstancetest helper that centralises theSchema.get()!.instance()pattern.The source-code changes in
components.tsandmetadata.tsare logically equivalent to the originals; no behavioral regressions were identified. The test-file changes are clean refactors.Key highlights:
metadata.tssetForeignnow throws descriptive errors (Schema "…" not found/Unable to infer foreign table name for field "…") instead of crashing with opaque null-reference errors — a genuine improvement.mandatory.test.tsreplaces fiveid!usages with explicitif (!id) throwguards, making test failures easier to diagnose.parseInt(val, 10)radix added incomponents.ts— good practice.foreignSchemavariable inValidation.Unlockis used in the.map()branch but theelsebranch still referencesfield.foreign[1]directly; both are equivalent, but using the variable consistently would improve readability.Confidence Score: 4/5
Validation.Unlockwhere the introducedforeignSchemavariable should be used consistently in both branches. No runtime regressions were identified.Validation.Unlock)Last reviewed commit: 1521c07