@tsslint/cli 2.0.5 → 2.0.7

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