immosquare-cleaner 0.1.109 → 0.1.110
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/immosquare-cleaner/version.rb +1 -1
- data/linters/{erb-lint-4.0.3.yml → erb-lint-4.0.4.yml} +5 -1
- data/linters/erb-lint.yml +4 -0
- data/linters/erb_lint/custom_align_consecutive_calls.rb +226 -0
- data/linters/{js-erb-lint-4.0.3.yml → js-erb-lint-4.0.4.yml} +1 -1
- data/linters/rubocop/cop/custom_cops/style/inline_multiline_calls.rb +118 -0
- data/linters/rubocop/cop/custom_cops/style/kwarg_priority_order.rb +103 -0
- data/linters/{rubocop-4.0.3.yml → rubocop-4.0.4.yml} +14 -1
- data/linters/rubocop.yml +15 -0
- data/package.json +3 -3
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ecfb20b449cc9d9a557ca71d325a463c4e3f11343b85ab2c336e74952a84599
|
|
4
|
+
data.tar.gz: e073034f35d4729ed66430456fc298eccc4dd1ee21f1e16f08ff263b51a63bc7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45aff6bbc275cf2494ffb00617e5ea934836a7e3cf50bb6b640cdc7d462b2bff15e3ed3da79e0edb85753129df1f54d4b0206b1e22851638b38be36a894348ed
|
|
7
|
+
data.tar.gz: 0024bf22be91d820c4f817960f1551d3370038c013c45905bbbd600a7136b4c8630c6f597b8c84c404ebcb7a2aa3b6ee83e5df188dfa771fd1ca69a2d9464630
|
|
@@ -9,10 +9,14 @@ linters:
|
|
|
9
9
|
enabled: true
|
|
10
10
|
CustomHtmlToContentTag:
|
|
11
11
|
enabled: true
|
|
12
|
+
CustomAlignConsecutiveCalls:
|
|
13
|
+
enabled: true
|
|
14
|
+
methods:
|
|
15
|
+
- link_to
|
|
12
16
|
Rubocop:
|
|
13
17
|
enabled: true
|
|
14
18
|
rubocop_config:
|
|
15
19
|
inherit_from:
|
|
16
|
-
- linters/rubocop-4.0.
|
|
20
|
+
- linters/rubocop-4.0.4.yml
|
|
17
21
|
Layout/TrailingWhitespace:
|
|
18
22
|
Enabled: false
|
data/linters/erb-lint.yml
CHANGED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rubocop-ast"
|
|
4
|
+
|
|
5
|
+
module ERBLint
|
|
6
|
+
module Linters
|
|
7
|
+
##============================================================##
|
|
8
|
+
## Aligns the arguments of consecutive ERB output calls to the
|
|
9
|
+
## same configured method (default: link_to) when:
|
|
10
|
+
## - they're on adjacent lines,
|
|
11
|
+
## - separated only by whitespace,
|
|
12
|
+
## - have the same arity,
|
|
13
|
+
## - have the same keyword keys in the same order.
|
|
14
|
+
##
|
|
15
|
+
## Each argument becomes a column; cells are right-padded with
|
|
16
|
+
## spaces so that the next argument starts at the same column
|
|
17
|
+
## across all lines in the group.
|
|
18
|
+
##
|
|
19
|
+
## @example
|
|
20
|
+
## bad
|
|
21
|
+
## <%= link_to(t("a"), foo_path(:id => 1), :class => "dropdown-item", :remote => true) %>
|
|
22
|
+
## <%= link_to(t("bbbb"), bar_path(:id => 2), :class => "dropdown-item #{x}", :remote => true) %>
|
|
23
|
+
##
|
|
24
|
+
## good
|
|
25
|
+
## <%= link_to(t("a"), foo_path(:id => 1), :class => "dropdown-item", :remote => true) %>
|
|
26
|
+
## <%= link_to(t("bbbb"), bar_path(:id => 2), :class => "dropdown-item #{x}", :remote => true) %>
|
|
27
|
+
##============================================================##
|
|
28
|
+
class CustomAlignConsecutiveCalls < Linter
|
|
29
|
+
|
|
30
|
+
include LinterRegistry
|
|
31
|
+
|
|
32
|
+
MSG = "Align consecutive `%s` calls."
|
|
33
|
+
|
|
34
|
+
class ConfigSchema < LinterConfig
|
|
35
|
+
|
|
36
|
+
property(:methods, :accepts => array_of?(String), :default => -> { ["link_to"] })
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
self.config_schema = ConfigSchema
|
|
41
|
+
|
|
42
|
+
def run(processed_source)
|
|
43
|
+
output_nodes = processed_source.ast.descendants(:erb).select {|n| output_erb?(n) }
|
|
44
|
+
return if output_nodes.size < 2
|
|
45
|
+
|
|
46
|
+
##============================================================##
|
|
47
|
+
## Group adjacent output ERB nodes (whitespace-only between).
|
|
48
|
+
##============================================================##
|
|
49
|
+
groups = group_adjacent(output_nodes, processed_source)
|
|
50
|
+
|
|
51
|
+
groups.each do |group|
|
|
52
|
+
next if group.size < 2
|
|
53
|
+
|
|
54
|
+
rebuild_group(group, processed_source)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def autocorrect(_processed_source, offense)
|
|
59
|
+
lambda do |corrector|
|
|
60
|
+
corrector.replace(offense.source_range, offense.context[:new_code])
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
private
|
|
65
|
+
|
|
66
|
+
##============================================================##
|
|
67
|
+
## Build aligned rewrites for the group, add an offense per
|
|
68
|
+
## call that needs to change.
|
|
69
|
+
##============================================================##
|
|
70
|
+
def rebuild_group(group, processed_source)
|
|
71
|
+
parsed = group.map {|node| parse_call(strip_code(extract_code(node))) }
|
|
72
|
+
return if parsed.any?(&:nil?)
|
|
73
|
+
|
|
74
|
+
method_name = parsed.first[:method]
|
|
75
|
+
return unless allowed_methods.include?(method_name)
|
|
76
|
+
return unless parsed.all? {|p| p[:method] == method_name }
|
|
77
|
+
|
|
78
|
+
##============================================================##
|
|
79
|
+
## All calls must share the same arg signature
|
|
80
|
+
## (same positional/kwarg layout, same kw keys in same order).
|
|
81
|
+
##============================================================##
|
|
82
|
+
signatures = parsed.map {|p| p[:args].map {|a| a[:kind] == :kwarg ? [:kwarg, a[:key]] : [:positional] } }
|
|
83
|
+
return unless signatures.uniq.size == 1
|
|
84
|
+
|
|
85
|
+
n_cols = parsed.first[:args].size
|
|
86
|
+
col_widths = (0...n_cols).map {|i| parsed.map {|p| p[:args][i][:text].length }.max }
|
|
87
|
+
|
|
88
|
+
parsed.each_with_index do |p, idx|
|
|
89
|
+
rebuilt = "#{p[:method]}(#{join_padded(p[:args], col_widths)})"
|
|
90
|
+
current = strip_code(extract_code(group[idx])).strip
|
|
91
|
+
next if current == rebuilt
|
|
92
|
+
|
|
93
|
+
code_loc = group[idx].children[2].loc
|
|
94
|
+
range = processed_source.to_source_range(code_loc.begin_pos...code_loc.end_pos)
|
|
95
|
+
add_offense(range, format(MSG, method_name), :new_code => " #{rebuilt} ")
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
##============================================================##
|
|
100
|
+
## Join args with `, ` and right-pad AFTER the comma so the
|
|
101
|
+
## next column starts at a consistent position across all rows
|
|
102
|
+
## in the group. Padding goes after the comma (not before) so
|
|
103
|
+
## the comma stays glued to its arg.
|
|
104
|
+
##============================================================##
|
|
105
|
+
def join_padded(args, col_widths)
|
|
106
|
+
last = args.size - 1
|
|
107
|
+
out = +""
|
|
108
|
+
args.each_with_index do |a, i|
|
|
109
|
+
if i == last
|
|
110
|
+
out << a[:text]
|
|
111
|
+
else
|
|
112
|
+
pad = " " * (col_widths[i] - a[:text].length)
|
|
113
|
+
out << a[:text] << ", " << pad
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
out
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def allowed_methods
|
|
120
|
+
Array(@config.methods)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
##============================================================##
|
|
124
|
+
## Parse a single Ruby call via the parser shipped with
|
|
125
|
+
## rubocop-ast. Returns nil if the source isn't a clean
|
|
126
|
+
## `method(args...)` call.
|
|
127
|
+
##
|
|
128
|
+
## Each hash pair is captured via `pair.loc.expression.source`
|
|
129
|
+
## so we preserve the original syntax (hashrocket vs short
|
|
130
|
+
## `key:` form). The `:key` field carries only the semantic
|
|
131
|
+
## key name (used for signature comparison across calls).
|
|
132
|
+
##
|
|
133
|
+
## Note (perf) : a `RuboCop::ProcessedSource` is created per
|
|
134
|
+
## call. For a view with hundreds of `link_to`s in a single
|
|
135
|
+
## group this scales linearly. Acceptable for the typical
|
|
136
|
+
## case (a few consecutive calls); memoise if it ever shows
|
|
137
|
+
## up in profiling.
|
|
138
|
+
##============================================================##
|
|
139
|
+
def parse_call(code)
|
|
140
|
+
return nil if code.nil? || code.empty?
|
|
141
|
+
|
|
142
|
+
source = RuboCop::ProcessedSource.new(code, RUBY_VERSION.to_f)
|
|
143
|
+
return nil if source.ast.nil?
|
|
144
|
+
|
|
145
|
+
node = source.ast
|
|
146
|
+
return nil unless node.respond_to?(:type) && node.type == :send
|
|
147
|
+
return nil unless node.children[0].nil?
|
|
148
|
+
|
|
149
|
+
method = node.children[1].to_s
|
|
150
|
+
args = []
|
|
151
|
+
node.children[2..].each do |arg|
|
|
152
|
+
if arg.type == :hash
|
|
153
|
+
arg.children.each do |pair|
|
|
154
|
+
key_node = pair.children.first
|
|
155
|
+
args << {:kind => :kwarg, :key => key_name(key_node), :text => pair.loc.expression.source}
|
|
156
|
+
end
|
|
157
|
+
else
|
|
158
|
+
args << {:kind => :positional, :text => arg.loc.expression.source}
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
{:method => method, :args => args}
|
|
163
|
+
rescue StandardError
|
|
164
|
+
nil
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
##============================================================##
|
|
168
|
+
## Extract the semantic key name from a hash pair's key node.
|
|
169
|
+
## Handles :sym (hashrocket and short syntax) and "string"
|
|
170
|
+
## keys. Dynamic keys fall back to their source.
|
|
171
|
+
##============================================================##
|
|
172
|
+
def key_name(key_node)
|
|
173
|
+
return nil unless key_node
|
|
174
|
+
|
|
175
|
+
case key_node.type
|
|
176
|
+
when :sym, :str then key_node.value.to_s
|
|
177
|
+
else key_node.loc.expression.source
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
##============================================================##
|
|
182
|
+
## Walk the output nodes and break into groups whenever the
|
|
183
|
+
## text between two adjacent nodes is not whitespace-only or
|
|
184
|
+
## contains zero newlines (meaning the nodes are on the same
|
|
185
|
+
## line).
|
|
186
|
+
##============================================================##
|
|
187
|
+
def group_adjacent(nodes, processed_source)
|
|
188
|
+
groups = []
|
|
189
|
+
current = []
|
|
190
|
+
source = processed_source.source_buffer.source
|
|
191
|
+
|
|
192
|
+
nodes.each do |node|
|
|
193
|
+
if current.empty?
|
|
194
|
+
current << node
|
|
195
|
+
next
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
between = source[current.last.loc.end_pos...node.loc.begin_pos]
|
|
199
|
+
if between.match?(/\A\s*\z/) && between.count("\n") >= 1
|
|
200
|
+
current << node
|
|
201
|
+
else
|
|
202
|
+
groups << current
|
|
203
|
+
current = [node]
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
groups << current unless current.empty?
|
|
208
|
+
groups
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def output_erb?(erb_node)
|
|
212
|
+
indicator = erb_node.children.first
|
|
213
|
+
indicator.respond_to?(:children) && indicator.children.first == "="
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def extract_code(erb_node)
|
|
217
|
+
erb_node.children[2]&.loc&.source
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def strip_code(code)
|
|
221
|
+
code.to_s.strip
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
end
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
module RuboCop
|
|
2
|
+
module Cop
|
|
3
|
+
module CustomCops
|
|
4
|
+
module Style
|
|
5
|
+
##============================================================##
|
|
6
|
+
## Collapses multi-line method calls onto a single line when
|
|
7
|
+
## the method name is part of the configurable allowlist
|
|
8
|
+
## (`Methods`). No max-length cap — the call is always
|
|
9
|
+
## collapsed.
|
|
10
|
+
##
|
|
11
|
+
## Designed for helper-like calls that read cleaner inline
|
|
12
|
+
## (e.g. `link_to`, `button_to`, ...) but get split by hand
|
|
13
|
+
## or by other autocorrects.
|
|
14
|
+
##
|
|
15
|
+
## The cop walks the AST and rebuilds the call from each
|
|
16
|
+
## argument's source. This is intentionally safer than a
|
|
17
|
+
## regex-based collapse: comments inside the call and
|
|
18
|
+
## multi-line string literals would otherwise be silently
|
|
19
|
+
## corrupted, so the cop refuses to act on them.
|
|
20
|
+
##
|
|
21
|
+
## @example
|
|
22
|
+
## bad
|
|
23
|
+
## link_to(t("app.add.something"),
|
|
24
|
+
## my_path(:id => id),
|
|
25
|
+
## :class => "dropdown-item",
|
|
26
|
+
## :remote => true)
|
|
27
|
+
##
|
|
28
|
+
## good
|
|
29
|
+
## link_to(t("app.add.something"), my_path(:id => id), :class => "dropdown-item", :remote => true)
|
|
30
|
+
##============================================================##
|
|
31
|
+
class InlineMultilineCalls < RuboCop::Cop::Base
|
|
32
|
+
|
|
33
|
+
extend AutoCorrector
|
|
34
|
+
|
|
35
|
+
MSG = "Collapse multi-line `%<name>s` call into a single line.".freeze
|
|
36
|
+
|
|
37
|
+
DEFAULT_METHODS = ["link_to"].freeze
|
|
38
|
+
|
|
39
|
+
def on_send(node)
|
|
40
|
+
return unless target_methods.include?(node.method_name.to_s)
|
|
41
|
+
return unless multiline_call?(node)
|
|
42
|
+
return if contains_comment?(node)
|
|
43
|
+
|
|
44
|
+
rebuilt = rebuild(node)
|
|
45
|
+
return if rebuilt.nil?
|
|
46
|
+
return if rebuilt.include?("\n")
|
|
47
|
+
return if rebuilt == node.source
|
|
48
|
+
|
|
49
|
+
add_offense(node, :message => format(MSG, :name => node.method_name)) do |corrector|
|
|
50
|
+
corrector.replace(node, rebuilt)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
alias on_csend on_send
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
##============================================================##
|
|
58
|
+
## A send node is multi-line if its source spans more than one
|
|
59
|
+
## line. We rely on the source range rather than `node.multiline?`
|
|
60
|
+
## because we want to react to formatting, not just node shape.
|
|
61
|
+
##============================================================##
|
|
62
|
+
def multiline_call?(node)
|
|
63
|
+
range = node.source_range
|
|
64
|
+
range.first_line != range.last_line
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
##============================================================##
|
|
68
|
+
## Refuse to act if any comment lives inside the call. Comments
|
|
69
|
+
## terminate at the next newline; collapsing newlines would
|
|
70
|
+
## swallow the args that follow the comment.
|
|
71
|
+
##============================================================##
|
|
72
|
+
def contains_comment?(node)
|
|
73
|
+
range = node.source_range
|
|
74
|
+
processed_source.comments.any? do |comment|
|
|
75
|
+
loc = comment.loc.expression
|
|
76
|
+
loc.begin_pos >= range.begin_pos && loc.end_pos <= range.end_pos
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
##============================================================##
|
|
81
|
+
## Rebuild the call by joining each argument's source. Hash
|
|
82
|
+
## args are unfolded into their individual pairs so the joiner
|
|
83
|
+
## (", ") is consistent across all chunks. Returns nil when
|
|
84
|
+
## an individual arg is itself multi-line — a heredoc, a
|
|
85
|
+
## multi-line string literal, or a multi-line block expression
|
|
86
|
+
## inside an arg. Touching those would be unsafe.
|
|
87
|
+
##============================================================##
|
|
88
|
+
def rebuild(node)
|
|
89
|
+
chunks = node.arguments.flat_map do |arg|
|
|
90
|
+
if arg.hash_type? && !arg.braces?
|
|
91
|
+
arg.children.map(&:source)
|
|
92
|
+
else
|
|
93
|
+
[arg.source]
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
return nil if chunks.any? {|src| src.include?("\n") }
|
|
98
|
+
|
|
99
|
+
receiver_part = node.receiver ? "#{node.receiver.source}#{node.csend_type? ? "&." : "."}" : ""
|
|
100
|
+
method_part = node.method_name
|
|
101
|
+
args_joined = chunks.join(", ")
|
|
102
|
+
|
|
103
|
+
if node.parenthesized?
|
|
104
|
+
"#{receiver_part}#{method_part}(#{args_joined})"
|
|
105
|
+
else
|
|
106
|
+
"#{receiver_part}#{method_part} #{args_joined}"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def target_methods
|
|
111
|
+
Array(cop_config["Methods"]).map(&:to_s).then {|list| list.empty? ? DEFAULT_METHODS : list }
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
module RuboCop
|
|
2
|
+
module Cop
|
|
3
|
+
module CustomCops
|
|
4
|
+
module Style
|
|
5
|
+
##============================================================##
|
|
6
|
+
## Reorders the kwargs (implicit hash arg) of configured method
|
|
7
|
+
## calls so that priority keys come first, in the order given
|
|
8
|
+
## by `PriorityKeys`. Other kwargs keep their relative order.
|
|
9
|
+
##
|
|
10
|
+
## Targets the last positional arg only when it is a non-braced
|
|
11
|
+
## hash (i.e. a real kwargs trailing hash). Explicit `{ ... }`
|
|
12
|
+
## hash literals are left untouched.
|
|
13
|
+
##
|
|
14
|
+
## @example PriorityKeys: ["remote", "method"]
|
|
15
|
+
## bad
|
|
16
|
+
## link_to(t("x"), path, :class => "x", :remote => true)
|
|
17
|
+
## link_to(t("x"), path, :class => "x", :method => :delete)
|
|
18
|
+
##
|
|
19
|
+
## good
|
|
20
|
+
## link_to(t("x"), path, :remote => true, :class => "x")
|
|
21
|
+
## link_to(t("x"), path, :method => :delete, :class => "x")
|
|
22
|
+
##============================================================##
|
|
23
|
+
class KwargPriorityOrder < RuboCop::Cop::Base
|
|
24
|
+
|
|
25
|
+
extend AutoCorrector
|
|
26
|
+
|
|
27
|
+
MSG = "Move priority kwargs (%<keys>s) to the front of the call.".freeze
|
|
28
|
+
|
|
29
|
+
DEFAULT_METHODS = ["link_to"].freeze
|
|
30
|
+
DEFAULT_PRIORITY_KEYS = ["remote", "method"].freeze
|
|
31
|
+
|
|
32
|
+
def on_send(node)
|
|
33
|
+
return unless target_methods.include?(node.method_name.to_s)
|
|
34
|
+
|
|
35
|
+
hash_arg = node.last_argument
|
|
36
|
+
return unless hash_arg&.hash_type?
|
|
37
|
+
return if hash_arg.braces?
|
|
38
|
+
|
|
39
|
+
pairs = hash_arg.children
|
|
40
|
+
return if pairs.size < 2
|
|
41
|
+
|
|
42
|
+
priority_pairs, rest = partition_priority(pairs)
|
|
43
|
+
return if priority_pairs.empty?
|
|
44
|
+
return if pairs.first(priority_pairs.size) == priority_pairs
|
|
45
|
+
|
|
46
|
+
new_hash_src = (priority_pairs + rest).map {|p| p.loc.expression.source }.join(", ")
|
|
47
|
+
return if new_hash_src == hash_arg.loc.expression.source
|
|
48
|
+
|
|
49
|
+
add_offense(hash_arg, :message => format(MSG, :keys => priority_keys.join(", "))) do |corrector|
|
|
50
|
+
corrector.replace(hash_arg, new_hash_src)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
alias on_csend on_send
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
##============================================================##
|
|
58
|
+
## Split pairs into priority (in PriorityKeys order) and rest
|
|
59
|
+
## (original order preserved).
|
|
60
|
+
##============================================================##
|
|
61
|
+
def partition_priority(pairs)
|
|
62
|
+
by_key = {}
|
|
63
|
+
rest = []
|
|
64
|
+
|
|
65
|
+
pairs.each do |pair|
|
|
66
|
+
key_str = key_name(pair.children.first)
|
|
67
|
+
if key_str && priority_keys.include?(key_str)
|
|
68
|
+
by_key[key_str] = pair
|
|
69
|
+
else
|
|
70
|
+
rest << pair
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
priority = priority_keys.filter_map {|k| by_key[k] }
|
|
75
|
+
[priority, rest]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
##============================================================##
|
|
79
|
+
## Extract the key name from a hash pair's key node. Handles
|
|
80
|
+
## :sym, "string", and dynamic keys (returns nil for the
|
|
81
|
+
## latter so they're treated as non-priority).
|
|
82
|
+
##============================================================##
|
|
83
|
+
def key_name(key_node)
|
|
84
|
+
return nil unless key_node
|
|
85
|
+
|
|
86
|
+
case key_node.type
|
|
87
|
+
when :sym, :str then key_node.value.to_s
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def priority_keys
|
|
92
|
+
Array(cop_config["PriorityKeys"]).map(&:to_s).then {|list| list.empty? ? DEFAULT_PRIORITY_KEYS : list }
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def target_methods
|
|
96
|
+
Array(cop_config["Methods"]).map(&:to_s).then {|list| list.empty? ? DEFAULT_METHODS : list }
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -4,13 +4,15 @@ require:
|
|
|
4
4
|
- rubocop/cop/custom_cops/style/comment_normalization
|
|
5
5
|
- rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
6
6
|
- rubocop/cop/custom_cops/style/align_assignments
|
|
7
|
+
- rubocop/cop/custom_cops/style/inline_multiline_calls
|
|
8
|
+
- rubocop/cop/custom_cops/style/kwarg_priority_order
|
|
7
9
|
AllCops:
|
|
8
10
|
NewCops: enable
|
|
9
11
|
EnabledByDefault: false
|
|
10
12
|
UseCache: true
|
|
11
13
|
SuggestExtensions: false
|
|
12
14
|
ActiveSupportExtensionsEnabled: true
|
|
13
|
-
TargetRubyVersion: 4.0.
|
|
15
|
+
TargetRubyVersion: 4.0.4
|
|
14
16
|
ParserEngine: parser_prism
|
|
15
17
|
Metrics:
|
|
16
18
|
Enabled: false
|
|
@@ -198,5 +200,16 @@ CustomCops/Style/FontAwesomeNormalization:
|
|
|
198
200
|
Enabled: true
|
|
199
201
|
CustomCops/Style/AlignAssignments:
|
|
200
202
|
Enabled: false
|
|
203
|
+
CustomCops/Style/InlineMultilineCalls:
|
|
204
|
+
Enabled: true
|
|
205
|
+
Methods:
|
|
206
|
+
- link_to
|
|
207
|
+
CustomCops/Style/KwargPriorityOrder:
|
|
208
|
+
Enabled: true
|
|
209
|
+
Methods:
|
|
210
|
+
- link_to
|
|
211
|
+
PriorityKeys:
|
|
212
|
+
- remote
|
|
213
|
+
- method
|
|
201
214
|
Gemspec/RequireMFA:
|
|
202
215
|
Enabled: false
|
data/linters/rubocop.yml
CHANGED
|
@@ -3,6 +3,8 @@ require:
|
|
|
3
3
|
- rubocop/cop/custom_cops/style/comment_normalization
|
|
4
4
|
- rubocop/cop/custom_cops/style/font_awesome_normalization
|
|
5
5
|
- rubocop/cop/custom_cops/style/align_assignments
|
|
6
|
+
- rubocop/cop/custom_cops/style/inline_multiline_calls
|
|
7
|
+
- rubocop/cop/custom_cops/style/kwarg_priority_order
|
|
6
8
|
|
|
7
9
|
# Enable all RuboCop methods and turn caching on for large files
|
|
8
10
|
AllCops:
|
|
@@ -225,6 +227,19 @@ CustomCops/Style/FontAwesomeNormalization:
|
|
|
225
227
|
CustomCops/Style/AlignAssignments:
|
|
226
228
|
Enabled: false # Force alignment of consecutive assignments
|
|
227
229
|
|
|
230
|
+
CustomCops/Style/InlineMultilineCalls:
|
|
231
|
+
Enabled: true # Always collapse multi-line calls of the listed methods onto a single line
|
|
232
|
+
Methods:
|
|
233
|
+
- link_to
|
|
234
|
+
|
|
235
|
+
CustomCops/Style/KwargPriorityOrder:
|
|
236
|
+
Enabled: true # Reorder kwargs of the listed methods so priority keys come first
|
|
237
|
+
Methods:
|
|
238
|
+
- link_to
|
|
239
|
+
PriorityKeys:
|
|
240
|
+
- remote
|
|
241
|
+
- method
|
|
242
|
+
|
|
228
243
|
#################### GEM ###########################
|
|
229
244
|
Gemspec/RequireMFA:
|
|
230
245
|
Enabled: false # Don't require MFA to push a gem
|
data/package.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@babel/parser": "^7.29.3",
|
|
6
6
|
"@eslint/js": "^10.0.1",
|
|
7
|
-
"@typescript-eslint/eslint-plugin": "^8.59.
|
|
8
|
-
"@typescript-eslint/parser": "^8.59.
|
|
9
|
-
"eslint": "^10.
|
|
7
|
+
"@typescript-eslint/eslint-plugin": "^8.59.3",
|
|
8
|
+
"@typescript-eslint/parser": "^8.59.3",
|
|
9
|
+
"eslint": "^10.4.0",
|
|
10
10
|
"eslint-plugin-align-assignments": "^1.1.2",
|
|
11
11
|
"eslint-plugin-align-import": "^1.0.0",
|
|
12
12
|
"eslint-plugin-erb": "^2.1.1",
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: immosquare-cleaner
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.110
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- immosquare
|
|
@@ -176,21 +176,24 @@ files:
|
|
|
176
176
|
- lib/immosquare-cleaner/railtie.rb
|
|
177
177
|
- lib/immosquare-cleaner/version.rb
|
|
178
178
|
- lib/tasks/immosquare_cleaner.rake
|
|
179
|
-
- linters/erb-lint-4.0.
|
|
179
|
+
- linters/erb-lint-4.0.4.yml
|
|
180
180
|
- linters/erb-lint.yml
|
|
181
|
+
- linters/erb_lint/custom_align_consecutive_calls.rb
|
|
181
182
|
- linters/erb_lint/custom_html_to_content_tag.rb
|
|
182
183
|
- linters/erb_lint/custom_single_line_if_modifier.rb
|
|
183
184
|
- linters/eslint-plugins/eslint10-compat.mjs
|
|
184
185
|
- linters/eslint.config.mjs
|
|
185
|
-
- linters/js-erb-lint-4.0.
|
|
186
|
+
- linters/js-erb-lint-4.0.4.yml
|
|
186
187
|
- linters/js-erb-lint.yml
|
|
187
188
|
- linters/normalize-comments.mjs
|
|
188
189
|
- linters/prettier.yml
|
|
189
|
-
- linters/rubocop-4.0.
|
|
190
|
+
- linters/rubocop-4.0.4.yml
|
|
190
191
|
- linters/rubocop.yml
|
|
191
192
|
- linters/rubocop/cop/custom_cops/style/align_assignments.rb
|
|
192
193
|
- linters/rubocop/cop/custom_cops/style/comment_normalization.rb
|
|
193
194
|
- linters/rubocop/cop/custom_cops/style/font_awesome_normalization.rb
|
|
195
|
+
- linters/rubocop/cop/custom_cops/style/inline_multiline_calls.rb
|
|
196
|
+
- linters/rubocop/cop/custom_cops/style/kwarg_priority_order.rb
|
|
194
197
|
- linters/rubocop/cop/style/method_call_with_args_parentheses_override.rb
|
|
195
198
|
- package.json
|
|
196
199
|
homepage: https://github.com/immosquare/Immosquare-cleaner
|