@tsslint/core 1.6.1 → 2.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/index.js +19 -22
- package/lib/build.js +1 -1
- package/lib/watch.d.ts +1 -1
- package/lib/watch.js +1 -30
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -48,17 +48,25 @@ function createLinter(ctx, rootDir, config, handleError, syntaxOnlyLanguageServi
|
|
|
48
48
|
? {
|
|
49
49
|
...ctx,
|
|
50
50
|
sourceFile: ctx.languageService.getProgram().getSourceFile(fileName),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
get program() {
|
|
52
|
+
return ctx.languageService.getProgram();
|
|
53
|
+
},
|
|
54
|
+
report,
|
|
55
|
+
reportError: report,
|
|
56
|
+
reportWarning: report,
|
|
57
|
+
reportSuggestion: report,
|
|
54
58
|
}
|
|
55
59
|
: {
|
|
56
60
|
...ctx,
|
|
57
61
|
languageService: syntaxOnlyLanguageService,
|
|
62
|
+
get program() {
|
|
63
|
+
throw new Error('Not supported');
|
|
64
|
+
},
|
|
58
65
|
sourceFile: getNonBoundSourceFile(fileName),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
report,
|
|
67
|
+
reportError: report,
|
|
68
|
+
reportWarning: report,
|
|
69
|
+
reportSuggestion: report,
|
|
62
70
|
};
|
|
63
71
|
const token = ctx.languageServiceHost.getCancellationToken?.();
|
|
64
72
|
const configs = getConfigsForFile(fileName, cache?.[2]);
|
|
@@ -103,10 +111,10 @@ function createLinter(ctx, rootDir, config, handleError, syntaxOnlyLanguageServi
|
|
|
103
111
|
shouldRetry = true;
|
|
104
112
|
}
|
|
105
113
|
else if (err instanceof Error) {
|
|
106
|
-
report(
|
|
114
|
+
report(err.stack ?? err.message, 0, 0, 0, err);
|
|
107
115
|
}
|
|
108
116
|
else {
|
|
109
|
-
report(
|
|
117
|
+
report(String(err), 0, 0, Number.MAX_VALUE);
|
|
110
118
|
}
|
|
111
119
|
}
|
|
112
120
|
if (cache && !rule2Mode.get(currentRuleId)) {
|
|
@@ -151,18 +159,9 @@ function createLinter(ctx, rootDir, config, handleError, syntaxOnlyLanguageServi
|
|
|
151
159
|
}
|
|
152
160
|
lintResult[2] = lintResult[2].filter(refactor => diagnosticSet.has(refactor.diagnostic));
|
|
153
161
|
return diagnostics;
|
|
154
|
-
function
|
|
155
|
-
return report(ts.DiagnosticCategory.Error, message, start, end, stackOffset);
|
|
156
|
-
}
|
|
157
|
-
function reportWarning(message, start, end, stackOffset) {
|
|
158
|
-
return report(ts.DiagnosticCategory.Warning, message, start, end, stackOffset);
|
|
159
|
-
}
|
|
160
|
-
function reportSuggestion(message, start, end, stackOffset) {
|
|
161
|
-
return report(ts.DiagnosticCategory.Suggestion, message, start, end, stackOffset);
|
|
162
|
-
}
|
|
163
|
-
function report(category, message, start, end, stackOffset = 2, err) {
|
|
162
|
+
function report(message, start, end, stackOffset = 1, err) {
|
|
164
163
|
const error = {
|
|
165
|
-
category,
|
|
164
|
+
category: ts.DiagnosticCategory.Message,
|
|
166
165
|
code: currentRuleId,
|
|
167
166
|
messageText: message,
|
|
168
167
|
file: rulesContext.sourceFile,
|
|
@@ -182,9 +181,7 @@ function createLinter(ctx, rootDir, config, handleError, syntaxOnlyLanguageServi
|
|
|
182
181
|
})),
|
|
183
182
|
});
|
|
184
183
|
}
|
|
185
|
-
|
|
186
|
-
handleError(error, err ?? new Error(), stackOffset);
|
|
187
|
-
}
|
|
184
|
+
handleError(error, err ?? new Error(), stackOffset);
|
|
188
185
|
let lintResult = lintResults.get(fileName);
|
|
189
186
|
if (!lintResult) {
|
|
190
187
|
lintResults.set(fileName, lintResult = [rulesContext.sourceFile, new Map(), []]);
|
package/lib/build.js
CHANGED
|
@@ -19,7 +19,7 @@ spinner, stopSnipper) {
|
|
|
19
19
|
stopSnipper?.('Failed to build ' + configFileDisplayPath + ' in ' + (Date.now() - buildStart) + 'ms', 1);
|
|
20
20
|
}
|
|
21
21
|
resolve(builtConfig);
|
|
22
|
-
}, false, createHash
|
|
22
|
+
}, false, createHash);
|
|
23
23
|
}
|
|
24
24
|
catch (e) {
|
|
25
25
|
stopSnipper?.('Failed to build ' + configFileDisplayPath + ' in ' + (Date.now() - buildStart) + 'ms', 1);
|
package/lib/watch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import esbuild = require('esbuild');
|
|
2
|
-
export declare function watchConfig(configFilePath: string, onBuild: (config: string | undefined, result: esbuild.BuildResult) => void, watch?: boolean, createHash?: (path: string) => string
|
|
2
|
+
export declare function watchConfig(configFilePath: string, onBuild: (config: string | undefined, result: esbuild.BuildResult) => void, watch?: boolean, createHash?: (path: string) => string): Promise<esbuild.BuildContext<{
|
|
3
3
|
entryPoints: string[];
|
|
4
4
|
bundle: true;
|
|
5
5
|
sourcemap: true;
|
package/lib/watch.js
CHANGED
|
@@ -6,9 +6,7 @@ const esbuild = require("esbuild");
|
|
|
6
6
|
const _path = require("path");
|
|
7
7
|
const fs = require("fs");
|
|
8
8
|
const url = require("url");
|
|
9
|
-
async function watchConfig(configFilePath, onBuild, watch = true, createHash = btoa
|
|
10
|
-
// @ts-expect-error
|
|
11
|
-
spinner, stopSnipper) {
|
|
9
|
+
async function watchConfig(configFilePath, onBuild, watch = true, createHash = btoa) {
|
|
12
10
|
const outDir = getDotTsslintPath(configFilePath);
|
|
13
11
|
const outFileName = createHash(_path.relative(outDir, configFilePath)) + '.mjs';
|
|
14
12
|
const outFile = _path.join(outDir, outFileName);
|
|
@@ -30,33 +28,6 @@ spinner, stopSnipper) {
|
|
|
30
28
|
plugins: [{
|
|
31
29
|
name: 'tsslint',
|
|
32
30
|
setup(build) {
|
|
33
|
-
build.onResolve({ filter: /^https?:\/\// }, async ({ path: importUrl }) => {
|
|
34
|
-
const cachePath = _path.join(outDir, importUrl.split('://')[0], ...importUrl.split('://')[1].split('/'));
|
|
35
|
-
if (!fs.existsSync(cachePath)) {
|
|
36
|
-
const start = Date.now();
|
|
37
|
-
spinner?.message('Downloading ' + importUrl);
|
|
38
|
-
const response = await fetch(importUrl);
|
|
39
|
-
if (!response.ok) {
|
|
40
|
-
throw new Error(`Failed to load ${importUrl}`);
|
|
41
|
-
}
|
|
42
|
-
stopSnipper?.('Downloaded ' + importUrl + ' in ' + (Date.now() - start) + 'ms');
|
|
43
|
-
const text = await response.text();
|
|
44
|
-
fs.mkdirSync(_path.dirname(cachePath), { recursive: true });
|
|
45
|
-
fs.writeFileSync(cachePath, text, 'utf8');
|
|
46
|
-
}
|
|
47
|
-
if (isTsFile(cachePath)) {
|
|
48
|
-
return {
|
|
49
|
-
path: cachePath,
|
|
50
|
-
external: false,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return {
|
|
55
|
-
path: url.pathToFileURL(cachePath).toString(),
|
|
56
|
-
external: true,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
31
|
build.onResolve({ filter: /.*/ }, ({ path, resolveDir }) => {
|
|
61
32
|
if (!isTsFile(path)) {
|
|
62
33
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"directory": "packages/core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@tsslint/types": "
|
|
15
|
+
"@tsslint/types": "2.0.0",
|
|
16
16
|
"esbuild": ">=0.17.0",
|
|
17
17
|
"minimatch": "^10.0.1"
|
|
18
18
|
},
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"postinstall": "node scripts/cleanCache.js"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "ae93f5a423f55be0af23e4b088bf589dbc215ef6"
|
|
26
26
|
}
|