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 +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/linters/normalize-comments.mjs +26 -4
- data/package.json +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9e023cd5eb031877e0c2d9c6e4831ddbf69634b25aa18f963125ff6f45ef886
|
|
4
|
+
data.tar.gz: dd026d694d3087313daba0df8324825f8bdfa1644cf1162d7aa232d650770f1d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f5baba5f2baf7162b9125f95bc7efd7b3f4d6ddbd1e71c9835f4e65b78aee6df735f4d36104d18ddfd3770af8017bbb5396461d6b6975760e120f082c37e73ee
|
|
7
|
+
data.tar.gz: 5054ed1b8398d2444dba17d78fb6d4bc5e99f61a87751459603a10463ceb13f6dad69c7ba2268b2a4dc215479852f063238a6fbfe118bd7fb36a8194d6982133
|
|
@@ -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
|
-
|
|
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
|
|
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.
|
|
8
|
-
"@typescript-eslint/parser": "^8.
|
|
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.
|
|
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.
|
|
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: []
|