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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df7883aaaa8cb83f5661b9edfcf74f12b6dc84bb89d135c518e7f78c6dee9068
4
- data.tar.gz: 5f8686b18e1f199663fdf3b8efa455e765e2d5f6800a6e4d8366610212eb25a4
3
+ metadata.gz: 738549237ab33ab64f83e5a7c2a6804023e44a4b820a672e19f22501f567dc8c
4
+ data.tar.gz: '0938d75738dde9b60da3f86303e2efc865a6651a2097f1c17b02a310fb48cc65'
5
5
  SHA512:
6
- metadata.gz: 915462fa70d43cf062f9970c8ad0fa85f2f4249f26a0618204f8e5ff472e63ac934732c40ab87ddf5a49ceebf1b70b91b55a7cacf1aed0413370cede971eedaa
7
- data.tar.gz: c669c6a2849482d58abe45de7012b324cfe8b68cefc7b551e64013d135013ac579017f40c4ef0d865c947b9f8cb91d96c04c63426bd1e83b500cf4bc942d8c91
6
+ metadata.gz: 44c40245e84d96ca53eca30b4b10520b150960df5caa08367167eee18b98039bc4dd79d0b3a1579f1cd1fc4adc6704c2e2889a2d49ebe6ac9b54c6500339f558
7
+ data.tar.gz: d1eb898d1bd7fae46842f82aa9c7c4b7acc980ec3866dbc9cd94a7dab20fc850e4f0a6509958a3bf22adfab47b8c9dc91fba8767aa52ba39362db8ac936c1db8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-erb (0.2.3)
4
+ rubocop-erb (0.2.4)
5
5
  better_html
6
6
  rubocop (~> 1.45)
7
7
 
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 |erb|
48
- erb.children.first&.type == :indicator && erb.children.first&.to_a&.first == '#'
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Erb
5
- VERSION = '0.2.3'
5
+ VERSION = '0.2.4'
6
6
  end
7
7
  end
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.3
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-16 00:00:00.000000000 Z
11
+ date: 2023-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: better_html