haml_lint 0.18.3 → 0.18.4
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/haml_lint/linter/classes_before_ids.rb +24 -12
- data/lib/haml_lint/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a141a32ca4f42038548109417fc4ce7e48cb04e5
|
4
|
+
data.tar.gz: 3cd8985abe66dd3164e0f61a76f55abddf2b3f54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d2b851b17f04696979385e41f8a8b9c699cbe7db29bd497e130d64f465c54cc29945126a53eec6d4dc5e99f5b96e89bf623b597ae02294a5af62d0b1021827
|
7
|
+
data.tar.gz: 389f9c938a65d66368de138aa56cc1a63eb26e70da3e97463f0f3a890aa9a59e3964e51dfc80d3c032ca5130b76541b2ee5247078841df15251c5015d61aa7b9
|
@@ -9,18 +9,20 @@ module HamlLint
|
|
9
9
|
'#' => :id,
|
10
10
|
}.freeze
|
11
11
|
|
12
|
+
MSG = '%s should be listed before %s (%s should precede %s)'.freeze
|
13
|
+
|
12
14
|
def visit_tag(node)
|
13
15
|
# Convert ".class#id" into [.class, #id] (preserving order)
|
14
16
|
components = node.static_attributes_source.scan(/[.#][^.#]+/)
|
15
17
|
|
16
18
|
first, second = attribute_prefix_order
|
17
19
|
|
18
|
-
|
19
|
-
next unless
|
20
|
-
|
20
|
+
components.each_cons(2) do |current_val, next_val|
|
21
|
+
next unless next_val.start_with?(first) &&
|
22
|
+
current_val.start_with?(second)
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
failure_message = format(MSG, *(attribute_type_order + [next_val, current_val]))
|
25
|
+
record_lint(node, failure_message)
|
24
26
|
break
|
25
27
|
end
|
26
28
|
end
|
@@ -28,13 +30,23 @@ module HamlLint
|
|
28
30
|
private
|
29
31
|
|
30
32
|
def attribute_prefix_order
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
default = %w[. #]
|
34
|
+
default.reverse! if ids_first?
|
35
|
+
default
|
36
|
+
end
|
37
|
+
|
38
|
+
def attribute_type_order
|
39
|
+
default = %w[Classes IDs]
|
40
|
+
default.reverse! if ids_first?
|
41
|
+
default
|
42
|
+
end
|
43
|
+
|
44
|
+
def enforced_style
|
45
|
+
config.fetch('EnforcedStyle', 'class')
|
46
|
+
end
|
47
|
+
|
48
|
+
def ids_first?
|
49
|
+
enforced_style == 'id'
|
38
50
|
end
|
39
51
|
end
|
40
52
|
end
|
data/lib/haml_lint/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_lint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.18.
|
4
|
+
version: 0.18.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-10-
|
12
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|