This repository was archived by the owner on Jul 27, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,32 +115,31 @@ See [config/default.yml](config/default.yml) for available options & defaults.
115115Use Liquid comments to disable and re-enable all checks for a section of your template:
116116
117117` ` ` liquid
118- {% comment %} theme-check-disable{% endcomment %}
118+ {% # theme-check-disable %}
119119{% assign x = 1 %}
120- {% comment %} theme-check-enable{% endcomment %}
120+ {% # theme-check-enable %}
121121```
122122
123123Disable a specific check by including it in the comment:
124124
125125``` liquid
126- {% comment %} theme-check-disable UnusedAssign{% endcomment %}
126+ {% # theme-check-disable UnusedAssign %}
127127{% assign x = 1 %}
128- {% comment %} theme-check-enable UnusedAssign{% endcomment %}
128+ {% # theme-check-enable UnusedAssign %}
129129```
130130
131131Disable multiple checks by including them as a comma-separated list:
132132
133133``` liquid
134- {% comment %} theme-check-disable UnusedAssign,SpaceInsideBraces{% endcomment %}
134+ {% # theme-check-disable UnusedAssign,SpaceInsideBraces %}
135135{%assign x = 1%}
136- {% comment %} theme-check-enable UnusedAssign,SpaceInsideBraces{% endcomment %}
136+ {% # theme-check-enable UnusedAssign,SpaceInsideBraces %}
137137```
138138
139139Disable checks for the _ entire document_ by placing the comment on the first line:
140140
141141``` liquid
142- {% comment %}theme-check-disable SpaceInsideBraces{% endcomment %}
143-
142+ {% # theme-check-disable SpaceInsideBraces %}
144143{%assign x = 1%}
145144```
146145
Original file line number Diff line number Diff line change @@ -57,9 +57,9 @@ This includes theme and remote scripts.
5757When you can't do anything about it, it is preferable to disable this rule using the comment syntax :
5858
5959` ` `
60- {% comment %} theme-check-disable AssetSizeJavaScript{% endcomment %}
60+ {% # theme-check-disable AssetSizeJavaScript %}
6161<script src="https://code.jquery.com/jquery-3.6.0.min.js" defer></script>
62- {% comment %} theme-check-enable AssetSizeJavaScript{% endcomment %}
62+ {% # theme-check-enable AssetSizeJavaScript %}
6363` ` `
6464
6565This makes disabling the rule an explicit affair and shows that the code is smelly.
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ This check aims at eliminating missing `theme-check-enable` comments.
1212<!doctype html>
1313<html>
1414 <head>
15- {% comment %} theme-check-disable ParserBlockingJavaScript{% endcomment %}
15+ {% # theme-check-disable ParserBlockingJavaScript %}
1616 <script src="https://cdnjs.com/jquery.min.js"></script>
1717 </head>
1818 <body>
@@ -27,9 +27,9 @@ This check aims at eliminating missing `theme-check-enable` comments.
2727<!doctype html>
2828<html>
2929 <head>
30- {% comment %} theme-check-disable ParserBlockingJavaScript{% endcomment %}
30+ {% # theme-check-disable ParserBlockingJavaScript %}
3131 <script src="https://cdnjs.com/jquery.min.js"></script>
32- {% comment %} theme-check-enable ParserBlockingJavaScript{% endcomment %}
32+ {% # theme-check-enable ParserBlockingJavaScript %}
3333 </head>
3434 <body>
3535 <!-- ... -->
Original file line number Diff line number Diff line change @@ -9,32 +9,32 @@ This check is aimed at eliminating excessive nesting of snippets.
99:-1 : Examples of ** incorrect** code for this check:
1010
1111``` liquid
12- {% comment %} templates/index.liquid{% endcomment %}
12+ {% # templates/index.liquid %}
1313 {% render 'one' %}
1414
15- {% comment %} snippets/one.liquid{% endcomment %}
15+ {% # snippets/one.liquid %}
1616 {% render 'two' %}
1717
18- {% comment %} snippets/two.liquid{% endcomment %}
18+ {% # snippets/two.liquid %}
1919 {% render 'three' %}
2020
21- {% comment %} snippets/three.liquid{% endcomment %}
21+ {% # snippets/three.liquid %}
2222 {% render 'four' %}
2323
24- {% comment %} snippets/four.liquid{% endcomment %}
24+ {% # snippets/four.liquid %}
2525 ok
2626```
2727
2828:+1 : Examples of ** correct** code for this check:
2929
3030``` liquid
31- {% comment %} templates/index.liquid{% endcomment %}
31+ {% # templates/index.liquid %}
3232 {% render 'one' %}
3333
34- {% comment %} snippets/one.liquid{% endcomment %}
34+ {% # snippets/one.liquid %}
3535 {% render 'two' %}
3636
37- {% comment %} snippets/two.liquid{% endcomment %}
37+ {% # snippets/two.liquid %}
3838 ok
3939```
4040
Original file line number Diff line number Diff line change @@ -9,30 +9,30 @@ This check is aimed at eliminating the use of translations that do not exist.
99:-1 : Examples of ** incorrect** code for this check:
1010
1111``` liquid
12- {% comment %} locales/en.default.json{% endcomment %}
12+ {% # locales/en.default.json %}
1313{
1414 "greetings": "Hello, world!",
1515 "general": {
1616 "close": "Close"
1717 }
1818}
1919
20- {% comment %} templates/index.liquid{% endcomment %}
20+ {% # templates/index.liquid %}
2121{{ "notfound" | t }}
2222```
2323
2424:+1 : Examples of ** correct** code for this check:
2525
2626``` liquid
27- {% comment %} locales/en.default.json{% endcomment %}
27+ {% # locales/en.default.json %}
2828{
2929 "greetings": "Hello, world!",
3030 "general": {
3131 "close": "Close"
3232 }
3333}
3434
35- {% comment %} templates/index.liquid{% endcomment %}
35+ {% # templates/index.liquid %}
3636{{ "greetings" | t }}
3737{{ "general.close" | t }}
3838```
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ This check is aimed at eliminating invalid HTML in translations.
1818:+1 : Examples of ** correct** code for this check:
1919
2020``` liquid
21- {% comment %} locales/en.default.json{% endcomment %}
21+ {% # locales/en.default.json %}
2222{
2323 "hello_html": "<h1>Hello, world</h1>",
2424 "image_html": "<img src='spongebob.png'>",
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ def on_comment(node)
1616 @disabled_checks . update ( node )
1717 end
1818
19+ def on_inline_comment ( node )
20+ @disabled_checks . update ( node )
21+ end
22+
1923 def after_document ( node )
2024 checks_missing_end_index = @disabled_checks . checks_missing_end_index
2125 return if checks_missing_end_index . empty?
Original file line number Diff line number Diff line change @@ -67,7 +67,12 @@ def remove_disabled_offenses(checks)
6767 private
6868
6969 def comment_text ( node )
70- node . value . nodelist . join
70+ case node . type_name
71+ when :comment
72+ node . value . nodelist . join
73+ when :inline_comment
74+ node . markup . sub ( /\s *#+\s */ , '' )
75+ end
7176 end
7277
7378 def start_disabling? ( text )
Original file line number Diff line number Diff line change @@ -158,6 +158,11 @@ def comment?
158158 @value . is_a? ( Liquid ::Comment )
159159 end
160160
161+ # {% # comment %}
162+ def inline_comment?
163+ @value . is_a? ( Liquid ::InlineComment )
164+ end
165+
161166 # Top level node of every liquid_file.
162167 def document?
163168 @value . is_a? ( Liquid ::Document )
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def visit(node)
2828 call_checks ( :after_node , node )
2929 end
3030
31- @disabled_checks . update ( node ) if node . comment?
31+ @disabled_checks . update ( node ) if node . comment? || node . inline_comment?
3232 end
3333
3434 def call_checks ( method , *args )
You can’t perform that action at this time.
0 commit comments