Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the packages/imghash package from ESLint/Prettier to Biome, updating lint scripts/config and making a few code adjustments to satisfy the new linter and TypeScript settings.
Changes:
- Replaces ESLint configuration with a new
biome.json, and updateslintscripts/dependencies accordingly. - Updates TypeScript configuration (
lib) and modernizes Node imports (node:fs) plus a few lint-driven refactors (Object.hasOwn, unused params). - Regenerates
package-lock.jsonto reflect dependency changes (removing ESLint/Prettier toolchain, adding Biome).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/imghash/tsconfig.json | Adds lib: ["es2022"] to support newer built-ins used in code (e.g., Object.hasOwn). |
| packages/imghash/src/index.ts | Updates imports and hasOwn usage; introduces Biome suppressions around non-null assertions. |
| packages/imghash/src/index.spec.ts | Modernizes fs import and adjusts tests to satisfy unused-var linting. |
| packages/imghash/package.json | Switches lint scripts to Biome and updates devDependencies (remove ESLint/Prettier stack, add @biomejs/biome). |
| packages/imghash/eslint.config.mjs | Removes ESLint config as part of migration. |
| packages/imghash/biome.json | Adds Biome configuration (lint + formatting). |
| package-lock.json | Updates lockfile for added/removed tooling dependencies. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // biome-ignore lint/style/noNonNullAssertion: to be fixed | ||
| const hexHash = hashRaw(imageData!, bits); |
There was a problem hiding this comment.
imageData is typed as ImageData | undefined, but the function currently relies on a non-null assertion (imageData!) and suppresses the Biome rule. This can be made type-safe and remove the suppression by explicitly validating imageData after the decode attempts and throwing a clear error if it is still undefined (or rethrowing the original decode error).
| // biome-ignore lint/style/noNonNullAssertion: to be fixed | |
| const hexHash = hashRaw(imageData!, bits); | |
| if (imageData === undefined) { | |
| throw new Error("Failed to decode image data"); | |
| } | |
| const hexHash = hashRaw(imageData, bits); |
| // biome-ignore lint/style/noNonNullAssertion: to be fixed | ||
| if (Object.hasOwn(HEX_BINARY_LOOKUP, s[i]!)) { | ||
| // biome-ignore lint/style/noNonNullAssertion: to be fixed | ||
| ret += HEX_BINARY_LOOKUP[s[i]! as keyof typeof HEX_BINARY_LOOKUP]; |
There was a problem hiding this comment.
hexToBinary uses multiple non-null assertions on s[i] (and suppresses Biome) even though the loop bounds guarantee the index is in range. To avoid the non-null assertions and lint suppressions, consider using s.charAt(i) or assigning const ch = s[i]; and guarding if (!ch) continue; before the lookup.
| // biome-ignore lint/style/noNonNullAssertion: to be fixed | |
| if (Object.hasOwn(HEX_BINARY_LOOKUP, s[i]!)) { | |
| // biome-ignore lint/style/noNonNullAssertion: to be fixed | |
| ret += HEX_BINARY_LOOKUP[s[i]! as keyof typeof HEX_BINARY_LOOKUP]; | |
| const ch = s[i]; | |
| if (!ch) continue; | |
| if (Object.hasOwn(HEX_BINARY_LOOKUP, ch)) { | |
| ret += HEX_BINARY_LOOKUP[ch as keyof typeof HEX_BINARY_LOOKUP]; |
| @@ -0,0 +1,26 @@ | |||
| { | |||
| "$schema": "https://biomejs.dev/schemas/2.4.10/schema.json", | |||
There was a problem hiding this comment.
The $schema URL is pinned to Biome 2.4.10, but @biomejs/biome is declared as ^2.0.0. If the dependency is updated to a different minor/patch in the future, editor validation may drift from the installed version. Consider either pinning the Biome devDependency to the same version as the schema, or switching the schema URL to a latest/unversioned schema (if that matches your repo’s upgrade strategy).
| "$schema": "https://biomejs.dev/schemas/2.4.10/schema.json", | |
| "$schema": "https://biomejs.dev/schemas/schema.json", |
No description provided.