@tsslint/cli 2.0.5 → 2.0.6
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 +38 -23
- package/package.json +6 -5
package/index.js
CHANGED
|
@@ -8,6 +8,7 @@ const worker = require("./lib/worker.js");
|
|
|
8
8
|
const glob = require("glob");
|
|
9
9
|
const fs = require("fs");
|
|
10
10
|
const os = require("os");
|
|
11
|
+
const minimatch = require("minimatch");
|
|
11
12
|
const languagePlugins = require("./lib/languagePlugins.js");
|
|
12
13
|
process.env.TSSLINT_CLI = '1';
|
|
13
14
|
const _reset = '\x1b[0m';
|
|
@@ -39,6 +40,13 @@ class Project {
|
|
|
39
40
|
constructor(tsconfig, languages) {
|
|
40
41
|
this.tsconfig = tsconfig;
|
|
41
42
|
this.languages = languages;
|
|
43
|
+
/**
|
|
44
|
+
* file names for passing to ts language service host (getScriptFileNames)
|
|
45
|
+
*/
|
|
46
|
+
this.rawFileNames = [];
|
|
47
|
+
/**
|
|
48
|
+
* file names after filter, for linting process
|
|
49
|
+
*/
|
|
42
50
|
this.fileNames = [];
|
|
43
51
|
this.options = {};
|
|
44
52
|
this.currentFileIndex = 0;
|
|
@@ -75,21 +83,23 @@ class Project {
|
|
|
75
83
|
return this;
|
|
76
84
|
}
|
|
77
85
|
const commonLine = await parseCommonLine(this.tsconfig, this.languages);
|
|
78
|
-
this.
|
|
86
|
+
this.rawFileNames = commonLine.fileNames;
|
|
79
87
|
this.options = commonLine.options;
|
|
80
|
-
if (!this.
|
|
88
|
+
if (!this.rawFileNames.length) {
|
|
81
89
|
clack.log.message(`${label} ${gray(path.relative(process.cwd(), this.tsconfig))} ${gray('(0)')}`);
|
|
82
90
|
return this;
|
|
83
91
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.fileNames = this.fileNames.filter(f => filesFilter.has(f));
|
|
92
|
+
if (filesFilter.length) {
|
|
93
|
+
this.fileNames = this.rawFileNames.filter(fileName => filesFilter.some(filter => minimatch.minimatch(fileName, filter, { dot: true })));
|
|
87
94
|
if (!this.fileNames.length) {
|
|
88
|
-
clack.log.
|
|
95
|
+
clack.log.message(`${label} ${gray(path.relative(process.cwd(), this.tsconfig))} ${gray('(No files left after filter)')}`);
|
|
89
96
|
return this;
|
|
90
97
|
}
|
|
91
98
|
}
|
|
92
|
-
|
|
99
|
+
else {
|
|
100
|
+
this.fileNames = this.rawFileNames;
|
|
101
|
+
}
|
|
102
|
+
const filteredLengthDiff = this.rawFileNames.length - this.fileNames.length;
|
|
93
103
|
clack.log.info(`${label} ${path.relative(process.cwd(), this.tsconfig)} ${gray(`(${this.fileNames.length}${filteredLengthDiff ? `, skipped ${filteredLengthDiff}` : ''})`)}`);
|
|
94
104
|
if (!process.argv.includes('--force')) {
|
|
95
105
|
this.cache = cache.loadCache(this.tsconfig, this.configFile, ts.sys.createHash);
|
|
@@ -272,27 +282,32 @@ class Project {
|
|
|
272
282
|
}
|
|
273
283
|
}
|
|
274
284
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
285
|
+
function normalizeFilterGlobPath(filterGlob, expandDirToGlob = true) {
|
|
286
|
+
let filterPath = path.resolve(process.cwd(), filterGlob);
|
|
287
|
+
if (expandDirToGlob && fs.existsSync(filterPath) && fs.statSync(filterPath).isDirectory()) {
|
|
288
|
+
filterPath = path.join(filterPath, '**/*');
|
|
289
|
+
}
|
|
290
|
+
return ts.server.toNormalizedPath(filterPath);
|
|
291
|
+
}
|
|
292
|
+
const filters = [];
|
|
293
|
+
const filterArgIndex = process.argv.indexOf('--filter');
|
|
278
294
|
if (filterArgIndex !== -1) {
|
|
279
|
-
|
|
295
|
+
const filterGlob = process.argv[filterArgIndex + 1];
|
|
296
|
+
if (!filterGlob || filterGlob.startsWith('-')) {
|
|
297
|
+
clack.log.error(red(`Missing argument for --filter.`));
|
|
298
|
+
process.exit(1);
|
|
299
|
+
}
|
|
300
|
+
filters.push(normalizeFilterGlobPath(filterGlob));
|
|
301
|
+
for (let i = filterArgIndex + 2; i < process.argv.length; i++) {
|
|
280
302
|
const filterGlob = process.argv[i];
|
|
281
|
-
if (
|
|
282
|
-
|
|
283
|
-
process.exit(1);
|
|
303
|
+
if (filterGlob.startsWith('-')) {
|
|
304
|
+
break;
|
|
284
305
|
}
|
|
285
|
-
|
|
286
|
-
for (const fileName of fileNames)
|
|
287
|
-
filterSet.add(fileName);
|
|
288
|
-
}
|
|
289
|
-
if (!filterSet.size) {
|
|
290
|
-
clack.log.error(red(`No files found after --filter files.`));
|
|
291
|
-
process.exit(1);
|
|
306
|
+
filters.push(normalizeFilterGlobPath(filterGlob));
|
|
292
307
|
}
|
|
293
308
|
}
|
|
294
309
|
for (const [tsconfig, languages] of tsconfigAndLanguages) {
|
|
295
|
-
projects.push(await new Project(tsconfig, languages).init(clack,
|
|
310
|
+
projects.push(await new Project(tsconfig, languages).init(clack, filters));
|
|
296
311
|
}
|
|
297
312
|
spinner?.start();
|
|
298
313
|
projects = projects.filter(project => !!project.configFile);
|
|
@@ -358,7 +373,7 @@ class Project {
|
|
|
358
373
|
return;
|
|
359
374
|
}
|
|
360
375
|
project.worker = linterWorker;
|
|
361
|
-
const setupSuccess = await linterWorker.setup(project.tsconfig, project.languages, project.configFile, project.builtConfig, project.
|
|
376
|
+
const setupSuccess = await linterWorker.setup(project.tsconfig, project.languages, project.configFile, project.builtConfig, project.rawFileNames, project.options);
|
|
362
377
|
if (!setupSuccess) {
|
|
363
378
|
projects = projects.filter(p => p !== project);
|
|
364
379
|
startWorker(linterWorker);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tsslint": "./bin/tsslint.js"
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@clack/prompts": "^0.8.2",
|
|
19
|
-
"@tsslint/config": "2.0.
|
|
20
|
-
"@tsslint/core": "2.0.
|
|
19
|
+
"@tsslint/config": "2.0.6",
|
|
20
|
+
"@tsslint/core": "2.0.6",
|
|
21
21
|
"@volar/language-core": "~2.4.0",
|
|
22
22
|
"@volar/language-hub": "0.0.1",
|
|
23
23
|
"@volar/typescript": "~2.4.0",
|
|
24
24
|
"glob": "^10.4.1",
|
|
25
|
-
"json5": "^2.2.3"
|
|
25
|
+
"json5": "^2.2.3",
|
|
26
|
+
"minimatch": "^10.0.1"
|
|
26
27
|
},
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"typescript": "*"
|
|
@@ -31,5 +32,5 @@
|
|
|
31
32
|
"@vue-vine/language-service": "latest",
|
|
32
33
|
"@vue/language-core": "latest"
|
|
33
34
|
},
|
|
34
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "b5914c99cb269150c2518f0f7b097ad2a996296d"
|
|
35
36
|
}
|