theme-check icon indicating copy to clipboard operation
theme-check copied to clipboard

Ignoring files not possible

Open Benecke opened this issue 2 years ago • 10 comments

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).

Benecke avatar May 05 '22 14:05 Benecke

Yes, I have same issue

slavamak avatar May 08 '22 22:05 slavamak

Have you tried

ignore:
  - src/*

?

charlespwd avatar May 10 '22 15:05 charlespwd

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

  • changed the config
  • restarted VS Code
  • opened the file /src/sections/components/cart-infos/schema_end.liquid
  • full theme check runs
  • Problems log is populated with the check of this file
Bildschirmfoto 2022-05-11 um 14 54 16

Edit:

I also tried

ignore:
  - src/**/*

Benecke avatar May 11 '22 12:05 Benecke

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 avatar May 12 '22 13:05 charlespwd

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

charlespwd avatar May 13 '22 13:05 charlespwd

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

  • tried it anyway: check still spits out file reports from src and theme directory
  • also, placing it in the theme folder won't work at all (no check runs)

Note that I tried it with:

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

Benecke avatar May 13 '22 14:05 Benecke

The idea is the following:

  • Have one .theme-check.yml at the root, this one checks $projectRoot/theme.
  • Have one .theme-check.yml at $projectRoot/src that extends: nothing (the colon should be irrelevant, it looks like we handle that)

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:

  • $projectRoot/src/theme/.theme-check.yml
  • $projectRoot/src/.theme-check.yml
  • $projectRoot/.theme-check.yml
  • and so on until it finds one.

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

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

  • $projectRoot/src/theme/.theme-check.yml
  • $projectRoot/src/.theme-check.yml
  • $projectRoot/.theme-check.yml

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 😓

charlespwd avatar May 13 '22 19:05 charlespwd

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.

Benecke avatar May 13 '22 21:05 Benecke

😅

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

charlespwd avatar May 16 '22 14:05 charlespwd

~~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! 😅

esbeto avatar Aug 11 '22 22:08 esbeto