rubocop-erb 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -0
- data/lib/rubocop/erb/ruby_extractor.rb +34 -2
- data/lib/rubocop/erb/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: 738549237ab33ab64f83e5a7c2a6804023e44a4b820a672e19f22501f567dc8c
|
4
|
+
data.tar.gz: '0938d75738dde9b60da3f86303e2efc865a6651a2097f1c17b02a310fb48cc65'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44c40245e84d96ca53eca30b4b10520b150960df5caa08367167eee18b98039bc4dd79d0b3a1579f1cd1fc4adc6704c2e2889a2d49ebe6ac9b54c6500339f558
|
7
|
+
data.tar.gz: d1eb898d1bd7fae46842f82aa9c7c4b7acc980ec3866dbc9cd94a7dab20fc850e4f0a6509958a3bf22adfab47b8c9dc91fba8767aa52ba39362db8ac936c1db8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,20 @@ spec/fixtures/dummy.erb:7:11: E: Lint/Syntax: unexpected token $end
|
|
54
54
|
1 file inspected, 4 offenses detected, 3 offenses autocorrectable
|
55
55
|
```
|
56
56
|
|
57
|
+
## Workaround
|
58
|
+
|
59
|
+
As a known issue, there seems to be a problem with .rubocop_todo.yml overriding config/default.yml provided by rubocop-erb, so we recommend adding a workaround to your .rubocop.yml as shown below:
|
60
|
+
|
61
|
+
```yaml
|
62
|
+
inherit_from: .rubocop_todo.yml
|
63
|
+
|
64
|
+
inherit_mode:
|
65
|
+
merge:
|
66
|
+
- Exclude
|
67
|
+
```
|
68
|
+
|
69
|
+
See [#15](https://github.com/r7kamura/rubocop-erb/issues/15) for more details.
|
70
|
+
|
57
71
|
## Related projects
|
58
72
|
|
59
73
|
- https://github.com/r7kamura/rubocop-haml
|
@@ -44,8 +44,9 @@ module RuboCop
|
|
44
44
|
|
45
45
|
# @return [Array<BetterHtml::AST::Node>]
|
46
46
|
def erbs
|
47
|
-
root.descendants(:erb).reject do |
|
48
|
-
|
47
|
+
root.descendants(:erb).reject do |node|
|
48
|
+
erb_node = ErbNode.new(node)
|
49
|
+
erb_node.comment? || erb_node.escape?
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -97,6 +98,37 @@ module RuboCop
|
|
97
98
|
def template_source
|
98
99
|
@processed_source.raw_source
|
99
100
|
end
|
101
|
+
|
102
|
+
class ErbNode
|
103
|
+
# @param [BetterHtml::AST::Node] node
|
104
|
+
def initialize(node)
|
105
|
+
@node = node
|
106
|
+
end
|
107
|
+
|
108
|
+
# @return [Boolean]
|
109
|
+
def comment?
|
110
|
+
indicator == '#'
|
111
|
+
end
|
112
|
+
|
113
|
+
# @return [Boolean]
|
114
|
+
def escape?
|
115
|
+
indicator == '%'
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
# @return [BetterHtml::AST::Node, nil]
|
121
|
+
def first_child
|
122
|
+
@node.children.first
|
123
|
+
end
|
124
|
+
|
125
|
+
# @return [String, nil]
|
126
|
+
def indicator
|
127
|
+
return unless first_child&.type == :indicator
|
128
|
+
|
129
|
+
first_child&.to_a&.first
|
130
|
+
end
|
131
|
+
end
|
100
132
|
end
|
101
133
|
end
|
102
134
|
end
|
data/lib/rubocop/erb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-erb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_html
|