@tsslint/cli 1.4.4 → 1.4.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 CHANGED
@@ -336,14 +336,13 @@ class Project {
336
336
  fileCache[0] = fileMtime;
337
337
  fileCache[1] = {};
338
338
  fileCache[2] = {};
339
- fileCache[3] = {};
340
339
  }
341
340
  else {
342
341
  cached++;
343
342
  }
344
343
  }
345
344
  else {
346
- project.cache[fileName] = fileCache = [fileMtime, {}, {}, {}];
345
+ project.cache[fileName] = fileCache = [fileMtime, {}, {}];
347
346
  }
348
347
  let diagnostics;
349
348
  if (process.argv.includes('--fix')) {
@@ -356,7 +355,7 @@ class Project {
356
355
  if (diagnostics.length) {
357
356
  hasFix ||= await linterWorker.hasCodeFixes(fileName);
358
357
  for (const diagnostic of diagnostics) {
359
- hasFix ||= !!fileCache[1][diagnostic.code];
358
+ hasFix ||= !!fileCache[1][diagnostic.code]?.[0];
360
359
  let output = ts.formatDiagnosticsWithColorAndContext([diagnostic], {
361
360
  getCurrentDirectory: ts.sys.getCurrentDirectory,
362
361
  getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? x => x : x => x.toLowerCase(),
@@ -377,7 +376,7 @@ class Project {
377
376
  }
378
377
  }
379
378
  }
380
- else if (!(await linterWorker.hasRules(fileName, fileCache[3]))) {
379
+ else if (!(await linterWorker.hasRules(fileName, fileCache[2]))) {
381
380
  excluded++;
382
381
  }
383
382
  else {
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[3]): readonly [boolean, Record<string, boolean>];
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,14 +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(fixes => fixes > 0)) {
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
213
  fileCache[2] = {};
208
214
  }
209
215
  diagnostics = linter.lint(fileName, fileCache);
210
216
  let fixes = linter
211
- .getCodeFixes(fileName, 0, Number.MAX_VALUE, diagnostics, fileCache[3])
217
+ .getCodeFixes(fileName, 0, Number.MAX_VALUE, diagnostics, fileCache[2])
212
218
  .filter(fix => fix.fixId === 'tsslint');
213
219
  if (language) {
214
220
  fixes = fixes.map(fix => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/cli",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
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.4",
20
- "@tsslint/core": "1.4.4",
19
+ "@tsslint/config": "1.4.6",
20
+ "@tsslint/core": "1.4.6",
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": "7e4401c6734fd2b8d09d9aa45584e83e3ecf9e48"
31
+ "gitHead": "9c5bc3471bb1c737144f90a1a70470975088e7fc"
32
32
  }