rubocop-slim 0.3.0 → 0.4.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/.rubocop.yml +1 -1
- data/Gemfile.lock +7 -7
- data/config/default.yml +8 -0
- data/lib/rubocop/slim/keyword_remover.rb +2 -2
- data/lib/rubocop/slim/ruby_extractor.rb +30 -9
- data/lib/rubocop/slim/version.rb +1 -1
- data/lib/rubocop/slim/when_decomposer.rb +1 -1
- data/rubocop-slim.gemspec +1 -1
- metadata +4 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1412b34e431ea64b3ebb1784f24b0a8fd41fc67f293278c27edd4996c6f1bc4a
|
|
4
|
+
data.tar.gz: 1d80d23726ef31a8204ee3b2e3a06c9b0998035e49dfe7addd97b886d5cb399f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c31f7ce364db6efc2c4ea2bd7cef636a231cedcdaa0b254f32a17570ce21dca5ab8bd2956e8836c7223bbf3e4d7e98071ee015d794b934df41b8ce91f6198d56
|
|
7
|
+
data.tar.gz: a33f1cf616116690d0f54d0f84d64fc500468e00e0f0c24795a81b7f8000bad8022c08cdd67a843ab26d343ad459382b1ce38cc4c9bd22ff955cd647ef3b72bb
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rubocop-slim (0.
|
|
4
|
+
rubocop-slim (0.4.0)
|
|
5
5
|
lint_roller (>= 1.1)
|
|
6
6
|
rubocop (>= 1.72.1)
|
|
7
7
|
slimi (~> 0.7)
|
|
@@ -36,7 +36,7 @@ GEM
|
|
|
36
36
|
language_server-protocol (3.17.0.4)
|
|
37
37
|
lint_roller (1.1.0)
|
|
38
38
|
logger (1.7.0)
|
|
39
|
-
minitest (5.
|
|
39
|
+
minitest (5.27.0)
|
|
40
40
|
mutex_m (0.3.0)
|
|
41
41
|
parallel (1.26.3)
|
|
42
42
|
parser (3.3.7.4)
|
|
@@ -86,18 +86,18 @@ GEM
|
|
|
86
86
|
activesupport
|
|
87
87
|
lint_roller (>= 1.1)
|
|
88
88
|
rubocop (>= 1.72.1)
|
|
89
|
-
slimi (0.
|
|
89
|
+
slimi (0.10.0)
|
|
90
90
|
temple
|
|
91
91
|
thor
|
|
92
92
|
tilt
|
|
93
|
-
temple (0.10.
|
|
94
|
-
thor (1.
|
|
95
|
-
tilt (2.
|
|
93
|
+
temple (0.10.7)
|
|
94
|
+
thor (1.5.0)
|
|
95
|
+
tilt (2.9.0)
|
|
96
96
|
tzinfo (2.0.6)
|
|
97
97
|
concurrent-ruby (~> 1.0)
|
|
98
98
|
unicode-display_width (3.1.4)
|
|
99
99
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
100
|
-
unicode-emoji (4.0
|
|
100
|
+
unicode-emoji (4.3.0)
|
|
101
101
|
|
|
102
102
|
PLATFORMS
|
|
103
103
|
ruby
|
data/config/default.yml
CHANGED
|
@@ -63,6 +63,10 @@ Layout/HashAlignment:
|
|
|
63
63
|
Exclude:
|
|
64
64
|
- '**/*.slim'
|
|
65
65
|
|
|
66
|
+
Layout/InitialIndentation:
|
|
67
|
+
Exclude:
|
|
68
|
+
- '**/*.slim'
|
|
69
|
+
|
|
66
70
|
Layout/IndentationConsistency:
|
|
67
71
|
Exclude:
|
|
68
72
|
- '**/*.slim'
|
|
@@ -175,6 +179,10 @@ Style/ParallelAssignment:
|
|
|
175
179
|
Exclude:
|
|
176
180
|
- '**/*.slim'
|
|
177
181
|
|
|
182
|
+
Style/RedundantParentheses:
|
|
183
|
+
Exclude:
|
|
184
|
+
- '**/*.slim'
|
|
185
|
+
|
|
178
186
|
Style/RescueModifier:
|
|
179
187
|
Exclude:
|
|
180
188
|
- '**/*.slim'
|
|
@@ -50,7 +50,7 @@ module RuboCop
|
|
|
50
50
|
| for[ \t]+\w+[ \t]+in
|
|
51
51
|
)
|
|
52
52
|
\b[ \t]*
|
|
53
|
-
/x
|
|
53
|
+
/x
|
|
54
54
|
|
|
55
55
|
class << self
|
|
56
56
|
# @param [String] code
|
|
@@ -93,7 +93,7 @@ module RuboCop
|
|
|
93
93
|
[ \t]*
|
|
94
94
|
(\#.*)?
|
|
95
95
|
\Z
|
|
96
|
-
/x
|
|
96
|
+
/x
|
|
97
97
|
|
|
98
98
|
class << self
|
|
99
99
|
# @param [String] code
|
|
@@ -7,6 +7,17 @@ module RuboCop
|
|
|
7
7
|
module Slim
|
|
8
8
|
# Extract Ruby codes from Slim template.
|
|
9
9
|
class RubyExtractor
|
|
10
|
+
# Keep `ruby:` bodies as is, so that their positions are available.
|
|
11
|
+
class Interpolation < ::Slimi::Filters::Interpolation
|
|
12
|
+
def on_slimi_embedded(
|
|
13
|
+
type,
|
|
14
|
+
expression,
|
|
15
|
+
attributes
|
|
16
|
+
)
|
|
17
|
+
type == 'ruby' ? [:slimi, :embedded, type, expression, attributes] : super
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
10
21
|
class << self
|
|
11
22
|
# @param [RuboCop::ProcessedSource] processed_source
|
|
12
23
|
# @return [Array<RuboCop::ProcessedSource>, nil]
|
|
@@ -39,7 +50,7 @@ module RuboCop
|
|
|
39
50
|
|
|
40
51
|
# @return [Array] Slim AST, represented in S-expression.
|
|
41
52
|
def ast
|
|
42
|
-
|
|
53
|
+
Interpolation.new.call(
|
|
43
54
|
::Slimi::Parser.new(file: file_path).call(template_source)
|
|
44
55
|
)
|
|
45
56
|
end
|
|
@@ -51,23 +62,24 @@ module RuboCop
|
|
|
51
62
|
|
|
52
63
|
# @return [Array<RuboCop::Slim::RubyClip]
|
|
53
64
|
def ruby_clips
|
|
54
|
-
ruby_ranges.
|
|
55
|
-
RubyClip.new(
|
|
65
|
+
ruby_ranges.flat_map do |(begin_, end_, embedded)|
|
|
66
|
+
ruby_clip = RubyClip.new(
|
|
56
67
|
code: template_source[begin_...end_],
|
|
57
68
|
offset: begin_
|
|
58
69
|
)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
next ruby_clip if embedded
|
|
71
|
+
|
|
72
|
+
WhenDecomposer.call(@processed_source, ruby_clip).map do |decomposed_ruby_clip|
|
|
73
|
+
KeywordRemover.call(decomposed_ruby_clip)
|
|
74
|
+
end
|
|
63
75
|
end
|
|
64
76
|
end
|
|
65
77
|
|
|
66
78
|
# @return [Array<Array<Integer>>]
|
|
67
79
|
def ruby_ranges
|
|
68
80
|
result = []
|
|
69
|
-
traverse(ast) do |begin_, end_|
|
|
70
|
-
result << [begin_, end_]
|
|
81
|
+
traverse(ast) do |begin_, end_, embedded|
|
|
82
|
+
result << [begin_, end_, embedded]
|
|
71
83
|
end
|
|
72
84
|
result
|
|
73
85
|
end
|
|
@@ -88,6 +100,15 @@ module RuboCop
|
|
|
88
100
|
)
|
|
89
101
|
return unless node.instance_of?(::Array)
|
|
90
102
|
|
|
103
|
+
if node[0..2] == [:slimi, :embedded, 'ruby']
|
|
104
|
+
lines = node[3].grep(::Array).select { |child| child[1] == :interpolate }
|
|
105
|
+
unless lines.empty?
|
|
106
|
+
begin_ = (template_source.rindex("\n", lines.first[2] - 1) || -1) + 1
|
|
107
|
+
block.call(begin_, lines.last[3], true)
|
|
108
|
+
end
|
|
109
|
+
return
|
|
110
|
+
end
|
|
111
|
+
|
|
91
112
|
block.call(node[2], node[3]) if node[0] == :slimi && node[1] == :position
|
|
92
113
|
node.each do |element|
|
|
93
114
|
traverse(element, &block)
|
data/lib/rubocop/slim/version.rb
CHANGED
data/rubocop-slim.gemspec
CHANGED
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
|
11
11
|
spec.summary = 'RuboCop plugin for Slim template.'
|
|
12
12
|
spec.homepage = 'https://github.com/r7kamura/rubocop-slim'
|
|
13
13
|
spec.license = 'MIT'
|
|
14
|
-
spec.required_ruby_version = '>=
|
|
14
|
+
spec.required_ruby_version = '>= 3.3'
|
|
15
15
|
|
|
16
16
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
17
17
|
spec.metadata['source_code_uri'] = spec.homepage
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-slim
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryo Nakamura
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: lint_roller
|
|
@@ -52,7 +51,6 @@ dependencies:
|
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
53
|
version: '0.7'
|
|
55
|
-
description:
|
|
56
54
|
email:
|
|
57
55
|
- r7kamura@gmail.com
|
|
58
56
|
executables: []
|
|
@@ -87,7 +85,6 @@ metadata:
|
|
|
87
85
|
source_code_uri: https://github.com/r7kamura/rubocop-slim
|
|
88
86
|
changelog_uri: https://github.com/r7kamura/rubocop-slim/releases
|
|
89
87
|
default_lint_roller_plugin: RuboCop::Slim::Plugin
|
|
90
|
-
post_install_message:
|
|
91
88
|
rdoc_options: []
|
|
92
89
|
require_paths:
|
|
93
90
|
- lib
|
|
@@ -95,15 +92,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
95
92
|
requirements:
|
|
96
93
|
- - ">="
|
|
97
94
|
- !ruby/object:Gem::Version
|
|
98
|
-
version: '
|
|
95
|
+
version: '3.3'
|
|
99
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
97
|
requirements:
|
|
101
98
|
- - ">="
|
|
102
99
|
- !ruby/object:Gem::Version
|
|
103
100
|
version: '0'
|
|
104
101
|
requirements: []
|
|
105
|
-
rubygems_version: 3.
|
|
106
|
-
signing_key:
|
|
102
|
+
rubygems_version: 3.6.9
|
|
107
103
|
specification_version: 4
|
|
108
104
|
summary: RuboCop plugin for Slim template.
|
|
109
105
|
test_files: []
|