@tsslint/cli 1.4.3 → 1.4.5
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 +8 -11
- package/lib/worker.d.ts +1 -1
- package/lib/worker.js +11 -7
- package/package.json +4 -4
package/index.js
CHANGED
|
@@ -335,16 +335,14 @@ class Project {
|
|
|
335
335
|
if (fileCache[0] !== fileMtime) {
|
|
336
336
|
fileCache[0] = fileMtime;
|
|
337
337
|
fileCache[1] = {};
|
|
338
|
-
fileCache[2]
|
|
339
|
-
fileCache[3].length = 0;
|
|
340
|
-
fileCache[4] = {};
|
|
338
|
+
fileCache[2] = {};
|
|
341
339
|
}
|
|
342
340
|
else {
|
|
343
341
|
cached++;
|
|
344
342
|
}
|
|
345
343
|
}
|
|
346
344
|
else {
|
|
347
|
-
project.cache[fileName] = fileCache = [fileMtime, {},
|
|
345
|
+
project.cache[fileName] = fileCache = [fileMtime, {}, {}];
|
|
348
346
|
}
|
|
349
347
|
let diagnostics;
|
|
350
348
|
if (process.argv.includes('--fix')) {
|
|
@@ -353,12 +351,11 @@ class Project {
|
|
|
353
351
|
else {
|
|
354
352
|
diagnostics = await linterWorker.lint(fileName, fileCache);
|
|
355
353
|
}
|
|
354
|
+
diagnostics = diagnostics.filter(diagnostic => diagnostic.category !== ts.DiagnosticCategory.Suggestion);
|
|
356
355
|
if (diagnostics.length) {
|
|
357
|
-
hasFix ||=
|
|
356
|
+
hasFix ||= await linterWorker.hasCodeFixes(fileName);
|
|
358
357
|
for (const diagnostic of diagnostics) {
|
|
359
|
-
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
358
|
+
hasFix ||= !!fileCache[1][diagnostic.code]?.[0];
|
|
362
359
|
let output = ts.formatDiagnosticsWithColorAndContext([diagnostic], {
|
|
363
360
|
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
364
361
|
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? x => x : x => x.toLowerCase(),
|
|
@@ -379,7 +376,7 @@ class Project {
|
|
|
379
376
|
}
|
|
380
377
|
}
|
|
381
378
|
}
|
|
382
|
-
else if (!(await linterWorker.hasRules(fileName, fileCache[
|
|
379
|
+
else if (!(await linterWorker.hasRules(fileName, fileCache[2]))) {
|
|
383
380
|
excluded++;
|
|
384
381
|
}
|
|
385
382
|
else {
|
|
@@ -408,10 +405,10 @@ class Project {
|
|
|
408
405
|
function updateSpinner() {
|
|
409
406
|
if (processFiles.size === 1) {
|
|
410
407
|
const fileName = processFiles.values().next().value;
|
|
411
|
-
spinner.message(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), fileName)}`);
|
|
408
|
+
spinner.message(darkGray(`[${processed + processFiles.size}/${allFilesNum}] ${path.relative(process.cwd(), fileName)}`));
|
|
412
409
|
}
|
|
413
410
|
else {
|
|
414
|
-
spinner.message(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`);
|
|
411
|
+
spinner.message(darkGray(`[${processed + processFiles.size}/${allFilesNum}] Processing ${processFiles.size} files`));
|
|
415
412
|
}
|
|
416
413
|
}
|
|
417
414
|
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[2]): readonly [boolean, Record<string, boolean>];
|
|
22
22
|
export {};
|
package/lib/worker.js
CHANGED
|
@@ -18,6 +18,7 @@ let fileNames = [];
|
|
|
18
18
|
let language;
|
|
19
19
|
let linter;
|
|
20
20
|
let linterLanguageService;
|
|
21
|
+
let linterSyntaxOnlyLanguageService;
|
|
21
22
|
const snapshots = new Map();
|
|
22
23
|
const versions = new Map();
|
|
23
24
|
const originalHost = {
|
|
@@ -68,6 +69,7 @@ const originalHost = {
|
|
|
68
69
|
};
|
|
69
70
|
const linterHost = { ...originalHost };
|
|
70
71
|
const originalService = ts.createLanguageService(linterHost);
|
|
72
|
+
const originalSyntaxOnlyService = ts.createLanguageService(linterHost, undefined, true);
|
|
71
73
|
function createLocal() {
|
|
72
74
|
return {
|
|
73
75
|
setup(...args) {
|
|
@@ -159,6 +161,7 @@ async function setup(tsconfig, languages, configFile, builtConfig, _fileNames, _
|
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
linterLanguageService = originalService;
|
|
164
|
+
linterSyntaxOnlyLanguageService = originalSyntaxOnlyService;
|
|
162
165
|
language = undefined;
|
|
163
166
|
const plugins = await languagePlugins.load(tsconfig, languages);
|
|
164
167
|
if (plugins.length) {
|
|
@@ -176,6 +179,9 @@ async function setup(tsconfig, languages, configFile, builtConfig, _fileNames, _
|
|
|
176
179
|
const proxy = (0, typescript_1.createProxyLanguageService)(linterLanguageService);
|
|
177
180
|
proxy.initialize(language);
|
|
178
181
|
linterLanguageService = proxy.proxy;
|
|
182
|
+
const syntaxOnly = (0, typescript_1.createProxyLanguageService)(linterSyntaxOnlyLanguageService);
|
|
183
|
+
syntaxOnly.initialize(language);
|
|
184
|
+
linterSyntaxOnlyLanguageService = syntaxOnly.proxy;
|
|
179
185
|
}
|
|
180
186
|
projectVersion++;
|
|
181
187
|
typeRootsVersion++;
|
|
@@ -192,7 +198,7 @@ async function setup(tsconfig, languages, configFile, builtConfig, _fileNames, _
|
|
|
192
198
|
languageServiceHost: linterHost,
|
|
193
199
|
typescript: ts,
|
|
194
200
|
tsconfig: ts.server.toNormalizedPath(tsconfig),
|
|
195
|
-
}, config, 'cli');
|
|
201
|
+
}, config, 'cli', linterSyntaxOnlyLanguageService);
|
|
196
202
|
return true;
|
|
197
203
|
}
|
|
198
204
|
function lintAndFix(fileName, fileCache) {
|
|
@@ -201,15 +207,14 @@ function lintAndFix(fileName, fileCache) {
|
|
|
201
207
|
let newSnapshot;
|
|
202
208
|
let diagnostics;
|
|
203
209
|
while (shouldRetry && retry--) {
|
|
204
|
-
if (Object.values(fileCache[1]).some(
|
|
210
|
+
if (Object.values(fileCache[1]).some(([hasFix]) => hasFix)) {
|
|
205
211
|
// Reset the cache if there are any fixes applied.
|
|
206
212
|
fileCache[1] = {};
|
|
207
|
-
fileCache[2]
|
|
208
|
-
fileCache[3].length = 0;
|
|
213
|
+
fileCache[2] = {};
|
|
209
214
|
}
|
|
210
215
|
diagnostics = linter.lint(fileName, fileCache);
|
|
211
216
|
let fixes = linter
|
|
212
|
-
.getCodeFixes(fileName, 0, Number.MAX_VALUE, diagnostics, fileCache[
|
|
217
|
+
.getCodeFixes(fileName, 0, Number.MAX_VALUE, diagnostics, fileCache[2])
|
|
213
218
|
.filter(fix => fix.fixId === 'tsslint');
|
|
214
219
|
if (language) {
|
|
215
220
|
fixes = fixes.map(fix => {
|
|
@@ -231,8 +236,7 @@ function lintAndFix(fileName, fileCache) {
|
|
|
231
236
|
ts.sys.writeFile(fileName, newSnapshot.getText(0, newSnapshot.getLength()));
|
|
232
237
|
fileCache[0] = fs.statSync(fileName).mtimeMs;
|
|
233
238
|
fileCache[1] = {};
|
|
234
|
-
fileCache[2]
|
|
235
|
-
fileCache[3].length = 0;
|
|
239
|
+
fileCache[2] = {};
|
|
236
240
|
}
|
|
237
241
|
if (shouldRetry) {
|
|
238
242
|
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.5",
|
|
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.5",
|
|
20
|
+
"@tsslint/core": "1.4.5",
|
|
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": "e8f0b027ff4e15d2633efd15c08bf2054896cf1b"
|
|
32
32
|
}
|