Skip to content

Commit bcd0a76

Browse files
lint and type-check TypeScript scripts in CI (#1815)
1 parent 824a963 commit bcd0a76

11 files changed

+472
-308
lines changed

package-lock.json

Lines changed: 457 additions & 286 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1962,7 +1962,7 @@
19621962
"watch": "npm run compile -- --watch",
19631963
"compile-documentation-webview": "del-cli ./assets/documentation-webview && esbuild ./src/documentation/webview/webview.ts --bundle --outfile=assets/documentation-webview/index.js --define:process.env.NODE_ENV=\\\"production\\\" --define:process.env.CI=\\\"\\\" --format=cjs --sourcemap",
19641964
"watch-documentation-webview": "npm run compile-documentation-webview -- --watch",
1965-
"lint": "eslint ./ --ext ts && tsc --noEmit",
1965+
"lint": "eslint ./ --ext ts && tsc --noEmit && tsc --noEmit -p scripts/tsconfig.json",
19661966
"update-swift-docc-render": "tsx ./scripts/update_swift_docc_render.ts",
19671967
"compile-icons": "tsx ./scripts/compile_icons.ts",
19681968
"format": "prettier --check .",
@@ -2002,6 +2002,9 @@
20022002
"@types/semver": "^7.7.0",
20032003
"@types/sinon": "^17.0.4",
20042004
"@types/sinon-chai": "^3.2.12",
2005+
"@types/svg2ttf": "^5.0.3",
2006+
"@types/svgicons2svgfont": "^10.0.5",
2007+
"@types/ttf2woff": "^2.0.4",
20052008
"@types/vscode": "^1.88.0",
20062009
"@types/xml2js": "^0.4.14",
20072010
"@typescript-eslint/eslint-plugin": "^8.39.1",

scripts/check_package_json.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import { getExtensionVersion, main } from "./lib/utilities";
1717

18-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1918
main(async () => {
2019
const version = await getExtensionVersion();
2120
if (version.minor % 2 !== 0) {

scripts/compile_icons.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ function minifyIcon(icon: string, color: string = "#424242"): string {
5151
}).data;
5252
}
5353

54-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
5554
main(async () => {
5655
const iconsSourceDirectory = path.join(__dirname, "../src/icons");
5756
const iconAssetsDirectory = path.join(__dirname, "../assets/icons");

scripts/dev_package.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import { getExtensionVersion, main, packageExtension } from "./lib/utilities";
1717

18-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1918
main(async () => {
2019
const version = await getExtensionVersion();
2120
const devVersion = `${version.major}.${version.minor}.${version.patch}-dev`;

scripts/download_vsix.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
//===----------------------------------------------------------------------===//
1414
/* eslint-disable no-console */
1515

16-
import * as DecompressType from "decompress";
16+
import decompress from "decompress";
1717
import { createWriteStream } from "node:fs";
1818
import { appendFile, unlink } from "node:fs/promises";
1919
import { pipeline } from "node:stream/promises";
2020
import { Octokit } from "octokit";
21-
22-
// eslint-disable-next-line @typescript-eslint/no-require-imports
23-
const decompress: typeof DecompressType = require("decompress");
21+
import { main } from "./lib/utilities";
2422

2523
const artifact_id = process.env["VSCODE_SWIFT_VSIX_ID"];
2624
if (!artifact_id) {
@@ -41,8 +39,7 @@ const repository = process.env["GITHUB_REPOSITORY"] || "swiftlang/vscode-swift";
4139
const owner = repository.split("/")[0];
4240
const repo = repository.split("/")[1];
4341

44-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
45-
(async function () {
42+
main(async function () {
4643
const octokit = new Octokit({
4744
auth: token,
4845
});
@@ -90,4 +87,4 @@ const repo = repository.split("/")[1];
9087
}
9188
}
9289
await unlink("artifacts.zip");
93-
})();
90+
});

scripts/lib/utilities.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ import { replaceInFile } from "replace-in-file";
2727
*
2828
* @param mainFn The main function of the script that will be run.
2929
*/
30-
export async function main(mainFn: () => Promise<void>): Promise<void> {
31-
try {
32-
await mainFn();
33-
} catch (error) {
30+
export function main(mainFn: () => Promise<void>) {
31+
mainFn().catch(error => {
3432
console.error(error);
3533
process.exit(1);
36-
}
34+
});
3735
}
3836

3937
/**

scripts/package.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import { getExtensionVersion, main, packageExtension } from "./lib/utilities";
1717

18-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
1918
main(async () => {
2019
const version = await getExtensionVersion();
2120
// Leave the "prerelease" tag out

scripts/preview_package.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function formatDate(date: Date): string {
2727
return year + month + day;
2828
}
2929

30-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
3130
main(async () => {
3231
const version = await getExtensionVersion();
3332
// Decrement the minor version and set the patch version to today's date

scripts/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"compilerOptions": {
33
"composite": true,
44

5-
"rootDir": ".",
6-
"outDir": "dist",
5+
"rootDir": "..",
6+
"outDir": "../dist",
77

88
"lib": ["ES2021"],
99
"target": "ES2020",
@@ -15,5 +15,6 @@
1515
"sourceMap": true,
1616

1717
"types": []
18-
}
18+
},
19+
"include": ["**/*.ts", "../src/icons/**/*.ts"]
1920
}

0 commit comments

Comments
 (0)