slim_lint 0.34.0 → 0.35.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/lib/slim_lint/linter/control_statement_spacing.rb +26 -3
- data/lib/slim_lint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9478570d94e93349a03f9f7a67789f3c0ff356bd8bd95ee7fe5628248eaaab9
|
|
4
|
+
data.tar.gz: 23bc11a5e84b251523397d12bcf0c776d8755373fffbfa7ce183353fe8a86b73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f40d2b1af0278fd5f2ea727f0a7ee39322df8b7c1ddf155ece528ac7f99c8dd8b0284af8d622e05eec9ef229544fd953b1f6a51cea9e11d35c23bba1d7d7c7c3
|
|
7
|
+
data.tar.gz: 6c96c5b859896bf1a3d04fe1ca336cfae1e7c15bbcb89f5a6143d1b952ec3508febab94dd4fa618fbbed98405bbaed941cd6a94bb3c2e2bad3a1bdc04ddb5574
|
|
@@ -11,10 +11,11 @@ module SlimLint
|
|
|
11
11
|
on [:html, :tag, anything, [],
|
|
12
12
|
[:slim, :output, anything, capture(:ruby, anything)]] do |sexp|
|
|
13
13
|
# Fetch original Slim code that contains an element with a control statement.
|
|
14
|
-
|
|
14
|
+
ruby = captures[:ruby]
|
|
15
|
+
line = source_line_for(sexp, /=[=<>]* *#{Regexp.escape(ruby[/[^\n]*/])}/)
|
|
16
|
+
next unless line
|
|
15
17
|
|
|
16
18
|
# Remove any Ruby code, because our regexp below must not match inside Ruby.
|
|
17
|
-
ruby = captures[:ruby]
|
|
18
19
|
line = line.sub(ruby, 'x')
|
|
19
20
|
|
|
20
21
|
next if line =~ /[^ ] ==?<?>? [^ ]/
|
|
@@ -23,11 +24,33 @@ module SlimLint
|
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
on [:slim, :control] do |sexp|
|
|
26
|
-
|
|
27
|
+
ruby = sexp[2]
|
|
28
|
+
line = source_line_for(sexp, /- *#{Regexp.escape(ruby[/[^\n]*/])}/)
|
|
29
|
+
next unless line
|
|
27
30
|
|
|
28
31
|
next if line =~ /^ *- [^ ]/
|
|
29
32
|
|
|
30
33
|
report_lint(sexp, MESSAGE_CONTROL)
|
|
31
34
|
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# Finds the original Slim source line for the given Sexp.
|
|
39
|
+
#
|
|
40
|
+
# Backslash (`\`) and comma (`,`) line continuations in preceding
|
|
41
|
+
# attributes are collapsed by the Slim parser without emitting a newline,
|
|
42
|
+
# which causes the line number reported for subsequent Sexps to be too low
|
|
43
|
+
# (see https://github.com/sds/slim-lint/issues/201). We compensate by
|
|
44
|
+
# searching forward from the reported line for the line that actually
|
|
45
|
+
# contains the statement, falling back to the reported line otherwise.
|
|
46
|
+
#
|
|
47
|
+
# @param sexp [SlimLint::Sexp]
|
|
48
|
+
# @param pattern [Regexp] matches the source line containing the statement
|
|
49
|
+
# @return [String, nil]
|
|
50
|
+
def source_line_for(sexp, pattern)
|
|
51
|
+
index = sexp.line - 1
|
|
52
|
+
lines = document.source_lines[index..] || []
|
|
53
|
+
lines.find { |line| line =~ pattern } || document.source_lines[index]
|
|
54
|
+
end
|
|
32
55
|
end
|
|
33
56
|
end
|
data/lib/slim_lint/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: slim_lint
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.35.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shane da Silva
|
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
182
182
|
- !ruby/object:Gem::Version
|
|
183
183
|
version: '0'
|
|
184
184
|
requirements: []
|
|
185
|
-
rubygems_version:
|
|
185
|
+
rubygems_version: 4.0.10
|
|
186
186
|
specification_version: 4
|
|
187
187
|
summary: Slim template linting tool
|
|
188
188
|
test_files: []
|