immosquare-cleaner 0.1.95 → 0.1.96

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: ef4743e368013a24d51795c0401fb25551318cf708de34ede70da2463732fb14
4
- data.tar.gz: d071271dcda68ef78e8c042217d39ba13f484b8081e120384c7c01b3c8e0deaa
3
+ metadata.gz: a9e023cd5eb031877e0c2d9c6e4831ddbf69634b25aa18f963125ff6f45ef886
4
+ data.tar.gz: dd026d694d3087313daba0df8324825f8bdfa1644cf1162d7aa232d650770f1d
5
5
  SHA512:
6
- metadata.gz: 11cda1db31886b571cf81a294798e080eef10e30870adeb23071d37242415d047e0b7916c3c6af0bca855f116c49808a2bd38aeba1744f7e29bd1fbd768a5385
7
- data.tar.gz: 2451ad2ef109bf3847a554d7d557bd182e24fae97c7be882e85e8ff1392cffc0a14258f724b2197e386ca6905a51e46c302d2c54d483eea8fc3b5ecd748b5520
6
+ metadata.gz: f5baba5f2baf7162b9125f95bc7efd7b3f4d6ddbd1e71c9835f4e65b78aee6df735f4d36104d18ddfd3770af8017bbb5396461d6b6975760e120f082c37e73ee
7
+ data.tar.gz: 5054ed1b8398d2444dba17d78fb6d4bc5e99f61a87751459603a10463ceb13f6dad69c7ba2268b2a4dc215479852f063238a6fbfe118bd7fb36a8194d6982133
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCleaner
2
- VERSION = "0.1.95".freeze
2
+ VERSION = "0.1.96".freeze
3
3
  end
@@ -36,6 +36,7 @@ const normalizeComments = (filePath) => {
36
36
  // Process blocks in reverse order to avoid line number shifts
37
37
  //============================================================//
38
38
  const blocksReversed = [...commentBlocks].reverse()
39
+ let hasChanges = false
39
40
 
40
41
  blocksReversed.forEach((block) => {
41
42
  const normalized = normalizeCommentBlock(block, lines)
@@ -47,10 +48,16 @@ const normalizeComments = (filePath) => {
47
48
  // Replace the lines in the original array
48
49
  //============================================================//
49
50
  lines.splice(startLine, endLine - startLine + 1, ...normalized)
51
+ hasChanges = true
50
52
  }
51
53
  })
52
54
 
53
- writeFileSync(filePath, lines.join("\n"))
55
+ //============================================================//
56
+ // Only write if there were changes
57
+ //============================================================//
58
+ if (hasChanges) {
59
+ writeFileSync(filePath, lines.join("\n"))
60
+ }
54
61
  }
55
62
 
56
63
  //============================================================//
@@ -64,7 +71,7 @@ const groupConsecutiveComments = (comments, originalLines) => {
64
71
 
65
72
  comments.forEach((comment) => {
66
73
  //============================================================//
67
- // Only process line comments (// style), not block comments (/* */)
74
+ // Only process line comments (// style), not block comments
68
75
  //============================================================//
69
76
  if (comment.type !== "CommentLine") {
70
77
  if (currentBlock.length > 0) {
@@ -89,8 +96,9 @@ const groupConsecutiveComments = (comments, originalLines) => {
89
96
 
90
97
  //============================================================//
91
98
  // Skip Sprockets directives (//= link, //= require, etc.)
99
+ // These start with "= " followed by a directive keyword
92
100
  //============================================================//
93
- if (comment.value.startsWith("=")) {
101
+ if (/^=\s*\w/.test(comment.value)) {
94
102
  if (currentBlock.length > 0) {
95
103
  blocks.push(currentBlock)
96
104
  currentBlock = []
@@ -149,7 +157,7 @@ const normalizeCommentBlock = (block, originalLines) => {
149
157
  const indent = firstLine.match(/^(\s*)/)[1]
150
158
 
151
159
  //============================================================//
152
- // Extract the text content from each comment
160
+ // Extract the text content from each comment (skip borders)
153
161
  //============================================================//
154
162
  const bodyLines = []
155
163
  let firstLineWithTextFound = false
@@ -189,6 +197,20 @@ const normalizeCommentBlock = (block, originalLines) => {
189
197
  })
190
198
  result.push(indent + BORDER_LINE)
191
199
 
200
+ //============================================================//
201
+ // Compare with existing - skip if already correctly formatted
202
+ //============================================================//
203
+ const startLine = block[0].loc.start.line - 1
204
+ const endLine = block[block.length - 1].loc.start.line - 1
205
+ const existingLines = originalLines.slice(startLine, endLine + 1)
206
+
207
+ //============================================================//
208
+ // Check if existing lines match the result exactly
209
+ //============================================================//
210
+ if (existingLines.length === result.length && existingLines.every((line, i) => line === result[i])) {
211
+ return null
212
+ }
213
+
192
214
  return result
193
215
  }
194
216
 
data/package.json CHANGED
@@ -4,8 +4,8 @@
4
4
  "dependencies": {
5
5
  "@babel/parser": "^7.28.5",
6
6
  "@eslint/js": "^9.39.1",
7
- "@typescript-eslint/eslint-plugin": "^8.48.1",
8
- "@typescript-eslint/parser": "^8.48.1",
7
+ "@typescript-eslint/eslint-plugin": "^8.49.0",
8
+ "@typescript-eslint/parser": "^8.49.0",
9
9
  "eslint": "^9.39.1",
10
10
  "eslint-plugin-align-assignments": "^1.1.2",
11
11
  "eslint-plugin-align-import": "^1.0.0",
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.95
4
+ version: 0.1.96
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubygems_version: 4.0.0
183
+ rubygems_version: 4.0.1
184
184
  specification_version: 4
185
185
  summary: A gem to lint and organize files in a Rails application.
186
186
  test_files: []