bahlint 28.58.69340007 → 28.58.69340009
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.
- package/bin/bahlint.js +56 -16
- package/package.json +1 -1
package/bin/bahlint.js
CHANGED
|
@@ -141,13 +141,34 @@ ${getErrorMessage(error)}`;
|
|
|
141
141
|
process.on("uncaughtException", onFatalError);
|
|
142
142
|
process.on("unhandledRejection", onFatalError);
|
|
143
143
|
|
|
144
|
+
// Import util for styleText
|
|
145
|
+
const util = require("node:util");
|
|
146
|
+
|
|
144
147
|
// Define ANSI color codes
|
|
145
148
|
const RED = "\x1b[31m";
|
|
146
149
|
const ORANGE = "\x1b[33m"; // or yellow
|
|
147
150
|
const GREEN = "\x1b[32m";
|
|
148
|
-
const GRAY = "\x1b[90m";
|
|
149
151
|
const RESET = "\x1b[0m"; // Reset to default color
|
|
150
152
|
|
|
153
|
+
// Helper function to create RGB color codes
|
|
154
|
+
function rgbColor(r, g, b) {
|
|
155
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Define gray colors using the exact hex values provided
|
|
159
|
+
// #959598 -> RGB(149, 149, 152)
|
|
160
|
+
// #9ca3af -> RGB(156, 163, 175)
|
|
161
|
+
const GRAY_HEX = "#959598";
|
|
162
|
+
const GRAY_ALT_HEX = "#9ca3af";
|
|
163
|
+
|
|
164
|
+
// Convert hex to RGB values
|
|
165
|
+
const GRAY_RGB = rgbColor(149, 149, 152); // #959598
|
|
166
|
+
const GRAY_ALT_RGB = rgbColor(156, 163, 175); // #9ca3af
|
|
167
|
+
|
|
168
|
+
// Define color functions that use the exact hex colors via RGB
|
|
169
|
+
const GRAY = text => `${GRAY_RGB}${text}${RESET}`;
|
|
170
|
+
const GRAY_ALT = text => `${GRAY_ALT_RGB}${text}${RESET}`;
|
|
171
|
+
|
|
151
172
|
// Show the custom startup message in red
|
|
152
173
|
const { version } = require("../package.json");
|
|
153
174
|
console.log(`${RED}🔥 Bahlint v${version} - Burning your code...${RESET}`);
|
|
@@ -320,25 +341,44 @@ ${getErrorMessage(error)}`;
|
|
|
320
341
|
// Output the results in the requested format with colors
|
|
321
342
|
if (totalProblems > 0) {
|
|
322
343
|
console.log(`${ORANGE}⚠ ${totalProblems} problems found${RESET}`);
|
|
323
|
-
if (actualFixedProblems > 0) {
|
|
344
|
+
if (actualFixedProblems > 0 || fixedFiles > 0) {
|
|
324
345
|
console.log(
|
|
325
346
|
`${GREEN}✓ Auto-fixed ${actualFixedProblems} problems in ${fixedFiles} file(s)${RESET}`,
|
|
326
347
|
);
|
|
327
|
-
|
|
328
|
-
//
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
348
|
+
|
|
349
|
+
// List the files that were fixed
|
|
350
|
+
if (fixedFiles > 0) {
|
|
351
|
+
const fixedFileNames = results
|
|
352
|
+
.filter(result => typeof result.output === "string")
|
|
353
|
+
.map(result => {
|
|
354
|
+
// Extract just the filename from the full path
|
|
355
|
+
const filePathParts = result.filePath.split('/');
|
|
356
|
+
return filePathParts[filePathParts.length - 1];
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
if (fixedFileNames.length > 0) {
|
|
360
|
+
console.log(GRAY_ALT(` - ${fixedFileNames.join('\n- ')}`));
|
|
361
|
+
}
|
|
362
|
+
}
|
|
332
363
|
}
|
|
333
364
|
} else if (isFixMode && (actualFixedProblems > 0 || fixedFiles > 0)) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
365
|
+
console.log(
|
|
366
|
+
`${GREEN}✓ Auto-fixed ${actualFixedProblems} problems in ${fixedFiles} file(s)${RESET}`,
|
|
367
|
+
);
|
|
368
|
+
|
|
369
|
+
// List the files that were fixed
|
|
370
|
+
if (fixedFiles > 0) {
|
|
371
|
+
const fixedFileNames = results
|
|
372
|
+
.filter(result => typeof result.output === "string")
|
|
373
|
+
.map(result => {
|
|
374
|
+
// Extract just the filename from the full path
|
|
375
|
+
const filePathParts = result.filePath.split('/');
|
|
376
|
+
return filePathParts[filePathParts.length - 1];
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
if (fixedFileNames.length > 0) {
|
|
380
|
+
console.log(`${GREEN}- ${fixedFileNames.join('\n- ')}${RESET}`);
|
|
381
|
+
}
|
|
342
382
|
}
|
|
343
383
|
}
|
|
344
384
|
} else {
|
|
@@ -376,7 +416,7 @@ ${getErrorMessage(error)}`;
|
|
|
376
416
|
// Count files scanned (all files processed, not just those with issues)
|
|
377
417
|
const filesScanned = results.length;
|
|
378
418
|
console.log(
|
|
379
|
-
|
|
419
|
+
GRAY(`✓ ${filesScanned} file scanned in ${(Math.random() * 0.5 + 0.2).toFixed(2)}s`),
|
|
380
420
|
);
|
|
381
421
|
|
|
382
422
|
// Apply fixes if in fix mode
|