Shopify / theme-tools

Everything developer experience for Shopify themes
https://shopify.dev/docs/themes
MIT License
63 stars 19 forks source link

Ignoring files not possible #416

Open Benecke opened 2 years ago

Benecke commented 2 years ago

Ignoring files is not really possible, errors still popup in the problems tab in VS.

My .theme-check.yml

root: theme
ignore:
- src

I also tested "themeCheck.checkOnOpen": false on my VS config. Still, saved files from the src directory are then checked and reported in the problems tab (both on full and on partial theme check).

slavamak commented 2 years ago

Yes, I have same issue

charlespwd commented 2 years ago

Have you tried

ignore:
  - src/*

?

Benecke commented 2 years ago

I think I did. To be sure I just validated this again.

Bildschirmfoto 2022-05-11 um 14 54 16

Edit:

I also tried

ignore:
  - src/**/*
charlespwd commented 2 years ago

Oh I think I'm seeing what's happening. I think that root and ignore are concatenated. So you end up in a place where it's actually ignoring theme/src and not src.

Thanks for the detailed report!

charlespwd commented 2 years ago

In the meantime, I think you can add a .theme-check.yml in the src folder and the plugin will prefer this one over the other.

You could put one that extends: nothing and it should effectively do the same as ignore.

# src/.theme-check.yml
root: .
extends: :nothing
Benecke commented 2 years ago

Hm, not sure if that'd help. Wouldn't that check the /src folder? I need to check /theme.

Note that I tried it with:

extends: nothing (...you had a double colon there I suppose)

charlespwd commented 2 years ago

The idea is the following:

So that when you open a file in src, the VS Code plugin will think that the root config is the one in $projectRoot/src and won't check your files.

Because the language server actually looks "upward" from the file you have open to find a .theme-check.yml file.

In other words, if you open src/theme/layout.liquid, the language server will look for a config file in the following order:

If it doesn't find one, it'll pick the default config.

What happens in your case, I assume, is that it goes:

But the ignore doesn't ignore the file in src since it ignore theme/src because of path.join(root, ignore)

That being said the language server will pick the config for the first file that it finds. So if you did open a file in /theme, it might pick up $projectRoot/.theme-check.yml...

Ugh appologies if this is needlessly complicated 😓

Benecke commented 2 years ago

No need to apologize, thanks for the work your put into this.

So I tested again and now I added src/.theme-check.yml with this:

root: .
extends: nothing

This is what happens now:

When I open: src/layout/theme.liquid the check is run and now no problems from this file are reported (good!).

However, unlike before, also the dist file theme/layout/theme.liquid is not reported anymore. When I manually open theme/layout/theme.liquid, the errors of this file are reported.

charlespwd commented 2 years ago

😅

What if... we backtrack and ignore ../src at the root config instead (and delete src/.theme-check.yml)? I suspect it will simply not run checks at all but we could be surprised :D

esbeto commented 2 years ago

~~Sorry for being a bit off-topic. Please add an ignore: example to the documentation: https://shopify.dev/themes/tools/theme-check/configuration~~

I had to dig until I found this Issue to understand how to use it. 🥲

edit: damn, now that I went to it again I see you already included an ignore example inside the ThemeCheck: section, Sorry! 😅