@tsslint/core 1.0.19 → 1.1.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 +44 -37
- package/lib/watch.js +4 -3
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -49,10 +49,10 @@ function createLinter(ctx, config, withStack) {
|
|
|
49
49
|
.map(config => ({
|
|
50
50
|
config,
|
|
51
51
|
includes: (config.include ?? []).map(include => {
|
|
52
|
-
return path.resolve(basePath, include);
|
|
52
|
+
return ts.server.toNormalizedPath(path.resolve(basePath, include));
|
|
53
53
|
}),
|
|
54
54
|
excludes: (config.exclude ?? []).map(exclude => {
|
|
55
|
-
return path.resolve(basePath, exclude);
|
|
55
|
+
return ts.server.toNormalizedPath(path.resolve(basePath, exclude));
|
|
56
56
|
}),
|
|
57
57
|
}));
|
|
58
58
|
const plugins = configs.map(({ config }) => config.plugins ?? []).flat().map(plugin => plugin(ctx));
|
|
@@ -104,45 +104,52 @@ function createLinter(ctx, config, withStack) {
|
|
|
104
104
|
if (debugInfo) {
|
|
105
105
|
debugInfo.messageText += '- Rules:\n';
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
details
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
107
|
+
const processRules = (rules, paths = []) => {
|
|
108
|
+
for (const [path, rule] of Object.entries(rules)) {
|
|
109
|
+
if (token?.isCancellationRequested()) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
if (typeof rule === 'object') {
|
|
113
|
+
processRules(rule, [...paths, path]);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
currentRuleId = [...paths, path].join('/');
|
|
117
|
+
currentIssues = 0;
|
|
118
|
+
currentFixes = 0;
|
|
119
|
+
currentRefactors = 0;
|
|
120
|
+
const start = Date.now();
|
|
121
|
+
try {
|
|
122
|
+
rule(rulesContext);
|
|
123
|
+
if (debugInfo) {
|
|
124
|
+
const time = Date.now() - start;
|
|
125
|
+
debugInfo.messageText += ` - ${currentRuleId}`;
|
|
126
|
+
const details = [];
|
|
127
|
+
if (currentIssues) {
|
|
128
|
+
details.push(`${currentIssues} issues`);
|
|
129
|
+
}
|
|
130
|
+
if (currentFixes) {
|
|
131
|
+
details.push(`${currentFixes} fixes`);
|
|
132
|
+
}
|
|
133
|
+
if (currentRefactors) {
|
|
134
|
+
details.push(`${currentRefactors} refactors`);
|
|
135
|
+
}
|
|
136
|
+
if (time) {
|
|
137
|
+
details.push(`${time}ms`);
|
|
138
|
+
}
|
|
139
|
+
if (details.length) {
|
|
140
|
+
debugInfo.messageText += ` (${details.join(', ')})`;
|
|
141
|
+
}
|
|
142
|
+
debugInfo.messageText += '\n';
|
|
136
143
|
}
|
|
137
|
-
debugInfo.messageText += '\n';
|
|
138
144
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
catch (err) {
|
|
146
|
+
if (debugInfo) {
|
|
147
|
+
debugInfo.messageText += ` - ${currentRuleId} (❌ ${err && typeof err === 'object' && 'stack' in err ? err.stack : String(err)}})\n`;
|
|
148
|
+
}
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
|
-
}
|
|
151
|
+
};
|
|
152
|
+
processRules(rules);
|
|
146
153
|
for (const plugin of plugins) {
|
|
147
154
|
if (plugin.resolveDiagnostics) {
|
|
148
155
|
diagnostics = plugin.resolveDiagnostics(sourceFile.fileName, diagnostics);
|
package/lib/watch.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.watchConfigFile = watchConfigFile;
|
|
|
4
4
|
const esbuild = require("esbuild");
|
|
5
5
|
const _path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
|
+
const url = require("url");
|
|
7
8
|
async function watchConfigFile(configFilePath, onBuild, watch = true, createHash = btoa, logger = console) {
|
|
8
9
|
let start;
|
|
9
10
|
const outDir = _path.resolve(configFilePath, '..', 'node_modules', '.tsslint');
|
|
@@ -13,7 +14,7 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
|
|
|
13
14
|
let config;
|
|
14
15
|
if (!result.errors.length) {
|
|
15
16
|
try {
|
|
16
|
-
config = (await import(
|
|
17
|
+
config = (await import(url.pathToFileURL(outFile).toString() + '?time=' + Date.now())).default;
|
|
17
18
|
}
|
|
18
19
|
catch (e) {
|
|
19
20
|
result.errors.push({ text: String(e) });
|
|
@@ -42,13 +43,13 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
|
|
|
42
43
|
cachePathToOriginalPath.set(cachePath, path);
|
|
43
44
|
return { path: cachePath, namespace: 'http-url' };
|
|
44
45
|
});
|
|
45
|
-
build.onResolve({ filter:
|
|
46
|
+
build.onResolve({ filter: /.*/, namespace: 'file' }, ({ path, resolveDir }) => {
|
|
46
47
|
if (!path.endsWith('.ts')) {
|
|
47
48
|
try {
|
|
48
49
|
const maybeJsPath = require.resolve(path, { paths: [resolveDir] });
|
|
49
50
|
if (maybeJsPath !== path && !maybeJsPath.endsWith('.ts')) {
|
|
50
51
|
return {
|
|
51
|
-
path: maybeJsPath,
|
|
52
|
+
path: url.pathToFileURL(maybeJsPath).toString(),
|
|
52
53
|
external: true,
|
|
53
54
|
};
|
|
54
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/core",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"directory": "packages/core"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@tsslint/types": "1.0
|
|
15
|
+
"@tsslint/types": "1.1.0",
|
|
16
16
|
"error-stack-parser": "^2.1.4",
|
|
17
17
|
"esbuild": "^0.23.0",
|
|
18
18
|
"minimatch": "^10.0.1",
|
|
19
19
|
"source-map-support": "^0.5.21"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "
|
|
21
|
+
"gitHead": "372a35afb3f9920d3835b90dad5b835ffaad9b3a"
|
|
22
22
|
}
|