@tsslint/core 1.1.0 → 1.1.2
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 +1 -0
- package/lib/watch.js +23 -26
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -143,6 +143,7 @@ function createLinter(ctx, config, withStack) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
catch (err) {
|
|
146
|
+
console.error(err);
|
|
146
147
|
if (debugInfo) {
|
|
147
148
|
debugInfo.messageText += ` - ${currentRuleId} (❌ ${err && typeof err === 'object' && 'stack' in err ? err.stack : String(err)}})\n`;
|
|
148
149
|
}
|
package/lib/watch.js
CHANGED
|
@@ -11,6 +11,8 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
|
|
|
11
11
|
const outFileName = createHash(_path.relative(outDir, configFilePath)) + '.mjs';
|
|
12
12
|
const outFile = _path.join(outDir, outFileName);
|
|
13
13
|
const resultHandler = async (result) => {
|
|
14
|
+
const t1 = Date.now() - start;
|
|
15
|
+
start = Date.now();
|
|
14
16
|
let config;
|
|
15
17
|
if (!result.errors.length) {
|
|
16
18
|
try {
|
|
@@ -20,7 +22,8 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
|
|
|
20
22
|
result.errors.push({ text: String(e) });
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
const t2 = Date.now() - start;
|
|
26
|
+
logger.log(`Built ${_path.relative(process.cwd(), configFilePath)} in ${t1}ms, loaded ${config ? 'successfully' : 'with errors'} in ${t2}ms`);
|
|
24
27
|
onBuild(config, result);
|
|
25
28
|
};
|
|
26
29
|
const cacheDir = _path.resolve(outDir, 'http_resources');
|
|
@@ -38,12 +41,26 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
|
|
|
38
41
|
build.onStart(() => {
|
|
39
42
|
start = Date.now();
|
|
40
43
|
});
|
|
41
|
-
build.onResolve({ filter: /^https?:\/\// }, ({ path }) => {
|
|
42
|
-
const cachePath = _path.join(cacheDir, createHash(
|
|
43
|
-
cachePathToOriginalPath.set(cachePath,
|
|
44
|
-
|
|
44
|
+
build.onResolve({ filter: /^https?:\/\// }, async ({ path: url }) => {
|
|
45
|
+
const cachePath = _path.join(cacheDir, createHash(_path.posix.dirname(url)), _path.posix.basename(url));
|
|
46
|
+
cachePathToOriginalPath.set(cachePath, url);
|
|
47
|
+
if (!fs.existsSync(cachePath)) {
|
|
48
|
+
console.time('Download ' + url);
|
|
49
|
+
const response = await fetch(url);
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`Failed to load ${url}`);
|
|
52
|
+
}
|
|
53
|
+
console.timeEnd('Download ' + url);
|
|
54
|
+
const text = await response.text();
|
|
55
|
+
fs.mkdirSync(_path.dirname(cachePath), { recursive: true });
|
|
56
|
+
fs.writeFileSync(cachePath, text, 'utf8');
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
path: cachePath,
|
|
60
|
+
external: true,
|
|
61
|
+
};
|
|
45
62
|
});
|
|
46
|
-
build.onResolve({ filter:
|
|
63
|
+
build.onResolve({ filter: /.*/ }, ({ path, resolveDir }) => {
|
|
47
64
|
if (!path.endsWith('.ts')) {
|
|
48
65
|
try {
|
|
49
66
|
const maybeJsPath = require.resolve(path, { paths: [resolveDir] });
|
|
@@ -58,26 +75,6 @@ async function watchConfigFile(configFilePath, onBuild, watch = true, createHash
|
|
|
58
75
|
}
|
|
59
76
|
return {};
|
|
60
77
|
});
|
|
61
|
-
build.onLoad({ filter: /.*/, namespace: 'http-url' }, async ({ path: cachePath }) => {
|
|
62
|
-
const path = cachePathToOriginalPath.get(cachePath);
|
|
63
|
-
if (fs.existsSync(cachePath)) {
|
|
64
|
-
return {
|
|
65
|
-
contents: fs.readFileSync(cachePath, 'utf8'),
|
|
66
|
-
loader: 'ts',
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const response = await fetch(path);
|
|
70
|
-
if (!response.ok) {
|
|
71
|
-
throw new Error(`Failed to load ${path}`);
|
|
72
|
-
}
|
|
73
|
-
const text = await response.text();
|
|
74
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
75
|
-
fs.writeFileSync(cachePath, text, 'utf8');
|
|
76
|
-
return {
|
|
77
|
-
contents: text,
|
|
78
|
-
loader: path.substring(path.lastIndexOf('.') + 1),
|
|
79
|
-
};
|
|
80
|
-
});
|
|
81
78
|
if (watch) {
|
|
82
79
|
build.onEnd(resultHandler);
|
|
83
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsslint/core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
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.1.
|
|
15
|
+
"@tsslint/types": "1.1.2",
|
|
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": "6c266922e32c08743e088c94b560e6980f77255a"
|
|
22
22
|
}
|