slim_lint 0.24.0 → 0.25.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58c99ab50012a0f3475e6518e69bade743b55e6ed5eb4f5dd25a98ea1b7a617e
|
4
|
+
data.tar.gz: 4593348af814f4bce1bd240d4982eec2acd9d4c7bbda5f5ccc231a3a51b8c148
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53ea008e7e03d7261af22c33e098be489096299117b9ec103406382568af8b8b3c10e0a77a3e97e9848c88a57d04d2f5a6b7998b48555d7ea205ceb136f95cdb
|
7
|
+
data.tar.gz: 1e5e98f7d7e6eacc805a85451b8428f2f746b91b5b3433ce5262779d6bd9285b6db00e463c3d1b79912e9b93b677b5f12f0bf0e50613f284b8b482732fc7e552
|
@@ -72,7 +72,7 @@ module SlimLint
|
|
72
72
|
# @param path [String]
|
73
73
|
# @return [String]
|
74
74
|
def normalize_path(path)
|
75
|
-
path.start_with?(".#{File::SEPARATOR}") ? path[2
|
75
|
+
path.start_with?(".#{File::SEPARATOR}") ? path[2..] : path
|
76
76
|
end
|
77
77
|
|
78
78
|
# Whether the given file should be treated as a Slim file.
|
@@ -9,8 +9,14 @@ module SlimLint
|
|
9
9
|
|
10
10
|
on [:html, :tag, anything, [],
|
11
11
|
[:slim, :output, anything, capture(:ruby, anything)]] do |sexp|
|
12
|
-
#
|
13
|
-
|
12
|
+
# Process original slim code so that multi-line attributes become single line.
|
13
|
+
# And store the correction line count
|
14
|
+
source = merge_multiline_attributes(document.source_lines)
|
15
|
+
|
16
|
+
# Fetch processed Slim code that contains an element with a control statement.
|
17
|
+
line = source[sexp.line - 1][:line]
|
18
|
+
# Apply correction to the line count.
|
19
|
+
sexp.line += source[sexp.line - 1][:line_count]
|
14
20
|
|
15
21
|
# Remove any Ruby code, because our regexp below must not match inside Ruby.
|
16
22
|
ruby = captures[:ruby]
|
@@ -20,5 +26,29 @@ module SlimLint
|
|
20
26
|
|
21
27
|
report_lint(sexp, MESSAGE)
|
22
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def merge_multiline_attributes(source_lines)
|
33
|
+
result = []
|
34
|
+
memo = ''
|
35
|
+
correction_line_count = 0
|
36
|
+
|
37
|
+
source_lines.each do |line|
|
38
|
+
memo += line.chomp('\\')
|
39
|
+
|
40
|
+
# Lines ending in a backslash are concatenated with the next line
|
41
|
+
# And count the number of lines to correct the sexp line count.
|
42
|
+
if line.match?(/\\$/)
|
43
|
+
correction_line_count += 1
|
44
|
+
next
|
45
|
+
end
|
46
|
+
|
47
|
+
# Add merged rows and correction line count to the result and reset the memo
|
48
|
+
result << { line: memo, line_count: correction_line_count }
|
49
|
+
memo = ''
|
50
|
+
end
|
51
|
+
result
|
52
|
+
end
|
23
53
|
end
|
24
54
|
end
|
@@ -27,11 +27,9 @@ module SlimLint
|
|
27
27
|
# @return [Array<Class>]
|
28
28
|
def extract_linters_from(linter_names)
|
29
29
|
linter_names.map do |linter_name|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
raise NoSuchLinter, "Linter #{linter_name} does not exist"
|
34
|
-
end
|
30
|
+
SlimLint::Linter.const_get(linter_name)
|
31
|
+
rescue NameError
|
32
|
+
raise NoSuchLinter, "Linter #{linter_name} does not exist"
|
35
33
|
end
|
36
34
|
end
|
37
35
|
end
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slim_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -50,20 +50,6 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '6.0'
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: pry
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0.13'
|
60
|
-
type: :development
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '0.13'
|
67
53
|
- !ruby/object:Gem::Dependency
|
68
54
|
name: rspec
|
69
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,14 +157,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
157
|
requirements:
|
172
158
|
- - ">="
|
173
159
|
- !ruby/object:Gem::Version
|
174
|
-
version:
|
160
|
+
version: '3.0'
|
175
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
162
|
requirements:
|
177
163
|
- - ">="
|
178
164
|
- !ruby/object:Gem::Version
|
179
165
|
version: '0'
|
180
166
|
requirements: []
|
181
|
-
rubygems_version: 3.1
|
167
|
+
rubygems_version: 3.0.3.1
|
182
168
|
signing_key:
|
183
169
|
specification_version: 4
|
184
170
|
summary: Slim template linting tool
|