Skip to content

Conversation

openscript
Copy link
Owner

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Oct 2, 2025

🦋 Changeset detected

Latest commit: 651a9e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro-loader-i18n Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@openscript openscript requested a review from Copilot October 2, 2025 09:22
@codecov
Copy link

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.15%. Comparing base (20511e7) to head (651a9e0).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #146      +/-   ##
==========================================
+ Coverage   98.10%   98.15%   +0.04%     
==========================================
  Files          17       17              
  Lines         475      487      +12     
  Branches      112      117       +5     
==========================================
+ Hits          466      478      +12     
  Misses          9        9              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@Copilot 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 enhances the i18n content handling to support objects nested within arrays, expanding the capability of the getAllUniqueKeys function to traverse more complex data structures.

  • Enhanced getAllUniqueKeys function to recursively process arrays and nested objects within arrays
  • Added comprehensive test coverage for objects nested in arrays and arrays within arrays scenarios
  • Updated test fixtures and snapshots to include gallery content with nested i18n structure

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
libs/astro-utils-i18n/src/utils/collection.ts Enhanced getAllUniqueKeys function to handle arrays and nested objects within arrays
libs/astro-utils-i18n/test/utils/collection.spec.ts Added test cases for objects nested in arrays and arrays within arrays
libs/astro-utils-i18n/test/utils/snapshots/collection.spec.ts.snap Updated snapshots for new test cases
libs/astro-loader-i18n/test/fixtures/collections.ts Added gallery fixture with nested i18n objects in arrays
libs/astro-loader-i18n/test/loaders/snapshots/i18n-file-loader.spec.ts.snap Updated snapshots with gallery test data
.changeset/plain-worms-find.md Added changeset documenting the new feature

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +10 to +11
// Wrap array in an object to reuse the function and ignore its key
getAllUniqueKeys({ array: item }, keys, true);
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The hardcoded 'array' key used as a wrapper creates an implicit dependency and reduces code clarity. Consider using a more descriptive constant or a different approach that doesn't require wrapping arrays in artificial objects.

Suggested change
// Wrap array in an object to reuse the function and ignore its key
getAllUniqueKeys({ array: item }, keys, true);
// Recurse into arrays within arrays
getAllUniqueKeys(item, keys, true);

Copilot uses AI. Check for mistakes.

Comment on lines +1 to +10
export function getAllUniqueKeys(obj: Record<string, unknown>, keys = new Set<string>(), ignore?: boolean): Set<string> {
Object.entries(obj).forEach(([key, value]) => {
keys.add(key);
if (value && typeof value === "object" && !Array.isArray(value)) {
getAllUniqueKeys(value as Record<string, unknown>, keys);
if (!ignore) keys.add(key);
if (value && typeof value === "object") {
if (Array.isArray(value)) {
value.forEach((item) => {
if (item && typeof item === "object") {
// Recurse into objects and arrays within arrays
if (Array.isArray(item)) {
// Wrap array in an object to reuse the function and ignore its key
Copy link

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

The ignore parameter lacks clear documentation and its purpose is not immediately obvious from the function signature. Consider adding JSDoc documentation or renaming the parameter to something more descriptive like skipCurrentLevelKeys.

Copilot uses AI. Check for mistakes.

@openscript openscript merged commit 8e4f95a into main Oct 2, 2025
3 checks passed
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.

1 participant