tz-clean 2.3.3 → 2.4.0
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/index.js +31 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -120,12 +120,28 @@ async function run() {
|
|
|
120
120
|
if (excludePaths.length > 0) console.log(`🚫 Exclude: ${excludePaths.join(', ')}`);
|
|
121
121
|
|
|
122
122
|
try {
|
|
123
|
+
process.stdout.write('⏳ [1/4] Running Prettier...');
|
|
123
124
|
const fixedFiles = runPrettier ? runPrettierTools(includePaths, excludePaths) : [];
|
|
125
|
+
process.stdout.write(`\r✅ [1/4] Prettier done (${fixedFiles.length} file(s) formatted) \n`);
|
|
126
|
+
|
|
127
|
+
process.stdout.write('⏳ [2/4] Stripping comments...');
|
|
124
128
|
const strippedFiles = stripCommentsAndEmptyLines(includePaths, excludePaths);
|
|
129
|
+
process.stdout.write(`\r✅ [2/4] Comments stripped (${strippedFiles.length} file(s) modified) \n`);
|
|
130
|
+
|
|
125
131
|
const allFixedFiles = [...new Set([...fixedFiles, ...strippedFiles])];
|
|
132
|
+
|
|
133
|
+
process.stdout.write('⏳ [3/4] Running Typecheck...');
|
|
126
134
|
const typecheckResult = runTypecheck ? runTypecheckTools() : { error: null, ran: false };
|
|
135
|
+
let typecheckStatus = 'skipped';
|
|
136
|
+
if (typecheckResult.ran) {
|
|
137
|
+
typecheckStatus = typecheckResult.error ? 'failed' : 'passed';
|
|
138
|
+
}
|
|
139
|
+
process.stdout.write(`\r✅ [3/4] Typecheck ${typecheckStatus} \n`);
|
|
140
|
+
|
|
141
|
+
process.stdout.write('⏳ [4/4] Running ESLint...');
|
|
127
142
|
const reportData = runEslint ? runEslintTools(includePaths, excludePaths) : [];
|
|
128
143
|
const { totalErrors, totalWarnings } = calculateTotals(reportData);
|
|
144
|
+
process.stdout.write(`\r✅ [4/4] ESLint done (${totalErrors} error(s), ${totalWarnings} warning(s)) \n`);
|
|
129
145
|
|
|
130
146
|
console.log('\n✅ Analysis complete!');
|
|
131
147
|
const response = await prompts({
|
|
@@ -259,6 +275,13 @@ function serveHostedReport(html) {
|
|
|
259
275
|
});
|
|
260
276
|
}
|
|
261
277
|
|
|
278
|
+
function skipLineComment(source, startIndex) {
|
|
279
|
+
let i = startIndex + 2;
|
|
280
|
+
const len = source.length;
|
|
281
|
+
while (i < len && source[i] !== '\n') i++;
|
|
282
|
+
return i;
|
|
283
|
+
}
|
|
284
|
+
|
|
262
285
|
function skipStringLiteral(source, startIndex) {
|
|
263
286
|
const quote = source[startIndex];
|
|
264
287
|
let i = startIndex + 1;
|
|
@@ -326,6 +349,13 @@ function stripCommentsFromSource(source) {
|
|
|
326
349
|
let i = 0;
|
|
327
350
|
const len = source.length;
|
|
328
351
|
|
|
352
|
+
if (source.startsWith('#!')) {
|
|
353
|
+
const end = source.indexOf('\n');
|
|
354
|
+
const shebanEnd = end === -1 ? len : end + 1;
|
|
355
|
+
result += source.slice(0, shebanEnd);
|
|
356
|
+
i = shebanEnd;
|
|
357
|
+
}
|
|
358
|
+
|
|
329
359
|
while (i < len) {
|
|
330
360
|
const ch = source[i];
|
|
331
361
|
|
|
@@ -342,8 +372,7 @@ function stripCommentsFromSource(source) {
|
|
|
342
372
|
}
|
|
343
373
|
|
|
344
374
|
if (ch === '/' && source[i + 1] === '/') {
|
|
345
|
-
i
|
|
346
|
-
while (i < len && source[i] !== '\n') i++;
|
|
375
|
+
i = skipLineComment(source, i);
|
|
347
376
|
continue;
|
|
348
377
|
}
|
|
349
378
|
|