Skip to content

Commit f6a0dee

Browse files
crisbetommalerba
authored andcommitted
build: check tooling scripts for compilation errors (#21604)
A lot of the scripts under `tools` are only run manually which means that it's easy for compilation errors to slip by when dependencies are updated. These changes add another CI check to ensure that the scripts compile. (cherry picked from commit a567c64)
1 parent 5900d70 commit f6a0dee

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ jobs:
395395
pkg_json_version=$(node -pe "require('./package.json').version")
396396
expected_version="${pkg_json_version}-sha-$(git rev-parse --short HEAD)"
397397
yarn check-release-output ${expected_version}
398+
- run:
399+
name: Checking tooling scripts
400+
command: yarn check-tools
398401

399402
# TODO(devversion): replace this with bazel tests that run Madge. This is
400403
# cumbersome and doesn't guarantee no circular deps for other entry-points.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"integration-tests:view-engine": "bazel test --test_tag_filters=view-engine-only --build_tests_only -- //integration/... -//integration/size-test/...",
4848
"integration-tests:size-test": "bazel test //integration/size-test/...",
4949
"check-mdc-tests": "ts-node --project scripts/tsconfig.json scripts/check-mdc-tests.ts",
50-
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts"
50+
"check-mdc-exports": "ts-node --project scripts/tsconfig.json scripts/check-mdc-exports.ts",
51+
"check-tools": "yarn tsc --project tools/tsconfig-ci.json"
5152
},
5253
"version": "11.1.0-rc.0",
5354
"dependencies": {

tools/tsconfig-ci.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// A lot of the scripts under `tools` are run manually, rather than on the CI. As such, it's easy
2+
// to miss compilation errors in them. This config is used to verify the files on the CI. Note that
3+
// the compiler options are somewhat loose, which is intentional in order to mimic the default
4+
// options used by `ts-node` when running the scripts.
5+
{
6+
"include": ["./**/*.ts"],
7+
"exclude": ["./public_api_guard/**/*.ts"],
8+
"compilerOptions": {
9+
"outDir": "../dist/tools",
10+
"lib": ["es2015"],
11+
"skipLibCheck": true,
12+
// Don't emit to the file system, because we only want to check for compilation errors.
13+
"noEmit": true
14+
}
15+
}

tools/tslint-rules/noUnescapedHtmlTagRule.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ class NoUnescapedHtmlTagWalker extends Lint.RuleWalker {
5151
// Whether an opening backtick has been found without a closing pair
5252
let openBacktick = false;
5353

54-
for (const char of fullText) {
55-
if (char === '`') {
54+
for (let i = 0; i < fullText.length; i++) {
55+
if (fullText[i] === '`') {
5656
openBacktick = !openBacktick;
57-
} else if (matches.test(char) && !openBacktick) {
57+
} else if (matches.test(fullText[i]) && !openBacktick) {
5858
return false;
5959
}
6060
}

0 commit comments

Comments
 (0)