immosquare-cleaner 0.1.82 → 0.1.83

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8e38b197fb7d113d6719e69a3aaa53cbb4ccd91663ee13f7f987a2651be2d9b1
4
- data.tar.gz: 68feb71efbcd5ffcc6b71906230e0db69cdc11bd0b67eec47abe618bae0f3323
3
+ metadata.gz: c1ef4621cff404769813cf6e8de68d657912a80e590f8626f6fb7b4e92c214e9
4
+ data.tar.gz: 427c3a61e31512a98a566f1ff786aeca114f7843bc707e4c1aa0de130adfb411
5
5
  SHA512:
6
- metadata.gz: fe430816fd49ab2e28ef871af7769567eeaa948e3f662c1ae576590633df4d6785782b0d03060808b4a1c0c2986ec6f17808c25f3ada516325a2f7bd5336dc70
7
- data.tar.gz: ce6c6e8abdcae48294d6dca00a08f3fe437a0c731c22867ef99af46ace2d66624349a7b3dbb5283a927ea6bf3e7c3165bb6903cf631079675296470a98e7f423
6
+ metadata.gz: 1e6a3fda2aab18322d56d2c580248cbfaba77c8c68c780c5aad461bcb832215a4062ff2da3eee716db76f9883bcea4cb793e8ba3fff43964407206f96240d270
7
+ data.tar.gz: 88535ccc05485fc89947862c3032abad0d9fe85113dc54e5aa953a56b4b9bce2a2ab974ae6165616be6d90124783c1dabf7ae99649b76a4b1aa02c6f03c87495
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCleaner
2
- VERSION = "0.1.82".freeze
2
+ VERSION = "0.1.83".freeze
3
3
  end
data/linters/erb-lint.yml CHANGED
@@ -8,8 +8,6 @@ linters:
8
8
  enabled: true
9
9
  CustomHtmlToContentTag:
10
10
  enabled: true
11
- CustomNormalizeAttributeSpaces:
12
- enabled: true
13
11
  Rubocop:
14
12
  enabled: true
15
13
  rubocop_config:
@@ -179,12 +179,21 @@ module ERBLint
179
179
 
180
180
  ##============================================================##
181
181
  ## Extract the method name from Ruby code using Prism parser
182
+ ## Handles both direct calls and calls with if/unless modifiers
182
183
  ##============================================================##
183
184
  def extract_method_name(erb_code)
184
185
  result = Prism.parse(erb_code)
185
186
  return nil unless result.success?
186
187
 
187
188
  node = result.value.statements.body.first
189
+
190
+ ##============================================================##
191
+ ## Handle if/unless modifiers: `render(...) if condition`
192
+ ##============================================================##
193
+ if node.is_a?(Prism::IfNode) || node.is_a?(Prism::UnlessNode)
194
+ node = node.statements&.body&.first
195
+ end
196
+
188
197
  return nil unless node.is_a?(Prism::CallNode)
189
198
 
190
199
  node.name.to_s
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.82
4
+ version: 0.1.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare
@@ -147,10 +147,8 @@ files:
147
147
  - lib/immosquare-cleaner/railtie.rb
148
148
  - lib/immosquare-cleaner/version.rb
149
149
  - lib/tasks/immosquare_cleaner.rake
150
- - linters/erb-lint-3.4.1.yml
151
150
  - linters/erb-lint.yml
152
151
  - linters/erb_lint/custom_html_to_content_tag.rb
153
- - linters/erb_lint/custom_normalize_attribute_spaces.rb
154
152
  - linters/erb_lint/custom_single_line_if_modifier.rb
155
153
  - linters/eslint.config.mjs
156
154
  - linters/prettier.yml
@@ -1,20 +0,0 @@
1
- ---
2
- EnableDefaultLinters: true
3
- linters:
4
- NoJavascriptTagHelper:
5
- enabled: false
6
- SpaceInHtmlTag:
7
- enabled: false
8
- CustomSingleLineIfModifier:
9
- enabled: true
10
- CustomHtmlToContentTag:
11
- enabled: true
12
- CustomNormalizeAttributeSpaces:
13
- enabled: true
14
- Rubocop:
15
- enabled: true
16
- rubocop_config:
17
- inherit_from:
18
- - linters/rubocop-3.4.1.yml
19
- Layout/TrailingWhitespace:
20
- Enabled: false
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ERBLint
4
- module Linters
5
- ##============================================================##
6
- ## This linter detects and removes multiple consecutive spaces
7
- ## in HTML attribute values.
8
- ##
9
- ## @example
10
- ## bad
11
- ## <div class="flex grow items-center">
12
- ##
13
- ## good
14
- ## <div class="flex grow items-center">
15
- ##
16
- ##============================================================##
17
- class CustomNormalizeAttributeSpaces < Linter
18
-
19
- include LinterRegistry
20
-
21
- MSG = "Remove multiple consecutive spaces in attribute value."
22
-
23
- def run(processed_source)
24
- process_node(processed_source, processed_source.ast)
25
- end
26
-
27
- def autocorrect(_processed_source, offense)
28
- lambda do |corrector|
29
- corrector.replace(offense.source_range, offense.context[:new_value])
30
- end
31
- end
32
-
33
- private
34
-
35
- ##============================================================##
36
- ## Recursively process all nodes in the AST
37
- ##============================================================##
38
- def process_node(processed_source, node)
39
- return unless node
40
-
41
- ##============================================================##
42
- ## Check attribute values for multiple spaces
43
- ##============================================================##
44
- if node.respond_to?(:type) && node.type == :attribute_value
45
- value_source = node.loc.source
46
- if value_source.match?(/ +/)
47
- normalized = value_source.gsub(/ +/, " ")
48
- range = processed_source.to_source_range(node.loc.begin_pos...node.loc.end_pos)
49
- add_offense(range, MSG, {:new_value => normalized})
50
- end
51
- end
52
-
53
- ##============================================================##
54
- ## Recurse into children
55
- ##============================================================##
56
- return unless node.respond_to?(:children)
57
-
58
- node.children.each {|child| process_node(processed_source, child) }
59
- end
60
-
61
- end
62
- end
63
- end