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: Customize which directory/directories contain section files #278

Open
nikitaourazbaev opened this issue Feb 6, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@nikitaourazbaev
Copy link

Is your feature request related to a problem? Please describe.
I’m getting an “unknown object” warning for all references to section in section files because our section files are in a _sections directory, as we use a minimal custom build step to process them. We don’t have an src directory.

Describe the solution you'd like
An additional setting on the existing root setting to list directories where these types of files may be located.

root:
  sections:
    - sections
    - _sections

This condition could then potentially check if any of the provided directories match:

https://github.com/Shopify/theme-tools/blob/main/packages/theme-check-common/src/checks/undefined-object/index.ts#L172

Describe alternatives you've considered
We could move all of our theme files to an src directory but this would require changing our build step to copy all other directories and files. Ideally we would prefer to keep our build tooling minimal.

We could disable the UndefinedObject check but we’d like to leave it on to catch actual undefined objects.

Additional context

@charlespwd
Copy link
Contributor

Ish this one is a bit of a pickle. Normally the recommendation is to disable the ones you don't like in src/.theme-check.yml and enable them in the dist output to be sure. I can see how that doesn't map to your setup.

Thing is, this isn't only UndefinedObject. It's going to do the same thing for code completion and hover as well (those objects won't be "in scope").

The other thing is that supporting this would be a documentation complexity burden. The more options we have, the harder it is for someone new to make sense of it. It would also make the stuff more brittle internally.

And what we'd gain is the support for yet another different way to build themes.

But I do appreciate the desire to be build-less (or almost)... That's kind of what we're going for (with obvious gaps).

I wonder if we could tackle this a bit differently. Maybe a {% # global sections, predictive_search, recommendations %} comment at the top of the file as a low-key way of declaring variables in scope. Or maybe revisit the contract we wanted to do for snippet signatures and extending that to non-snippet files.

@nikitaourazbaev
Copy link
Author

Thanks, I know it’s a bit of a unique issue, so I really appreciate you considering solutions! My ultimate goal is to not have any build process at all, but we’re not quite there yet. Theme blocks should get us much closer though.

Globals comments would definitely work. I’m not sure I’m familiar with the snippet signatures contract but sounds like that would also work (and would be useful for snippets too, of course).

@mgmanzella mgmanzella added the enhancement New feature or request label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants