@@ -152,7 +152,7 @@ normalize_yaml_config() {
152152# Normalize ESLint configuration files (.mjs/.js)
153153normalize_eslint_config () {
154154 local file=$1
155- # Sort the rule lines within the rules object for consistent comparison
155+ # Sort the rule lines within the rules object and normalize JSON object properties
156156 awk '
157157 /rules: \{/ {
158158 print;
@@ -171,8 +171,49 @@ normalize_eslint_config() {
171171 next
172172 }
173173 inRules {
174+ # Normalize JSON object properties within rule configurations
175+ line = $0
176+ # Look for JSON objects like {"key1": value1, "key2": value2}
177+ if (match(line, /\{[^}]*\}/)) {
178+ # Extract the JSON object
179+ obj_start = RSTART
180+ obj_len = RLENGTH
181+ before = substr(line, 1, obj_start-1)
182+ obj = substr(line, obj_start, obj_len)
183+ after = substr(line, obj_start+obj_len)
184+
185+ # Parse and sort the object properties
186+ if (match(obj, /^\{.*\}$/)) {
187+ # Remove braces and split by comma
188+ content = substr(obj, 2, length(obj)-2)
189+ gsub(/^\s+|\s+$/, "", content) # trim spaces
190+
191+ if (content != "") {
192+ # Split by comma (simple approach)
193+ n = split(content, parts, /,\s*/)
194+ # Sort the parts
195+ for (i = 1; i <= n; i++) {
196+ for (j = i+1; j <= n; j++) {
197+ if (parts[i] > parts[j]) {
198+ temp = parts[i]
199+ parts[i] = parts[j]
200+ parts[j] = temp
201+ }
202+ }
203+ }
204+ # Reconstruct the object
205+ new_obj = "{"
206+ for (i = 1; i <= n; i++) {
207+ if (i > 1) new_obj = new_obj ", "
208+ new_obj = new_obj parts[i]
209+ }
210+ new_obj = new_obj "}"
211+ line = before new_obj after
212+ }
213+ }
214+ }
174215 # Collect rule lines for sorting
175- rules[NR] = $0
216+ rules[NR] = line
176217 next
177218 }
178219 { print }
0 commit comments