Skip to content

chore: migrate from eslint to biome#354

Merged
pwlmc merged 1 commit intomasterfrom
pwlmc/migrate-to-biome
Apr 4, 2026
Merged

chore: migrate from eslint to biome#354
pwlmc merged 1 commit intomasterfrom
pwlmc/migrate-to-biome

Conversation

@pwlmc
Copy link
Copy Markdown
Owner

@pwlmc pwlmc commented Apr 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 4, 2026 20:54
Copy link
Copy Markdown

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

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 updates lint scripts/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.json to 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.

Comment on lines +93 to 94
// biome-ignore lint/style/noNonNullAssertion: to be fixed
const hexHash = hashRaw(imageData!, bits);
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

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

Suggested change
// 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);

Copilot uses AI. Check for mistakes.
Comment on lines +108 to 111
// 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];
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
// 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];

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,26 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

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

Suggested change
"$schema": "https://biomejs.dev/schemas/2.4.10/schema.json",
"$schema": "https://biomejs.dev/schemas/schema.json",

Copilot uses AI. Check for mistakes.
@pwlmc pwlmc merged commit 2814fc4 into master Apr 4, 2026
11 checks passed
@pwlmc pwlmc deleted the pwlmc/migrate-to-biome branch April 4, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants