@tsslint/cli 1.4.2 → 1.4.4
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 +34 -14
- package/lib/worker.d.ts +1 -1
- package/lib/worker.js +4 -6
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -15,6 +15,11 @@ const darkGray = (s) => '\x1b[90m' + s + _reset;
|
|
|
15
15
|
const lightRed = (s) => '\x1b[91m' + s + _reset;
|
|
16
16
|
const lightGreen = (s) => '\x1b[92m' + s + _reset;
|
|
17
17
|
const lightYellow = (s) => '\x1b[93m' + s + _reset;
|
|
18
|
+
// https://talyian.github.io/ansicolors/
|
|
19
|
+
const tsColor = (s) => '\x1b[34m' + s + _reset;
|
|
20
|
+
const vueColor = (s) => '\x1b[32m' + s + _reset;
|
|
21
|
+
const mdxColor = (s) => '\x1b[33m' + s + _reset;
|
|
22
|
+
const astroColor = (s) => '\x1b[38;5;209m' + s + _reset;
|
|
18
23
|
let threads = 1;
|
|
19
24
|
if (process.argv.includes('--threads')) {
|
|
20
25
|
const threadsIndex = process.argv.indexOf('--threads');
|
|
@@ -45,18 +50,34 @@ class Project {
|
|
|
45
50
|
// @ts-expect-error
|
|
46
51
|
clack) {
|
|
47
52
|
this.configFile = ts.findConfigFile(path.dirname(this.tsconfig), ts.sys.fileExists, 'tsslint.config.ts');
|
|
53
|
+
const labels = [];
|
|
54
|
+
if (this.languages.length === 0) {
|
|
55
|
+
labels.push(tsColor('TS'));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (this.languages.includes('vue')) {
|
|
59
|
+
labels.push(vueColor('Vue'));
|
|
60
|
+
}
|
|
61
|
+
if (this.languages.includes('mdx')) {
|
|
62
|
+
labels.push(mdxColor('MDX'));
|
|
63
|
+
}
|
|
64
|
+
if (this.languages.includes('astro')) {
|
|
65
|
+
labels.push(astroColor('Astro'));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const label = labels.join(darkGray(' | '));
|
|
48
69
|
if (!this.configFile) {
|
|
49
|
-
clack.log.error(`${
|
|
70
|
+
clack.log.error(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${darkGray('(No tsslint.config.ts found)')}`);
|
|
50
71
|
return this;
|
|
51
72
|
}
|
|
52
73
|
const commonLine = await parseCommonLine(this.tsconfig, this.languages);
|
|
53
74
|
this.fileNames = commonLine.fileNames;
|
|
54
75
|
this.options = commonLine.options;
|
|
55
76
|
if (!this.fileNames.length) {
|
|
56
|
-
clack.log.warn(`${
|
|
77
|
+
clack.log.warn(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${darkGray('(No included files)')}`);
|
|
57
78
|
return this;
|
|
58
79
|
}
|
|
59
|
-
clack.log.info(`${
|
|
80
|
+
clack.log.info(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${darkGray(`(${this.fileNames.length})`)}`);
|
|
60
81
|
if (!process.argv.includes('--force')) {
|
|
61
82
|
this.cache = cache.loadCache(this.tsconfig, this.configFile, ts.sys.createHash);
|
|
62
83
|
}
|
|
@@ -314,16 +335,15 @@ class Project {
|
|
|
314
335
|
if (fileCache[0] !== fileMtime) {
|
|
315
336
|
fileCache[0] = fileMtime;
|
|
316
337
|
fileCache[1] = {};
|
|
317
|
-
fileCache[2]
|
|
318
|
-
fileCache[3]
|
|
319
|
-
fileCache[4] = {};
|
|
338
|
+
fileCache[2] = {};
|
|
339
|
+
fileCache[3] = {};
|
|
320
340
|
}
|
|
321
341
|
else {
|
|
322
342
|
cached++;
|
|
323
343
|
}
|
|
324
344
|
}
|
|
325
345
|
else {
|
|
326
|
-
project.cache[fileName] = fileCache = [fileMtime, {},
|
|
346
|
+
project.cache[fileName] = fileCache = [fileMtime, {}, {}, {}];
|
|
327
347
|
}
|
|
328
348
|
let diagnostics;
|
|
329
349
|
if (process.argv.includes('--fix')) {
|
|
@@ -332,17 +352,17 @@ class Project {
|
|
|
332
352
|
else {
|
|
333
353
|
diagnostics = await linterWorker.lint(fileName, fileCache);
|
|
334
354
|
}
|
|
355
|
+
diagnostics = diagnostics.filter(diagnostic => diagnostic.category !== ts.DiagnosticCategory.Suggestion);
|
|
335
356
|
if (diagnostics.length) {
|
|
336
|
-
hasFix ||=
|
|
357
|
+
hasFix ||= await linterWorker.hasCodeFixes(fileName);
|
|
337
358
|
for (const diagnostic of diagnostics) {
|
|
338
|
-
|
|
339
|
-
continue;
|
|
340
|
-
}
|
|
359
|
+
hasFix ||= !!fileCache[1][diagnostic.code];
|
|
341
360
|
let output = ts.formatDiagnosticsWithColorAndContext([diagnostic], {
|
|
342
361
|
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
343
362
|
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? x => x : x => x.toLowerCase(),
|
|
344
363
|
getNewLine: () => ts.sys.newLine,
|
|
345
364
|
});
|
|
365
|
+
output = output.trimEnd();
|
|
346
366
|
output = output.replace(`TS${diagnostic.code}`, String(diagnostic.code));
|
|
347
367
|
if (diagnostic.category === ts.DiagnosticCategory.Error) {
|
|
348
368
|
errors++;
|
|
@@ -357,7 +377,7 @@ class Project {
|
|
|
357
377
|
}
|
|
358
378
|
}
|
|
359
379
|
}
|
|
360
|
-
else if (!(await linterWorker.hasRules(fileName, fileCache[
|
|
380
|
+
else if (!(await linterWorker.hasRules(fileName, fileCache[3]))) {
|
|
361
381
|
excluded++;
|
|
362
382
|
}
|
|
363
383
|
else {
|
|
@@ -386,10 +406,10 @@ class Project {
|
|
|
386
406
|
function updateSpinner() {
|
|
387
407
|
if (processFiles.size === 1) {
|
|
388
408
|
const fileName = processFiles.values().next().value;
|
|
389
|
-
spinner.message(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), fileName)}`);
|
|
409
|
+
spinner.message(darkGray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), fileName)}`));
|
|
390
410
|
}
|
|
391
411
|
else {
|
|
392
|
-
spinner.message(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`);
|
|
412
|
+
spinner.message(darkGray(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`));
|
|
393
413
|
}
|
|
394
414
|
}
|
|
395
415
|
function log(msg, code) {
|
package/lib/worker.d.ts
CHANGED
|
@@ -18,5 +18,5 @@ declare function setup(tsconfig: string, languages: string[], configFile: string
|
|
|
18
18
|
declare function lintAndFix(fileName: string, fileCache: core.FileLintCache): readonly [ts.DiagnosticWithLocation[], core.FileLintCache];
|
|
19
19
|
declare function lint(fileName: string, fileCache: core.FileLintCache): readonly [ts.DiagnosticWithLocation[], core.FileLintCache];
|
|
20
20
|
declare function hasCodeFixes(fileName: string): boolean;
|
|
21
|
-
declare function hasRules(fileName: string, minimatchCache: core.FileLintCache[
|
|
21
|
+
declare function hasRules(fileName: string, minimatchCache: core.FileLintCache[3]): readonly [boolean, Record<string, boolean>];
|
|
22
22
|
export {};
|
package/lib/worker.js
CHANGED
|
@@ -192,7 +192,7 @@ async function setup(tsconfig, languages, configFile, builtConfig, _fileNames, _
|
|
|
192
192
|
languageServiceHost: linterHost,
|
|
193
193
|
typescript: ts,
|
|
194
194
|
tsconfig: ts.server.toNormalizedPath(tsconfig),
|
|
195
|
-
}, config, 'cli'
|
|
195
|
+
}, config, 'cli');
|
|
196
196
|
return true;
|
|
197
197
|
}
|
|
198
198
|
function lintAndFix(fileName, fileCache) {
|
|
@@ -204,12 +204,11 @@ function lintAndFix(fileName, fileCache) {
|
|
|
204
204
|
if (Object.values(fileCache[1]).some(fixes => fixes > 0)) {
|
|
205
205
|
// Reset the cache if there are any fixes applied.
|
|
206
206
|
fileCache[1] = {};
|
|
207
|
-
fileCache[2]
|
|
208
|
-
fileCache[3].length = 0;
|
|
207
|
+
fileCache[2] = {};
|
|
209
208
|
}
|
|
210
209
|
diagnostics = linter.lint(fileName, fileCache);
|
|
211
210
|
let fixes = linter
|
|
212
|
-
.getCodeFixes(fileName, 0, Number.MAX_VALUE, diagnostics, fileCache[
|
|
211
|
+
.getCodeFixes(fileName, 0, Number.MAX_VALUE, diagnostics, fileCache[3])
|
|
213
212
|
.filter(fix => fix.fixId === 'tsslint');
|
|
214
213
|
if (language) {
|
|
215
214
|
fixes = fixes.map(fix => {
|
|
@@ -231,8 +230,7 @@ function lintAndFix(fileName, fileCache) {
|
|
|
231
230
|
ts.sys.writeFile(fileName, newSnapshot.getText(0, newSnapshot.getLength()));
|
|
232
231
|
fileCache[0] = fs.statSync(fileName).mtimeMs;
|
|
233
232
|
fileCache[1] = {};
|
|
234
|
-
fileCache[2]
|
|
235
|
-
fileCache[3].length = 0;
|
|
233
|
+
fileCache[2] = {};
|
|
236
234
|
}
|
|
237
235
|
if (shouldRetry) {
|
|
238
236
|
diagnostics = linter.lint(fileName, fileCache);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/cli",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsslint": "./bin/tsslint.js"
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@clack/prompts": "^0.8.2",
|
|
19
|
-
"@tsslint/config": "1.4.
|
|
20
|
-
"@tsslint/core": "1.4.
|
|
19
|
+
"@tsslint/config": "1.4.4",
|
|
20
|
+
"@tsslint/core": "1.4.4",
|
|
21
21
|
"@volar/language-core": "~2.4.0",
|
|
22
22
|
"@volar/typescript": "~2.4.0",
|
|
23
23
|
"glob": "^10.4.1"
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@vue/language-core": "latest"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "7e4401c6734fd2b8d09d9aa45584e83e3ecf9e48"
|
|
32
32
|
}
|