@tsslint/cli 1.4.1 → 1.4.3

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 (3) hide show
  1. package/index.js +25 -3
  2. package/lib/worker.js +23 -2
  3. 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(`${purple('[project]')} ${path.relative(process.cwd(), this.tsconfig)} ${darkGray('(No tsslint.config.ts found)')}`);
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(`${purple('[project]')} ${path.relative(process.cwd(), this.tsconfig)} ${darkGray('(No included files)')}`);
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(`${purple('[project]')} ${path.relative(process.cwd(), this.tsconfig)} ${darkGray(`(${this.fileNames.length})`)}`);
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
  }
@@ -343,6 +364,7 @@ class Project {
343
364
  getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? x => x : x => x.toLowerCase(),
344
365
  getNewLine: () => ts.sys.newLine,
345
366
  });
367
+ output = output.trimEnd();
346
368
  output = output.replace(`TS${diagnostic.code}`, String(diagnostic.code));
347
369
  if (diagnostic.category === ts.DiagnosticCategory.Error) {
348
370
  errors++;
package/lib/worker.js CHANGED
@@ -46,6 +46,22 @@ const originalHost = {
46
46
  }
47
47
  return snapshots.get(fileName);
48
48
  },
49
+ getScriptKind(fileName) {
50
+ const languageId = (0, typescript_1.resolveFileLanguageId)(fileName);
51
+ switch (languageId) {
52
+ case 'javascript':
53
+ return ts.ScriptKind.JS;
54
+ case 'javascriptreact':
55
+ return ts.ScriptKind.JSX;
56
+ case 'typescript':
57
+ return ts.ScriptKind.TS;
58
+ case 'typescriptreact':
59
+ return ts.ScriptKind.TSX;
60
+ case 'json':
61
+ return ts.ScriptKind.JSON;
62
+ }
63
+ return ts.ScriptKind.Unknown;
64
+ },
49
65
  getDefaultLibFileName(options) {
50
66
  return ts.getDefaultLibFilePath(options);
51
67
  },
@@ -164,14 +180,19 @@ async function setup(tsconfig, languages, configFile, builtConfig, _fileNames, _
164
180
  projectVersion++;
165
181
  typeRootsVersion++;
166
182
  fileNames = _fileNames;
167
- options = _options;
183
+ options = plugins.some(plugin => plugin.typescript?.extraFileExtensions.length)
184
+ ? {
185
+ ..._options,
186
+ allowNonTsExtensions: true,
187
+ }
188
+ : _options;
168
189
  linter = core.createLinter({
169
190
  configFile,
170
191
  languageService: linterLanguageService,
171
192
  languageServiceHost: linterHost,
172
193
  typescript: ts,
173
194
  tsconfig: ts.server.toNormalizedPath(tsconfig),
174
- }, config, 'cli', clack);
195
+ }, config, 'cli');
175
196
  return true;
176
197
  }
177
198
  function lintAndFix(fileName, fileCache) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsslint/cli",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
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.1",
20
- "@tsslint/core": "1.4.1",
19
+ "@tsslint/config": "1.4.3",
20
+ "@tsslint/core": "1.4.3",
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": "54f42ec9414029a356fa19a762260f03392563fa"
31
+ "gitHead": "7cdb4a39c0af8ee4cebd430bb546c6b6e2ddc28b"
32
32
  }