theme-check 0.3.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/theme-check.yml +10 -3
- data/.rubocop.yml +12 -3
- data/CHANGELOG.md +42 -0
- data/CONTRIBUTING.md +5 -2
- data/Gemfile +5 -3
- data/LICENSE.md +2 -0
- data/README.md +12 -4
- data/RELEASING.md +10 -3
- data/Rakefile +6 -0
- data/config/default.yml +16 -0
- data/data/shopify_liquid/tags.yml +27 -0
- data/data/shopify_translation_keys.yml +850 -0
- data/docs/checks/CHECK_DOCS_TEMPLATE.md +47 -0
- data/docs/checks/asset_size_css.md +52 -0
- data/docs/checks/asset_size_javascript.md +79 -0
- data/docs/checks/convert_include_to_render.md +48 -0
- data/docs/checks/default_locale.md +46 -0
- data/docs/checks/deprecated_filter.md +46 -0
- data/docs/checks/img_width_and_height.md +79 -0
- data/docs/checks/liquid_tag.md +65 -0
- data/docs/checks/matching_schema_translations.md +93 -0
- data/docs/checks/matching_translations.md +72 -0
- data/docs/checks/missing_enable_comment.md +50 -0
- data/docs/checks/missing_required_template_files.md +26 -0
- data/docs/checks/missing_template.md +40 -0
- data/docs/checks/nested_snippet.md +69 -0
- data/docs/checks/parser_blocking_javascript.md +97 -0
- data/docs/checks/remote_asset.md +82 -0
- data/docs/checks/required_directories.md +25 -0
- data/docs/checks/required_layout_theme_object.md +28 -0
- data/docs/checks/space_inside_braces.md +63 -0
- data/docs/checks/syntax_error.md +49 -0
- data/docs/checks/template_length.md +50 -0
- data/docs/checks/translation_key_exists.md +63 -0
- data/docs/checks/undefined_object.md +53 -0
- data/docs/checks/unknown_filter.md +45 -0
- data/docs/checks/unused_assign.md +47 -0
- data/docs/checks/unused_snippet.md +32 -0
- data/docs/checks/valid_html_translation.md +53 -0
- data/docs/checks/valid_json.md +60 -0
- data/docs/checks/valid_schema.md +50 -0
- data/lib/theme_check.rb +4 -0
- data/lib/theme_check/asset_file.rb +34 -0
- data/lib/theme_check/check.rb +20 -10
- data/lib/theme_check/checks/asset_size_css.rb +89 -0
- data/lib/theme_check/checks/asset_size_javascript.rb +68 -0
- data/lib/theme_check/checks/convert_include_to_render.rb +1 -1
- data/lib/theme_check/checks/default_locale.rb +1 -0
- data/lib/theme_check/checks/deprecated_filter.rb +1 -1
- data/lib/theme_check/checks/img_width_and_height.rb +74 -0
- data/lib/theme_check/checks/liquid_tag.rb +3 -3
- data/lib/theme_check/checks/matching_schema_translations.rb +1 -0
- data/lib/theme_check/checks/matching_translations.rb +2 -1
- data/lib/theme_check/checks/missing_enable_comment.rb +1 -0
- data/lib/theme_check/checks/missing_required_template_files.rb +1 -2
- data/lib/theme_check/checks/missing_template.rb +1 -0
- data/lib/theme_check/checks/nested_snippet.rb +1 -0
- data/lib/theme_check/checks/parser_blocking_javascript.rb +8 -15
- data/lib/theme_check/checks/remote_asset.rb +98 -0
- data/lib/theme_check/checks/required_directories.rb +1 -1
- data/lib/theme_check/checks/required_layout_theme_object.rb +1 -1
- data/lib/theme_check/checks/space_inside_braces.rb +1 -0
- data/lib/theme_check/checks/syntax_error.rb +1 -0
- data/lib/theme_check/checks/template_length.rb +1 -0
- data/lib/theme_check/checks/translation_key_exists.rb +14 -1
- data/lib/theme_check/checks/undefined_object.rb +16 -7
- data/lib/theme_check/checks/unknown_filter.rb +1 -0
- data/lib/theme_check/checks/unused_assign.rb +5 -3
- data/lib/theme_check/checks/unused_snippet.rb +1 -0
- data/lib/theme_check/checks/valid_html_translation.rb +2 -1
- data/lib/theme_check/checks/valid_json.rb +1 -0
- data/lib/theme_check/checks/valid_schema.rb +1 -0
- data/lib/theme_check/cli.rb +49 -13
- data/lib/theme_check/config.rb +5 -2
- data/lib/theme_check/disabled_checks.rb +2 -2
- data/lib/theme_check/in_memory_storage.rb +13 -8
- data/lib/theme_check/language_server.rb +12 -0
- data/lib/theme_check/language_server/completion_engine.rb +38 -0
- data/lib/theme_check/language_server/completion_helper.rb +25 -0
- data/lib/theme_check/language_server/completion_provider.rb +28 -0
- data/lib/theme_check/language_server/completion_providers/filter_completion_provider.rb +51 -0
- data/lib/theme_check/language_server/completion_providers/object_completion_provider.rb +31 -0
- data/lib/theme_check/language_server/completion_providers/render_snippet_completion_provider.rb +43 -0
- data/lib/theme_check/language_server/completion_providers/tag_completion_provider.rb +31 -0
- data/lib/theme_check/language_server/constants.rb +10 -0
- data/lib/theme_check/language_server/document_link_engine.rb +48 -0
- data/lib/theme_check/language_server/handler.rb +105 -10
- data/lib/theme_check/language_server/position_helper.rb +27 -0
- data/lib/theme_check/language_server/protocol.rb +41 -0
- data/lib/theme_check/language_server/server.rb +9 -4
- data/lib/theme_check/language_server/tokens.rb +55 -0
- data/lib/theme_check/liquid_check.rb +11 -0
- data/lib/theme_check/node.rb +1 -2
- data/lib/theme_check/offense.rb +52 -15
- data/lib/theme_check/regex_helpers.rb +15 -0
- data/lib/theme_check/releaser.rb +39 -0
- data/lib/theme_check/remote_asset_file.rb +44 -0
- data/lib/theme_check/shopify_liquid.rb +1 -0
- data/lib/theme_check/shopify_liquid/deprecated_filter.rb +10 -8
- data/lib/theme_check/shopify_liquid/filter.rb +3 -5
- data/lib/theme_check/shopify_liquid/object.rb +2 -6
- data/lib/theme_check/shopify_liquid/tag.rb +14 -0
- data/lib/theme_check/storage.rb +3 -3
- data/lib/theme_check/string_helpers.rb +47 -0
- data/lib/theme_check/tags.rb +1 -2
- data/lib/theme_check/theme.rb +7 -1
- data/lib/theme_check/version.rb +1 -1
- data/theme-check.gemspec +1 -2
- metadata +57 -18
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Discourage use of third party domains for hosting assets (`RemoteAsset`)
|
|
2
|
+
|
|
3
|
+
Years ago, loading jQuery from a common CDN was good for performance because the browser cache could be reused across website. This is no longer true because browsers now include the domain from which the request was made in the cache key.
|
|
4
|
+
|
|
5
|
+
Therefore, this technique now makes things worse. Here's why:
|
|
6
|
+
|
|
7
|
+
* **The benefits of HTTP/2 prioritization are lost.** HTTP/2 prioritization is a mechanism used by servers. If different servers are used to deliver assets, there's no way to prioritize.
|
|
8
|
+
* **A new connection dance (DNS, TCP, TLS) must be done to start downloading the resource.** With HTTPS, this takes 5 round trips to achieve. The farther away the buyer is from that domain, the longer it takes.
|
|
9
|
+
* **The [slow start][slowstart] part of the Internet's TCP congestion control strategy must happen on every connection.** This means that the download "acceleration" we commonly observe must be repeated many times over.
|
|
10
|
+
|
|
11
|
+
The fix? Deliver as much as you can from a small number of connections. In a Shopify context, this is done by leveraging the `assets/` folder and the [URL filters][url_filters].
|
|
12
|
+
|
|
13
|
+
## Check Details
|
|
14
|
+
|
|
15
|
+
This check is aimed at eliminating unnecessary HTTP connections.
|
|
16
|
+
|
|
17
|
+
:-1: Examples of **incorrect** code for this check:
|
|
18
|
+
|
|
19
|
+
```liquid
|
|
20
|
+
<!-- Using multiple CDNs -->
|
|
21
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" defer></script>
|
|
22
|
+
{{ "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" | stylesheet_tag }}
|
|
23
|
+
<img src="https://example.com/heart.png" ...>
|
|
24
|
+
|
|
25
|
+
<!-- Missing img_url filter -->
|
|
26
|
+
<img src="{{ image }}" ...>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
In the examples above, multiple connections are competing for resources, are accelerating download independently and are improperly prioritized.
|
|
30
|
+
|
|
31
|
+
:+1: Examples of **correct** code for this check:
|
|
32
|
+
|
|
33
|
+
```liquid
|
|
34
|
+
<!-- Good -->
|
|
35
|
+
<script src="{{ 'jquery.min.js' | asset_url }}" defer></script>
|
|
36
|
+
{{ 'bootstrap.min.css' | asset_url | stylesheet_tag }}
|
|
37
|
+
|
|
38
|
+
<!-- Better -->
|
|
39
|
+
<script src="{{ 'theme.js' | asset_url }}" defer></script>
|
|
40
|
+
{{ 'theme.css' | asset_url | stylesheet_tag }}
|
|
41
|
+
|
|
42
|
+
<!-- Images -->
|
|
43
|
+
<img src="{{ image | img_url }}" ...>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
In the above, the JavaScript, CSS and images are all loading from the same connection. Making it so the browser and CDN can properly prioritize which assets are downloaded first while maintaining a "hot" connection that downloads fast.
|
|
47
|
+
|
|
48
|
+
This can be done by downloading the files from those CDNs directly into your theme's `assets/` folder.
|
|
49
|
+
|
|
50
|
+
Use the [`img_url` filter][img_url] for images.
|
|
51
|
+
|
|
52
|
+
## Check Options
|
|
53
|
+
|
|
54
|
+
The default configuration for this check is the following:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
RemoteAsset:
|
|
58
|
+
enabled: true
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## When Not To Use It
|
|
62
|
+
|
|
63
|
+
When the remote content is highly dynamic.
|
|
64
|
+
|
|
65
|
+
## Version
|
|
66
|
+
|
|
67
|
+
This check has been introduced in Theme Check 0.7.0.
|
|
68
|
+
|
|
69
|
+
## Resources
|
|
70
|
+
|
|
71
|
+
- [Announcement by Google][googleprivacy]
|
|
72
|
+
- [HTTP Cache Partioning Explainer](https://github.com/shivanigithub/http-cache-partitioning)
|
|
73
|
+
- [Slow Start][slowstart]
|
|
74
|
+
- [Rule Source][codesource]
|
|
75
|
+
- [Documentation Source][docsource]
|
|
76
|
+
|
|
77
|
+
[googleprivacy]: https://developers.google.com/web/updates/2020/10/http-cache-partitioning#resources
|
|
78
|
+
[codesource]: /lib/theme_check/checks/remote_asset.rb
|
|
79
|
+
[docsource]: /docs/checks/remote_asset.md
|
|
80
|
+
[slowstart]: https://en.wikipedia.org/wiki/TCP_congestion_control#Slow_start
|
|
81
|
+
[url_filters]: https://shopify.dev/docs/themes/liquid/reference/filters/url-filters
|
|
82
|
+
[img_url]: https://shopify.dev/docs/themes/liquid/reference/filters/url-filters#img_url
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Prevent missing directories (`RequiredDirectories`)
|
|
2
|
+
|
|
3
|
+
This check exists to warn theme developers about missing required directories in their structure.
|
|
4
|
+
|
|
5
|
+
## Check Options
|
|
6
|
+
|
|
7
|
+
The default configuration for this check is the following:
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
RequiredDirectories:
|
|
11
|
+
enabled: true
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Version
|
|
15
|
+
|
|
16
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
17
|
+
|
|
18
|
+
## Resources
|
|
19
|
+
|
|
20
|
+
- [Shopify Theme File Structure](https://shopify.dev/tutorials/develop-theme-files)
|
|
21
|
+
- [Rule Source][codesource]
|
|
22
|
+
- [Documentation Source][docsource]
|
|
23
|
+
|
|
24
|
+
[codesource]: /lib/theme_check/checks/required_directories.rb
|
|
25
|
+
[docsource]: /docs/checks/required_directories.md
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Prevent missing required objects in theme.liquid (`RequiredLayoutThemeObject`)
|
|
2
|
+
|
|
3
|
+
## Check Details
|
|
4
|
+
|
|
5
|
+
This check prevents missing `{{ content_for_header }}` and `{{ content_for_layout }}` objects in `layout/theme.liquid`.
|
|
6
|
+
|
|
7
|
+
## Check Options
|
|
8
|
+
|
|
9
|
+
The default configuration for this check is the following:
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
RequiredLayoutThemeObject:
|
|
13
|
+
enabled: true
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Version
|
|
17
|
+
|
|
18
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
19
|
+
|
|
20
|
+
## Resources
|
|
21
|
+
|
|
22
|
+
- [Shopify theme.liquid requirements][themeliquid]
|
|
23
|
+
- [Rule Source][codesource]
|
|
24
|
+
- [Documentation Source][docsource]
|
|
25
|
+
|
|
26
|
+
[codesource]: /lib/theme_check/checks/required_layout_theme_object.rb
|
|
27
|
+
[docsource]: /docs/checks/required_layout_theme_object.md
|
|
28
|
+
[themeliquid]: https://shopify.dev/docs/themes/theme-templates/theme-liquid
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Ensure consistent spacing inside Liquid tags and variables (`SpaceInsideBraces`)
|
|
2
|
+
|
|
3
|
+
Warns against inconsistent spacing inside liquid tags and variables.
|
|
4
|
+
|
|
5
|
+
## Check Details
|
|
6
|
+
|
|
7
|
+
This check is aimed at eliminating ugly Liquid:
|
|
8
|
+
|
|
9
|
+
:-1: Examples of **incorrect** code for this check:
|
|
10
|
+
|
|
11
|
+
```liquid
|
|
12
|
+
<!-- Around braces -->
|
|
13
|
+
{% assign x = 1%}
|
|
14
|
+
{{ x}}
|
|
15
|
+
{{x }}
|
|
16
|
+
|
|
17
|
+
<!-- After commas and semicolons -->
|
|
18
|
+
{% form 'type', object, key:value %}
|
|
19
|
+
{% endform %}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
:+1: Examples of **correct** code for this check:
|
|
23
|
+
|
|
24
|
+
```liquid
|
|
25
|
+
{% assign x = 1 %}
|
|
26
|
+
{{ x }}
|
|
27
|
+
{% form 'type', object, key: value, key2: value %}
|
|
28
|
+
{% endform %}
|
|
29
|
+
{{ "ignore:stuff, indeed" }}
|
|
30
|
+
{% render 'product-card',
|
|
31
|
+
product_card_product: product_recommendation,
|
|
32
|
+
show_vendor: section.settings.show_vendor,
|
|
33
|
+
media_size: section.settings.product_recommendations_image_ratio,
|
|
34
|
+
center_align_text: section.settings.center_align_text
|
|
35
|
+
%}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Check Options
|
|
39
|
+
|
|
40
|
+
The default configuration for this check is the following:
|
|
41
|
+
|
|
42
|
+
```yaml
|
|
43
|
+
SpaceInsideBraces:
|
|
44
|
+
enabled: true
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## When Not To Use It
|
|
48
|
+
|
|
49
|
+
If you don't care about the look of your code.
|
|
50
|
+
|
|
51
|
+
## Version
|
|
52
|
+
|
|
53
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
54
|
+
|
|
55
|
+
## Resources
|
|
56
|
+
|
|
57
|
+
- [Liquid Style Guide][styleguide]
|
|
58
|
+
- [Rule Source][codesource]
|
|
59
|
+
- [Documentation Source][docsource]
|
|
60
|
+
|
|
61
|
+
[styleguide]: https://github.com/Shopify/liquid-style-guide
|
|
62
|
+
[codesource]: /lib/theme_check/checks/space_inside_braces.rb
|
|
63
|
+
[docsource]: /docs/checks/space_inside_braces.md
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Prevent Syntax Errors (`SyntaxError`)
|
|
2
|
+
|
|
3
|
+
This check exists to inform the user of Liquid syntax error earlier.
|
|
4
|
+
|
|
5
|
+
## Check Details
|
|
6
|
+
|
|
7
|
+
This check is aimed at eliminating syntax errors.
|
|
8
|
+
|
|
9
|
+
:-1: Examples of **incorrect** code for this check:
|
|
10
|
+
|
|
11
|
+
```liquid
|
|
12
|
+
{% include 'muffin'
|
|
13
|
+
{% assign foo = 1 }}
|
|
14
|
+
{% unknown %}
|
|
15
|
+
{% if collection | size > 0 %}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
:+1: Examples of **correct** code for this check:
|
|
19
|
+
|
|
20
|
+
```liquid
|
|
21
|
+
{% include 'muffin' %}
|
|
22
|
+
{% assign foo = 1 %}
|
|
23
|
+
{% if collection.size > 0 %}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Check Options
|
|
27
|
+
|
|
28
|
+
The default configuration for this check is the following:
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
SyntaxError:
|
|
32
|
+
enabled: true
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## When Not To Use It
|
|
36
|
+
|
|
37
|
+
It is not safe to disable this rule.
|
|
38
|
+
|
|
39
|
+
## Version
|
|
40
|
+
|
|
41
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
42
|
+
|
|
43
|
+
## Resources
|
|
44
|
+
|
|
45
|
+
- [Rule Source][codesource]
|
|
46
|
+
- [Documentation Source][docsource]
|
|
47
|
+
|
|
48
|
+
[codesource]: /lib/theme_check/checks/syntax_error.rb
|
|
49
|
+
[docsource]: /docs/checks/syntax_error.md
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Discourage the use of large template files (`TemplateLength`)
|
|
2
|
+
|
|
3
|
+
This check exists to discourage the use of large template files. Use snippets to componentize your theme.
|
|
4
|
+
|
|
5
|
+
## Check Details
|
|
6
|
+
|
|
7
|
+
This check is aimed at eliminating large template files.
|
|
8
|
+
|
|
9
|
+
:-1: Examples of **incorrect** code for this check:
|
|
10
|
+
|
|
11
|
+
- Files that have more lines than the threshold
|
|
12
|
+
|
|
13
|
+
:+1: Examples of **correct** code for this check:
|
|
14
|
+
|
|
15
|
+
- Files that have less lines than the threshold
|
|
16
|
+
|
|
17
|
+
## Check Options
|
|
18
|
+
|
|
19
|
+
The default configuration for this check is the following:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
TemplateLength:
|
|
23
|
+
enabled: true
|
|
24
|
+
max_length: 200
|
|
25
|
+
exclude_schema: true
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### `max_length`
|
|
29
|
+
|
|
30
|
+
The `max_length` (Default: `200`) option determines the maximum number of lines allowed inside a liquid file.
|
|
31
|
+
|
|
32
|
+
### `exclude_schema`
|
|
33
|
+
|
|
34
|
+
The `exclude_schema` (Default: `true`) option determines if the schema lines from a template should be excluded from the line count.
|
|
35
|
+
|
|
36
|
+
## When Not To Use It
|
|
37
|
+
|
|
38
|
+
If you don't care about template lengths, then it's safe to disable this rule.
|
|
39
|
+
|
|
40
|
+
## Version
|
|
41
|
+
|
|
42
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
43
|
+
|
|
44
|
+
## Resources
|
|
45
|
+
|
|
46
|
+
- [Rule Source][codesource]
|
|
47
|
+
- [Documentation Source][docsource]
|
|
48
|
+
|
|
49
|
+
[codesource]: /lib/theme_check/checks/template_length.rb
|
|
50
|
+
[docsource]: /docs/checks/template_length.md
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Prevent use of undefined translations (`TranslationKeyExists`)
|
|
2
|
+
|
|
3
|
+
This check exists to prevent translation errors in themes.
|
|
4
|
+
|
|
5
|
+
## Check Details
|
|
6
|
+
|
|
7
|
+
This check is aimed at eliminating the use of translations that do not exist.
|
|
8
|
+
|
|
9
|
+
:-1: Examples of **incorrect** code for this check:
|
|
10
|
+
|
|
11
|
+
```liquid
|
|
12
|
+
{% comment %}locales/en.default.json{% endcomment %}
|
|
13
|
+
{
|
|
14
|
+
"greetings": "Hello, world!",
|
|
15
|
+
"general": {
|
|
16
|
+
"close": "Close"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
{% comment %}templates/index.liquid{% endcomment %}
|
|
21
|
+
{{ "notfound" | t }}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
:+1: Examples of **correct** code for this check:
|
|
25
|
+
|
|
26
|
+
```liquid
|
|
27
|
+
{% comment %}locales/en.default.json{% endcomment %}
|
|
28
|
+
{
|
|
29
|
+
"greetings": "Hello, world!",
|
|
30
|
+
"general": {
|
|
31
|
+
"close": "Close"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
{% comment %}templates/index.liquid{% endcomment %}
|
|
36
|
+
{{ "greetings" | t }}
|
|
37
|
+
{{ "general.close" | t }}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Check Options
|
|
41
|
+
|
|
42
|
+
The default configuration for this check is the following:
|
|
43
|
+
|
|
44
|
+
```yaml
|
|
45
|
+
TranslationKeyExists:
|
|
46
|
+
enabled: true
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## When Not To Use It
|
|
50
|
+
|
|
51
|
+
It is not safe to disable this check.
|
|
52
|
+
|
|
53
|
+
## Version
|
|
54
|
+
|
|
55
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
56
|
+
|
|
57
|
+
## Resources
|
|
58
|
+
|
|
59
|
+
- [Rule Source][codesource]
|
|
60
|
+
- [Documentation Source][docsource]
|
|
61
|
+
|
|
62
|
+
[codesource]: /lib/theme_check/checks/translation_key_exists.rb
|
|
63
|
+
[docsource]: /docs/checks/translation_key_exists.md
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Prevent undefined object errors (`UndefinedObject`)
|
|
2
|
+
|
|
3
|
+
This check prevents errors by making sure that no undefined variables are being used
|
|
4
|
+
|
|
5
|
+
## Check Details
|
|
6
|
+
|
|
7
|
+
This check is aimed at eliminating undefined object errors.
|
|
8
|
+
|
|
9
|
+
:-1: Examples of **incorrect** code for this check:
|
|
10
|
+
|
|
11
|
+
```liquid
|
|
12
|
+
{% assign greetings = "Hello" %}
|
|
13
|
+
{% if greeting == "Hello" %}
|
|
14
|
+
|
|
15
|
+
{{ articl }}
|
|
16
|
+
{{ prodcut }}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
:+1: Examples of **correct** code for this check:
|
|
20
|
+
|
|
21
|
+
```liquid
|
|
22
|
+
{% assign greetings = "Hello" %}
|
|
23
|
+
{% if greetings == "Hello" %}
|
|
24
|
+
|
|
25
|
+
{{ article }}
|
|
26
|
+
{{ product }}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Check Options
|
|
30
|
+
|
|
31
|
+
The default configuration for this check is the following:
|
|
32
|
+
|
|
33
|
+
```yaml
|
|
34
|
+
UndefinedObject:
|
|
35
|
+
enabled: true
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## When Not To Use It
|
|
39
|
+
|
|
40
|
+
It is discouraged to disable this rule.
|
|
41
|
+
|
|
42
|
+
## Version
|
|
43
|
+
|
|
44
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
45
|
+
|
|
46
|
+
## Resources
|
|
47
|
+
|
|
48
|
+
- [Shopify Object Reference](https://shopify.dev/docs/themes/liquid/reference/objects)
|
|
49
|
+
- [Rule Source][codesource]
|
|
50
|
+
- [Documentation Source][docsource]
|
|
51
|
+
|
|
52
|
+
[codesource]: /lib/theme_check/checks/undefined_object.rb
|
|
53
|
+
[docsource]: /docs/checks/undefined_object.md
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Prevent use of unknown filters (`UnknownFilter`)
|
|
2
|
+
|
|
3
|
+
This check exists to prevent user errors.
|
|
4
|
+
|
|
5
|
+
## Check Details
|
|
6
|
+
|
|
7
|
+
This check is aimed at preventing the use of unknown filters.
|
|
8
|
+
|
|
9
|
+
:-1: Examples of **incorrect** code for this check:
|
|
10
|
+
|
|
11
|
+
```liquid
|
|
12
|
+
{{ x | some_unknown_filter }}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
:+1: Examples of **correct** code for this check:
|
|
16
|
+
|
|
17
|
+
```liquid
|
|
18
|
+
{{ x | upcase }}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Check Options
|
|
22
|
+
|
|
23
|
+
The default configuration for this check is the following:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
UnknownFilter:
|
|
27
|
+
enabled: true
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## When Not To Use It
|
|
31
|
+
|
|
32
|
+
It is not safe to disable this rule.
|
|
33
|
+
|
|
34
|
+
## Version
|
|
35
|
+
|
|
36
|
+
This check has been introduced in Theme Check 0.1.0.
|
|
37
|
+
|
|
38
|
+
## Resources
|
|
39
|
+
|
|
40
|
+
- [Shopify Filter Reference](https://shopify.dev/docs/themes/liquid/reference/filters)
|
|
41
|
+
- [Rule Source][codesource]
|
|
42
|
+
- [Documentation Source][docsource]
|
|
43
|
+
|
|
44
|
+
[codesource]: /lib/theme_check/checks/unknown_filter.rb
|
|
45
|
+
[docsource]: /docs/checks/unknown_filter.md
|