immosquare-cleaner 0.1.94 → 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/lib/immosquare-cleaner.rb +1 -1
- data/lib/tasks/immosquare_cleaner.rake +10 -1
- data/linters/normalize-comments.mjs +37 -3
- 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
|
data/lib/immosquare-cleaner.rb
CHANGED
|
@@ -168,7 +168,7 @@ module ImmosquareCleaner
|
|
|
168
168
|
File.write(temp_file_path, File.read(file_path))
|
|
169
169
|
cmds = []
|
|
170
170
|
cmds << "bundle exec erb_lint --config #{erblint_config_with_version_path} #{file_path} #{ImmosquareCleaner.configuration.erblint_options || "--autocorrect"}" if file_path.end_with?(".erb")
|
|
171
|
-
cmds << "bun #{gem_root}/linters/normalize-comments.mjs #{temp_file_path}"
|
|
171
|
+
cmds << "bun #{gem_root}/linters/normalize-comments.mjs #{temp_file_path}" if !file_path.end_with?(".erb")
|
|
172
172
|
cmds << "bun eslint --config #{gem_root}/linters/eslint.config.mjs #{temp_file_path} --fix"
|
|
173
173
|
|
|
174
174
|
launch_cmds(cmds)
|
|
@@ -21,8 +21,17 @@ namespace :immosquare_cleaner do
|
|
|
21
21
|
".lock",
|
|
22
22
|
".lockb",
|
|
23
23
|
".otf",
|
|
24
|
-
".ttf"
|
|
24
|
+
".ttf",
|
|
25
|
+
".png",
|
|
26
|
+
".jpg",
|
|
27
|
+
".jpeg",
|
|
28
|
+
".gif",
|
|
29
|
+
".svg",
|
|
30
|
+
".ico",
|
|
31
|
+
".webp",
|
|
32
|
+
".csv"
|
|
25
33
|
]
|
|
34
|
+
|
|
26
35
|
file_paths = Dir.glob("#{Rails.root}/**/*").reject do |file_path|
|
|
27
36
|
File.directory?(file_path) || file_path.gsub("#{Rails.root}/", "").start_with?(*paths_to_exclude) || file_path.end_with?(*extensions_to_exclude)
|
|
28
37
|
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
|
-
|
|
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) {
|
|
@@ -87,6 +94,19 @@ const groupConsecutiveComments = (comments, originalLines) => {
|
|
|
87
94
|
return
|
|
88
95
|
}
|
|
89
96
|
|
|
97
|
+
//============================================================//
|
|
98
|
+
// Skip Sprockets directives (//= link, //= require, etc.)
|
|
99
|
+
// These start with "= " followed by a directive keyword
|
|
100
|
+
//============================================================//
|
|
101
|
+
if (/^=\s*\w/.test(comment.value)) {
|
|
102
|
+
if (currentBlock.length > 0) {
|
|
103
|
+
blocks.push(currentBlock)
|
|
104
|
+
currentBlock = []
|
|
105
|
+
}
|
|
106
|
+
lastLine = -2
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
90
110
|
//============================================================//
|
|
91
111
|
// Check if this is a standalone comment (line starts with //)
|
|
92
112
|
// Skip end-of-line comments (e.g., const x = 1 // comment)
|
|
@@ -137,7 +157,7 @@ const normalizeCommentBlock = (block, originalLines) => {
|
|
|
137
157
|
const indent = firstLine.match(/^(\s*)/)[1]
|
|
138
158
|
|
|
139
159
|
//============================================================//
|
|
140
|
-
// Extract the text content from each comment
|
|
160
|
+
// Extract the text content from each comment (skip borders)
|
|
141
161
|
//============================================================//
|
|
142
162
|
const bodyLines = []
|
|
143
163
|
let firstLineWithTextFound = false
|
|
@@ -177,6 +197,20 @@ const normalizeCommentBlock = (block, originalLines) => {
|
|
|
177
197
|
})
|
|
178
198
|
result.push(indent + BORDER_LINE)
|
|
179
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
|
+
|
|
180
214
|
return result
|
|
181
215
|
}
|
|
182
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: []
|