theme-check 0.2.2 → 0.4.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/.rubocop.yml +1 -0
- data/CHANGELOG.md +40 -0
- data/CONTRIBUTING.md +2 -0
- data/README.md +45 -4
- data/RELEASING.md +41 -0
- data/Rakefile +24 -4
- data/config/default.yml +16 -0
- data/data/shopify_liquid/plus_objects.yml +15 -0
- data/data/shopify_liquid/tags.yml +26 -0
- data/dev.yml +2 -0
- data/lib/theme_check.rb +5 -0
- data/lib/theme_check/analyzer.rb +0 -6
- data/lib/theme_check/check.rb +11 -0
- data/lib/theme_check/checks.rb +10 -0
- data/lib/theme_check/checks/missing_enable_comment.rb +31 -0
- data/lib/theme_check/checks/parser_blocking_javascript.rb +55 -0
- data/lib/theme_check/checks/space_inside_braces.rb +1 -0
- data/lib/theme_check/checks/template_length.rb +11 -3
- data/lib/theme_check/checks/undefined_object.rb +27 -6
- data/lib/theme_check/checks/unused_assign.rb +4 -3
- data/lib/theme_check/checks/valid_html_translation.rb +2 -2
- data/lib/theme_check/cli.rb +31 -7
- data/lib/theme_check/config.rb +95 -43
- data/lib/theme_check/corrector.rb +0 -4
- data/lib/theme_check/disabled_checks.rb +77 -0
- data/lib/theme_check/file_system_storage.rb +51 -0
- data/lib/theme_check/in_memory_storage.rb +37 -0
- data/lib/theme_check/json_file.rb +12 -10
- data/lib/theme_check/language_server.rb +10 -0
- data/lib/theme_check/language_server/completion_engine.rb +38 -0
- data/lib/theme_check/language_server/completion_helper.rb +35 -0
- data/lib/theme_check/language_server/completion_provider.rb +23 -0
- data/lib/theme_check/language_server/completion_providers/filter_completion_provider.rb +47 -0
- data/lib/theme_check/language_server/completion_providers/object_completion_provider.rb +31 -0
- data/lib/theme_check/language_server/completion_providers/tag_completion_provider.rb +31 -0
- data/lib/theme_check/language_server/handler.rb +74 -13
- 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 +2 -2
- data/lib/theme_check/language_server/tokens.rb +55 -0
- data/lib/theme_check/offense.rb +51 -14
- data/lib/theme_check/shopify_liquid.rb +1 -0
- data/lib/theme_check/shopify_liquid/object.rb +6 -0
- data/lib/theme_check/shopify_liquid/tag.rb +16 -0
- data/lib/theme_check/storage.rb +25 -0
- data/lib/theme_check/template.rb +26 -21
- data/lib/theme_check/theme.rb +14 -9
- data/lib/theme_check/version.rb +1 -1
- data/lib/theme_check/visitor.rb +14 -3
- data/packaging/homebrew/theme_check.base.rb +10 -6
- metadata +22 -2
data/lib/theme_check/template.rb
CHANGED
@@ -3,16 +3,29 @@ require "pathname"
|
|
3
3
|
|
4
4
|
module ThemeCheck
|
5
5
|
class Template
|
6
|
-
|
6
|
+
def initialize(relative_path, storage)
|
7
|
+
@storage = storage
|
8
|
+
@relative_path = relative_path
|
9
|
+
end
|
7
10
|
|
8
|
-
def
|
9
|
-
@path
|
10
|
-
@root = Pathname(root)
|
11
|
-
@updated = false
|
11
|
+
def path
|
12
|
+
@storage.path(@relative_path)
|
12
13
|
end
|
13
14
|
|
14
15
|
def relative_path
|
15
|
-
@
|
16
|
+
@relative_pathname ||= Pathname.new(@relative_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def source
|
20
|
+
@source ||= @storage.read(@relative_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def write
|
24
|
+
content = updated_content
|
25
|
+
if source != content
|
26
|
+
@storage.write(@relative_path, content)
|
27
|
+
@source = content
|
28
|
+
end
|
16
29
|
end
|
17
30
|
|
18
31
|
def name
|
@@ -31,15 +44,17 @@ module ThemeCheck
|
|
31
44
|
name.start_with?('snippets')
|
32
45
|
end
|
33
46
|
|
34
|
-
def source
|
35
|
-
@source ||= @path.read
|
36
|
-
end
|
37
|
-
|
38
47
|
def lines
|
39
48
|
# Retain trailing newline character
|
40
49
|
@lines ||= source.split("\n", -1)
|
41
50
|
end
|
42
51
|
|
52
|
+
# Not entirely obvious but lines is mutable, corrections are to be
|
53
|
+
# applied on @lines.
|
54
|
+
def updated_content
|
55
|
+
lines.join("\n")
|
56
|
+
end
|
57
|
+
|
43
58
|
def excerpt(line)
|
44
59
|
lines[line - 1].strip
|
45
60
|
end
|
@@ -65,18 +80,8 @@ module ThemeCheck
|
|
65
80
|
parse.root
|
66
81
|
end
|
67
82
|
|
68
|
-
def update!
|
69
|
-
@updated = true
|
70
|
-
end
|
71
|
-
|
72
|
-
def write
|
73
|
-
if @updated
|
74
|
-
@path.write(lines.join("\n"))
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
83
|
def ==(other)
|
79
|
-
other.is_a?(Template) &&
|
84
|
+
other.is_a?(Template) && relative_path == other.relative_path
|
80
85
|
end
|
81
86
|
|
82
87
|
def self.parse(source)
|
data/lib/theme_check/theme.rb
CHANGED
@@ -4,18 +4,27 @@ require "pathname"
|
|
4
4
|
module ThemeCheck
|
5
5
|
class Theme
|
6
6
|
DEFAULT_LOCALE_REGEXP = %r{^locales/(.*)\.default$}
|
7
|
-
|
7
|
+
LIQUID_REGEX = /\.liquid$/i
|
8
|
+
JSON_REGEX = /\.json$/i
|
8
9
|
|
9
|
-
def initialize(
|
10
|
-
@
|
10
|
+
def initialize(storage)
|
11
|
+
@storage = storage
|
11
12
|
end
|
12
13
|
|
13
14
|
def liquid
|
14
|
-
@liquid ||= @
|
15
|
+
@liquid ||= @storage.files
|
16
|
+
.select { |path| LIQUID_REGEX.match?(path) }
|
17
|
+
.map { |path| Template.new(path, @storage) }
|
15
18
|
end
|
16
19
|
|
17
20
|
def json
|
18
|
-
@json ||= @
|
21
|
+
@json ||= @storage.files
|
22
|
+
.select { |path| JSON_REGEX.match?(path) }
|
23
|
+
.map { |path| JsonFile.new(path, @storage) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def directories
|
27
|
+
@storage.directories
|
19
28
|
end
|
20
29
|
|
21
30
|
def default_locale_json
|
@@ -52,9 +61,5 @@ module ThemeCheck
|
|
52
61
|
def snippets
|
53
62
|
liquid.select(&:snippet?)
|
54
63
|
end
|
55
|
-
|
56
|
-
def directories
|
57
|
-
@directories ||= @root.glob('*').select { |f| File.directory?(f) }.map { |f| f.relative_path_from(@root) }
|
58
|
-
end
|
59
64
|
end
|
60
65
|
end
|
data/lib/theme_check/version.rb
CHANGED
data/lib/theme_check/visitor.rb
CHANGED
@@ -6,12 +6,15 @@ module ThemeCheck
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def visit_template(template)
|
9
|
+
@disabled_checks = DisabledChecks.new
|
9
10
|
visit(Node.new(template.root, nil, template))
|
10
11
|
rescue Liquid::Error => exception
|
11
12
|
exception.template_name = template.name
|
12
13
|
call_checks(:on_error, exception)
|
13
14
|
end
|
14
15
|
|
16
|
+
private
|
17
|
+
|
15
18
|
def visit(node)
|
16
19
|
call_checks(:on_node, node)
|
17
20
|
call_checks(:on_tag, node) if node.tag?
|
@@ -22,16 +25,24 @@ module ThemeCheck
|
|
22
25
|
call_checks(:after_tag, node) if node.tag?
|
23
26
|
call_checks(:after_node, node)
|
24
27
|
end
|
25
|
-
end
|
26
28
|
|
27
|
-
|
29
|
+
@disabled_checks.update(node) if node.comment?
|
30
|
+
end
|
28
31
|
|
29
32
|
def visit_children(node)
|
30
33
|
node.children.each { |child| visit(child) }
|
31
34
|
end
|
32
35
|
|
33
36
|
def call_checks(method, *args)
|
34
|
-
|
37
|
+
checks.call(method, *args)
|
38
|
+
end
|
39
|
+
|
40
|
+
def checks
|
41
|
+
return @checks unless @disabled_checks.any?
|
42
|
+
|
43
|
+
return @checks.always_enabled if @disabled_checks.all_disabled?
|
44
|
+
|
45
|
+
@checks.except_for(@disabled_checks)
|
35
46
|
end
|
36
47
|
end
|
37
48
|
end
|
@@ -61,12 +61,16 @@ class ThemeCheck < Formula
|
|
61
61
|
ENV['PATH'] = ENV['PATH'].sub(HOMEBREW_SHIMS_PATH.to_s, '/usr/local/bin')
|
62
62
|
end
|
63
63
|
|
64
|
-
system(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
system(
|
65
|
+
"#{ruby_bin}/gem",
|
66
|
+
"install",
|
67
|
+
cached_download,
|
68
|
+
"--no-document",
|
69
|
+
"--no-wrapper",
|
70
|
+
"--no-user-install",
|
71
|
+
"--install-dir", prefix,
|
72
|
+
"--bindir", bin
|
73
|
+
)
|
70
74
|
|
71
75
|
raise "gem install 'theme-check' failed with status #{$CHILD_STATUS.exitstatus}" unless $CHILD_STATUS.success?
|
72
76
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: theme-check
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc-André Cournoyer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -65,18 +65,22 @@ files:
|
|
65
65
|
- ".github/workflows/theme-check.yml"
|
66
66
|
- ".gitignore"
|
67
67
|
- ".rubocop.yml"
|
68
|
+
- CHANGELOG.md
|
68
69
|
- CODE_OF_CONDUCT.md
|
69
70
|
- CONTRIBUTING.md
|
70
71
|
- Gemfile
|
71
72
|
- Guardfile
|
72
73
|
- LICENSE.md
|
73
74
|
- README.md
|
75
|
+
- RELEASING.md
|
74
76
|
- Rakefile
|
75
77
|
- bin/liquid-server
|
76
78
|
- config/default.yml
|
77
79
|
- data/shopify_liquid/deprecated_filters.yml
|
78
80
|
- data/shopify_liquid/filters.yml
|
79
81
|
- data/shopify_liquid/objects.yml
|
82
|
+
- data/shopify_liquid/plus_objects.yml
|
83
|
+
- data/shopify_liquid/tags.yml
|
80
84
|
- dev.yml
|
81
85
|
- docs/preview.png
|
82
86
|
- exe/theme-check
|
@@ -91,9 +95,11 @@ files:
|
|
91
95
|
- lib/theme_check/checks/liquid_tag.rb
|
92
96
|
- lib/theme_check/checks/matching_schema_translations.rb
|
93
97
|
- lib/theme_check/checks/matching_translations.rb
|
98
|
+
- lib/theme_check/checks/missing_enable_comment.rb
|
94
99
|
- lib/theme_check/checks/missing_required_template_files.rb
|
95
100
|
- lib/theme_check/checks/missing_template.rb
|
96
101
|
- lib/theme_check/checks/nested_snippet.rb
|
102
|
+
- lib/theme_check/checks/parser_blocking_javascript.rb
|
97
103
|
- lib/theme_check/checks/required_directories.rb
|
98
104
|
- lib/theme_check/checks/required_layout_theme_object.rb
|
99
105
|
- lib/theme_check/checks/space_inside_braces.rb
|
@@ -111,12 +117,24 @@ files:
|
|
111
117
|
- lib/theme_check/cli.rb
|
112
118
|
- lib/theme_check/config.rb
|
113
119
|
- lib/theme_check/corrector.rb
|
120
|
+
- lib/theme_check/disabled_checks.rb
|
121
|
+
- lib/theme_check/file_system_storage.rb
|
122
|
+
- lib/theme_check/in_memory_storage.rb
|
114
123
|
- lib/theme_check/json_check.rb
|
115
124
|
- lib/theme_check/json_file.rb
|
116
125
|
- lib/theme_check/json_helpers.rb
|
117
126
|
- lib/theme_check/language_server.rb
|
127
|
+
- lib/theme_check/language_server/completion_engine.rb
|
128
|
+
- lib/theme_check/language_server/completion_helper.rb
|
129
|
+
- lib/theme_check/language_server/completion_provider.rb
|
130
|
+
- lib/theme_check/language_server/completion_providers/filter_completion_provider.rb
|
131
|
+
- lib/theme_check/language_server/completion_providers/object_completion_provider.rb
|
132
|
+
- lib/theme_check/language_server/completion_providers/tag_completion_provider.rb
|
118
133
|
- lib/theme_check/language_server/handler.rb
|
134
|
+
- lib/theme_check/language_server/position_helper.rb
|
135
|
+
- lib/theme_check/language_server/protocol.rb
|
119
136
|
- lib/theme_check/language_server/server.rb
|
137
|
+
- lib/theme_check/language_server/tokens.rb
|
120
138
|
- lib/theme_check/liquid_check.rb
|
121
139
|
- lib/theme_check/locale_diff.rb
|
122
140
|
- lib/theme_check/node.rb
|
@@ -128,6 +146,8 @@ files:
|
|
128
146
|
- lib/theme_check/shopify_liquid/deprecated_filter.rb
|
129
147
|
- lib/theme_check/shopify_liquid/filter.rb
|
130
148
|
- lib/theme_check/shopify_liquid/object.rb
|
149
|
+
- lib/theme_check/shopify_liquid/tag.rb
|
150
|
+
- lib/theme_check/storage.rb
|
131
151
|
- lib/theme_check/tags.rb
|
132
152
|
- lib/theme_check/template.rb
|
133
153
|
- lib/theme_check/theme.rb
|