theme-check 1.11.0 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/CHANGELOG.md +7 -0
  4. data/CONTRIBUTING.md +82 -0
  5. data/README.md +4 -0
  6. data/Rakefile +7 -0
  7. data/TROUBLESHOOTING.md +65 -0
  8. data/data/shopify_liquid/built_in_liquid_objects.json +60 -0
  9. data/data/shopify_liquid/documentation/filters.json +5528 -0
  10. data/data/shopify_liquid/documentation/latest.json +1 -0
  11. data/data/shopify_liquid/documentation/objects.json +19272 -0
  12. data/data/shopify_liquid/documentation/tags.json +1252 -0
  13. data/lib/theme_check/checks/undefined_object.rb +4 -0
  14. data/lib/theme_check/language_server/completion_context.rb +52 -0
  15. data/lib/theme_check/language_server/completion_engine.rb +15 -21
  16. data/lib/theme_check/language_server/completion_provider.rb +16 -1
  17. data/lib/theme_check/language_server/completion_providers/assignments_completion_provider.rb +36 -0
  18. data/lib/theme_check/language_server/completion_providers/filter_completion_provider.rb +49 -6
  19. data/lib/theme_check/language_server/completion_providers/object_attribute_completion_provider.rb +47 -0
  20. data/lib/theme_check/language_server/completion_providers/object_completion_provider.rb +10 -7
  21. data/lib/theme_check/language_server/completion_providers/render_snippet_completion_provider.rb +5 -1
  22. data/lib/theme_check/language_server/completion_providers/tag_completion_provider.rb +8 -1
  23. data/lib/theme_check/language_server/handler.rb +3 -1
  24. data/lib/theme_check/language_server/protocol.rb +9 -0
  25. data/lib/theme_check/language_server/type_helper.rb +22 -0
  26. data/lib/theme_check/language_server/variable_lookup_finder/assignments_finder/node_handler.rb +63 -0
  27. data/lib/theme_check/language_server/variable_lookup_finder/assignments_finder/scope.rb +57 -0
  28. data/lib/theme_check/language_server/variable_lookup_finder/assignments_finder/scope_visitor.rb +42 -0
  29. data/lib/theme_check/language_server/variable_lookup_finder/assignments_finder.rb +76 -0
  30. data/lib/theme_check/language_server/variable_lookup_finder/constants.rb +43 -0
  31. data/lib/theme_check/language_server/variable_lookup_finder/liquid_fixer.rb +103 -0
  32. data/lib/theme_check/language_server/variable_lookup_finder/potential_lookup.rb +10 -0
  33. data/lib/theme_check/language_server/variable_lookup_finder/tolerant_parser.rb +94 -0
  34. data/lib/theme_check/language_server/variable_lookup_finder.rb +60 -100
  35. data/lib/theme_check/language_server/variable_lookup_traverser.rb +70 -0
  36. data/lib/theme_check/language_server.rb +12 -0
  37. data/lib/theme_check/remote_asset_file.rb +13 -7
  38. data/lib/theme_check/shopify_liquid/documentation/markdown_template.rb +51 -0
  39. data/lib/theme_check/shopify_liquid/documentation.rb +44 -0
  40. data/lib/theme_check/shopify_liquid/filter.rb +4 -0
  41. data/lib/theme_check/shopify_liquid/object.rb +4 -0
  42. data/lib/theme_check/shopify_liquid/source_index/base_entry.rb +60 -0
  43. data/lib/theme_check/shopify_liquid/source_index/base_state.rb +23 -0
  44. data/lib/theme_check/shopify_liquid/source_index/filter_entry.rb +18 -0
  45. data/lib/theme_check/shopify_liquid/source_index/filter_state.rb +11 -0
  46. data/lib/theme_check/shopify_liquid/source_index/object_entry.rb +14 -0
  47. data/lib/theme_check/shopify_liquid/source_index/object_state.rb +11 -0
  48. data/lib/theme_check/shopify_liquid/source_index/parameter_entry.rb +21 -0
  49. data/lib/theme_check/shopify_liquid/source_index/property_entry.rb +9 -0
  50. data/lib/theme_check/shopify_liquid/source_index/return_type_entry.rb +37 -0
  51. data/lib/theme_check/shopify_liquid/source_index/tag_entry.rb +20 -0
  52. data/lib/theme_check/shopify_liquid/source_index/tag_state.rb +11 -0
  53. data/lib/theme_check/shopify_liquid/source_index.rb +56 -0
  54. data/lib/theme_check/shopify_liquid/source_manager.rb +111 -0
  55. data/lib/theme_check/shopify_liquid/tag.rb +4 -0
  56. data/lib/theme_check/shopify_liquid.rb +17 -1
  57. data/lib/theme_check/version.rb +1 -1
  58. data/shipit.rubygems.yml +3 -0
  59. data/theme-check.gemspec +3 -1
  60. metadata +37 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99089d8a9e02b33f55c11e18d0d0dea02f8b4b9be24f548c2ba4852823d54d2e
4
- data.tar.gz: aa7c80503782d3817fe49fd4460ff565144339c19ea87a1ec9c516573116299f
3
+ metadata.gz: 81371af549f2572360879747bb2e4a05ccddc52e564180d6ae7d0b8e73026e3f
4
+ data.tar.gz: 586263191e54240240110853f7a4973413bb5aa1c1e2412c2ac293876a25fc1f
5
5
  SHA512:
6
- metadata.gz: 99f92709c2d233e05f5ba79b9c83243fc3fe3cd0ce640c7b2444b24c7922f57e76d40910997fab8ac7aa10ffe553ae3fcfde68bc310e0330279f0bb4419bd9d8
7
- data.tar.gz: 6e43b16af119f881d5ae36501d638b7bb1459fe4fdfe124f396338012d28b5e5c8f4ad9b28b8ab3e3afd83c92044391ae31af6ca3f3914f898501d08e7710ca3
6
+ metadata.gz: b050fff19499529cc00a4382ddc2b525002cfb3058bb4f292d0a2181093d4a4854e62f1cf0736397f0eee40aca8d2f1ec073a3a6093b1e50106fd66600938e90
7
+ data.tar.gz: '09f65761f31e53c11c3e723d1651426a6787b5360a67bf8c9c833cd51ab2352b32b18b69580c143193f45ce9438e09a22c95dda66a98c344e4eaee5d3293ce9b'
data/.gitignore CHANGED
@@ -14,3 +14,6 @@ Gemfile.lock
14
14
  packaging/builds
15
15
  .vscode
16
16
  *.DS_Store
17
+
18
+ # Theme Liquid docs live at git@github.com:Shopify/theme-liquid-docs.git,
19
+ /data/shopify_liquid/documentation/
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ v1.12.0 / 2022-12-12
2
+ ==================
3
+
4
+ * Introduce Intelligent Code Completion ([#672](https://github.com/Shopify/theme-check/issues/672))
5
+ * Update TROUBLESHOOTING.md to include language server stopping guide ([#664](https://github.com/Shopify/theme-check/issues/664))
6
+ * Create troubleshooting doc, update contributing and readme with links ([#630](https://github.com/Shopify/theme-check/issues/630))
7
+ * robots Object in robots.txt file ([#644](https://github.com/Shopify/theme-check/issues/644)). Thanks @we5!
1
8
 
2
9
  v1.11.0 / 2022-08-22
3
10
  ====================
data/CONTRIBUTING.md CHANGED
@@ -21,6 +21,84 @@ For your contribution to be accepted you will need to sign the [Shopify Contribu
21
21
  4. Push to the branch (`git push origin my-new-feature`)
22
22
  5. Create a new Pull Request
23
23
 
24
+ ## Run Language Server
25
+ If you're making changes to the language server and you want to debug, you can run the repo's version of `theme-check-language-server`.
26
+
27
+ ### Setup
28
+
29
+ Before configuring your IDE, run the following commands in a terminal:
30
+
31
+ * Make sure you have a `$HOME/bin`
32
+ ```bash
33
+ mkdir -p $HOME/bin
34
+ ```
35
+ * Paste this script to create an executable wrapper in `$HOME/bin/theme-check-language-server` for language server
36
+ ```bash
37
+ cat <<-'EOF' > $HOME/bin/theme-check-language-server
38
+ #!/usr/bin/env bash
39
+ cd "$HOME/src/github.com/Shopify/theme-check" &> /dev/null
40
+ chruby () {
41
+ source '/opt/dev/sh/chruby/chruby.sh'
42
+ chruby "$@"
43
+ }
44
+ export THEME_CHECK_DEBUG=true
45
+ export THEME_CHECK_DEBUG_LOG_FILE="/tmp/theme-check-debug.log"
46
+ touch "$THEME_CHECK_DEBUG_LOG_FILE"
47
+ chruby 2.7 &>/dev/null
48
+ gem env &>/dev/null
49
+ bin/theme-check-language-server
50
+ EOF
51
+ ```
52
+ * Make the script executable
53
+ ```bash
54
+ chmod u+x $HOME/bin/theme-check-language-server
55
+ ```
56
+
57
+ #### Configure VS Code
58
+
59
+ * Install the [Shopify Liquid](https://github.com/shopify/theme-check-vscode) plugin
60
+
61
+ * Add the following to `settings.json`:
62
+
63
+ ```json
64
+ "shopifyLiquid.formatterDevPreview": true,
65
+ "shopifyLiquid.languageServerPath": "/Users/<YOUR_USERNAME>/bin/theme-check-language-server",
66
+ ```
67
+
68
+ #### Configure Vim
69
+
70
+ If you use `coc.nvim` as your completion engine, add this to your CocConfig:
71
+
72
+ ```json
73
+ "languageserver": {
74
+ "theme-check": {
75
+ "command": "/Users/<YOUR_USERNAME>/bin/theme-check-language-server",
76
+ "trace.server": "verbose",
77
+ "filetypes": ["liquid", "liquid.html"],
78
+ "rootPatterns": [".theme-check.yml", "snippets/*"],
79
+ "settings": {
80
+ "themeCheck": {
81
+ "checkOnSave": true,
82
+ "checkOnEnter": true,
83
+ "checkOnChange": false
84
+ }
85
+ }
86
+ }
87
+ ```
88
+
89
+ ### Confirm Setup
90
+
91
+ * In another terminal from the root of theme check run `tail -f /tmp/theme-check-debug.log` to watch the server logs
92
+ * Restart your IDE, confirm the response for initialize in the logs is pointing to the language server in the `$HOME/bin` directory (the version will be different)
93
+
94
+ ```json
95
+ "serverInfo": {
96
+ "name": "/Users/johndoe/bin/theme-check-language-server",
97
+ "version": "1.10.3"
98
+ }
99
+ ```
100
+
101
+
24
102
  ## Running Tests
25
103
 
26
104
  ```
@@ -123,3 +201,7 @@ chrome /tmp/fg.svg
123
201
  What you'll see is an interactive version of the following image:
124
202
 
125
203
  ![flamegraph](docs/flamegraph.svg)
204
+
205
+ ## Troubleshooting
206
+
207
+ If you run into issues during development, see the [troubleshooting guide](/TROUBLESHOOTING.md)
data/README.md CHANGED
@@ -190,3 +190,7 @@ DeprecateLazysizes:
190
190
  ⚠️ **Note:** Quickfixes only work on a freshly checked file. If any of those configurations are turned off, you will need to rerun theme-check in order to apply quickfixes.
191
191
 
192
192
  In VS Code, these can be set directly in your `settings.json`.
193
+
194
+ ## Contributing
195
+
196
+ For guidance on contributing, refer to this [doc](/CONTRIBUTING)
data/Rakefile CHANGED
@@ -53,6 +53,13 @@ task :prerelease, [:version] do |_t, args|
53
53
  ThemeCheck::Releaser.new.release(args.version)
54
54
  end
55
55
 
56
+ desc("Download theme-liquid-docs")
57
+ task :download_theme_liquid_docs do
58
+ require 'theme_check/shopify_liquid/source_manager'
59
+
60
+ ThemeCheck::ShopifyLiquid::SourceManager.download
61
+ end
62
+
56
63
  desc "Create a new check"
57
64
  task :new_check, [:name] do |_t, args|
58
65
  require "theme_check/string_helpers"
@@ -0,0 +1,65 @@
1
+ # Troubleshooting
2
+
3
+ ## Issues with Language Server
4
+
5
+ ### Language server erroring out on startup
6
+
7
+ The following error can cause language server to crash:
8
+ ```bash
9
+ Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
10
+ /Users/johndoe/.gem/ruby/3.1.2/gems/bundler-2.2.22/lib/bundler/spec_set.rb:91:in `block in materialize': Could not find ruby-prof-0.18.0 in any of the sources (Bundler::GemNotFound)
11
+ ```
12
+
13
+ Confirm the version of theme-check matches the version in the wrapper in `~/bin/theme-language-server`. If it doesn't match the ruby version, run the following from the theme-check directory:
14
+
15
+ ```bash
16
+ chruby 3.1.2 #your `~/bin/theme-language-server` ruby version
17
+ bundle install
18
+ ```
19
+
20
+ ### Language server changes not propogating to your IDE
21
+
22
+ Look at logs for language server and check the response for initialize. If it looks like this, you're pointing to the Shopify CLI and not the language server in the repo:
23
+
24
+ ```json
25
+ "serverInfo": {
26
+ "name": "/opt/homebrew/bin/shopify",
27
+ "version": "1.10.3"
28
+ }
29
+ ```
30
+
31
+ Check the config for your IDE/completion engine and confirm the Shopify CLI path isn't present (this by default overrides theme-check pointing to the repo's language server). If you're using VS Code this would be in your `settings.json`.
32
+
33
+ The response for initialize should look like this:
34
+
35
+ ```json
36
+ "serverInfo": {
37
+ "name": "/Users/johndoe/src/github.com/Shopify/theme-check/bin/theme-check-language-server",
38
+ "version": "1.10.3"
39
+ }
40
+ ```
41
+
42
+ If this isn't an issue, confirm the theme check repo's version of ruby matches the ruby version of your theme. If it doesn't, from the theme-check repo run:
43
+
44
+ ```bash
45
+ chruby 3.1.2 #your theme ruby version
46
+ bundle install
47
+ ```
48
+
49
+ ### Language server sends an `initialize()` request to the client and stops
50
+
51
+ To debug, confirm these steps are included in your local language server startup script:
52
+
53
+ ```bash
54
+ export THEME_CHECK_DEBUG=true
55
+ export THEME_CHECK_DEBUG_LOG_FILE="/tmp/theme-check-debug.log"
56
+ touch "$THEME_CHECK_DEBUG_LOG_FILE"
57
+ ```
58
+
59
+ An example script can be found [here](/CONTRIBUTING.md#run-language-server).
60
+
61
+ Open `/tmp/theme-check-debug.log` in your IDE. Check if there are any exceptions being raised by language server.
62
+
63
+ If there are no exceptions, check if there are any logs that aren't in jsonrpc. The language server and client use stdin and stdout to communicate using jsonrpc. Debugging statements that aren't in a jsonrpc format might trigger unexpected behavior (this includes any logs from language server or echo statements in your language server script).
64
+
65
+
@@ -0,0 +1,60 @@
1
+ [
2
+ {
3
+ "properties": [
4
+ {
5
+ "name": "first",
6
+ "return_type": [
7
+ {
8
+ "type": "generic"
9
+ }
10
+ ],
11
+ "description": "Returns the first item of an array."
12
+ },
13
+ {
14
+ "name": "size",
15
+ "description": "Returns the number of items in an array."
16
+ },
17
+ {
18
+ "name": "last",
19
+ "return_type": [
20
+ {
21
+ "type": "generic"
22
+ }
23
+ ],
24
+ "description": "Returns the last item of an array."
25
+ }
26
+ ],
27
+ "name": "array",
28
+ "description": "Arrays hold lists of variables of any type."
29
+ },
30
+ {
31
+ "properties": [
32
+ {
33
+ "name": "size",
34
+ "description": "Returns the number of characters in a string."
35
+ }
36
+ ],
37
+ "name": "string",
38
+ "description": "Strings are sequences of characters wrapped in single or double quotes."
39
+ },
40
+ {
41
+ "properties": [],
42
+ "name": "number",
43
+ "description": "Numeric values, including floats and integers."
44
+ },
45
+ {
46
+ "properties": [],
47
+ "name": "boolean",
48
+ "description": "A binary value, either true or false."
49
+ },
50
+ {
51
+ "properties": [],
52
+ "name": "nil",
53
+ "description": "An undefined value. Tags or outputs that return nil don't print anything to the page. They are also treated as false."
54
+ },
55
+ {
56
+ "properties": [],
57
+ "name": "empty",
58
+ "description": "An empty object is returned if you try to access an object that is defined, but has no value. For example a page or product that’s been deleted, or a setting with no value. You can compare an object with empty to check whether an object exists before you access any of its attributes."
59
+ }
60
+ ]