@tsslint/cli 3.0.0-alpha.0 → 3.0.0
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/bin/tsslint.js +1 -1
- package/index.js +22 -32
- package/lib/cache.d.ts +1 -1
- package/lib/cache.js +13 -7
- package/lib/worker.js +13 -9
- package/package.json +8 -5
package/bin/tsslint.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env -S node --experimental-strip-types --no-warnings
|
|
2
2
|
require('../index');
|
package/index.js
CHANGED
|
@@ -5,7 +5,6 @@ const path = require("path");
|
|
|
5
5
|
const cache = require("./lib/cache.js");
|
|
6
6
|
const worker = require("./lib/worker.js");
|
|
7
7
|
const fs = require("fs");
|
|
8
|
-
const os = require("os");
|
|
9
8
|
const minimatch = require("minimatch");
|
|
10
9
|
const languagePlugins = require("./lib/languagePlugins.js");
|
|
11
10
|
process.env.TSSLINT_CLI = '1';
|
|
@@ -25,15 +24,15 @@ const vueVineColor = (s) => '\x1b[38;5;48m' + s + _reset;
|
|
|
25
24
|
const mdxColor = (s) => '\x1b[33m' + s + _reset;
|
|
26
25
|
const astroColor = (s) => '\x1b[38;5;209m' + s + _reset;
|
|
27
26
|
let threads = 1;
|
|
28
|
-
if (process.argv.includes('--threads')) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
27
|
+
// if (process.argv.includes('--threads')) {
|
|
28
|
+
// const threadsIndex = process.argv.indexOf('--threads');
|
|
29
|
+
// const threadsArg = process.argv[threadsIndex + 1];
|
|
30
|
+
// if (!threadsArg || threadsArg.startsWith('-')) {
|
|
31
|
+
// console.error(red(`Missing argument for --threads.`));
|
|
32
|
+
// process.exit(1);
|
|
33
|
+
// }
|
|
34
|
+
// threads = Math.min(os.availableParallelism(), Number(threadsArg));
|
|
35
|
+
// }
|
|
37
36
|
class Project {
|
|
38
37
|
constructor(tsconfig, languages) {
|
|
39
38
|
this.tsconfig = tsconfig;
|
|
@@ -135,17 +134,11 @@ class Project {
|
|
|
135
134
|
}
|
|
136
135
|
if (![
|
|
137
136
|
'--project',
|
|
138
|
-
'--projects',
|
|
139
137
|
'--vue-project',
|
|
140
|
-
'--vue-projects',
|
|
141
138
|
'--vue-vine-project',
|
|
142
|
-
'--vue-vine-projects',
|
|
143
139
|
'--mdx-project',
|
|
144
|
-
'--mdx-projects',
|
|
145
140
|
'--astro-project',
|
|
146
|
-
'--astro-projects',
|
|
147
141
|
'--ts-macro-project',
|
|
148
|
-
'--ts-macro-projects',
|
|
149
142
|
].some(flag => process.argv.includes(flag))) {
|
|
150
143
|
const language = await clack.select({
|
|
151
144
|
message: 'Select framework',
|
|
@@ -220,34 +213,32 @@ class Project {
|
|
|
220
213
|
else {
|
|
221
214
|
const options = [
|
|
222
215
|
{
|
|
223
|
-
|
|
216
|
+
projectFlag: '--project',
|
|
224
217
|
language: undefined,
|
|
225
218
|
},
|
|
226
219
|
{
|
|
227
|
-
|
|
220
|
+
projectFlag: '--vue-project',
|
|
228
221
|
language: 'vue',
|
|
229
222
|
},
|
|
230
223
|
{
|
|
231
|
-
|
|
224
|
+
projectFlag: '--vue-vine-project',
|
|
232
225
|
language: 'vue-vine',
|
|
233
226
|
},
|
|
234
227
|
{
|
|
235
|
-
|
|
236
|
-
projectsFlag: '--mdx-projects',
|
|
228
|
+
projectFlag: '--mdx-project',
|
|
237
229
|
language: 'mdx',
|
|
238
230
|
},
|
|
239
231
|
{
|
|
240
|
-
|
|
232
|
+
projectFlag: '--astro-project',
|
|
241
233
|
language: 'astro',
|
|
242
234
|
},
|
|
243
235
|
{
|
|
244
|
-
|
|
236
|
+
projectFlag: '--ts-macro-project',
|
|
245
237
|
language: 'ts-macro',
|
|
246
238
|
},
|
|
247
239
|
];
|
|
248
|
-
for (const {
|
|
249
|
-
|
|
250
|
-
if (!projectFlag) {
|
|
240
|
+
for (const { projectFlag, language } of options) {
|
|
241
|
+
if (!process.argv.includes(projectFlag)) {
|
|
251
242
|
continue;
|
|
252
243
|
}
|
|
253
244
|
let foundArg = false;
|
|
@@ -328,13 +319,12 @@ class Project {
|
|
|
328
319
|
(spinner?.stop ?? clack.log.message)(cached
|
|
329
320
|
? gray(`Processed ${processed} files with cache. (Use `) + cyan(`--force`) + gray(` to ignore cache.)`)
|
|
330
321
|
: gray(`Processed ${processed} files.`));
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
clack.log.
|
|
334
|
-
+ cyan(`${
|
|
322
|
+
const deprecatedFlag = process.argv.find(arg => arg.endsWith('-projects'));
|
|
323
|
+
if (deprecatedFlag) {
|
|
324
|
+
clack.log.error(gray(`Use `)
|
|
325
|
+
+ cyan(`${deprecatedFlag.slice(0, -1)}`)
|
|
335
326
|
+ gray(` instead of `)
|
|
336
|
-
+ cyan(`${
|
|
337
|
-
+ gray(` starting from version 1.5.0.`));
|
|
327
|
+
+ cyan(`${deprecatedFlag}.`));
|
|
338
328
|
}
|
|
339
329
|
const data = [
|
|
340
330
|
[passed, 'passed', green],
|
package/lib/cache.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import core = require('@tsslint/core');
|
|
2
|
-
export type CacheData = Record<string, core.FileLintCache>;
|
|
2
|
+
export type CacheData = Record<string, /* fileName */ core.FileLintCache>;
|
|
3
3
|
export declare function loadCache(tsconfig: string, configFilePath: string, createHash?: (path: string) => string): CacheData;
|
|
4
4
|
export declare function saveCache(tsconfig: string, configFilePath: string, cache: CacheData, createHash?: (path: string) => string): void;
|
package/lib/cache.js
CHANGED
|
@@ -4,15 +4,18 @@ exports.loadCache = loadCache;
|
|
|
4
4
|
exports.saveCache = saveCache;
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
|
+
const os = require("os");
|
|
8
|
+
const pkg = require('../package.json');
|
|
7
9
|
function loadCache(tsconfig, configFilePath, createHash = btoa) {
|
|
8
|
-
const outDir =
|
|
9
|
-
const cacheFileName = createHash(path.relative(outDir, configFilePath)) + '_'
|
|
10
|
+
const outDir = getTsslintCachePath(configFilePath, createHash);
|
|
11
|
+
const cacheFileName = createHash(path.relative(outDir, configFilePath)) + '_'
|
|
12
|
+
+ createHash(JSON.stringify(process.argv)) + '_' + createHash(path.relative(outDir, tsconfig)) + '.cache.json';
|
|
10
13
|
const cacheFilePath = path.join(outDir, cacheFileName);
|
|
11
14
|
const cacheFileStat = fs.statSync(cacheFilePath, { throwIfNoEntry: false });
|
|
12
15
|
const configFileStat = fs.statSync(configFilePath, { throwIfNoEntry: false });
|
|
13
16
|
if (cacheFileStat?.isFile() && cacheFileStat.mtimeMs > (configFileStat?.mtimeMs ?? 0)) {
|
|
14
17
|
try {
|
|
15
|
-
return
|
|
18
|
+
return JSON.parse(fs.readFileSync(cacheFilePath, 'utf8'));
|
|
16
19
|
}
|
|
17
20
|
catch {
|
|
18
21
|
return {};
|
|
@@ -21,13 +24,16 @@ function loadCache(tsconfig, configFilePath, createHash = btoa) {
|
|
|
21
24
|
return {};
|
|
22
25
|
}
|
|
23
26
|
function saveCache(tsconfig, configFilePath, cache, createHash = btoa) {
|
|
24
|
-
const outDir =
|
|
25
|
-
const cacheFileName = createHash(path.relative(outDir, configFilePath)) + '_'
|
|
27
|
+
const outDir = getTsslintCachePath(configFilePath, createHash);
|
|
28
|
+
const cacheFileName = createHash(path.relative(outDir, configFilePath)) + '_'
|
|
29
|
+
+ createHash(JSON.stringify(process.argv)) + '_' + createHash(path.relative(outDir, tsconfig)) + '.cache.json';
|
|
26
30
|
const cacheFilePath = path.join(outDir, cacheFileName);
|
|
27
31
|
fs.mkdirSync(outDir, { recursive: true });
|
|
28
32
|
fs.writeFileSync(cacheFilePath, JSON.stringify(cache));
|
|
29
33
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
34
|
+
function getTsslintCachePath(configFilePath, createHash) {
|
|
35
|
+
const projectRoot = path.resolve(configFilePath, '..');
|
|
36
|
+
const projectHash = createHash(projectRoot);
|
|
37
|
+
return path.join(os.tmpdir(), 'tsslint-cache-' + pkg.version + '-' + projectHash);
|
|
32
38
|
}
|
|
33
39
|
//# sourceMappingURL=cache.js.map
|
package/lib/worker.js
CHANGED
|
@@ -188,7 +188,7 @@ async function setup(tsconfig, languages, configFile, _fileNames, _options) {
|
|
|
188
188
|
languageService: linterLanguageService,
|
|
189
189
|
languageServiceHost: linterHost,
|
|
190
190
|
typescript: ts,
|
|
191
|
-
}, path.dirname(configFile), config, () =>
|
|
191
|
+
}, path.dirname(configFile), config, () => [], linterSyntaxOnlyLanguageService);
|
|
192
192
|
return true;
|
|
193
193
|
}
|
|
194
194
|
function lint(fileName, fix, fileCache) {
|
|
@@ -247,10 +247,12 @@ function lint(fileName, fix, fileCache) {
|
|
|
247
247
|
},
|
|
248
248
|
relatedInformation: diagnostic.relatedInformation?.map(info => ({
|
|
249
249
|
...info,
|
|
250
|
-
file: info.file
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
file: info.file
|
|
251
|
+
? {
|
|
252
|
+
fileName: info.file.fileName,
|
|
253
|
+
text: getFileText(info.file.fileName),
|
|
254
|
+
}
|
|
255
|
+
: undefined,
|
|
254
256
|
})),
|
|
255
257
|
}));
|
|
256
258
|
}
|
|
@@ -263,10 +265,12 @@ function lint(fileName, fix, fileCache) {
|
|
|
263
265
|
},
|
|
264
266
|
relatedInformation: diagnostic.relatedInformation?.map(info => ({
|
|
265
267
|
...info,
|
|
266
|
-
file: info.file
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
file: info.file
|
|
269
|
+
? {
|
|
270
|
+
fileName: info.file.fileName,
|
|
271
|
+
text: info.file.text,
|
|
272
|
+
}
|
|
273
|
+
: undefined,
|
|
270
274
|
})),
|
|
271
275
|
}));
|
|
272
276
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/cli",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"engines": {
|
|
6
|
+
"node": ">=22.6.0"
|
|
7
|
+
},
|
|
5
8
|
"bin": {
|
|
6
9
|
"tsslint": "./bin/tsslint.js"
|
|
7
10
|
},
|
|
@@ -16,8 +19,8 @@
|
|
|
16
19
|
},
|
|
17
20
|
"dependencies": {
|
|
18
21
|
"@clack/prompts": "^0.8.2",
|
|
19
|
-
"@tsslint/config": "3.0.0
|
|
20
|
-
"@tsslint/core": "3.0.0
|
|
22
|
+
"@tsslint/config": "3.0.0",
|
|
23
|
+
"@tsslint/core": "3.0.0",
|
|
21
24
|
"@volar/language-core": "~2.4.0",
|
|
22
25
|
"@volar/language-hub": "0.0.1",
|
|
23
26
|
"@volar/typescript": "~2.4.0",
|
|
@@ -26,5 +29,5 @@
|
|
|
26
29
|
"peerDependencies": {
|
|
27
30
|
"typescript": "*"
|
|
28
31
|
},
|
|
29
|
-
"gitHead": "
|
|
30
|
-
}
|
|
32
|
+
"gitHead": "69bc86cf2dd81f9e48fc15ed9b9f0351fa2fc19e"
|
|
33
|
+
}
|