Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Theme Check] Add check for duplicate settings id's #696

Merged
merged 3 commits into from
Jan 28, 2025
Merged

Conversation

zacariec
Copy link
Contributor

@zacariec zacariec commented Jan 10, 2025

Closes https://github.com/Shopify/develop-advanced-edits/issues/263

Implements a new validation check to prevent duplicate setting IDs across theme configurations. This helps theme developers identify and fix duplicate IDs early in development, preventing potential conflicts and overrides.

The implementation includes:

  • New JSONCheckDefinition for unique setting ID validation
  • Test coverage for valid and invalid theme configurations
  • Detection logic for finding duplicate IDs in settings schema

See:
Ticket: 49020903
Shopify/cli#4187

What are you adding in this PR?

This PR adds a new theme check validator that detects duplicate setting IDs in theme configurations. The validator scans settings_schema.json files and reports an error when it finds multiple settings using the same ID value, preventing potential runtime conflicts.
Key changes:

  • New UniqueSettingIds check that validates setting ID uniqueness
  • Integration with the existing theme checker infrastructure
  • Test coverage for both valid and invalid scenarios
  • Error reporting with precise location information

What's next? Any followup issues?

Potential follow-ups:

  • Consider extending the check to validate uniqueness across sections
  • Add documentation for theme developers about ID uniqueness requirements
  • Consider adding quick-fix suggestions for duplicate IDs

What did you learn?

Working with AST traversal for JSON validation showed that we need a consistent approach to handle nested property validation. The existing node type checks provided a good pattern to follow.

Before you deploy

  • This PR includes a new checks or changes the configuration of a check
  • I included a minor bump changeset
  • It's in the allChecks array in src/checks/index.ts
  • I ran yarn build and committed the updated configuration files

@zacariec zacariec requested a review from a team as a code owner January 10, 2025 00:38
@zacariec zacariec changed the title Issues/263 [Theme Check] Add check for duplicate settings id's Jan 10, 2025
Copy link
Contributor

@aswamy aswamy left a comment

Choose a reason for hiding this comment

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

✅ Code looking good
✅ Tophatting went well

Implements a new validation check to prevent duplicate setting IDs
across theme configurations. This helps theme developers identify and
fix duplicate IDs early in development, preventing potential conflicts
and overrides.

The implementation includes:
- New JSONCheckDefinition for unique setting ID validation
- Test coverage for valid and invalid theme configurations
- Detection logic for finding duplicate IDs in settings schema

See:
Ticket: 49020903
Shopify/cli#4187
Copy link
Contributor Author

zacariec commented Jan 28, 2025

Merge activity

  • Jan 27, 10:19 PM EST: A user started a stack merge that includes this pull request via Graphite.
  • Jan 27, 10:19 PM EST: A user merged this pull request with Graphite.

@zacariec zacariec merged commit ed3c437 into main Jan 28, 2025
6 checks passed
@zacariec zacariec deleted the issues/263 branch January 28, 2025 03:19
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.

3 participants