rubocop-erb 0.2.2 → 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: 99ed46b9d8eba4e69cea7d354412e033b02648eace4dfd38d9bcd59f83e0943d
4
- data.tar.gz: bb8f0f0aeae48270f3c2ea4a7a90da7b2ebc5f51c85c7df2e9f2dda039fd6f1e
3
+ metadata.gz: 738549237ab33ab64f83e5a7c2a6804023e44a4b820a672e19f22501f567dc8c
4
+ data.tar.gz: '0938d75738dde9b60da3f86303e2efc865a6651a2097f1c17b02a310fb48cc65'
5
5
  SHA512:
6
- metadata.gz: 8aa2e1476e145e3174417b20baef489ada2b253fcfcf5bdb0e2ad80463e192588a7180c9a643b1eccf9d85a3b8a6828cc23b5372b4e5928856855a7cec744575
7
- data.tar.gz: 8e5c7ecc7da0bbea9d862d5aac33ff89768de9b2d85365a560e4b799363d07636cd4d9cfb654ceb0794cf79c556cea3c685204ed3b118bc46c581e7debb53899
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.2)
4
+ rubocop-erb (0.2.4)
5
5
  better_html
6
6
  rubocop (~> 1.45)
7
7
 
@@ -39,7 +39,7 @@ GEM
39
39
  crass (~> 1.0.2)
40
40
  nokogiri (>= 1.5.9)
41
41
  minitest (5.17.0)
42
- nokogiri (1.14.1-x86_64-linux)
42
+ nokogiri (1.14.2-x86_64-linux)
43
43
  racc (~> 1.4)
44
44
  parallel (1.22.1)
45
45
  parser (3.2.0.0)
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
@@ -51,7 +51,7 @@ module RuboCop
51
51
  | while
52
52
  | for[ \t]+\w+[ \t]+in
53
53
  )
54
- [ \t]
54
+ \b[ \t]*
55
55
  /x.freeze
56
56
 
57
57
  class << self
@@ -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.2'
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.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-10 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