8000 Add DeprecatedFonts theme check by miazbikowski · Pull Request #967 · Shopify/theme-tools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add DeprecatedFonts theme check #967

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

Merged
merged 1 commit into from
Jun 18, 2025

Conversation

miazbikowski
Copy link
Contributor
@miazbikowski miazbikowski commented Jun 9, 2025

What are you adding in this PR?

Video Demo:

Demo video: https://screenshot.click/17-29-7jiob-03dcd.mp4

Outdated:

This adds a check for section and block schemas to stop usage of deprecated fonts in:

  1. settings
  2. preset settings
  3. preset block settings (including nested blocks)

image.png

We're doing this as part of the Monotype migration project which aims to move all deprecated fonts to a replacement by September.

What's next? Any followup issues?

Yes, settings_schema.json is most likely of all files to have fonts. We need to write a theme check for this. We may also, if possible, wish to add a check for json templates and settings_data.json to thoroughly warn against deprecated font usage.

What did you learn?

That there are no existing checks for settings_schema.json or the other data files, so we don't have the building blocks for these.

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
      • If applicable, I've updated the theme-app-extension.yml config
    • I've made a PR to update the shopify.dev theme check docs if applicable (link PR here).
  • I included a minor bump changeset
  • My feature is backward compatible
  • I included a patch bump changeset

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@miazbikowski miazbikowski force-pushed the miaz/deprecated-fonts-theme-check branch 9 times, most recently from 19e0a4b to 56b4f02 Compare June 11, 2025 15:48
@miazbikowski miazbikowski marked this pull request as ready for review June 11, 2025 15:49
@miazbikowski miazbikowski requested a review from a team as a code owner June 11, 2025 15:49
@miazbikowski miazbikowski force-pushed the miaz/deprecated-fonts-theme-check branch from 56b4f02 to 66da27d Compare June 11, 2025 17:57
}

// only read setting type if value is a deprecated font
async function checkBlocksHashForDeprecatedFonts(
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this function and its array equivalent can be merged into one - they share most of their code. The for-loop just has to be modified a little so we check if it's an array of hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I do this in theme-graph to traverse both array and hash form with the same for loop.

I'm able to get the nodeAtPath in both forms too!

    // Iterate over array entries or object entries depending on how the blocks are defined
    const iterator = Array.isArray(preset.blocks)
      ? preset.blocks.entries()
      : Object.entries(preset.blocks!);

    for (const [keyOrIndex, block] of iterator) {
      const nodePath = ['presets', i, 'blocks', keyOrIndex];
      const node = nodeAtPath(ast, nodePath)! as ObjectNode;
      
      // ...
      
      }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! As a ruby dev who doesn't know typescript, I don't always have the most refined typescript code. But I incorporated this approach and was able to consolidate :)

@miazbikowski miazbikowski force-pushed the miaz/deprecated-fonts-theme-check branch 3 times, most recently from f17e5f8 to c65aabf Compare June 16, 2025 15:45
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 looks good. One missing edge case and i think we're good.

@miazbikowski miazbikowski force-pushed the miaz/deprecated-fonts-theme-check branch 2 times, most recently from 1ecd52f to 2259a97 Compare June 17, 2025 19:32
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.

🙏 thank you for your patience on this! This is amazing stuff!

message: string,
fullHighlight: boolean = true,
) {
const node = nodeAtPath(ast, ast_path)! as ArrayNode;
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this casting is dangerous given this method is extracted as a util 🤔?

Why not call context.report directly and do the casting when you need it instead?

Would remove the need for the fullHighlight thing?

reportWarning is pretty generic and it would feel weird to try to use that in a Liquid check, I'm not sure this deserves to be extracted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point re: extracting, so, un-extracting :)

@miazbikowski miazbikowski force-pushed the miaz/deprecated-fonts-theme-check branch from 2259a97 to 8305695 Compare June 18, 2025 16:10
@miazbikowski miazbikowski force-pushed the miaz/deprecated-fonts-theme-check branch from 8305695 to a3a513d Compare June 18, 2025 17:28
@miazbikowski miazbikowski merged commit 5ca2fca into main Jun 18, 2025
7 checks passed
@miazbikowski miazbikowski deleted the miaz/deprecated-fonts-theme-check branch June 18, 2025 17: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.

3 participants
0